private static SModule getModuleForModel(MPSProject project, SModel model) { // language's and solution's own models (+generator models in language) SModule owner = model.getModule(); SModule mainModule = owner instanceof Generator ? ((Generator) owner).getSourceLanguage() : owner; if (project.isProjectModule(mainModule)) return owner; // accessories models in languages /* //with this enabled, alt-f1 does not work in case node is in non-owned accessory model to a project language for (Language l : project.getProjectLanguages()) { if (l.isAccessoryModel(model.getSModelReference())) return l; } */ // runtime models in languages for (Language l : project.getProjectModules(Language.class)) { for (SModuleReference depModule : l.getRuntimeModulesReferences()) { if (depModule.equals(mainModule.getModuleReference())) return owner; } } // accessories models in devkits // runtime models in devkits return owner; }
/*package*/ Solution createNewSolution(final IFile solutionDescriptorFile) { MPSProject mpsProject = myThis.getProject(); // Prepare files File dir = new File(solutionDescriptorFile.getAbsolutePath()).getParentFile(); if (!(dir.exists())) { dir.mkdirs(); } String solutionFileName = solutionDescriptorFile.getName(); String solutionName = solutionFileName.substring(0, solutionFileName.length() - 4); // Create // RE-2448 ModelRoot modelRoot = new ModelRoot(); modelRoot.setPrefix(""); modelRoot.setPath(solutionDescriptorFile.getParent().getAbsolutePath()); final Solution solution = Solution.createStubSolution(solutionName, solutionDescriptorFile, mpsProject, modelRoot); SolutionDescriptor solutionDescriptor = solution.getModuleDescriptor(); solutionDescriptor.setCompileInMPS(myThis.getCompileInMPS()); // Add SWC file to the classpath ModelRoot stubModelEntry = new ModelRoot(); stubModelEntry.setPath(myThis.getSourcesPath()); stubModelEntry.setManager(LanguageID.AS_MANAGER); solutionDescriptor.getStubModelEntries().add(stubModelEntry); // Add languages refs solutionDescriptor .getUsedLanguages() .add(ModuleReference.fromString(Languages.ACTION_SCRIPT_INTERNAL)); solutionDescriptor .getUsedLanguages() .add(ModuleReference.fromString(Languages.ACTION_SCRIPT_LOGGING)); solutionDescriptor .getUsedLanguages() .add(ModuleReference.fromString(Languages.ACTION_SCRIPT_ASSETS)); // Add playerglobal reference Dependency playerGlobalDependency = new Dependency(); playerGlobalDependency.setModuleRef(ModuleReference.fromString(PLAYERGLOBAL_SWC)); solutionDescriptor.getDependencies().add(playerGlobalDependency); // Save the solution descriptor ModelAccess.instance() .writeFilesInEDT( new Runnable() { public void run() { solution.save(); } }); mpsProject.addProjectModule(solution); return solution; }
@Nullable public Object getData(DataProvider dataProvider) { IOperationContext context = (IOperationContext) dataProvider.getData(MPSDataKeys.OPERATION_CONTEXT.getName()); if (context == null) return null; IScope scope = context.getScope(); if (scope != null) return scope; MPSProject project = (MPSProject) dataProvider.getData(MPSDataKeys.MPS_PROJECT.getName()); if (project != null) return project.getProject().getComponent(ProjectScope.class); return GlobalScope.getInstance(); }
public NodeFileStatusMapping( MPSProject project, CurrentDifferenceRegistry registry, NodeVirtualFileSystem nodeFileSystem) { super(project.getProject()); myRegistry = registry; myMPSProject = project; myNodeFileSystem = nodeFileSystem; }
public void doInit(MPSProject project) { TransientModels_CustomProjectPlugin.this.myNotifier = new TransientModelsNotification(project.getProject()); ThreadUtils.runInUIThreadNoWait( new Runnable() { public void run() { TransientModels_CustomProjectPlugin.this.myNotifier.projectOpened(); } }); }
private boolean calcStatus(@NotNull final SNodeReference root) { ComputeRunnable<FileStatus> cr = new ComputeRunnable<FileStatus>( new Computable<FileStatus>() { public FileStatus compute() { SModel m = root.getModelReference().resolve(myMPSProject.getRepository()); if (m instanceof EditableSModel && m.getSource() instanceof FileDataSource && !(m.isReadOnly())) { EditableSModel model = (EditableSModel) m; if (ConflictsUtil.isModelOrModuleConflicting(model, myProject)) { return FileStatus.MERGED_WITH_CONFLICTS; } CurrentDifference diff = myRegistry.getCurrentDifference(model); List<ModelChange> modelChanges = check_onkh7z_a0d0b0a0a0a0o(diff.getChangeSet()); List<ModelChange> rootChanges = ListSequence.fromList(modelChanges) .where( new IWhereFilter<ModelChange>() { public boolean accept(ModelChange ch) { return root.getNodeId().equals(ch.getRootId()); } }) .toListSequence(); if (ListSequence.fromList(rootChanges).count() != 0) { if (ListSequence.fromList(rootChanges).first() instanceof AddRootChange) { VirtualFile vf = VirtualFileUtils.getVirtualFile( ((FileDataSource) m.getSource()).getFile()); if (vf != null) { FileStatus modelStatus = FileStatusManager.getInstance(myProject).getStatus(vf); if (BaseVersionUtil.isAddedFileStatus(modelStatus)) { return modelStatus; } } return FileStatus.ADDED; } return FileStatus.MODIFIED; } } return FileStatus.NOT_CHANGED; } }); myMPSProject.getModelAccess().runReadAction(cr); FileStatus status = cr.getResult(); synchronized (myFileStatusMap) { if (MapSequence.fromMap(myFileStatusMap).get(root) != status) { MapSequence.fromMap(myFileStatusMap).put(root, status); return true; } else { return false; } } }
public void doInit(MPSProject project) { ExtensionPoint<BeforeRunTaskProvider<BeforeRunTask>> beforeTasksExtensionPoint = Extensions.getArea(project.getProject()) .getExtensionPoint(BeforeRunTaskProvider.EXTENSION_POINT_NAME); { BeforeRunTaskProvider beforeTask = (BeforeRunTaskProvider) new GenerateBuild_BeforeTask(); ListSequence.fromList(BeforeTasksInitializer_CustomProjectPlugin.this.myRegisteredBeforeTasks) .addElement(beforeTask); beforeTasksExtensionPoint.registerExtension(beforeTask); } }
public void doDispose(MPSProject project) { ExtensionPoint<BeforeRunTaskProvider<BeforeRunTask>> beforeTasksExtensionPoint = Extensions.getArea(project.getProject()) .getExtensionPoint(BeforeRunTaskProvider.EXTENSION_POINT_NAME); for (BeforeRunTaskProvider beforeTask : ListSequence.fromList( BeforeTasksInitializer_CustomProjectPlugin.this.myRegisteredBeforeTasks)) { beforeTasksExtensionPoint.unregisterExtension(beforeTask); } ListSequence.fromList(BeforeTasksInitializer_CustomProjectPlugin.this.myRegisteredBeforeTasks) .clear(); }
private void statusChanged(@NotNull final SNodeReference nodePointer) { myMPSProject .getModelAccess() .runReadAction( new Runnable() { public void run() { FileStatusManager fsm = FileStatusManager.getInstance(myProject); SNode currentNode = nodePointer.resolve(myMPSProject.getRepository()); if (currentNode == null) { return; } statusChanged(fsm, currentNode); } }); }
public Set<SReference> findUsages(MPSProject project, Iterable<SNode> nodes) { return FindUsagesFacade.getInstance() .findUsages( project.getScope(), SetSequence.fromSetWithValues( new HashSet<SNode>(), Sequence.fromIterable(nodes) .translate( new ITranslator2<SNode, SNode>() { public Iterable<SNode> translate(SNode it) { return SNodeOperations.getNodeDescendants( it, null, true, new SAbstractConcept[] {}); } })), new EmptyProgressMonitor()); }
public void apply(final MPSProject project, final List<SNode> nodesToMove) { final Wrappers._T<SModel> currentModel = new Wrappers._T<SModel>(); project .getRepository() .getModelAccess() .runReadAction( new Runnable() { public void run() { currentModel.value = SNodeOperations.getModel(ListSequence.fromList(nodesToMove).first()); } }); final NodeLocation newLocation = MoveNodesDialog.getSelectedObject( project.getProject(), currentModel.value, new MoveNodesDialog.ModelFilter("Choose Node or Model") { @Override public boolean check(NodeLocation selectedObject, SModel model) { return true; } }); if (newLocation == null) { return; } project .getRepository() .getModelAccess() .runReadAction( new Runnable() { public void run() { for (SNode node : ListSequence.fromList(nodesToMove)) { if (!(SNodeUtil.isAccessible(node, project.getRepository()))) { return; } } if (!(newLocation.isValid(project, nodesToMove))) { return; } final Set<SReference> refUsages = findUsages(project, nodesToMove); SearchResults<SNode> searchResults = nodesToRefactoringResult( nodesToMove, SetSequence.fromSet(refUsages) .select( new ISelector<SReference, SNode>() { public SNode select(SReference it) { return it.getSourceNode(); } }), "reference"); RefactoringViewUtil.refactor( project, searchResults, new _FunctionTypes._void_P1_E0<Set<SNode>>() { public void invoke(final Set<SNode> included) { Map<SReference, SNode> usagesMap = classifyUsages( SetSequence.fromSet(refUsages) .where( new IWhereFilter<SReference>() { public boolean accept(SReference it) { return SetSequence.fromSet(included) .contains(it.getSourceNode()); } })); newLocation.insertNodes(nodesToMove); for (IMapping<SReference, SNode> mapping : MapSequence.fromMap(usagesMap)) { updateUsage(mapping.key(), mapping.value()); } } }, "Move nodes"); } }); }
protected void statusChanged(FileStatusManager fsm, @NotNull SNode node) { fsm.fileStatusChanged(myNodeFileSystem.getFileFor(myMPSProject.getRepository(), node)); }
public TransientModelsComponent( com.intellij.openapi.project.Project ideaProject, MPSProject project, TransientSwapOwnerComponent swapOwner) { super(project.getRepository(), swapOwner); }