public void execute(final SNode node, final EditorContext editorContext) { EditorCell selectedCell = editorContext.getSelectedCell(); if (!(selectedCell.isReferenceCell())) { return; } SNode contextNode = SNodeOperations.cast( selectedCell.getSNode(), "jetbrains.mps.lang.core.structure.BaseConcept"); if (contextNode == null) { return; } String role = selectedCell.getRole(); if (SNodeOperations.isInstanceOf( contextNode, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation")) { SNode attributedNode = SNodeOperations.cast( SNodeOperations.getParent(contextNode), "jetbrains.mps.lang.core.structure.BaseConcept"); assert attributedNode != null; AttributeOperations.setAttribute( attributedNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), role), null); return; } if (AttributeOperations.getAttribute( contextNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), role)) != null) { AttributeOperations.setAttribute( contextNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), role), null); } else { SNode referenceAntiquotation = SNodeFactoryOperations.setNewAttribute( contextNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), role), "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"); if (selectedCell.isSingleNodeCell()) { SPropertyOperations.set( referenceAntiquotation, "label", SPropertyOperations.getString( SNodeOperations.getConceptDeclaration(contextNode), "name")); } } }
public List<?> createParameterObjects( SNode node, IScope scope, IOperationContext operationContext, EditorContext editorContext) { List<SNode> res = ListSequence.fromList(new LinkedList<SNode>()); ListSequence.fromList(res) .addElement( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.regexp.structure.NegativeLookAheadRegexp")); ListSequence.fromList(res) .addElement( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.regexp.structure.NegativeLookBehindRegexp")); ListSequence.fromList(res) .addElement( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.regexp.structure.PositiveLookAheadRegexp")); ListSequence.fromList(res) .addElement( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.regexp.structure.PositiveLookBehindRegexp")); ListSequence.fromList(res) .addElement( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.regexp.structure.MatchParensRegexp")); return res; }
public static List<SubstituteAction> nodeSubstituteActionsBuilder_ActionsFactory_SNodeOperation_1201875763403( final IOperationContext operationContext, final NodeSubstituteActionsFactoryContext _context) { List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>()); ListSequence.fromList(result) .addSequence( ListSequence.fromList( ChildSubstituteActionsHelper.createDefaultSubstituteActions( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.typesystem.structure.Node_TypeOperation"), _context.getParentNode(), _context.getCurrentTargetNode(), _context.getChildSetter(), operationContext))); ListSequence.fromList(result) .addSequence( ListSequence.fromList( ChildSubstituteActionsHelper.createDefaultSubstituteActions( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.typesystem.structure.Node_InferTypeOperation"), _context.getParentNode(), _context.getCurrentTargetNode(), _context.getChildSetter(), operationContext))); return result; }
public static void addVariablePattern(EditorContext context) { EditorCell contextCell = context.getSelectedCell(); SNode node = contextCell.getSNode(); SNode linkDeclaration = SNodeOperations.cast( contextCell.getLinkDeclaration(), "jetbrains.mps.lang.structure.structure.LinkDeclaration"); SNode genuineLinkDeclaration = SModelUtil.getGenuineLinkDeclaration(linkDeclaration); if (linkDeclaration != null && SPropertyOperations.hasValue( genuineLinkDeclaration, "metaClass", "reference", "reference")) { String role = SPropertyOperations.getString(genuineLinkDeclaration, "role"); AttributeOperations.createAndSetAttrbiute( node, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.pattern.structure.LinkPatternVariableDeclaration"), role), "jetbrains.mps.lang.pattern.structure.LinkPatternVariableDeclaration"); } else { AttributeOperations.createAndSetAttrbiute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.pattern.structure.Pattern")), "jetbrains.mps.lang.pattern.structure.PatternVariableDeclaration"); } }
private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) { return SNodeOperations.getConceptDeclaration(node) == SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.closures.structure.ClosureLiteral") || SNodeOperations.getConceptDeclaration(node) == SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.closures.structure.UnrestrictedClosureLiteral"); }
public static List<SubstituteAction> nodeSubstituteActionsBuilder_ActionsFactory_TypeClause_1185801400389( final IOperationContext operationContext, final NodeSubstituteActionsFactoryContext _context) { List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>()); { SNode outputConcept = SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.typesystem.structure.NormalTypeClause"); SNode childConcept = (SNode) _context.getChildConcept(); if (SConceptOperations.isSuperConceptOf(childConcept, NameUtil.nodeFQName(outputConcept))) { SNode wrappedConcept = SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.structure.Expression"); IChildNodeSetter setter = new AbstractChildNodeSetter() { private SNode wrapNode( SNode nodeToWrap, SModel model, @Nullable EditorContext editorContext) { SNode normalTypeClause = SNodeFactoryOperations.createNewNode( model, "jetbrains.mps.lang.typesystem.structure.NormalTypeClause", null); SLinkOperations.setTarget(normalTypeClause, "normalType", nodeToWrap, true); return normalTypeClause; } public boolean returnSmallPart(SNode nodeToWrap) { return false; } @Override public SNode doExecute( SNode pn, SNode oc, SNode nc, IScope sc, @Nullable EditorContext editorContext) { SNode wrappedNode = wrapNode(nc, nc.getModel(), editorContext); _context .getChildSetter() .execute( _context.getParentNode(), _context.getCurrentTargetNode(), wrappedNode, operationContext.getScope(), editorContext); return (returnSmallPart(nc) ? nc : wrappedNode); } }; ListSequence.fromList(result) .addSequence( ListSequence.fromList( ModelActions.createChildNodeSubstituteActions( _context.getParentNode(), _context.getCurrentTargetNode(), wrappedConcept, setter, operationContext))); } } return result; }
public List<?> createParameterObjects( SNode node, IScope scope, IOperationContext operationContext, EditorContext editorContext) { // hack before actions are refactored List<INodeSubstituteAction> actions = ModelActions.createChildSubstituteActions( SNodeOperations.getParent(node), node, SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.structure.BinaryOperation"), new AbstractChildNodeSetter() { protected SNode doExecute( SNode parentNode, SNode oldChild, SNode newChild, IScope scope) { SNode sourceNode = (SNode) oldChild; SNode result = (SNode) newChild; SNodeOperations.replaceWithAnother(sourceNode, result); SLinkOperations.setTarget( result, "leftExpression", SLinkOperations.getTarget(sourceNode, "lValue", true), true); SLinkOperations.setTarget( result, "rightExpression", SLinkOperations.getTarget(sourceNode, "rValue", true), true); return result; } }, operationContext); return actions; }
public static List<INodeSubstituteAction> sideTransform_ActionsFactory_IGeneralizedWordUnit_3147078024758607987( final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) { List<INodeSubstituteAction> result = ListSequence.fromList(new ArrayList<INodeSubstituteAction>()); { SNode concept = SConceptOperations.findConceptDeclaration( "jetbrains.mps.bash.structure.ArithmeticExpansion"); ListSequence.fromList(result) .addElement( new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) { public SNode doSubstitute(String pattern) { SNode newNode = SNodeFactoryOperations.createNewNode( "jetbrains.mps.bash.structure.ArithmeticExpansion", null); SNodeOperations.insertNextSiblingChild(_context.getSourceNode(), newNode); return newNode; } public String getMatchingText(String pattern) { return "$(("; } public String getVisibleMatchingText(String pattern) { return this.getMatchingText(pattern); } }); } return result; }
private void _populateLocalVariables( SNode statementList, SNode beforeStatement, List<SNode> result) { if (statementList == null) { return; } if (statementList != beforeStatement) { this._populateLocalVariablesFromList(statementList, beforeStatement, result); } SNode containingStatement = SNodeOperations.as( LocalVariablesScope.findThisOrParent( statementList, SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.structure.ILocalVariableElement")), "jetbrains.mps.baseLanguage.structure.ILocalVariableElement"); if (containingStatement != null) { statementList = SNodeOperations.getAncestor( containingStatement, "jetbrains.mps.baseLanguage.structure.ILocalVariableElementList", false, false); this._populateLocalVariables(statementList, containingStatement, result); } }
public boolean canWrap(@NotNull SNode node) { if (eq_kl7j79_a0a0b2( SNodeOperations.getConceptDeclaration(node), SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.structure.ClassConcept"))) { if (SPropertyOperations.getBoolean( SNodeOperations.cast(node, "jetbrains.mps.baseLanguage.structure.ClassConcept"), "abstractClass")) { return false; } SNode ancestor = SNodeOperations.cast(node, "jetbrains.mps.baseLanguage.structure.Classifier"); if (!(BehaviorReflection.invokeVirtual( Boolean.TYPE, ancestor, "virtual_checkLoops_3980490811621705344", new Object[] {}))) { return false; } while (ancestor != null && SNodeOperations.isInstanceOf( ancestor, "jetbrains.mps.baseLanguage.structure.ClassConcept") && !(BehaviorReflection.invokeVirtual( String.class, ancestor, "virtual_getFqName_1213877404258", new Object[] {}) .equals(TestCase.class.getCanonicalName()))) { ancestor = check_kl7j79_a0a0d0a0b2( SLinkOperations.getTarget( SNodeOperations.cast( ancestor, "jetbrains.mps.baseLanguage.structure.ClassConcept"), "superclass", true)); } return ancestor != null; } return false; }
public static List<SubstituteAction> sideTransform_ActionsFactory_VarDecl_6585869519574765725( final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) { List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>()); ListSequence.fromList(result) .addElement( new AbstractSideTransformHintSubstituteAction( SConceptOperations.findConceptDeclaration( "jetbrains.mps.nanoc.structure.CExpression"), _context.getSourceNode()) { public SNode doSubstitute( @Nullable final EditorContext editorContext, String pattern) { return SNodeFactoryOperations.setNewChild( _context.getSourceNode(), "initializer", "jetbrains.mps.nanoc.structure.CExpression"); } public String getMatchingText(String pattern) { return "="; } public String getVisibleMatchingText(String pattern) { return getMatchingText(pattern); } }); return result; }
public static List<SubstituteAction> sideTransform_ActionsFactory_VarRef_6585869519574772785( final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) { List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>()); ListSequence.fromList(result) .addElement( new AbstractSideTransformHintSubstituteAction( SConceptOperations.findConceptDeclaration( "jetbrains.mps.nanoc.structure.CAssignmentExpression"), _context.getSourceNode()) { public SNode doSubstitute( @Nullable final EditorContext editorContext, String pattern) { SNode result = SNodeOperations.replaceWithAnother( _context.getSourceNode(), SNodeFactoryOperations.createNewNode( "jetbrains.mps.nanoc.structure.CAssignmentExpression", null)); return SLinkOperations.setTarget( result, "variable", _context.getSourceNode(), true); } public String getMatchingText(String pattern) { return "="; } public String getVisibleMatchingText(String pattern) { return getMatchingText(pattern); } }); return result; }
public static boolean baseMappingRule_Condition_1566704013439143567( final IOperationContext operationContext, final BaseMappingRuleContext _context) { if (!(SNodeOperations.getConceptDeclaration(SNodeOperations.getParent(_context.getNode())) == SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.structure.StatementList"))) { return false; } SNode methodLike = SNodeOperations.getAncestor( SNodeOperations.getParent(_context.getNode()), "jetbrains.mps.baseLanguage.structure.IMethodLike", false, false); if (!(BehaviorReflection.invokeVirtual( (Class<SNode>) ((Class) Object.class), methodLike, "virtual_getLastStatement_1239354409446", new Object[] {}) == _context.getNode())) { return false; } if (!(LastStatementUtil.canMakeReturnStatement(_context.getNode()))) { return false; } return true; }
public InstanceMethodDeclarationScope(SNode classifierNode, Iterable<SNode> extendedClassifiers) { super( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration"), classifierNode, extendedClassifiers); }
public static List<INodeSubstituteAction> sideTransform_ActionsFactory_Attribute_1225239967737( final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) { List<INodeSubstituteAction> result = ListSequence.fromList(new ArrayList<INodeSubstituteAction>()); { SNode concept = SConceptOperations.findConceptDeclaration("jetbrains.mps.sampleXML.structure.Attribute"); ListSequence.fromList(result) .addElement( new AbstractSideTransformHintSubstituteAction(concept, _context.getSourceNode()) { public SNode doSubstitute(String pattern) { // add next attribute SNode nextAttr = SConceptOperations.createNewNode( "jetbrains.mps.sampleXML.structure.Attribute", null); SPropertyOperations.set( nextAttr, "name", ((pattern == null ? null : pattern.trim()))); SNodeOperations.insertNextSiblingChild(_context.getSourceNode(), nextAttr); return nextAttr; } public String getMatchingText(String pattern) { return pattern; } public String getVisibleMatchingText(String pattern) { return this.getMatchingText(pattern); } }); } return result; }
public static List<INodeSubstituteAction> sideTransform_ActionsFactory_ArithmeticExpression_3263637656461345409( final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) { List<INodeSubstituteAction> result = ListSequence.fromList(new ArrayList<INodeSubstituteAction>()); { final String[] lastPattern = new String[1]; List<INodeSubstituteAction> list = ModelActions.createChildSubstituteActions( _context.getSourceNode(), null, SConceptOperations.findConceptDeclaration( "jetbrains.mps.bash.structure.BinaryArithmeticExpression"), new AbstractChildNodeSetter() { public SNode doExecute( SNode parentNode, SNode oldChild, SNode newChild, IScope p3) { return substitute(newChild, lastPattern[0]); } private SNode substitute(SNode result, String pattern) { SNode source = SNodeOperations.cast( _context.getSourceNode(), "jetbrains.mps.bash.structure.ArithmeticExpression"); while (SNodeOperations.isInstanceOf( SNodeOperations.getParent(source), "jetbrains.mps.bash.structure.BinaryArithmeticExpression")) { SNode parent = SNodeOperations.cast( SNodeOperations.getParent(source), "jetbrains.mps.bash.structure.BinaryArithmeticExpression"); if (SConceptPropertyOperations.getInteger(result, "priority") < SConceptPropertyOperations.getInteger(parent, "priority")) { source = parent; } else { break; } } SNodeOperations.replaceWithAnother(source, result); SLinkOperations.setTarget(result, "leftExpression", source, true); return result; } }, operationContext); for (final INodeSubstituteAction action : list) { ListSequence.fromList(result) .addElement( new NodeSubstituteActionWrapper(action) { @Override public SNode substitute(@Nullable EditorContext context, String pattern) { lastPattern[0] = pattern; return super.substitute(context, pattern); } }); } } return result; }
public void execute(final SNode node, final EditorContext editorContext) { DocCommentHelper.addJavadocLangIfMissing(node); if ((AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))) == null)) { SNodeFactoryOperations.setNewAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment")), "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"); SNode line = SNodeFactoryOperations.addNewChild( AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))), "body", "jetbrains.mps.baseLanguage.javadoc.structure.CommentLine"); SNodeFactoryOperations.addNewChild( line, "part", "jetbrains.mps.baseLanguage.javadoc.structure.TextCommentLinePart"); } else { AttributeOperations.setAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment")), null); } editorContext.select( ListSequence.fromList( SLinkOperations.getTargets( AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))), "body", true)) .first()); }
public static List<INodeSubstituteAction> nodeSubstituteActionsBuilder_ActionsFactory_LValue_9034131902188086416( final IOperationContext operationContext, final NodeSubstituteActionsFactoryContext _context) { List<INodeSubstituteAction> result = ListSequence.fromList(new ArrayList<INodeSubstituteAction>()); { SNode outputConcept = SConceptOperations.findConceptDeclaration( "jetbrains.mps.bash.structure.VariableNameDeclaration"); SNode childConcept = (SNode) _context.getChildConcept(); if (outputConcept == null || SConceptOperations.isSuperConceptOf( childConcept, NameUtil.nodeFQName(outputConcept))) { ListSequence.fromList(result) .addElement( new DefaultSimpleSubstituteAction( outputConcept, _context.getParentNode(), _context.getCurrentTargetNode(), _context.getChildSetter(), operationContext.getScope()) { public SNode createChildNode( Object parameterObject, SModel model, String pattern) { SNode name = SNodeFactoryOperations.createNewNode( "jetbrains.mps.bash.structure.VariableNameDeclaration", null); SPropertyOperations.set(name, "name", pattern); return name; } public boolean hasSubstitute() { return true; } public boolean canSubstitute_internal(String pattern, boolean strictly) { SNode name = VariableNameDeclaration_Behavior.testName_9034131902194480300( _context.getCurrentTargetNode(), pattern); if ((name != null)) { return false; } return REGEXP_x583g4_a0a2a2a0a0a0a2a0a1a6.matcher(pattern).matches(); } public String getMatchingText(String pattern) { return pattern; } public String getVisibleMatchingText(String pattern) { return this.getMatchingText(pattern); } }); } } return result; }
private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) { return NodesTestCase_Behavior.call_isIntentionApplicable_1217250498008( SConceptRepository.getInstance() .getConcept( NameUtil.nodeFQName( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.test.structure.NodesTestCase"))), node); }
public void execute(final SNode node, final EditorContext editorContext) { AttributeOperations.setAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe")), SNodeFactoryOperations.createNewNode( "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe", null)); }
public String getDescription(final SNode node, final EditorContext editorContext) { String type = (SNodeOperations.getConceptDeclaration(node) == SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.closures.structure.ClosureLiteral") ? "Unrestricted" : "Restricted"); return "Convert to " + type + " Closure Literal"; }
public boolean canWrap(@NotNull SNode node) { if (eq_kl7j79_a0a0b4( SNodeOperations.getConceptDeclaration(node), SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.structure.ClassConcept"))) { return JUnit4TestWrapper.isJUnit4TestCase( SNodeOperations.cast(node, "jetbrains.mps.baseLanguage.structure.ClassConcept")); } return false; }
public String getDescription(final SNode node, final EditorContext editorContext) { return ((AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))) == null) ? "Add Documentation Comment" : "Remove Documentation Comment"); }
public static List<SubstituteAction> sideTransform_ActionsFactory_Expression_2879868312063092085( final IOperationContext operationContext, final SideTransformActionsBuilderContext _context) { List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>()); ListSequence.fromList(result) .addElement( new AbstractSideTransformHintSubstituteAction( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.pattern.structure.OrPattern"), _context.getSourceNode()) { public SNode doSubstitute( @Nullable final EditorContext editorContext, String pattern) { SNode orPattern = SNodeFactoryOperations.createNewNode( "jetbrains.mps.lang.pattern.structure.OrPattern", null); SNodeOperations.replaceWithAnother(_context.getSourceNode(), orPattern); return SLinkOperations.setTarget( ListSequence.fromList(SLinkOperations.getTargets(orPattern, "clause", true)) .first(), "patternNode", _context.getSourceNode(), true); } public String getMatchingText(String pattern) { return "|"; } public String getVisibleMatchingText(String pattern) { return getMatchingText(pattern); } @Override protected boolean isEnabled() { SNode sourceNode = getSourceNode(); SNode parent = SNodeOperations.getParent(sourceNode); SNode containingLink = SNodeOperations.getContainingLinkDeclaration(sourceNode); return parent == null || containingLink == null || (ModelConstraints.canBeParent( parent, SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.pattern.structure.OrPattern"), containingLink, null, null) && ModelConstraints.canBeAncestor( parent, null, SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.pattern.structure.OrPattern"), null)); } }); return result; }
public static List<INodeSubstituteAction> nodeSubstituteActionsBuilder_ActionsFactory_IGeneralizedWordUnit_3263637656457821343( final IOperationContext operationContext, final NodeSubstituteActionsFactoryContext _context) { List<INodeSubstituteAction> result = ListSequence.fromList(new ArrayList<INodeSubstituteAction>()); { SNode outputConcept = SConceptOperations.findConceptDeclaration("jetbrains.mps.bash.structure.SimpleWord"); SNode childConcept = (SNode) _context.getChildConcept(); if (outputConcept == null || SConceptOperations.isSuperConceptOf( childConcept, NameUtil.nodeFQName(outputConcept))) { ListSequence.fromList(result) .addElement( new DefaultSimpleSubstituteAction( outputConcept, _context.getParentNode(), _context.getCurrentTargetNode(), _context.getChildSetter(), operationContext.getScope()) { public SNode createChildNode( Object parameterObject, SModel model, String pattern) { SNode newNode = SNodeFactoryOperations.createNewNode( "jetbrains.mps.bash.structure.SimpleWord", null); SPropertyOperations.set(newNode, "word", pattern); return newNode; } public boolean hasSubstitute() { return true; } public boolean canSubstitute_internal(String pattern, boolean strictly) { if (strictly) { return REGEXP_x583g4_a0a0a0a2a0a0a0a2a0a1a3.matcher(pattern).matches(); } else { return REGEXP_x583g4_a0a0a0a0c0a0a0a0c0a0b0d.matcher(pattern).matches(); } } public String getMatchingText(String pattern) { return pattern; } public String getVisibleMatchingText(String pattern) { return this.getMatchingText(pattern); } }); } } return result; }
public boolean isApplicableToNode(final SNode node, final EditorContext editorContext) { return SNodeOperations.isInstanceOf( SLinkOperations.getTarget(node, "operation", true), "jetbrains.mps.baseLanguage.structure.InstanceMethodCallOperation") && AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe"))) == null; }
public List<?> createParameterObjects( SNode node, IOperationContext operationContext, EditorContext editorContext) { return ListSequence.fromList( SConceptOperations.getAllSubConcepts( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.generator.structure.NodeMacro"), SNodeOperations.getModel(node))) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return !(SPropertyOperations.getBoolean(it, "abstract")); } }) .subtract( Sequence.fromIterable( Sequence.<SNode>singleton( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.generator.structure.SwitchMacro")))) .toListSequence(); }
public static List<SubstituteAction> nodeSubstituteActionsBuilder_ActionsFactory_CExpression_6585869519574739818( final IOperationContext operationContext, final NodeSubstituteActionsFactoryContext _context) { List<SubstituteAction> result = ListSequence.fromList(new ArrayList<SubstituteAction>()); { SNode outputConcept = SConceptOperations.findConceptDeclaration("jetbrains.mps.nanoc.structure.CExpression"); SNode childConcept = (SNode) _context.getChildConcept(); if (outputConcept == null || SConceptOperations.isSuperConceptOf( childConcept, NameUtil.nodeFQName(outputConcept))) { ListSequence.fromList(result) .addElement( new DefaultSimpleSubstituteAction( outputConcept, _context.getParentNode(), _context.getCurrentTargetNode(), _context.getChildSetter(), operationContext.getScope()) { public SNode createChildNode( Object parameterObject, SModel model, String pattern) { SNode result = SNodeFactoryOperations.createNewNode( "jetbrains.mps.nanoc.structure.IntConst", null); SPropertyOperations.set(result, "value", pattern); return result; } public boolean hasSubstitute() { return true; } public boolean canSubstitute_internal(String pattern, boolean strictly) { if (strictly) { return REGEXP_x583g4_a0a0a0a2a0a0a0a2a0a1a2.matcher(pattern).matches(); } else { return REGEXP_x583g4_a0a0a0a0c0a0a0a0c0a0b0c.matcher(pattern).matches(); } } public String getMatchingText(String pattern) { return pattern; } public String getVisibleMatchingText(String pattern) { return getMatchingText(pattern); } }); } } return result; }
private void _populateLocalVariables(SNode loopStatement, List<SNode> result) { for (SNode child : SNodeOperations.getChildren(loopStatement)) { if (child.getRoleInParent().equals("body")) { continue; } if (SNodeOperations.isInstanceOf( child, "jetbrains.mps.baseLanguage.structure.LocalVariableDeclaration")) { result.add(child); } // <node> List<SNode> moreChildren = new ArrayList<SNode>(); if (SNodeOperations.isInstanceOf( loopStatement, "jetbrains.mps.lang.typesystem.structure.MultipleForeachLoop")) { ListSequence.fromList(moreChildren) .addSequence( ListSequence.fromList( SLinkOperations.getTargets( SNodeOperations.cast( loopStatement, "jetbrains.mps.lang.typesystem.structure.MultipleForeachLoop"), "loopVariable", true)) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return (SLinkOperations.getTarget(it, "variable", true) != null); } }) .select( new ISelector<SNode, SNode>() { public SNode select(SNode it) { return SLinkOperations.getTarget(it, "variable", true); } })); } for (SNode child_ : moreChildren) { result.add(child_); } } SNode containingLoop = SNodeOperations.as( LocalVariablesScope.findThisOrParent( SNodeOperations.getParent(loopStatement), SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.structure.AbstractLoopStatement")), "jetbrains.mps.baseLanguage.structure.AbstractLoopStatement"); if (containingLoop != null) { this._populateLocalVariables(containingLoop, result); } }
public void execute(final SNode node, final EditorContext editorContext) { EditorCell cell = editorContext.getSelectedCell(); String linkRole = QueriesUtil.getEditedLinkRole(cell); SNode referentNode = QueriesUtil.getEditedLinkReferentNode(cell); SNode result = SNodeFactoryOperations.setNewAttribute( referentNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.editor.editorTest.structure.ReferenceAnnotataion"), linkRole), "jetbrains.mps.lang.editor.editorTest.structure.ReferenceAnnotataion"); }