public void test_target() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   TestUtilities.assertEquals(
       Sequence.fromArray(
           new SNode[] {
             SNodeOperations.cast(
                 this.getNodeById("2906110183022219847"),
                 "jetbrains.mps.lang.smodelTests.structure.Root"),
             SNodeOperations.cast(
                 this.getNodeById("2906110183022219848"),
                 "jetbrains.mps.lang.smodelTests.structure.Child"),
             SNodeOperations.cast(
                 this.getNodeById("2906110183022311236"),
                 "jetbrains.mps.lang.smodelTests.structure.ChildSubConcept")
           }),
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022219844"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .select(
               new ISelector<SReference, SNode>() {
                 public SNode select(SReference it) {
                   return SLinkOperations.getTargetNode(it);
                 }
               }));
 }
 public static Scope virtual_getProjectStructureScope_3734116213129936182(
     SNode thisNode, final SNode kind) {
   if (SConceptOperations.isSubConceptOf(
           kind, "jetbrains.mps.build.mps.structure.BuildMps_AbstractModule")
       || SConceptOperations.isSubConceptOf(
           kind, "jetbrains.mps.build.mps.structure.BuildMps_IdeaPlugin")
       || SConceptOperations.isSubConceptOf(
           kind, "jetbrains.mps.build.mps.structure.BuildMps_Group")) {
     return new CompositeScope(
         Sequence.fromIterable(
                 BuildProject_Behavior.call_getVisibleProjects_1224588814561807665(
                     BuildPlugin_Behavior.call_getProject_1224588814561866657(thisNode), false))
             .select(
                 new ISelector<SNode, DescendantsScope>() {
                   public DescendantsScope select(SNode it) {
                     return DescendantsScope.forNamedElements(
                         it,
                         SLinkOperations.findLinkDeclaration(
                             "jetbrains.mps.build.structure.BuildProject", "parts"),
                         kind);
                   }
                 })
             .concat(
                 Sequence.fromIterable(
                     Sequence.<DescendantsScope>singleton(
                         DescendantsScope.forNamedElements(
                             BuildPlugin_Behavior.call_getProject_1224588814561866657(thisNode),
                             SLinkOperations.findLinkDeclaration(
                                 "jetbrains.mps.build.structure.BuildProject", "parts"),
                             kind))))
             .toGenericArray(DescendantsScope.class));
   }
   return null;
 }
 public void test_childrenByLinkDeclarationSpecialized() throws Exception {
   this.addNodeById("8758390115029078425");
   this.addNodeById("5815925154349132136");
   this.addNodeById("2166349271756548530");
   TestUtilities.assertEquals(
       Sequence.fromArray(
           new SNode[] {
             SNodeOperations.cast(
                 this.getNodeById("2600026384779198859"),
                 "jetbrains.mps.lang.smodelTests.structure.GrandChild")
           }),
       SNodeOperations.getChildren(
           SNodeOperations.cast(
               this.getNodeById("8758390115029078430"),
               "jetbrains.mps.lang.smodelTests.structure.ChildSubConcept"),
           SLinkOperations.findLinkDeclaration(
               "jetbrains.mps.lang.smodelTests.structure.ChildSubConcept",
               "specializedGranChild_0_1")));
   TestUtilities.assertEquals(
       Sequence.fromArray(
           new SNode[] {
             SNodeOperations.cast(
                 this.getNodeById("2600026384779198859"),
                 "jetbrains.mps.lang.smodelTests.structure.GrandChild")
           }),
       SNodeOperations.getChildren(
           SNodeOperations.cast(
               this.getNodeById("8758390115029078430"),
               "jetbrains.mps.lang.smodelTests.structure.ChildSubConcept"),
           SLinkOperations.findLinkDeclaration(
               "jetbrains.mps.lang.smodelTests.structure.Child", "grandChild_0_1")));
 }
Exemple #4
0
 private Iterable<String> getCommandsFromItem(Object item) {
   if (item == null) {
     return ListSequence.fromList(new ArrayList<String>());
   }
   if (item instanceof String) {
     if (isNotEmptyString(((String) item))) {
       return ProcessHandlerBuilder.splitCommandInParts((String) item);
     }
   } else if (item instanceof File) {
     String path = ((File) item).getAbsolutePath();
     if ((path != null && path.length() > 0)) {
       return Sequence.<String>singleton(path);
     }
   } else if (item instanceof CommandPart) {
     return ((CommandPart) item).getCommandList();
   } else if (item instanceof Iterable) {
     List<String> result = ListSequence.fromList(new ArrayList<String>());
     for (Object it : (Iterable) item) {
       ListSequence.fromList(result).addSequence(Sequence.fromIterable(getCommandsFromItem(it)));
     }
     return result;
   } else {
     if (LOG.isEnabledFor(Priority.ERROR)) {
       LOG.error("Unknown type of command part " + item);
     }
   }
   return ListSequence.fromList(new ArrayList<String>());
 }
Exemple #5
0
 public Iterable<SNode> getAvailableElements(@Nullable String prefix) {
   List<SNode> result = new ArrayList<SNode>();
   ListSequence.fromList(result)
       .addSequence(
           Sequence.fromIterable(scope.getAvailableElements(prefix))
               .where(
                   new IWhereFilter<SNode>() {
                     public boolean accept(SNode it) {
                       return it.isInstanceOfConcept(kindConceptFqName);
                     }
                   }));
   ListSequence.fromList(result)
       .addSequence(
           Sequence.fromIterable(parentScope.getAvailableElements(prefix))
               .where(
                   new IWhereFilter<SNode>() {
                     public boolean accept(SNode it) {
                       return it.isInstanceOfConcept(kindConceptFqName);
                     }
                   })
               .where(
                   new IWhereFilter<SNode>() {
                     public boolean accept(SNode it) {
                       return !(it.isInstanceOfConcept(hidingRootConceptFqName))
                           || !(SetSequence.fromSet(names).contains(it.getName()));
                     }
                   }));
   return result;
 }
 public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
   try {
     for (SModel model :
         Sequence.fromIterable(
             ((MPSProject) MapSequence.fromMap(_params).get("mpsProject")).getProjectModels())) {
       if (!(model instanceof RefactorableSModelDescriptor)) {
         continue;
       }
       if (SModelStereotype.isStubModelStereotype(SModelStereotype.getStereotype(model))) {
         continue;
       }
       UpdateRefactoringVersions_Action.this.updateModelVersion(
           (RefactorableSModelDescriptor) model, _params);
     }
     for (SModel model :
         Sequence.fromIterable(
             ((MPSProject) MapSequence.fromMap(_params).get("mpsProject")).getProjectModels())) {
       if (!(model instanceof EditableSModelDescriptor)) {
         continue;
       }
       if (SModelStereotype.isStubModelStereotype(SModelStereotype.getStereotype(model))) {
         continue;
       }
       UpdateRefactoringVersions_Action.this.updateImportVersions(
           (EditableSModelDescriptor) model, _params);
     }
     SModelRepository.getInstance().saveAll();
   } catch (Throwable t) {
     LOG.error("User's action execute method failed. Action:" + "UpdateRefactoringVersions", t);
   }
 }
Exemple #7
0
 public void collectRequired(Iterable<SModule> pool) {
   Set<SModuleReference> allRequired =
       SetSequence.fromSetWithValues(
           new HashSet<SModuleReference>(),
           Sequence.fromIterable(MapSequence.fromMap(allDeps).values())
               .translate(
                   new ITranslator2<ModulesCluster.ModuleDeps, SModuleReference>() {
                     public Iterable<SModuleReference> translate(ModulesCluster.ModuleDeps dep) {
                       return dep.required;
                     }
                   }));
   List<SModule> available = Sequence.fromIterable(pool).toListSequence();
   int atSize;
   do {
     atSize = MapSequence.fromMap(allDeps).count();
     for (Iterator<SModule> it = ListSequence.fromList(available).iterator(); it.hasNext(); ) {
       SModule mod = it.next();
       SModuleReference mr = mod.getModuleReference();
       if (SetSequence.fromSet(allRequired).contains(mr)) {
         primAdd(mod);
         SetSequence.fromSet(allRequired)
             .addSequence(ListSequence.fromList(MapSequence.fromMap(allDeps).get(mr).required));
         it.remove();
       }
     }
   } while (atSize < MapSequence.fromMap(allDeps).count());
 }
 private Iterable<SNode> getOperatorContainers() {
   Iterable<SNode> visibleContainers =
       ListSequence.fromList(
               SModelOperations.getRoots(
                   myModel,
                   "jetbrains.mps.baseLanguage.overloadedOperators.structure.ContainerImport"))
           .where(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return (SLinkOperations.getTarget(it, "container", false) != null);
                 }
               })
           .select(
               new ISelector<SNode, SNode>() {
                 public SNode select(SNode it) {
                   return SLinkOperations.getTarget(it, "container", false);
                 }
               });
   if (Sequence.fromIterable(visibleContainers).isEmpty()) {
     visibleContainers =
         SModelOperations.getRootsIncludingImported(
             myModel,
             "jetbrains.mps.baseLanguage.overloadedOperators.structure.OverloadedOperatorContainer");
   }
   return Sequence.fromIterable(visibleContainers)
       .translate(
           new ITranslator2<SNode, SNode>() {
             public Iterable<SNode> translate(SNode it) {
               return SLinkOperations.getTargets(it, "operators", true);
             }
           });
 }
 public void test_roles() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   TestUtilities.assertEquals(
       Sequence.fromArray(
           new String[] {
             SPropertyOperations.getString(
                 SLinkOperations.findLinkDeclaration(
                     "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer", "root"),
                 "role"),
             SPropertyOperations.getString(
                 SLinkOperations.findLinkDeclaration(
                     "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer", "leftChild"),
                 "role"),
             SPropertyOperations.getString(
                 SLinkOperations.findLinkDeclaration(
                     "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer",
                     "rightChild"),
                 "role")
           }),
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022219844"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .select(
               new ISelector<SReference, String>() {
                 public String select(SReference it) {
                   return SLinkOperations.getRole(it);
                 }
               }));
 }
 public List<SNode> getFields() {
   List<SNode> result = new ArrayList<SNode>();
   ListSequence.fromList(result)
       .addSequence(Sequence.fromIterable(MapSequence.fromMap(myFieldsByName).values()));
   ListSequence.fromList(result)
       .addSequence(Sequence.fromIterable(MapSequence.fromMap(myStaticFieldsByName).values()));
   return result;
 }
 @Nullable
 public static ITestNodeWrapper tryToWrap(@NotNull SNode node) {
   for (TestNodeWrapperFactory factory :
       Sequence.fromIterable(Sequence.fromArray(TestNodeWrapperFactory.values()))) {
     if (factory.canWrap(node)) {
       return factory.wrap(node);
     }
   }
   return null;
 }
 public static List<SNode> virtual_getOwnMethods_1906502351318572840(SNode thisNode) {
   List<SNode> baseMethodDeclarations = new ArrayList<SNode>();
   ListSequence.fromList(baseMethodDeclarations)
       .addSequence(
           Sequence.fromIterable(Classifier_Behavior.call_methods_5292274854859311639(thisNode)));
   ListSequence.fromList(baseMethodDeclarations)
       .addSequence(
           Sequence.fromIterable(
               ClassConcept_Behavior.call_staticMethods_5292274854859435867(thisNode)));
   return baseMethodDeclarations;
 }
Exemple #13
0
 private void addTypeParams(PsiTypeParameterListOwner from, SNode to) {
   ListSequence.fromList(SLinkOperations.getTargets(to, "typeVariableDeclaration", true))
       .addSequence(
           Sequence.fromIterable(Sequence.fromArray(from.getTypeParameters()))
               .select(
                   new ISelector<PsiTypeParameter, SNode>() {
                     public SNode select(PsiTypeParameter it) {
                       return convertTypeParameter(it);
                     }
                   }));
 }
Exemple #14
0
 public MPSModulesClosure generationDependenciesClosure() {
   // direct and indirect dependencies of used languages and their runtimes; source languages of
   // generators involved
   for (SNode m : Sequence.fromIterable(initialModules)) {
     Iterable<SNode> usedLanguages = getUsedLanguages(m);
     collectDependencies(usedLanguages, false);
     collectAllUsedLanguageRuntimesAndTheirDeps(usedLanguages);
     modules.addAll(Sequence.fromIterable(usedLanguages).toListSequence());
     collectGeneratorsDependendencies(usedLanguages);
   }
   return this;
 }
 public void test_unspecifiedReferences() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   // Adding one unspecified reference and checking if it was added properly
   int initialSize =
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022432277"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .count();
   String unspecifiedReferenceName =
       this.addUnspecifiedReference(
           SNodeOperations.cast(
               this.getNodeById("2906110183022432277"),
               "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer"),
           SNodeOperations.cast(
               this.getNodeById("2906110183022219849"),
               "jetbrains.mps.lang.smodelTests.structure.GrandChild"));
   Assert.assertEquals(
       initialSize + 1,
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022432277"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .count());
   // Checking if unspecified reference is working properly
   Iterable<SReference> unspecifiedReferences =
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022432277"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .where(
               new IWhereFilter<SReference>() {
                 public boolean accept(SReference it) {
                   return (SLinkOperations.findLinkDeclaration(it) == null);
                 }
               });
   Assert.assertEquals(1, Sequence.fromIterable(unspecifiedReferences).count());
   SReference theReference = Sequence.fromIterable(unspecifiedReferences).first();
   Assert.assertEquals(unspecifiedReferenceName, SLinkOperations.getRole(theReference));
   Assert.assertEquals(
       SNodeOperations.cast(
           this.getNodeById("2906110183022219849"),
           "jetbrains.mps.lang.smodelTests.structure.GrandChild"),
       SLinkOperations.getTargetNode(theReference));
 }
Exemple #16
0
 private void collectDependencies(Iterable<SNode> sequence, boolean reexportOnly) {
   if (Sequence.fromIterable(sequence).isEmpty()) {
     return;
   }
   Set<SNode> dependencies = SetSequence.fromSet(new HashSet<SNode>());
   for (SNode module : Sequence.fromIterable(sequence)) {
     SetSequence.fromSet(dependencies)
         .addSequence(Sequence.fromIterable(getDependencies(module, reexportOnly)));
   }
   SetSequence.fromSet(dependencies).removeSequence(SetSequence.fromSet(modules));
   modules.addAll(dependencies);
   collectDependencies(dependencies, reexportOnly);
 }
Exemple #17
0
 public MPSModulesClosure designtimeClosure() {
   // direct and indirect dependencies of the modules, languages used and their runtimes
   collectDependencies(initialModules, false);
   collectAllUsedLanguageRuntimesAndTheirDeps(initialModules);
   for (SNode m : Sequence.fromIterable(initialModules)) {
     Iterable<SNode> usedLanguages = getUsedLanguages(m);
     collectDependencies(usedLanguages, false);
     collectAllUsedLanguageRuntimesAndTheirDeps(usedLanguages);
     modules.addAll(Sequence.fromIterable(usedLanguages).toListSequence());
   }
   modules.removeAll(Sequence.fromIterable(initialModules).toListSequence());
   return this;
 }
 public void test_forSpecializedLink() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   TestUtilities.assertEquals(
       Sequence.fromArray(
           new SNode[] {
             SNodeOperations.cast(
                 this.getNodeById("2906110183022311236"),
                 "jetbrains.mps.lang.smodelTests.structure.ChildSubConcept")
           }),
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022354866"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept")))
           .where(
               new IWhereFilter<SReference>() {
                 public boolean accept(SReference it) {
                   return SLinkOperations.findLinkDeclaration(it)
                       == SLinkOperations.findLinkDeclaration(
                           "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer",
                           "rightChild");
                 }
               })
           .select(
               new ISelector<SReference, SNode>() {
                 public SNode select(SReference it) {
                   return SLinkOperations.getTargetNode(it);
                 }
               }));
   Assert.assertTrue(
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022354866"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept")))
           .where(
               new IWhereFilter<SReference>() {
                 public boolean accept(SReference it) {
                   return SLinkOperations.findLinkDeclaration(it)
                       == SLinkOperations.findLinkDeclaration(
                           "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept",
                           "specializedRightChild");
                 }
               })
           .isEmpty());
 }
Exemple #19
0
  public MPSModulesClosure runtimeDependencies() {
    // direct dependencies of used languages' runtime solutions
    if (Sequence.fromIterable(initialModules).count() != 1) {
      throw new IllegalStateException("cannot build runtime dependencies for several modules");
    }

    SNode initial = Sequence.fromIterable(initialModules).first();
    Set<SNode> langs = SetSequence.fromSet(new HashSet<SNode>());
    Set<SNode> solutions = SetSequence.fromSet(new HashSet<SNode>());
    fillUsedLanguageRuntimes(initial, langs, solutions);
    modules.addAll(solutions);
    languagesWithRuntime.addAll(langs);
    return this;
  }
Exemple #20
0
 private void collectAllUsedLanguageRuntimesAndTheirDeps(Iterable<SNode> sequence) {
   if (Sequence.fromIterable(sequence).isEmpty()) {
     return;
   }
   Set<SNode> langs = SetSequence.fromSet(new HashSet<SNode>());
   Set<SNode> solutions = SetSequence.fromSet(new HashSet<SNode>());
   for (SNode module : Sequence.fromIterable(sequence)) {
     fillUsedLanguageRuntimes(module, langs, solutions);
   }
   SetSequence.fromSet(solutions).removeSequence(SetSequence.fromSet(modules));
   modules.addAll(solutions);
   languagesWithRuntime.addAll(langs);
   collectDependencies(((Iterable<SNode>) solutions), false);
   collectAllUsedLanguageRuntimesAndTheirDeps(((Iterable<SNode>) solutions));
 }
 private static List<SNode> getParameters_id5keEkmeCqHW(@NotNull SNode __thisNode__) {
   if (CommandDeclaration_BehaviorDescriptor.isDebuggable_idJzCdmU6yOQ.invoke(
       ExecuteCommandPart_BehaviorDescriptor.getCommandDeclaration_id5keEkmeCqIg.invoke(
           __thisNode__))) {
     return ListSequence.fromList(
             SLinkOperations.getChildren(
                 __thisNode__,
                 MetaAdapterFactory.getContainmentLink(
                     0xf3347d8a0e794f35L,
                     0x8ac91574f25c986fL,
                     0x550ea9458ea107acL,
                     0x550ea9458ea107adL,
                     "parameterDeclaration")))
         .select(
             new ISelector<SNode, SNode>() {
               public SNode select(SNode it) {
                 return SNodeOperations.cast(
                     it,
                     MetaAdapterFactory.getConcept(
                         0xf3347d8a0e794f35L,
                         0x8ac91574f25c986fL,
                         0x65afee7b2c712158L,
                         "jetbrains.mps.execution.commands.structure.CommandParameterDeclaration"));
               }
             })
         .union(
             Sequence.fromIterable(
                 Sequence.<SNode>singleton(
                     SLinkOperations.getTarget(
                         ExecuteCommandPart_BehaviorDescriptor.getCommandDeclaration_id5keEkmeCqIg
                             .invoke(__thisNode__),
                         MetaAdapterFactory.getContainmentLink(
                             0xf3347d8a0e794f35L,
                             0x8ac91574f25c986fL,
                             0xbe3a0d5ba1a2be8L,
                             0x75aadb0d4e6223baL,
                             "debuggerParameter")))))
         .toListSequence();
   }
   return SLinkOperations.getChildren(
       __thisNode__,
       MetaAdapterFactory.getContainmentLink(
           0xf3347d8a0e794f35L,
           0x8ac91574f25c986fL,
           0x550ea9458ea107acL,
           0x550ea9458ea107adL,
           "parameterDeclaration"));
 }
 public Map<SReference, SNode> classifyUsages(Iterable<SReference> usages) {
   Map<SReference, SNode> result = MapSequence.fromMap(new HashMap<SReference, SNode>());
   for (SReference ref : Sequence.fromIterable(usages)) {
     MapSequence.fromMap(result).put(ref, ref.getTargetNode());
   }
   return result;
 }
Exemple #23
0
  public static Iterable<Element> children(Element container, String tagName) {
    if (container == null) {
      return Sequence.fromIterable(Collections.<Element>emptyList());
    }

    return (Iterable<Element>) ((List<Element>) container.getChildren(tagName));
  }
Exemple #24
0
 public Iterable<IFacet.Name> required() {
   return Sequence.fromArray(
       new IFacet.Name[] {
         new IFacet.Name("jetbrains.mps.lang.core.Generate"),
         new IFacet.Name("jetbrains.mps.lang.core.Make")
       });
 }
Exemple #25
0
 public Iterable<ITarget.Name> before() {
   return Sequence.fromArray(
       new ITarget.Name[] {
         new ITarget.Name("jetbrains.mps.lang.core.Make.reconcile"),
         new ITarget.Name("jetbrains.mps.lang.core.Make.make")
       });
 }
Exemple #26
0
  public static boolean baseMappingRule_Condition_2379134940425784781(
      final IOperationContext operationContext, final BaseMappingRuleContext _context) {
    boolean methodHasDispatchModifier =
        SNodeOperations.isInstanceOf(
                SNodeOperations.getParent(_context.getNode()),
                "jetbrains.mps.baseLanguage.structure.MethodDeclaration")
            && ListSequence.fromList(
                    SLinkOperations.getTargets(
                        SNodeOperations.cast(
                            SNodeOperations.getParent(_context.getNode()),
                            "jetbrains.mps.baseLanguage.structure.MethodDeclaration"),
                        "modifiers",
                        true))
                .any(
                    new IWhereFilter<SNode>() {
                      public boolean accept(SNode it) {
                        return SNodeOperations.isInstanceOf(
                            it,
                            "jetbrains.mps.baseLanguage.doubleDispatch.structure.DispatchModifier");
                      }
                    });

    return methodHasDispatchModifier
        && Sequence.fromIterable(
                DispatchGenUtil.getMatchingMethods(
                    SNodeOperations.cast(
                        SNodeOperations.getParent(_context.getNode()),
                        "jetbrains.mps.baseLanguage.structure.MethodDeclaration")))
            .isNotEmpty();
  }
Exemple #27
0
 protected Set<IModule> getInitialModules() {
   Set<IModule> result = SetSequence.fromSet(new HashSet<IModule>());
   SetSequence.fromSet(result).addElement(DiffTemporaryModule.this);
   SetSequence.fromSet(result)
       .addSequence(Sequence.fromIterable(GlobalScope.getInstance().getVisibleModules()));
   return result;
 }
 private Iterable<SNode> getFieldDeclarationsWithoutGetterOrSetter(
     final SNode classConcept, final Map<String, Object> _params) {
   final Project project =
       ((EditorContext) MapSequence.fromMap(_params).get("editorContext"))
           .getOperationContext()
           .getProject();
   return Sequence.fromIterable(
           BehaviorReflection.invokeNonVirtual(
               (Class<Iterable<SNode>>) ((Class) Object.class),
               classConcept,
               "jetbrains.mps.baseLanguage.structure.ClassConcept",
               "call_fields_5292274854859383272",
               new Object[] {}))
       .where(
           new IWhereFilter<SNode>() {
             public boolean accept(SNode field) {
               final String setterName =
                   GenerateGettersAndSettersUtil.getFieldSetterName(field, project);
               final String getterName =
                   GenerateGettersAndSettersUtil.getFieldGetterName(field, project);
               return !(Sequence.fromIterable(
                           BehaviorReflection.invokeNonVirtual(
                               (Class<Iterable<SNode>>) ((Class) Object.class),
                               classConcept,
                               "jetbrains.mps.baseLanguage.structure.Classifier",
                               "call_methods_5292274854859311639",
                               new Object[] {}))
                       .any(
                           new IWhereFilter<SNode>() {
                             public boolean accept(SNode method) {
                               return getterName.equals(
                                       SPropertyOperations.getString(method, "name"))
                                   && ListSequence.fromList(
                                           SLinkOperations.getTargets(method, "parameter", true))
                                       .isEmpty();
                             }
                           }))
                   && !(Sequence.fromIterable(
                           BehaviorReflection.invokeNonVirtual(
                               (Class<Iterable<SNode>>) ((Class) Object.class),
                               classConcept,
                               "jetbrains.mps.baseLanguage.structure.Classifier",
                               "call_methods_5292274854859311639",
                               new Object[] {}))
                       .any(
                           new IWhereFilter<SNode>() {
                             public boolean accept(SNode method) {
                               return setterName.equals(
                                       SPropertyOperations.getString(method, "name"))
                                   && (int)
                                           ListSequence.fromList(
                                                   SLinkOperations.getTargets(
                                                       method, "parameter", true))
                                               .count()
                                       == 1;
                             }
                           }));
             }
           });
 }
 public static SNode templateFragment_ContextNodeQuery_3618324829955828392(
     final TemplateFragmentContext _context) {
   SNode demoApp =
       SNodeOperations.cast(
           _context.getMainContextNode(),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf8c108ca66L,
               "jetbrains.mps.baseLanguage.structure.ClassConcept"));
   SNode method =
       Sequence.fromIterable(
               ClassConcept_BehaviorDescriptor.staticMethods_id4_LVZ3pCeXr.invoke(demoApp))
           .where(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return SPropertyOperations.getString(
                           it,
                           MetaAdapterFactory.getProperty(
                               0xceab519525ea4f22L,
                               0x9b92103b95ca8c0cL,
                               0x110396eaaa4L,
                               0x110396ec041L,
                               "name"))
                       .equals("addContent");
                 }
               })
           .first();
   return SLinkOperations.getTarget(
       method,
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, 0xf8cc56b1ffL, "body"));
 }
Exemple #30
0
 @Override
 protected void doInit() {
   DependencyTree tree = (DependencyTree) getTree();
   for (DepPath c : Sequence.fromIterable(myCycles).distinct()) {
     Iterator<DepLink> itr = Sequence.fromIterable(c.elements()).iterator();
     // skip first path element, which is always the one from my getCapturedDependencies()
     itr.next();
     MPSTreeNode parent = this;
     while (itr.hasNext()) {
       DependencyTreeNode dtn = new DependencyTreeNode(tree.getProject(), itr.next());
       parent.add(dtn);
       parent = dtn;
     }
   }
   myInitialized = true;
 }