private String createMethodParameterTypesString(SNode method, Map<SNode, SNode> typeByTypeVar) { StringBuilder result = new StringBuilder(); for (SNode parm : SLinkOperations.getChildren( method, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, 0xf8cc56b1feL, "parameter"))) { SNode type = SLinkOperations.getTarget( parm, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type")); type = GenericTypesUtil.getTypeWithResolvedTypeVars(type, typeByTypeVar); if (result.length() > 0) { result.append(','); } if (type != null) { result.append( ((String) BHReflection.invoke( type, SMethodTrimmedId.create("getErasureSignature", null, "hEwIzNx")))); } else { result.append(""); } } return result.toString(); }
private SNode getConceptDeclaration(SNode node, final Map<String, Object> _params) { { final SNode acd = node; if (SNodeOperations.isInstanceOf( acd, MetaAdapterFactory.getConcept( 0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"))) { return acd; } } { final SNode conceptAspect = node; if (SNodeOperations.isInstanceOf( conceptAspect, MetaAdapterFactory.getInterfaceConcept( 0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x24614259e94f0c84L, "jetbrains.mps.lang.structure.structure.IConceptAspect"))) { return ((SNode) BHReflection.invoke( conceptAspect, SMethodTrimmedId.create("getBaseConcept", null, "2hxg_BDjKM8"))); } } return null; }
public static SNode getAttribute(SNode node, IAttributeDescriptor descriptor) { Iterable<SNode> list = getAttributes(node, descriptor); if (Sequence.fromIterable(list).isEmpty()) { return null; } if (Sequence.fromIterable(list).count() > 1) { if (LOG.isEnabledFor(Level.ERROR)) { LOG.error( Sequence.fromIterable(list).count() + " nodes match single value attribute. The first found node returned as the value."); } if (LOG.isEnabledFor(Level.ERROR)) { LOG.error( " node=" + node.getReference() + "; attribute=" + ((String) BHReflection.invoke( SNodeOperations.asSConcept( SNodeOperations.getConcept(Sequence.fromIterable(list).first())), SMethodTrimmedId.create("getRole", null, "1653mnvAgoG"))) + " (" + Sequence.fromIterable(list).first().getNodeId() + ")"); } } return Sequence.fromIterable(list).first(); }
public static SNode setAttribute(SNode node, IAttributeDescriptor descriptor, SNode value) { Iterable<SNode> oldlist = getAttributes(node, descriptor); if (Sequence.fromIterable(oldlist).isEmpty() && (value != null)) { addAttribute(node, descriptor, value); } else if ((value == null)) { deleteAttribute(node, descriptor, value); } else { if (Sequence.fromIterable(oldlist).count() > 1) { if (LOG.isEnabledFor(Level.ERROR)) { LOG.error( Sequence.fromIterable(oldlist).count() + " nodes match signle value attribute during attribute replacing. Only the first found node replaced."); } if (LOG.isEnabledFor(Level.ERROR)) { LOG.error( " node=" + node.getReference() + "; attribute=" + ((String) BHReflection.invoke( SNodeOperations.asSConcept( SNodeOperations.getConcept(Sequence.fromIterable(oldlist).first())), SMethodTrimmedId.create("getRole", null, "1653mnvAgoG"))) + " (" + Sequence.fromIterable(oldlist).first().getNodeId() + ")"); } } SNodeOperations.replaceWithAnother(Sequence.fromIterable(oldlist).first(), value); descriptor.update(value); } return value; }
private SContainmentLink getContainmentLink() { if (myContainmentLink == null) { myContainmentLink = ((SContainmentLink) BHReflection.invoke( myComment, SMethodTrimmedId.create( "getLink", MetaAdapterFactory.getConcept( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x9d98713f247885aL, "jetbrains.mps.lang.core.structure.ChildAttribute"), "BpxLfMirzf"))); } return myContainmentLink; }
@Override protected void init() { this.myFieldsByName = MapSequence.fromMap(new HashMap<String, SNode>()); this.myStaticFieldsByName = MapSequence.fromMap(new HashMap<String, SNode>()); List<SNode> allFields = ListSequence.fromList(new ArrayList<SNode>()); List<SNode> classifiers = ((ClassifierAndSuperClassifiersCache) this.getOwnerCache()).getClassifiers(); for (SNode classifier : classifiers) { Iterable<SNode> staticFields = ((Iterable<SNode>) BHReflection.invoke( classifier, SMethodTrimmedId.create( "staticFields", MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"), "4_LVZ3pBr7M"))); ListSequence.fromList(allFields).addSequence(Sequence.fromIterable(staticFields)); for (SNode staticField : staticFields) { String name = SPropertyOperations.getString( staticField, MetaAdapterFactory.getProperty( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")); if (name == null) { name = ""; } if (!(MapSequence.fromMap(myStaticFieldsByName).containsKey(name))) { MapSequence.fromMap(myStaticFieldsByName).put(name, staticField); } } if (SNodeOperations.isInstanceOf( classifier, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept"))) { Iterable<SNode> fields = ((Iterable<SNode>) BHReflection.invoke( (SNodeOperations.cast( classifier, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept"))), SMethodTrimmedId.create( "fields", MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept"), "4_LVZ3pC27C"))); ListSequence.fromList(allFields).addSequence(Sequence.fromIterable(fields)); for (SNode field : fields) { String name = SPropertyOperations.getString( field, MetaAdapterFactory.getProperty( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")); if (name == null) { name = ""; } if (!(MapSequence.fromMap(myFieldsByName).containsKey(name))) { MapSequence.fromMap(myFieldsByName).put(name, field); } } } } myDependsOnNodes = SetSequence.fromSet(new HashSet<SNode>()); SetSequence.fromSet(myDependsOnNodes).addSequence(ListSequence.fromList(classifiers)); SetSequence.fromSet(myDependsOnNodes).addSequence(ListSequence.fromList(allFields)); }
@Override protected void init() { List<SNode> allMethods = new ArrayList<SNode>(); List<SNode> classifiers = ((ClassifierAndSuperClassifiersCache) this.getOwnerCache()).getClassifiers(); for (SNode classifier : classifiers) { ListSequence.fromList(allMethods) .addSequence( Sequence.fromIterable( ((Iterable<SNode>) BHReflection.invoke( classifier, SMethodTrimmedId.create( "methods", MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"), "4_LVZ3pBKCn"))))); ListSequence.fromList(allMethods) .addSequence( Sequence.fromIterable( ((Iterable<SNode>) BHReflection.invoke( classifier, SMethodTrimmedId.create( "staticMethods", MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"), "7fFTwQrQPHW"))))); } this.myMethodsByName = MapSequence.fromMap(new HashMap<String, List<SNode>>()); this.myOverriddenMethods = MapSequence.fromMap(new HashMap<SNode, List<SNode>>()); forEachInAllMethods: for (SNode currMethod : allMethods) { String name = SPropertyOperations.getString( currMethod, MetaAdapterFactory.getProperty( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")); if (name == null) { name = ""; } if (!(MapSequence.fromMap(this.myMethodsByName).containsKey(name))) { List<SNode> methods = new ArrayList<SNode>(); methods.add(currMethod); MapSequence.fromMap(myMethodsByName).put(name, methods); MapSequence.fromMap(myOverriddenMethods).put(currMethod, new ArrayList<SNode>()); } else { int currMethodParmCount = ListSequence.fromList( SLinkOperations.getChildren( currMethod, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, 0xf8cc56b1feL, "parameter"))) .count(); List<SNode> equalParmCountMethods = new ArrayList<SNode>(); List<SNode> methods = MapSequence.fromMap(this.myMethodsByName).get(name); for (SNode method : methods) { if ((SNodeOperations.getParent(currMethod) != SNodeOperations.getParent(method)) && ListSequence.fromList( SLinkOperations.getChildren( method, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, 0xf8cc56b1feL, "parameter"))) .count() == currMethodParmCount) { equalParmCountMethods.add(method); } } if (equalParmCountMethods.size() > 0) { if (currMethodParmCount == 0) { ListSequence.fromList( MapSequence.fromMap(myOverriddenMethods) .get(ListSequence.fromList(equalParmCountMethods).first())) .addElement(currMethod); continue forEachInAllMethods; } Map<SNode, SNode> typeByTypeVar = ((ClassifierAndSuperClassifiersCache) this.getOwnerCache()) .getTypeByTypeVariableMap(); String currentParms = this.createMethodParameterTypesString(currMethod, typeByTypeVar); for (SNode otherMethod : equalParmCountMethods) { String otherParms = this.createMethodParameterTypesString(otherMethod, typeByTypeVar); if (otherParms.equals(currentParms)) { MapSequence.fromMap(this.myOverriddenMethods).get(otherMethod).add(currMethod); continue forEachInAllMethods; } } } ListSequence.fromList(MapSequence.fromMap(myMethodsByName).get(name)) .addElement(currMethod); MapSequence.fromMap(myOverriddenMethods).put(currMethod, new ArrayList<SNode>()); } } this.myDependsOnNodes = SetSequence.fromSet(new HashSet<SNode>()); for (SNode classifier : classifiers) { SetSequence.fromSet(this.myDependsOnNodes).addElement(classifier); } for (SNode method : allMethods) { SetSequence.fromSet(this.myDependsOnNodes).addElement(method); for (SNode parm : SLinkOperations.getChildren( method, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, 0xf8cc56b1feL, "parameter"))) { SNode type = SLinkOperations.getTarget( parm, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type")); if (type == null) { continue; } SetSequence.fromSet(myDependsOnNodes).addElement(type); SetSequence.fromSet(myDependsOnNodes) .addSequence( ListSequence.fromList( SNodeOperations.getNodeDescendants( type, null, false, new SAbstractConcept[] {}))); } } }
public static boolean isVisible(@NotNull SNode context, @NotNull SNode name) { // only check visibility of the name, accessibility of qualifier and if the name is member is // not checked here if (SNodeOperations.isInstanceOf( name, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"))) { return isClassifierAccessible( context, SNodeOperations.cast( name, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"))); } if (SNodeOperations.isInstanceOf( SNodeOperations.getParent(name), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101edd46144L, "jetbrains.mps.baseLanguage.structure.Interface"))) { return true; } if (SNodeOperations.isInstanceOf( SLinkOperations.getTarget( name, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x112670d273fL, 0x112670d886aL, "visibility")), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10af9581ff1L, "jetbrains.mps.baseLanguage.structure.PublicVisibility")) || SNodeOperations.isInstanceOf( name, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc367388b3L, "jetbrains.mps.baseLanguage.structure.EnumConstantDeclaration"))) { return true; } if (SNodeOperations.isInstanceOf( SLinkOperations.getTarget( name, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x112670d273fL, 0x112670d886aL, "visibility")), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10af9586f0cL, "jetbrains.mps.baseLanguage.structure.PrivateVisibility"))) { return topClassifier(context) == topClassifier(name); } // package or protected access if (packageName(context).equals(packageName(name))) { return true; } if (SNodeOperations.isInstanceOf( SLinkOperations.getTarget( name, MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x112670d273fL, 0x112670d886aL, "visibility")), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10af958b686L, "jetbrains.mps.baseLanguage.structure.ProtectedVisibility"))) { // check special cases of protected access SNode classifier = SNodeOperations.getNodeAncestor( name, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"), false, false); for (SNode cls : ListSequence.fromList( SNodeOperations.getNodeAncestors( context, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier"), true))) { if (BaseLanguageUtil.isAssignable(cls, classifier)) { if (SNodeOperations.isInstanceOf( name, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca68L, "jetbrains.mps.baseLanguage.structure.FieldDeclaration")) && SNodeOperations.isInstanceOf( context, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b483d77aL, "jetbrains.mps.baseLanguage.structure.FieldReferenceOperation")) || SNodeOperations.isInstanceOf( name, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b21dL, "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration")) && SNodeOperations.isInstanceOf( context, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x118154a6332L, "jetbrains.mps.baseLanguage.structure.InstanceMethodCallOperation"))) { // check ExpressionName or PrimaryExpression is subclass of cls, works only with right // context // will not work in the case: otherClass.method(protectedMethod()) with enclosed node // as context if (TypeChecker.getInstance() .getSubtypingManager() .isSubtype( ((SNode) BHReflection.invoke( SNodeOperations.cast( SNodeOperations.getParent(context), MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, "jetbrains.mps.baseLanguage.structure.DotExpression")), SMethodTrimmedId.create( "getOperandType", MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, "jetbrains.mps.baseLanguage.structure.DotExpression"), "7GulAc9z0dN"))), _quotation_createNode_v8uv56_b0a2a0a0a2a7a1(cls))) { return true; } } else if (SNodeOperations.isInstanceOf( name, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b204L, "jetbrains.mps.baseLanguage.structure.ConstructorDeclaration"))) { // check it is superclass constructor invocation or anonymous class instance creation return SNodeOperations.isInstanceOf( context, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf93d512e1eL, "jetbrains.mps.baseLanguage.structure.SuperConstructorInvocation")) || SNodeOperations.isInstanceOf( context, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x1107e0cb103L, "jetbrains.mps.baseLanguage.structure.AnonymousClass")) || SNodeOperations.isInstanceOf( context, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x1133e3b449aL, "jetbrains.mps.baseLanguage.structure.AnonymousClassCreator")); } else { return true; } } } } return false; }
public void execute( @Nullable final SNode command, @Nullable final Runnable executeBefore, @Nullable final Runnable executeAfter) { myTool.selectTab(this); final SNode[] typedCommand = new SNode[1]; getProject() .getModelAccess() .executeCommand( new Runnable() { public void run() { typedCommand[0] = SConceptOperations.createNewNode( SNodeOperations.asInstanceConcept( MetaAdapterFactory.getConcept( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x4e27160acb4484bL, "jetbrains.mps.console.base.structure.CommandHolder"))); if (command != null) { addNodeImports(command); SLinkOperations.setTarget( typedCommand[0], MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x4e27160acb4484bL, 0x4e27160acb44924L, "command"), SNodeOperations.copyNode( SLinkOperations.getTarget( SLinkOperations.getTarget( myRoot, MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x15fb34051f725a2cL, 0x15fb34051f725bb1L, "commandHolder")), MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x4e27160acb4484bL, 0x4e27160acb44924L, "command")))); SLinkOperations.setTarget( SLinkOperations.getTarget( myRoot, MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x15fb34051f725a2cL, 0x15fb34051f725bb1L, "commandHolder")), MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x4e27160acb4484bL, 0x4e27160acb44924L, "command"), SNodeOperations.copyNode(command)); } } }); BHReflection.invoke( SLinkOperations.getTarget( SLinkOperations.getTarget( myRoot, MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x15fb34051f725a2cL, 0x15fb34051f725bb1L, "commandHolder")), MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x4e27160acb4484bL, 0x4e27160acb44924L, "command")), SMethodTrimmedId.create("execute", null, "5WvH$QO9bva"), getConsoleContext(), getConsoleStream(), new Runnable() { public void run() { getProject() .getModelAccess() .executeCommand( new Runnable() { public void run() { ListSequence.fromList( SLinkOperations.getChildren( SLinkOperations.getTarget( myRoot, MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x15fb34051f725a2cL, 0x15fb34051f725bafL, "history")), MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0xa835f28c1aa02beL, 0x63da33792b5df49aL, "item"))) .addElement( SNodeOperations.copyNode( SLinkOperations.getTarget( myRoot, MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x15fb34051f725a2cL, 0x15fb34051f725bb1L, "commandHolder")))); SNodeOperations.deleteNode( SLinkOperations.getTarget( SLinkOperations.getTarget( myRoot, MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x15fb34051f725a2cL, 0x15fb34051f725bb1L, "commandHolder")), MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x4e27160acb4484bL, 0x4e27160acb44924L, "command"))); check_6q36mf_a2a0a0a0a0a2a0d0kc(executeBefore); } }); } }, new Runnable() { public void run() { getProject() .getModelAccess() .executeCommand( new Runnable() { public void run() { SLinkOperations.setTarget( SLinkOperations.getTarget( myRoot, MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x15fb34051f725a2cL, 0x15fb34051f725bb1L, "commandHolder")), MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x4e27160acb4484bL, 0x4e27160acb44924L, "command"), SLinkOperations.getTarget( typedCommand[0], MetaAdapterFactory.getContainmentLink( 0xde1ad86d6e504a02L, 0xb306d4d17f64c375L, 0x4e27160acb4484bL, 0x4e27160acb44924L, "command"))); check_6q36mf_a1a0a0a0a0a3a0d0kc(executeAfter); } }); } }); }