public ModuleDescriptor loadModuleDescriptor(IFile file) { try { String filePath = file.getPath(); if (filePath.endsWith(SLASH_META_INF_MODULE_XML)) { DeploymentDescriptor deploymentDescriptor = DeploymentDescriptorPersistence.loadDeploymentDescriptor(file); ModuleDescriptor result = null; IFile realDescriptorFile = getRealDescriptorFile(filePath, deploymentDescriptor); if (realDescriptorFile != null) { result = loadModuleDescriptor(realDescriptorFile); } // TODO create module without sources if (result != null) { result.setDeploymentDescriptor(deploymentDescriptor); // TODO fix stubs } return result; } else { return DescriptorIOFacade.getInstance().fromFileType(file).readFromFile(file); } } catch (Exception t) { LOG.error("Fail to load module from descriptor " + file.getPath(), t); return null; } }
private List<File> getRoots() { List<File> roots = new ArrayList<File>(); for (ModuleDescriptor moduleDescriptor : getModuleDescriptors()) { roots.addAll(moduleDescriptor.getContentRoots()); } return roots; }
protected Map< ModuleDescriptor, Map<File, List<FacetDetectionProcessor.DetectedInWizardFacetInfo>>> calculate() { myLastRoots = getRoots(); ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); Map<ModuleDescriptor, Map<File, List<FacetDetectionProcessor.DetectedInWizardFacetInfo>>> result = new HashMap< ModuleDescriptor, Map<File, List<FacetDetectionProcessor.DetectedInWizardFacetInfo>>>(); for (ModuleDescriptor moduleDescriptor : getModuleDescriptors()) { Map<File, List<FacetDetectionProcessor.DetectedInWizardFacetInfo>> root2Facets = new HashMap<File, List<FacetDetectionProcessor.DetectedInWizardFacetInfo>>(); for (File root : moduleDescriptor.getContentRoots()) { FacetDetectionProcessor processor = new FacetDetectionProcessor(progressIndicator, myModuleType); processor.process(root); List<FacetDetectionProcessor.DetectedInWizardFacetInfo> facets = processor.getDetectedFacetsInfos(); if (!facets.isEmpty()) { root2Facets.put(root, facets); } } if (!root2Facets.isEmpty()) { result.put(moduleDescriptor, root2Facets); } } return result; }
public ModuleManager(Receptor rec) { mlce = new ModuleListChangedEvent(rec); mae = new ModuleAddedEvent(rec); mre = new ModuleRemovedEvent(rec); recOut = rec.getOutComm(); dbReportListeners = new LinkedList(); listeners = new LinkedList(); receptor = rec; modToHandle = new HashMap(); hashToModule = new HashMap(); handleToAnalMod = new HashMap(); handles = new LinkedList(); nameToFInst = new HashMap(); downloadSet = Collections.synchronizedSet(new HashSet()); checkingSet = Collections.synchronizedSet(new HashSet()); phantomModules = Collections.synchronizedList(new LinkedList()); ModuleLinker linker = receptor.getLinker(); Iterator it = linker.getDescriptors().iterator(); while (it.hasNext()) { ModuleDescriptor desc = (ModuleDescriptor) it.next(); if (desc.getType() == Descriptor.TYPE_FLOW) { loadFlowModule(desc); } } refresh = Settings.v().getRefreshInterval(); Settings.v().addConfigChangeListener(this); receptor.getLinker().addModuleLinkerListener(this); (refThread = new Thread(this, "Module Manager")).start(); }
private EunomiaModule newModuleInstance(ModuleDescriptor desc) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoModuleJarException { String className = classPrefix[desc.getType()] + desc.getName() + ".Main"; ClassLoader loader = desc.getClassLoader(); Class klass = loader.loadClass(className); return (EunomiaModule) klass.newInstance(); }
public void checkModuleHash(String name, int type, byte[] hash) { ModuleDescriptor module = receptor.getLinker().getMapping(name, type); if (module != null && !Arrays.equals(module.getHash(), hash)) { logger.info("Updating module '" + name + "'"); receptor.getLinker().deleteModule(module); downloadModule(name, type); } }
private void processExcludes( @NotNull IFile descriptorFile, ModuleDescriptor descriptor, Set<IFile> excludes) { if (descriptor == null || descriptorFile.isReadOnly()) { return; } for (String p : descriptor.getSourcePaths()) { excludes.add(FileSystem.getInstance().getFileByPath(p)); } IFile genPath = ProjectPathUtil.getGeneratorOutputPath(descriptorFile.getParent(), descriptor); if (genPath != null) { excludes.add(genPath); if (!descriptorFile.isReadOnly()) { FileSystem.getInstance().getFileByPath(FileGenerationUtil.getCachesPath(genPath.getPath())); } } IFile testsGenPath = ProjectPathUtil.getGeneratorTestsOutputPath(descriptorFile, descriptor); if (testsGenPath != null) { excludes.add(testsGenPath); if (!descriptorFile.isReadOnly()) { FileSystem.getInstance() .getFileByPath(FileGenerationUtil.getCachesPath(testsGenPath.getPath())); } } for (ModelRootDescriptor rootDescriptor : descriptor.getModelRootDescriptors()) { ModelRoot root = rootDescriptor.getRoot(); if (root == null || root.getManager() != null && root.getManager() != LanguageID.JAVA_MANAGER) { continue; } excludes.add(FileSystem.getInstance().getFileByPath(root.getPath())); } IFile classesGen = ProjectPathUtil.getClassesGenFolder(descriptorFile.getParent(), false); if (classesGen != null) { excludes.add(classesGen); } // todo: specify what kind of descriptor can be input for this method if (descriptor instanceof LanguageDescriptor) { IFile generatorClassesGen = ProjectPathUtil.getClassesGenFolder(descriptorFile.getParent(), true); if (generatorClassesGen != null) { excludes.add(generatorClassesGen); } } for (String entry : descriptor.getAdditionalJavaStubPaths()) { excludes.add(FileSystem.getInstance().getFileByPath(entry)); } }
public ModuleDescriptor findAreaById(String id) { Iterator<GroupDescriptor> iterator = groups.iterator(); while (iterator.hasNext()) { GroupDescriptor group = iterator.next(); Iterator<ModuleDescriptor> dit = group.getModules().iterator(); while (dit.hasNext()) { ModuleDescriptor locDemo = (ModuleDescriptor) dit.next(); if (locDemo.getId().equals(id)) { return locDemo; } } } return null; }
public ModuleHandle loadHandle(ModelInputStream stream) throws IOException { if (stream.readShort() != 0x1be0) throw new IOException("bad stream: no start marker"); String file = stream.readString(); ModuleDescriptor descriptor; int type = stream.readByte(); if (type == 1) { descriptor = new LanguageDescriptor(); } else if (type == 2) { descriptor = new SolutionDescriptor(); } else if (type == 3) { descriptor = new DevkitDescriptor(); } else { throw new IOException("broken stream: invalid descriptor type"); } descriptor.load(stream); return new ModuleHandle(FileSystem.getInstance().getFileByPath(file), descriptor); }
public ModuleDescriptor getCurrentArea() { String areaId = getViewParameter(AREA_VIEW_PARAMETER); if (currentArea == null || !currentArea.getId().equals(areaId)) { if (areaId != null) { currentArea = findAreaById(areaId); currentSection = null; } } return currentArea; }
private void loadFlowModule(ModuleDescriptor desc) { try { FlowModule mod = (FlowModule) newModuleInstance(desc); nameToFInst.put(desc.getName(), mod); Class[] list = mod.getFilterMessageClassList(); for (int i = 0; i < list.length; i++) { receptor.getClassLocator().addClass(list[i]); } } catch (Exception ex) { ex.printStackTrace(); } }
public void moduleFileAdded(ModuleFileAddedEvent e) { ModuleDescriptor desc = e.getModuleDescriptor(); if (desc.getType() == Descriptor.TYPE_FLOW) { loadFlowModule(desc); } String modName = desc.getName(); Object[] handles = phantomModules.toArray(); downloadSet.remove(modName); for (int i = 0; i < handles.length; i++) { ModuleHandle handle = (ModuleHandle) handles[i]; if (handle.getModuleName().equals(modName)) { if (newModuleInstantiation(handle, false) != null) { phantomModules.remove(handle); fireModuleAdded(handle); } } } }
public String getActivePage() { if (currentSection != null) return currentSection.getId(); if (currentArea != null) return currentArea.getId(); return null; }