public void test_SimpleFindAndMoveForIntroduceLocalVarTest() throws Exception { this.addNodeById("7568753874916244225"); this.addNodeById("7568753874916244315"); IntroduceLocalVariableRefactoring refactoring = new IntroduceLocalVariableRefactoring(); refactoring.init( SNodeOperations.cast( this.getNodeById("7568753874916244242"), "jetbrains.mps.baseLanguage.structure.StringLiteral"), null); refactoring.setName("s"); refactoring.setReplacingAll(true); refactoring.doRefactoring(); { List<SNode> nodesBefore = ListSequence.fromListAndArray( new ArrayList<SNode>(), SNodeOperations.cast( this.getNodeById("7568753874916244226"), "jetbrains.mps.baseLanguage.structure.ClassConcept")); List<SNode> nodesAfter = ListSequence.fromListAndArray( new ArrayList<SNode>(), SNodeOperations.cast( this.getNodeById("7568753874916244316"), "jetbrains.mps.baseLanguage.structure.ClassConcept")); Assert.assertNull( "nodes '" + nodesBefore + "' and '" + nodesAfter + "' do not match!", NodesMatcher.matchNodes(nodesBefore, nodesAfter)); } }
@Override protected void doFind( SNode node, SearchScope scope, List<SNode> _results, ProgressMonitor monitor) { monitor.start(getDescription(), 1); try { for (SNode nodeUsage : FindUtils.executeFinder( "jetbrains.mps.lang.structure.findUsages.NodeUsages_Finder", node, scope, monitor.subTask(1))) { if (SNodeOperations.hasRole( nodeUsage, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, 0x10f6353296dL, "superclass"))) { ListSequence.fromList(_results).addElement(SNodeOperations.getParent(nodeUsage)); } else if (SNodeOperations.isInstanceOf( nodeUsage, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x1107e0cb103L, "jetbrains.mps.baseLanguage.structure.AnonymousClass"))) { ListSequence.fromList(_results).addElement(nodeUsage); } } } finally { monitor.done(); } }
public SNode getNearestOverloaded(SNode node, SNode leftType, SNode rightType) { if (!(SNodeOperations.isInstanceOf( node, "jetbrains.mps.baseLanguage.structure.BinaryOperation"))) { return null; } SNode result = (SNode) (node.getUserObject("operator")); if (result != null) { return result; } Map<SNode, Boolean> operatorMap = getOverloadedOperators( SNodeOperations.cast(node, "jetbrains.mps.baseLanguage.structure.BinaryOperation"), leftType, rightType); if (MapSequence.fromMap(operatorMap).isEmpty()) { return null; } result = MapSequence.fromMap(operatorMap).first().key(); boolean resultReversed = MapSequence.fromMap(operatorMap).first().value(); for (IMapping<SNode, Boolean> operatorEntry : MapSequence.fromMap(operatorMap)) { SNode operator = operatorEntry.key(); boolean reversed = operatorEntry.value() != resultReversed; if (isSubTypeOperator(operator, result, reversed)) { result = operator; resultReversed = operatorEntry.value(); } } node.putUserObject("operator", result); node.putUserObject("reversed", resultReversed); return result; }
public static boolean nodeSubstituteActionsBuilder_Precondition_Statement_7750890258733139493( final IOperationContext operationContext, final NodeSubstitutePreconditionContext _context) { if ((SNodeOperations.getAncestor( _context.getParentNode(), "jetbrains.mps.lang.typesystem.structure.InferenceRule", false, false) != null)) { return true; } SNode method = SNodeOperations.getAncestor( _context.getParentNode(), "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration", false, false); if ((method != null) && BaseMethodDeclaration_Behavior.call_hasAnnotation_5499146221535822693( method, SNodeOperations.getNode( "r:00000000-0000-4000-0000-011c895902b5(jetbrains.mps.lang.typesystem.dependencies)", "1196177069451"))) { return true; } return false; }
@Override public void childRemoved(SModelChildEvent event) { if (SNodeOperations.isInstanceOf( ((SNode) event.getParent()), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"))) { if (!(SNodeOperations.isInstanceOf( ((SNode) event.getChild()), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration")))) { return; } } if (SNodeOperations.isInstanceOf( ((SNode) event.getParent()), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration"))) { String role = event.getChildRole(); if (!("parameter".equals(role))) { return; } } super.childRemoved(event); }
public void execute(SNode node) { if ((boolean) Expression__BehaviorDescriptor.singleValue_id1o8Ht9sES3u.invoke( SNodeOperations.asSConcept( SNodeOperations.getConceptDeclaration( SLinkOperations.getTarget( ((SNode) RemoveUnnecessaryParentheses_QuickFix.this .getField("bottomLineParens")[0]), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfb4ed32b7fL, 0xfb4ed32b80L, "expression")))))) { SNodeOperations.replaceWithAnother( node, SLinkOperations.getTarget( ((SNode) RemoveUnnecessaryParentheses_QuickFix.this.getField("bottomLineParens")[0]), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfb4ed32b7fL, 0xfb4ed32b80L, "expression"))); } SNodeOperations.replaceWithAnother( node, ((SNode) RemoveUnnecessaryParentheses_QuickFix.this.getField("bottomLineParens")[0])); }
public static void nodeFactory_NodeSetup_CoerceExpression_1178879020941( final IOperationContext operationContext, final NodeSetupContext _context) { if (SNodeOperations.isInstanceOf( _context.getSampleNode(), "jetbrains.mps.lang.typesystem.structure.CoerceExpression")) { SLinkOperations.setTarget( _context.getNewNode(), "nodeToCoerce", SLinkOperations.getTarget( SNodeOperations.cast( _context.getSampleNode(), "jetbrains.mps.lang.typesystem.structure.CoerceExpression"), "nodeToCoerce", true), true); SLinkOperations.setTarget( _context.getNewNode(), "pattern", SLinkOperations.getTarget( SNodeOperations.cast( _context.getSampleNode(), "jetbrains.mps.lang.typesystem.structure.CoerceExpression"), "pattern", true), true); } }
public static Object referenceMacro_GetReferent_293523277269645392( final IOperationContext operationContext, final ReferenceMacroContext _context) { return SNodeOperations.cast( SNodeOperations.getParent( SLinkOperations.getTarget(_context.getNode(), "headerRowLinkDeclaration", false)), "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"); }
public SNode convertField(PsiField x, SNode parentConcept) { SNode field; if (isStatic(x) || SConceptOperations.isSubConceptOf( parentConcept, "jetbrains.mps.baseLanguage.structure.Interface")) { field = SConceptOperations.createNewNode( "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration", null); } else { field = SConceptOperations.createNewNode( "jetbrains.mps.baseLanguage.structure.FieldDeclaration", null); SPropertyOperations.set( SNodeOperations.cast(field, "jetbrains.mps.baseLanguage.structure.FieldDeclaration"), "isVolatile", "" + (x.hasModifierProperty(PsiModifier.VOLATILE))); SPropertyOperations.set( SNodeOperations.cast(field, "jetbrains.mps.baseLanguage.structure.FieldDeclaration"), "isTransient", "" + (x.hasModifierProperty(PsiModifier.TRANSIENT))); } SPropertyOperations.set(field, "name", x.getName()); SLinkOperations.setTarget( SNodeOperations.cast(field, "jetbrains.mps.baseLanguage.structure.ClassifierMember"), "visibility", getVisibility(x), true); SPropertyOperations.set(field, "isFinal", "" + (isFinal(x))); SLinkOperations.setTarget(field, "type", convertType(x.getType()), true); addAnnotations(x, field); return field; }
public void execute(final SNode node, final EditorContext editorContext) { String name = CreateFromUsageUtil.getText(editorContext); if (name == null || name.length() == 0) { name = "default_" + SPropertyOperations.getString(node, "name"); } SNode t = SNodeFactoryOperations.createNewRootNode( SNodeOperations.getModel(node), "jetbrains.mps.lang.generator.structure.TemplateDeclaration", null); SPropertyOperations.set(t, "name", name); t.setProperty( SModelTreeNode.PACK, SPropertyOperations.getString( SNodeOperations.cast( SNodeOperations.getContainingRoot(node), "jetbrains.mps.lang.core.structure.BaseConcept"), "virtualPackage")); // make reference SNode tr = SNodeFactoryOperations.createNewNode( "jetbrains.mps.lang.generator.structure.TemplateDeclarationReference", null); SLinkOperations.setTarget(tr, "template", t, false); SLinkOperations.setTarget(node, "defaultConsequence", tr, true); }
private static SNode getDependencyTarget_id4RsV8qJH_ED( @NotNull SNode __thisNode__, VisibleArtifacts artifacts) { if (SNodeOperations.getContainingRoot(__thisNode__) == SNodeOperations.getContainingRoot( SLinkOperations.getTarget( __thisNode__, MetaAdapterFactory.getReferenceLink( 0x798100da4f0a421aL, 0xb99171f8c50ce5d2L, 0x4ddcec86afb65a3fL, 0x4ddcec86afb65a40L, "folder")))) { return null; } return JavaExportUtil.requireJarFolder( artifacts, SLinkOperations.getTarget( __thisNode__, MetaAdapterFactory.getReferenceLink( 0x798100da4f0a421aL, 0xb99171f8c50ce5d2L, 0x4ddcec86afb65a3fL, 0x4ddcec86afb65a40L, "folder")), __thisNode__); }
public static boolean baseMappingRule_Condition_1217891542034( final BaseMappingRuleContext _context) { return SNodeOperations.isInstanceOf( SLinkOperations.getTarget( SNodeOperations.as( SLinkOperations.getTarget( _context.getNode(), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11b0d00332cL, 0xf8c77f1e97L, "lValue")), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, "jetbrains.mps.baseLanguage.structure.DotExpression")), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, 0x116b46b36c4L, "operation")), MetaAdapterFactory.getConcept( 0xd7706f639be2479cL, 0xa3daae92af1e64d5L, 0x11b8fe60348L, "jetbrains.mps.lang.generator.generationContext.structure.GenerationContextOp_UserObjectAccessBase")); }
/*package*/ static boolean isRerunnable_id1JWcQ2Vfe4u(@NotNull SNode __thisNode__) { SNode prop = Sequence.fromIterable( DSLClassMember__BehaviorDescriptor.find_id2gzehMfi1$l.invoke( SNodeOperations.getNode( "90746344-04fd-4286-97d5-b46ae6a81709/r:52a3d974-bd4f-4651-ba6e-a2de5e336d95(jetbrains.mps.lang.migration/jetbrains.mps.lang.migration.methods)", "2016543223706274716"), __thisNode__)) .first(); return prop != null && SPropertyOperations.getBoolean( SNodeOperations.cast( prop, MetaAdapterFactory.getConcept( 0xc7d5b9dda05f4be2L, 0xbc73f2e16994cc67L, 0x59e9926e84100ec3L, "jetbrains.mps.baseLanguage.lightweightdsl.structure.BooleanPropertyInstance")), MetaAdapterFactory.getProperty( 0xc7d5b9dda05f4be2L, 0xbc73f2e16994cc67L, 0x59e9926e84100ec3L, 0x59e9926e84100ec4L, "value")); }
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 static List<SNode> virtual_getTestMethods_2148145109766218395(SNode thisNode) { List<SNode> result = new ArrayList<SNode>(); if (!(SPropertyOperations.getBoolean(thisNode, "abstractClass"))) { ListSequence.fromList(result) .addSequence( ListSequence.fromList( SLinkOperations.getTargets( SLinkOperations.getTarget(thisNode, "testMethodList", true), "testMethod", true))); if (SNodeOperations.isInstanceOf( SLinkOperations.getTarget( SLinkOperations.getTarget(thisNode, "superclass", true), "classifier", false), "jetbrains.mps.baseLanguage.unitTest.structure.ITestCase")) { ListSequence.fromList(result) .addSequence( ListSequence.fromList( BehaviorReflection.invokeVirtual( (Class<List<SNode>>) ((Class) Object.class), SNodeOperations.cast( SLinkOperations.getTarget( SLinkOperations.getTarget(thisNode, "superclass", true), "classifier", false), "jetbrains.mps.baseLanguage.unitTest.structure.ITestCase"), "virtual_getTestMethods_2148145109766218395", new Object[] {}))); } } return result; }
public void test_RemoveParameter() throws Exception { this.addNodeById("1230052944082"); this.addNodeById("1230052944093"); ChangeMethodSignatureParameters params = new ChangeMethodSignatureParameters( SNodeOperations.cast( this.getNodeById("1230052944084"), "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration")); ListSequence.fromList(SLinkOperations.getTargets(params.getDeclaration(), "parameter", true)) .clear(); ChangeMethodSignatureRefactoring ref = new ChangeMethodSignatureRefactoring( params, SNodeOperations.cast( this.getNodeById("1230052944084"), "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration")); ref.doRefactoring(); { List<SNode> nodesBefore = ListSequence.fromListAndArray( new ArrayList<SNode>(), SNodeOperations.cast( this.getNodeById("1230052944083"), "jetbrains.mps.baseLanguage.structure.ClassConcept")); List<SNode> nodesAfter = ListSequence.fromListAndArray( new ArrayList<SNode>(), SNodeOperations.cast( this.getNodeById("1230052944094"), "jetbrains.mps.baseLanguage.structure.ClassConcept")); Assert.assertNull( "nodes '" + nodesBefore + "' and '" + nodesAfter + "' do not match!", NodesMatcher.matchNodes(nodesBefore, nodesAfter)); } }
public static boolean call_isParameterOfThisMethod_1240394425603(SNode thisNode) { // todo: method from ParameterReference. Remove. if (!(SNodeOperations.isInstanceOf( SLinkOperations.getTarget(thisNode, "variableDeclaration", false), "jetbrains.mps.baseLanguage.structure.ParameterDeclaration"))) { throw new IllegalArgumentException(); } if (SNodeOperations.getAncestor( thisNode, "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration", false, false) == SNodeOperations.getAncestor( SLinkOperations.getTarget(thisNode, "variableDeclaration", false), "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration", false, false)) { if (SNodeOperations.getAncestor( thisNode, "jetbrains.mps.baseLanguage.structure.Closureoid", false, false) == SNodeOperations.getAncestor( SLinkOperations.getTarget(thisNode, "variableDeclaration", false), "jetbrains.mps.baseLanguage.structure.Closureoid", false, false)) { return true; } } return false; }
/*package*/ static List<SNode> getApplicableConceptFunctionParameter_id2D1PBM_bxJg( @NotNull SAbstractConcept __thisConcept__) { List<SNode> result = ConceptFunction__BehaviorDescriptor.getApplicableConceptFunctionParameter_id2D1PBM_bxJg .invokeSpecial(__thisConcept__); ListSequence.fromList(result) .addElement( SNodeOperations.getNode( "r:00000000-0000-4000-0000-011c895902a8(jetbrains.mps.lang.actions.structure)", "5584396657084912703")); ListSequence.fromList(result) .addElement( SNodeOperations.getNode( "r:00000000-0000-4000-0000-011c895902a8(jetbrains.mps.lang.actions.structure)", "5584396657084920413")); ListSequence.fromList(result) .addElement( SNodeOperations.getNode( "r:00000000-0000-4000-0000-011c895902a8(jetbrains.mps.lang.actions.structure)", "5584396657084920670")); ListSequence.fromList(result) .addElement( SNodeOperations.getNode( "r:00000000-0000-4000-0000-011c895902bc(jetbrains.mps.lang.sharedConcepts.structure)", "1161622665029")); return result; }
public static void nodeFactory_NodeSetup_IsSubtypeExpression_1177408248540( final IOperationContext operationContext, final NodeSetupContext _context) { if (SNodeOperations.isInstanceOf( _context.getSampleNode(), "jetbrains.mps.lang.typesystem.structure.IsSubtypeExpression")) { SLinkOperations.setTarget( _context.getNewNode(), "subtypeExpression", SLinkOperations.getTarget( SNodeOperations.cast( _context.getSampleNode(), "jetbrains.mps.lang.typesystem.structure.IsSubtypeExpression"), "subtypeExpression", true), true); SLinkOperations.setTarget( _context.getNewNode(), "supertypeExpression", SLinkOperations.getTarget( SNodeOperations.cast( _context.getSampleNode(), "jetbrains.mps.lang.typesystem.structure.IsSubtypeExpression"), "supertypeExpression", true), true); } }
public static boolean baseMappingRule_Condition_1196429868936( final BaseMappingRuleContext _context) { return SNodeOperations.isInstanceOf( TypeChecker.getInstance() .getTypeOf( SLinkOperations.getTarget( _context.getNode(), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11cL, "leftExpression"))), MetaAdapterFactory.getConcept( 0xff24ab03965e4d15L, 0x9aed52dc276658f4L, 0x11686a0422aL, "jetbrains.mps.samples.complex.structure.ComplexType")) && SNodeOperations.isInstanceOf( TypeChecker.getInstance() .getTypeOf( SLinkOperations.getTarget( _context.getNode(), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11bL, "rightExpression"))), MetaAdapterFactory.getConcept( 0xff24ab03965e4d15L, 0x9aed52dc276658f4L, 0x11686a0422aL, "jetbrains.mps.samples.complex.structure.ComplexType")); }
public static void nodeFactory_NodeSetup_TypeOfExpression_1179476271704( final IOperationContext operationContext, final NodeSetupContext _context) { if (SNodeOperations.isInstanceOf( _context.getSampleNode(), "jetbrains.mps.baseLanguage.structure.Expression")) { if (!(SNodeOperations.isInstanceOf( _context.getSampleNode(), "jetbrains.mps.lang.typesystem.structure.TypeOfExpression"))) { SLinkOperations.setTarget( _context.getNewNode(), "term", SNodeOperations.cast( _context.getSampleNode(), "jetbrains.mps.baseLanguage.structure.Expression"), true); } else { SLinkOperations.setTarget( _context.getNewNode(), "term", SLinkOperations.getTarget( SNodeOperations.cast( _context.getSampleNode(), "jetbrains.mps.lang.typesystem.structure.TypeOfExpression"), "term", true), true); } } }
@Override public void execute(@NotNull String pattern) { final SNode result = SNodeFactoryOperations.createNewNode( SNodeFactoryOperations.asInstanceConcept( MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11adecdb4f0L, "jetbrains.mps.baseLanguage.structure.PostfixIncrementExpression")), null); SLinkOperations.setTarget( result, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x120a4c1f269L, 0x120a4c433a6L, "expression"), SNodeOperations.copyNode(_context.getNode())); SNodeOperations.replaceWithAnother(_context.getNode(), result); SelectionUtil.selectLabelCellAnSetCaret( _context.getEditorContext(), result, SelectionManager.LAST_CELL, -1); return; }
private static List<SNode> getImplementedAndExtended( SNode classifier, Map<SNode, SNode> typeByTypeVar) { Set<SNode> set = SetSequence.fromSet(new LinkedHashSet<SNode>()); ClassifierAndSuperClassifiersCache.ClassifiersDataSet.collectImplementedAndExtended( classifier, set, null, typeByTypeVar); List<SNode> result = new ArrayList<SNode>(); ListSequence.fromList(result).addSequence(SetSequence.fromSet(set)); SNode objectClass = SNodeOperations.getNode( "6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.lang(JDK/)", "~Object"); if (objectClass != null && !(SetSequence.fromSet(set).contains(objectClass))) { int indexOfFirstInterface = 0; for (SNode classifierInResult : set) { if (SNodeOperations.isInstanceOf( classifierInResult, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101edd46144L, "jetbrains.mps.baseLanguage.structure.Interface"))) { break; } indexOfFirstInterface++; } if (indexOfFirstInterface == 0) { result.add(objectClass); } else { result.add(indexOfFirstInterface, objectClass); } } return result; }
@Deprecated private static boolean staticCanBeAChild_Old( SNode node, SNode parentNode, SNode link, SNode childConcept, final IOperationContext operationContext) { return (SNodeOperations.getNodeAncestor( parentNode, MetaAdapterFactory.getConcept( 0x22e72e4c0f6946ceL, 0x84036750153aa615L, 0x220f4a2c4aff4248L, "jetbrains.mps.execution.configurations.structure.ExecuteBeforeTask_ConceptFunction"), true, false) != null) || (SNodeOperations.getNodeAncestor( parentNode, MetaAdapterFactory.getConcept( 0x22e72e4c0f6946ceL, 0x84036750153aa615L, 0x5532ce3cbd91002cL, "jetbrains.mps.execution.configurations.structure.ExecuteConfiguration_Function"), true, false) != null); }
public static SNode virtual_getCreatorExpression_7057666463730727863( SNode thisNode, SNode parentRef) { SNode result = SNodeOperations.copyNode( SLinkOperations.getTarget( SLinkOperations.getTarget(thisNode, "declaration", false), "creator", true)); List<SNode> params = SLinkOperations.getTargets( SLinkOperations.getTarget(thisNode, "declaration", false), "parameter", true); List<SNode> args = SLinkOperations.getTargets(thisNode, "argument", true); if (ListSequence.fromList(params).count() != ListSequence.fromList(args).count()) { throw new RuntimeException(); } for (SNode ref : SNodeOperations.getDescendants( result, "jetbrains.mps.baseLanguage.builders.structure.SimpleBuilderParameterReference", false, new String[] {})) { int index = ListSequence.fromList(params).indexOf(SLinkOperations.getTarget(ref, "parameter", false)); SNodeOperations.replaceWithAnother( ref, SNodeOperations.copyNode(ListSequence.fromList(args).getElement(index))); } return result; }
public static String call_getAnonymousClassPresentation_3421461530438560331( SNode thisNode, SNode containingClassifier) { String result = "Anonymous in "; SNode containingMethod = SNodeOperations.getNodeAncestor( thisNode, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration"), false, false); if (containingMethod != null && SNodeOperations.getParent(containingMethod) == containingClassifier) { result += SPropertyOperations.getString( containingMethod, MetaAdapterFactory.getProperty( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")) + "() in "; } return result; }
public void execute(final SNode node, final EditorContext editorContext) { SNode templateNode = SNodeFactoryOperations.createNewRootNode( SNodeOperations.getModel(node), "jetbrains.mps.lang.generator.structure.TemplateDeclaration", null); SNode ruleNode = SNodeOperations.getAncestor( node, "jetbrains.mps.lang.generator.structure.BaseMappingRule", false, false); SLinkOperations.setTarget( templateNode, "applicableConcept", SLinkOperations.getTarget(ruleNode, "applicableConcept", false), false); SPropertyOperations.set(templateNode, "name", "template1"); SLinkOperations.setTarget( templateNode, "contentNode", SLinkOperations.getTarget(node, "templateNode", true), true); SPropertyOperations.set( templateNode, "virtualPackage", SPropertyOperations.getString(SNodeOperations.getContainingRoot(node), "virtualPackage")); SNode templateRefNode = SNodeFactoryOperations.replaceWithNewChild( node, "jetbrains.mps.lang.generator.structure.TemplateDeclarationReference"); SLinkOperations.setTarget(templateRefNode, "template", templateNode, false); SelectionUtil.selectNode(editorContext, templateNode); }
public static boolean virtual_isMpsStartRequired_3310779261129403089(SNode thisNode) { for (SNode annotationInstance : ListSequence.fromList(SLinkOperations.getTargets(thisNode, "annotation", true))) { if (SLinkOperations.getTarget(annotationInstance, "annotation", false) .equals( SNodeOperations.getNode( "f:java_stub#920eaa0e-ecca-46bc-bee7-4e5c59213dd6#jetbrains.mps(Testbench/jetbrains.mps@java_stub)", "~MPSLaunch"))) { return true; } } for (SNode method : SLinkOperations.getTargets( SLinkOperations.getTarget(thisNode, "testMethodList", true), "testMethod", true)) { for (SNode annotationInstance : SLinkOperations.getTargets(method, "annotation", true)) { if (SLinkOperations.getTarget(annotationInstance, "annotation", false) .equals( SNodeOperations.getNode( "f:java_stub#920eaa0e-ecca-46bc-bee7-4e5c59213dd6#jetbrains.mps(Testbench/jetbrains.mps@java_stub)", "~MPSLaunch"))) { return true; } } } return false; }
private Map<SNode, Boolean> getOverloadedOperators(SNode node, SNode leftType, SNode rightType) { Map<SNode, Boolean> result = MapSequence.fromMap(new HashMap<SNode, Boolean>()); if (!(SNodeOperations.isInstanceOf( node, "jetbrains.mps.baseLanguage.structure.BinaryOperation"))) { return result; } for (SNode operator : getOperatorContainers()) { if (isOverloading( SNodeOperations.cast(node, "jetbrains.mps.baseLanguage.structure.BinaryOperation"), leftType, rightType, operator)) { MapSequence.fromMap(result).put(operator, false); } if (SPropertyOperations.getBoolean(operator, "commutative") && isOverloading( SNodeOperations.cast(node, "jetbrains.mps.baseLanguage.structure.BinaryOperation"), rightType, leftType, operator)) { MapSequence.fromMap(result).put(operator, true); } } return result; }
protected void applyTransormMigration( SNode origin, Computable<SNode> migration, _FunctionTypes._void_P2_E0<? super SNode, ? super SNode> postprocess) { MigrationScriptBase.SNodePlacePointer pointer = createSNodePlacePointer(origin); List<SNode> descendants = SNodeOperations.getNodeDescendants(origin, null, true, new SAbstractConcept[] {}); SNode migrated = migration.compute(); if (postprocess != null) { postprocess.invoke(origin, migrated); } if (migrated == null) { // origin should be removed pointer.remove(); } else { if (!(ListSequence.fromList(descendants).contains(migrated)) && migrated instanceof jetbrains.mps.smodel.SNode) { // returned value is new created node if (!(ListSequence.fromList(SNodeOperations.getNodeAncestors(origin, null, false)) .contains(migrated))) { // origin is not keeped ((jetbrains.mps.smodel.SNode) migrated).setId(origin.getNodeId()); } } pointer.insertOrReplace(migrated); } }