private static Color _StyleParameter_QueryFunction_ktoyyv_a0c0( EditorContext editorContext, SNode node) { if (AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke( node, editorContext.getRepository()) == null) { return MPSColors.YELLOW; } else { return null; } }
@Override protected SubstituteMenuLookup getSubstituteMenuLookup(TransformationMenuContext context) { final EditorContext editorContext = context.getEditorContext(); return new DefaultSubstituteMenuLookup( LanguageRegistry.getInstance(editorContext.getRepository()), MetaAdapterFactory.getConcept( 0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x7ce1116e3a6fb0beL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstituteChild")); }
@Nullable @Override protected SubstituteMenuLookup getLookup(SubstituteMenuContext _context) { final EditorContext editorContext = _context.getEditorContext(); return new DefaultSubstituteMenuLookup( LanguageRegistry.getInstance(editorContext.getRepository()), MetaAdapterFactory.getConcept( 0x798100da4f0a421aL, 0xb99171f8c50ce5d2L, 0x3395e884b61c2404L, "jetbrains.mps.build.structure.BuildSource_JavaCP")); }
@Nullable @Override protected SubstituteMenuLookup getSubstituteMenuLookup(TransformationMenuContext _context) { final EditorContext editorContext = _context.getEditorContext(); return new DefaultSubstituteMenuLookup( LanguageRegistry.getInstance(editorContext.getRepository()), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, "jetbrains.mps.baseLanguage.structure.BinaryOperation")); }
@NotNull private String[] getInitialEditorHints(EditorContext editorContext) { if (myInitialEditorHints != null) { return myInitialEditorHints; } Project project = ProjectHelper.toIdeaProject(ProjectHelper.getProject(editorContext.getRepository())); if (project == null) { return EMPTY_HINTS_ARRAY; } HintsState state = ConceptEditorHintSettingsComponent.getInstance(project).getState(); return state.getEnabledHints().toArray(EMPTY_HINTS_ARRAY); }
@Override public void execute(final EditorContext context) { LOG.assertLog( context.getRepository().getModelAccess().isCommandAction(), "This action must be performed in command"); final EditorComponent editorComponent = (EditorComponent) context.getEditorComponent(); final Selection selection = editorComponent.getSelectionManager().getSelection(); final List<SNode> selectedNodes = selection.getSelectedNodes(); // this is used in case node is in repo to pass it into invokeLater final List<SNodeReference> selectedReferences = new ArrayList<SNodeReference>(); for (SNode node : selectedNodes) { selectedReferences.add(node.getReference()); } final CellInfo pasteTargetCellInfo; final SNode cellNodeSelected; final SNodeReference selectedCellReference; if (selection instanceof SingularSelection) { EditorCell pasteTargetCell = getCellToPasteTo(context.getSelectedCell()); if (pasteTargetCell == null) { return; } pasteTargetCellInfo = APICellAdapter.getCellInfo(pasteTargetCell); cellNodeSelected = pasteTargetCell.getSNode(); selectedCellReference = cellNodeSelected.getReference(); } else { pasteTargetCellInfo = null; cellNodeSelected = null; selectedCellReference = null; } final SModel modelToPaste = selectedNodes.get(0).getModel(); // sometimes model is not in repository (paste in merge dialog) final boolean inRepository = modelToPaste.getReference().resolve(context.getRepository()) != null; // FIXME relationship between Project and Editor needs attention, it's bad to extract final Project mpsProject = ProjectHelper.getProject(context.getRepository()); if (mpsProject == null) { LOG.warning("Paste needs a project to show a dialog for additional imports"); return; } final PasteNodeData pasteNodeData = CopyPasteUtil.getPasteNodeDataFromClipboard(modelToPaste); // FIXME why SwingUtlities? Is it necessary to execute in EDT thread? If yes, use ThreadUtils. // If not, use any other thread than UI, e.g. app's pooled one. SwingUtilities.invokeLater( new Runnable() { @Override public void run() { final Runnable addImportsRunnable = CopyPasteUtil.addImportsWithDialog(pasteNodeData, modelToPaste, mpsProject); context .getRepository() .getModelAccess() .executeCommandInEDT( new Runnable() { @Override public void run() { if (addImportsRunnable != null) { addImportsRunnable.run(); } List<SNode> pasteNodes = pasteNodeData.getNodes(); List<SNode> currentSelectedNodes; if (!inRepository) { currentSelectedNodes = selectedNodes; } else { currentSelectedNodes = new ArrayList<SNode>(); for (SNodeReference ref : selectedReferences) { currentSelectedNodes.add( ref.resolve(MPSModuleRepository.getInstance())); } } NodePaster nodePaster = new NodePaster(pasteNodes); boolean disposed = checkDisposedSelectedNodes(currentSelectedNodes, selectedReferences); boolean canPasteWithRemove = !disposed && nodePaster.canPasteWithRemove(currentSelectedNodes); if (selection instanceof SingularSelection && (selection instanceof EditorCellLabelSelection && !isCompletelySelected((EditorCellLabelSelection) selection) || (selection instanceof EditorCellSelection && !canPasteWithRemove))) { EditorCell selectedCell = pasteTargetCellInfo.findCell(editorComponent); assert selectedCell != null; if (canPasteBefore(selectedCell, pasteNodes)) { SNode selectedNode = inRepository ? selectedCellReference.resolve( MPSModuleRepository.getInstance()) : cellNodeSelected; if (checkDisposed(selectedCellReference, cellNodeSelected)) { return; } new NodePaster(pasteNodes) .pasteRelative(selectedNode, PastePlaceHint.BEFORE_ANCHOR); } else { new NodePaster(pasteNodes).paste(selectedCell); } } else if ((selection instanceof MultipleSelection || selection instanceof EditorCellSelection) && canPasteWithRemove) { nodePaster.pasteWithRemove(currentSelectedNodes); } else { return; } Set<SReference> requireResolveReferences = new HashSet<SReference>(); for (SReference ref : pasteNodeData.getRequireResolveReferences()) { // ref can be detached from modeltoPaste while using copy/paste handlers if (ref.getSourceNode() == null || ref.getSourceNode().getModel() == null) continue; requireResolveReferences.add(ref); } ResolverComponent.getInstance() .resolveScopesOnly(requireResolveReferences, context.getRepository()); // set selection editorComponent.getUpdater().flushModelEvents(); SNode lastNode = pasteNodes.get(pasteNodes.size() - 1); editorComponent .getSelectionManager() .setSelection(lastNode, SelectionManager.LAST_CELL, -1); } }); } }); }