CodeOrchestraStreamHandler( SModelDescriptor modelDescriptor, IFile outputDir, CodeOrchestraGenerationFileProcessor processor) { myOriginalOutputDir = outputDir; CodeOrchestraGenerateManager codeOrchestraGenerateManager = processor.getProject().getComponent(CodeOrchestraGenerateManager.class); CodeOrchestraGenerationContext currentContext = codeOrchestraGenerateManager.getCurrentContext(); if (currentContext == null) { myOutputDir = outputDir; myCachesOutputDir = FileGenerationUtil.getCachesDir(outputDir); } else { ModuleReference rootModuleReference = currentContext.getRootModule(); // We override the output path for the AS & JS modules if (currentContext.isSingleOutputContext()) { IModule rootModule = MPSModuleRepository.getInstance().getModule(rootModuleReference); myOutputDir = FileSystem.getInstance().getFileByPath(rootModule.getOutputFor(modelDescriptor)); myCachesOutputDir = FileGenerationUtil.getCachesDir(myOutputDir); } else { myOutputDir = outputDir; myCachesOutputDir = FileGenerationUtil.getCachesDir(outputDir); } } myModelDescriptor = modelDescriptor; myProcessor = processor; }
protected void readModules(FileMPSProject.ProjectDescriptor projDesc) { myErrors = null; // load solutions Set<ModuleReference> existingModules = getModuleReferences(); for (Path modulePath : projDesc.getModules()) { String path = modulePath.getPath(); IFile descriptorFile = FileSystem.getInstance().getFileByPath(path); if (descriptorFile.exists()) { ModuleDescriptor descriptor = ModulesMiner.getInstance().loadModuleDescriptor(descriptorFile); if (descriptor != null) { ModulesMiner.ModuleHandle moduleHandle = new ModulesMiner.ModuleHandle(descriptorFile, descriptor); IModule m = ModuleRepositoryFacade.createModule(moduleHandle, this); ModuleReference moduleReference = m.getModuleReference(); if (!(existingModules.remove(moduleReference))) { super.addModule(moduleReference); } } else { error("Can't load module from " + descriptorFile.getPath() + " Unknown file type."); } } else { error("Can't load module from " + descriptorFile.getPath() + " File doesn't exist."); } } for (ModuleReference ref : existingModules) { super.removeModule(ref); } }
private static boolean renderingCondition_fl5ndt_a2b1b0( SNode node, EditorContext editorContext, IScope scope) { String path = null; IModule module = SNodeOperations.getModel(node).getModelDescriptor().getModule(); if (module != null) { path = MacrosFactory.forModuleFile(module.getDescriptorFile()) .expandPath(SPropertyOperations.getString(node, "icon")); } return path != null && FileSystem.getInstance().getFileByPath(path).exists(); }
@Nullable public static IFile getRealDescriptorFile(IModule module) { if (module.getDescriptorFile() != null && module.getModuleDescriptor() != null && module.getModuleDescriptor().getDeploymentDescriptor() != null) { return getRealDescriptorFile( module.getDescriptorFile().getPath(), module.getModuleDescriptor().getDeploymentDescriptor()); } return null; }
public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) { try { IModule module = ((SModelDescriptor) MapSequence.fromMap(_params).get("model")).getModule(); TreeFileChooser treeFileChooser = new TreeFileChooser(); treeFileChooser.setDirectoriesAreAlwaysVisible(true); treeFileChooser.setMode(TreeFileChooser.MODE_DIRECTORIES); final SModel sModel = ((SModelDescriptor) MapSequence.fromMap(_params).get("model")).getSModel(); treeFileChooser.setFileFilter( new IFileFilter() { public boolean accept(IFile file) { return JavaCompiler.checkBaseModelMatchesSourceDirectory( sModel, new File(file.getPath())); } }); String generatorOutputPath = module.getGeneratorOutputPath(); File initial = null; File output = new File(generatorOutputPath); if (output.exists()) { initial = output; File sourceRoot = new File(initial.getParentFile(), "source"); if (!(sourceRoot.exists())) { sourceRoot = new File(initial.getParentFile(), "src"); } initial = sourceRoot; if (sourceRoot.exists()) { File modelSource = new File(sourceRoot, NameUtil.pathFromNamespace(sModel.getLongName())); if (modelSource.exists()) { initial = modelSource; } } } if (initial != null) { treeFileChooser.setInitialFile( FileSystem.getInstance().getFileByPath(initial.getAbsolutePath())); } IFile result = treeFileChooser.showDialog(((Frame) MapSequence.fromMap(_params).get("frame"))); if (result != null) { JavaCompiler javaCompiler = new JavaCompiler( ((IOperationContext) MapSequence.fromMap(_params).get("context")), module, new File(result.getPath()), false, sModel); javaCompiler.compile(); } } catch (Throwable t) { if (log.isErrorEnabled()) { log.error("User's action execute method failed. Action:" + "GetModelContentsFromSource", t); } } }
@Override public Iterable<SModel> getModels() { List<SModel> result = new ArrayList<SModel>(); synchronized (LOCK) { initialize(); for (IModule module : myVisibleModules) { result.addAll(IterableUtil.asCollection(module.getModels())); } for (Language language : myUsedLanguages) { result.addAll(language.getModels()); // todo: ? result.addAll(language.getAccessoryModels()); } } return result; }
private void fillInDevkits(Set<IModule> initialModules) { myUsedDevkits = new HashSet<DevKit>(); for (IModule m : initialModules) { if (m instanceof DevKit) { DevKit dk = (DevKit) m; myUsedDevkits.add(dk); myUsedDevkits.addAll(dk.getAllExtendedDevkits()); } for (DevKit dk : ModuleUtil.refsToDevkits(m.getUsedDevkitReferences())) { myUsedDevkits.add(dk); myUsedDevkits.addAll(dk.getAllExtendedDevkits()); } } }
public static Iterable<SModelDescriptor> call_models_1280144168199531863(SNode thisNode) { ModuleReference moduleReference = BehaviorReflection.invokeVirtual( ModuleReference.class, SLinkOperations.getTarget(thisNode, "moduleRef", true), "virtual_moduleReference_1280144168199513544", new Object[] {}); if (moduleReference == null) { return null; } IModule module = MPSModuleRepository.getInstance().getModule(moduleReference); if (module == null) { return null; } return module.getOwnModelDescriptors(); }
public static IScope call_scope_1280144168199518341(SNode thisNode) { ModuleReference moduleReference = BehaviorReflection.invokeVirtual( ModuleReference.class, SLinkOperations.getTarget(thisNode, "moduleRef", true), "virtual_moduleReference_1280144168199513544", new Object[] {}); if (moduleReference == null) { return null; } IModule module = MPSModuleRepository.getInstance().getModule(moduleReference); if (module == null) { return null; } return module.getScope(); }