コード例 #1
0
 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);
   }
 }
コード例 #2
0
ファイル: QueriesGenerated.java プロジェクト: handong890/MPS
 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"));
 }
コード例 #3
0
ファイル: ModuleLoaderUtils.java プロジェクト: sprig/MPS
 public static SNode getOriginalModule(SNode module, TemplateQueryContext genContext) {
   SNode originalModule =
       SNodeOperations.as(
           DependenciesHelper.getOriginalNode(module, genContext),
           "jetbrains.mps.build.mps.structure.BuildMps_Module");
   return (originalModule != null ? originalModule : module);
 }
コード例 #4
0
 private static Boolean hasParameterRefs_id6qD99pUaonP(@NotNull SNode __thisNode__) {
   SNode node = __thisNode__;
   node = SNodeOperations.getParent(node);
   while (node != null
       && !((SNodeOperations.isInstanceOf(
               node,
               MetaAdapterFactory.getInterfaceConcept(
                   0x7c9e280794ad4afcL,
                   0xadf0aaee45eb2895L,
                   0x48db75d5dc496a4fL,
                   "jetbrains.mps.samples.lambdaCalculus.structure.VariableOwner"))
           && !(ListSequence.fromList(
                   VariableOwner_BehaviorDescriptor.getVariables_id7M_MU5__$7C.invoke(
                       SNodeOperations.cast(
                           node,
                           MetaAdapterFactory.getInterfaceConcept(
                               0x7c9e280794ad4afcL,
                               0xadf0aaee45eb2895L,
                               0x48db75d5dc496a4fL,
                               "jetbrains.mps.samples.lambdaCalculus.structure.VariableOwner"))))
               .contains(
                   SNodeOperations.as(
                       __thisNode__,
                       MetaAdapterFactory.getConcept(
                           0x7c9e280794ad4afcL,
                           0xadf0aaee45eb2895L,
                           0x48db75d5dc496b12L,
                           "jetbrains.mps.samples.lambdaCalculus.structure.Variable"))))))) {
     node = SNodeOperations.getParent(node);
   }
   if (SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0x7c9e280794ad4afcL,
           0xadf0aaee45eb2895L,
           0x448ba254edbfc79fL,
           "jetbrains.mps.samples.lambdaCalculus.structure.LetExpression"))) {
     return true;
   }
   if (!(SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0x7c9e280794ad4afcL,
           0xadf0aaee45eb2895L,
           0x37d11ba7d7ec98e9L,
           "jetbrains.mps.samples.lambdaCalculus.structure.LambdaExpression")))) {
     return false;
   }
   return LambdaExpression_BehaviorDescriptor.isInFull_id6nQdzuslK0D.invoke(
       SNodeOperations.cast(
           node,
           MetaAdapterFactory.getConcept(
               0x7c9e280794ad4afcL,
               0xadf0aaee45eb2895L,
               0x37d11ba7d7ec98e9L,
               "jetbrains.mps.samples.lambdaCalculus.structure.LambdaExpression")));
 }
コード例 #5
0
 public void applyRule(
     final SNode internalNewExpression,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   SNode type;
   if ((SLinkOperations.getTarget(internalNewExpression, "type", true) != null)) {
     type = SLinkOperations.getTarget(internalNewExpression, "type", true);
   } else {
     type = _quotation_createNode_8luvtd_a0a0a1a1();
   }
   {
     SNode _nodeToCheck_1029348928467 = internalNewExpression;
     EquationInfo _info_12389875345 =
         new EquationInfo(
             _nodeToCheck_1029348928467,
             null,
             "r:00000000-0000-4000-0000-011c895903ab(jetbrains.mps.baseLanguageInternal.typesystem)",
             "1196525371896",
             0,
             null);
     typeCheckingContext.createEquation(
         (SNode)
             typeCheckingContext.typeOf(
                 _nodeToCheck_1029348928467,
                 "r:00000000-0000-4000-0000-011c895903ab(jetbrains.mps.baseLanguageInternal.typesystem)",
                 "1196525371898",
                 true),
         (SNode)
             _quotation_createNode_8luvtd_a0c0b(
                 SPropertyOperations.getString(internalNewExpression, "fqClassName"),
                 SLinkOperations.getTarget(
                     SNodeOperations.as(
                         type, "jetbrains.mps.baseLanguage.structure.ClassifierType"),
                     "classifier",
                     false),
                 SLinkOperations.getTargets(
                     SNodeOperations.as(
                         type, "jetbrains.mps.baseLanguage.structure.ClassifierType"),
                     "parameter",
                     true)),
         _info_12389875345);
   }
 }
コード例 #6
0
ファイル: MPSModulesClosure.java プロジェクト: Ju2ender/MPS
 private void fillUsedLanguageRuntimes(
     SNode m, Set<SNode> runtimeLanguages, Set<SNode> runtimeSolutions) {
   for (SNode language : getUsedLanguages(m)) {
     boolean hasRuntime = false;
     for (SNode rdep :
         SLinkOperations.getChildren(
             language,
             MetaAdapterFactory.getContainmentLink(
                 0xcf935df46994e9cL,
                 0xa132fa109541cba3L,
                 0x2c446791464290f8L,
                 0x2c4467914643be24L,
                 "runtime"))) {
       if (!(SNodeOperations.isInstanceOf(
           rdep,
           MetaAdapterFactory.getConcept(
               0xcf935df46994e9cL,
               0xa132fa109541cba3L,
               0x2c4467914644b6e3L,
               "jetbrains.mps.build.mps.structure.BuildMps_ModuleSolutionRuntime")))) {
         hasRuntime = true;
         continue;
       }
       SNode runtimeSolution =
           SNodeOperations.as(
               toOriginal(
                   SLinkOperations.getTarget(
                       SNodeOperations.cast(
                           rdep,
                           MetaAdapterFactory.getConcept(
                               0xcf935df46994e9cL,
                               0xa132fa109541cba3L,
                               0x2c4467914644b6e3L,
                               "jetbrains.mps.build.mps.structure.BuildMps_ModuleSolutionRuntime")),
                       MetaAdapterFactory.getReferenceLink(
                           0xcf935df46994e9cL,
                           0xa132fa109541cba3L,
                           0x2c4467914644b6e3L,
                           0x2c4467914644b6e4L,
                           "solution"))),
               MetaAdapterFactory.getConcept(
                   0xcf935df46994e9cL,
                   0xa132fa109541cba3L,
                   0x2c446791464290f7L,
                   "jetbrains.mps.build.mps.structure.BuildMps_Solution"));
       if (runtimeSolution != null) {
         SetSequence.fromSet(runtimeSolutions).addElement(runtimeSolution);
       }
     }
     if (hasRuntime) {
       SetSequence.fromSet(runtimeLanguages).addElement(language);
     }
   }
 }
コード例 #7
0
 public static boolean baseMappingRule_Condition_1217891542034(
     final IOperationContext operationContext, final BaseMappingRuleContext _context) {
   return SNodeOperations.isInstanceOf(
       SLinkOperations.getTarget(
           SNodeOperations.as(
               SLinkOperations.getTarget(_context.getNode(), "lValue", true),
               "jetbrains.mps.baseLanguage.structure.DotExpression"),
           "operation",
           true),
       "jetbrains.mps.lang.generator.generationContext.structure.GenerationContextOp_UserObjectAccessBase");
 }
コード例 #8
0
 public static boolean static_canBeAChild(
     SNode node,
     SNode parentNode,
     SNode link,
     SNode childConcept,
     final IOperationContext operationContext) {
   SNode dtype =
       BehaviorReflection.invokeVirtual(
           (Class<SNode>) ((Class) Object.class),
           SNodeOperations.as(
               SNodeOperations.getParent(parentNode),
               "jetbrains.mps.baseLanguage.structure.TypeDerivable"),
           "virtual_deriveType_1213877435747",
           new Object[] {
             SNodeOperations.as(parentNode, "jetbrains.mps.baseLanguage.structure.Expression")
           });
   return (dtype == null)
       || SConceptOperations.isSuperConceptOf(
           SNodeOperations.getConceptDeclaration(dtype),
           "jetbrains.mps.baseLanguage.collections.structure.MapType");
 }
コード例 #9
0
  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);
    }
  }
コード例 #10
0
ファイル: QueriesGenerated.java プロジェクト: handong890/MPS
 public static SNode sourceNodeQuery_5615708520037052712(
     final SourceSubstituteMacroNodeContext _context) {
   return SLinkOperations.getTarget(
       SNodeOperations.as(
           SNodeOperations.getParent(_context.getNode()),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x116b46a08c4L,
               "jetbrains.mps.baseLanguage.structure.DotExpression")),
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, 0x116b46a4416L, "operand"));
 }
コード例 #11
0
ファイル: Context.java プロジェクト: sprig/MPS
 public MacroHelper getMacros(SNode context) {
   SNode buildProject = getBuildProject(context);
   if (buildProject == null) {
     return null;
   }
   buildProject =
       SNodeOperations.as(
           DependenciesHelper.getOriginalNode(buildProject, myGenerationContext),
           "jetbrains.mps.build.structure.BuildProject");
   if (buildProject == null) {
     return null;
   }
   return new MacroHelper.MacroContext(buildProject, myGenerationContext).getMacros(buildProject);
 }
コード例 #12
0
ファイル: BaseConsoleTab.java プロジェクト: ozlembb/MPS
 protected SNode getLastReponse() {
   SNode last =
       SNodeOperations.as(
           ListSequence.fromList(
                   SLinkOperations.getChildren(
                       SLinkOperations.getTarget(
                           myRoot,
                           MetaAdapterFactory.getContainmentLink(
                               0xde1ad86d6e504a02L,
                               0xb306d4d17f64c375L,
                               0x15fb34051f725a2cL,
                               0x15fb34051f725bafL,
                               "history")),
                       MetaAdapterFactory.getContainmentLink(
                           0xde1ad86d6e504a02L,
                           0xb306d4d17f64c375L,
                           0xa835f28c1aa02beL,
                           0x63da33792b5df49aL,
                           "item")))
               .last(),
           MetaAdapterFactory.getConcept(
               0xde1ad86d6e504a02L,
               0xb306d4d17f64c375L,
               0x4e3b035171a5ba02L,
               "jetbrains.mps.console.base.structure.Response"));
   if (last != null) {
     return last;
   }
   return SLinkOperations.addNewChild(
       SLinkOperations.getTarget(
           myRoot,
           MetaAdapterFactory.getContainmentLink(
               0xde1ad86d6e504a02L,
               0xb306d4d17f64c375L,
               0x15fb34051f725a2cL,
               0x15fb34051f725bafL,
               "history")),
       MetaAdapterFactory.getContainmentLink(
           0xde1ad86d6e504a02L,
           0xb306d4d17f64c375L,
           0xa835f28c1aa02beL,
           0x63da33792b5df49aL,
           "item"),
       SNodeOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0xde1ad86d6e504a02L,
               0xb306d4d17f64c375L,
               0x4e3b035171a5ba02L,
               "jetbrains.mps.console.base.structure.Response")));
 }
コード例 #13
0
 public static boolean baseMappingRule_Condition_1202780919451(
     final BaseMappingRuleContext _context) {
   if (!(SPropertyOperations.hasValue(
       SNodeOperations.as(
           SNodeOperations.getAncestor(_context.getNode(), null, false, true),
           "jetbrains.mps.transformation.test.inputLang.structure.InputRoot"),
       "useInTest",
       "test1",
       "none"))) {
     return false;
   }
   return !(SPropertyOperations.hasValue(
       _context.getNode(), "option", "drop_it", "option_default"));
 }
コード例 #14
0
 public static boolean static_canBeAChild(
     final IOperationContext operationContext, final CanBeAChildContext _context) {
   return TypeChecker.getInstance()
       .getSubtypingManager()
       .isSubtype(
           TypeChecker.getInstance()
               .getTypeOf(
                   SLinkOperations.getTarget(
                       SNodeOperations.as(
                           _context.getParentNode(),
                           "jetbrains.mps.baseLanguage.structure.DotExpression"),
                       "operand",
                       true)),
           new CallMethodOperation_Constraints.QuotationClass_j1qytb_a1a0a0a().createNode());
 }
コード例 #15
0
 private void _populateLocalVariablesForCatch(SNode tryCatchStatement, List<SNode> result) {
   SNode throwable = SLinkOperations.getTarget(tryCatchStatement, "throwable", true);
   if (throwable != null) {
     result.add(throwable);
   }
   SNode containingCatchClause =
       SNodeOperations.as(
           LocalVariablesScope.findThisOrParent(
               SNodeOperations.getParent(tryCatchStatement),
               SConceptOperations.findConceptDeclaration(
                   "jetbrains.mps.baseLanguage.structure.CatchClause")),
           "jetbrains.mps.baseLanguage.structure.CatchClause");
   if (containingCatchClause != null) {
     this._populateLocalVariablesForCatch(containingCatchClause, result);
   }
 }
コード例 #16
0
 private static String fullName_id4Vpsm2KEoLo(@NotNull SNode __thisNode__) {
   return SPropertyOperations.getString(
           SNodeOperations.as(
               SNodeOperations.getParent(__thisNode__),
               MetaAdapterFactory.getInterfaceConcept(
                   0xceab519525ea4f22L,
                   0x9b92103b95ca8c0cL,
                   0x110396eaaa4L,
                   "jetbrains.mps.lang.core.structure.INamedConcept")),
           MetaAdapterFactory.getProperty(
               0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"))
       + "->"
       + SPropertyOperations.getString(
           __thisNode__,
           MetaAdapterFactory.getProperty(
               0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"));
 }
コード例 #17
0
 public static void virtual_unpack_7128123785277710736(
     SNode thisNode, UnpackHelper helper, Iterable<Object> artifacts) {
   // TODO extract! (it is a copy of Folder behavior)
   SNode parent = helper.parent(thisNode);
   String parentLocation = helper.contentLocations().get(parent);
   String folderLocation =
       parentLocation
           + "/"
           + BuildString_Behavior.call_getText_4380385936562005550(
               SLinkOperations.getTarget(
                   SLinkOperations.getTarget(thisNode, "plugin", false), "containerName", true),
               helper.getMacroHelper());
   helper.locations().put(thisNode, folderLocation);
   helper.contentLocations().put(thisNode, folderLocation);
   for (SNode ic :
       ListSequence.fromList(SLinkOperations.getTargets(thisNode, "children", true))
           .where(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return SNodeOperations.isInstanceOf(
                       it, "jetbrains.mps.build.structure.BuildLayout_ImportContent");
                 }
               })
           .select(
               new ISelector<SNode, SNode>() {
                 public SNode select(SNode it) {
                   return SNodeOperations.cast(
                       it, "jetbrains.mps.build.structure.BuildLayout_ImportContent");
                 }
               })) {
     SNode node =
         SNodeOperations.as(
             SLinkOperations.getTarget(ic, "target", false),
             "jetbrains.mps.build.structure.BuildLayout_PathElement");
     if ((node != null)) {
       // note: if node is imported directly - do not override its original location
       if (!(helper.locations().containsKey(node))) {
         helper.locations().put(node, folderLocation);
       }
       if (!(helper.contentLocations().containsKey(node))) {
         helper.contentLocations().put(node, folderLocation);
       }
     }
   }
 }
コード例 #18
0
 public List<String> getPostfixes(
     SNode node, IScope scope, IOperationContext operationContext, EditorContext editorContext) {
   SNode nodeConcept =
       SLinkOperations.getTarget(
           SNodeOperations.as(
               SNodeOperations.getParent(node),
               "jetbrains.mps.lang.smodel.structure.IfInstanceOfStatement"),
           "nodeConcept",
           false);
   List<String> variableSuffixes =
       ListSequence.fromListAndArray(new ArrayList<String>(), "node");
   if (nodeConcept != null) {
     String name = NameUtil.decapitalize(SPropertyOperations.getString(nodeConcept, "name"));
     ListSequence.fromList(variableSuffixes)
         .addSequence(ListSequence.fromList(NameUtil.splitByCamels(name)));
   }
   return variableSuffixes;
 }
コード例 #19
0
 public static boolean static_canBeAChild(
     SNode node,
     SNode parentNode,
     SNode link,
     SNode childConcept,
     final IOperationContext operationContext) {
   return (SNodeOperations.getNodeAncestor(
               parentNode,
               MetaAdapterFactory.getConcept(
                   0x756e911c3f1f4a48L,
                   0xbdf5a2ceb91b723cL,
                   0xd244b712f91012dL,
                   "jetbrains.mps.execution.settings.structure.EditorOperationDeclaration"),
               true,
               false)
           == null)
       && (TypeChecker.getInstance()
               .getRuntimeSupport()
               .coerce_(
                   TypeChecker.getInstance()
                       .getTypeOf(
                           SLinkOperations.getTarget(
                               SNodeOperations.as(
                                   parentNode,
                                   MetaAdapterFactory.getConcept(
                                       0xf3061a5392264cc5L,
                                       0xa443f952ceaf5816L,
                                       0x116b46a08c4L,
                                       "jetbrains.mps.baseLanguage.structure.DotExpression")),
                               MetaAdapterFactory.getContainmentLink(
                                   0xf3061a5392264cc5L,
                                   0xa443f952ceaf5816L,
                                   0x116b46a08c4L,
                                   0x116b46a4416L,
                                   "operand"))),
                   HUtil.createMatchingPatternByConcept(
                       MetaAdapterFactory.getConcept(
                           0x756e911c3f1f4a48L,
                           0xbdf5a2ceb91b723cL,
                           0xd244b712f91001cL,
                           "jetbrains.mps.execution.settings.structure.PersistentConfigurationType")),
                   true)
           != null);
 }
コード例 #20
0
 public void applyRule(
     final SNode switchCase,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   SNode switchNode =
       SNodeOperations.as(
           SNodeOperations.getParent(switchCase),
           "jetbrains.mps.baseLanguage.structure.SwitchStatement");
   if ((switchNode != null)) {
     if (!(typeCheckingContext.isSingleTypeComputation())) {
       {
         SNode _nodeToCheck_1029348928467 =
             SLinkOperations.getTarget(switchCase, "expression", true);
         EquationInfo _info_12389875345 =
             new EquationInfo(
                 _nodeToCheck_1029348928467,
                 null,
                 "r:00000000-0000-4000-0000-011c895902c5(jetbrains.mps.baseLanguage.typesystem)",
                 "9035995549588792237",
                 0,
                 null);
         typeCheckingContext.createLessThanInequality(
             (SNode)
                 typeCheckingContext.typeOf(
                     _nodeToCheck_1029348928467,
                     "r:00000000-0000-4000-0000-011c895902c5(jetbrains.mps.baseLanguage.typesystem)",
                     "9035995549588792243",
                     true),
             (SNode)
                 typeCheckingContext.typeOf(
                     SLinkOperations.getTarget(switchNode, "expression", true),
                     "r:00000000-0000-4000-0000-011c895902c5(jetbrains.mps.baseLanguage.typesystem)",
                     "9035995549588792240",
                     true),
             true,
             false,
             _info_12389875345);
       }
     }
   }
 }
コード例 #21
0
 public static boolean static_canBeAChild(
     SNode node,
     SNode parentNode,
     SNode link,
     SNode childConcept,
     final IOperationContext operationContext) {
   return (TypeChecker.getInstance()
           .getRuntimeSupport()
           .coerce_(
               TypeChecker.getInstance()
                   .getTypeOf(
                       SLinkOperations.getTarget(
                           SNodeOperations.as(
                               parentNode, "jetbrains.mps.baseLanguage.structure.DotExpression"),
                           "operand",
                           true)),
               HUtil.createMatchingPatternByConceptFQName(
                   "jetbrains.mps.baseLanguage.collections.structure.MappingType"),
               false)
       != null);
 }
コード例 #22
0
  public static Object virtual_getCompileTimeConstantValue_1238860310638(
      SNode thisNode, IModule module) {
    if (SNodeOperations.isInstanceOf(
        SLinkOperations.getTarget(thisNode, "variableDeclaration", false),
        "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration")) {
      // todo
      SNode declaration =
          SNodeOperations.cast(
              SLinkOperations.getTarget(thisNode, "variableDeclaration", false),
              "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration");
      SNode classifier =
          SNodeOperations.as(
              SNodeOperations.getParent(declaration),
              "jetbrains.mps.baseLanguage.structure.Classifier");
      if ((classifier != null)
          && SModelStereotype.isStubModelStereotype(
              SNodeOperations.getModel(classifier).getSModelReference().getStereotype())) {
        return Expression_Behavior.call_eval_1213877519769(thisNode, module);
      } else {
        return (BehaviorReflection.invokeVirtual(
                Boolean.TYPE,
                SLinkOperations.getTarget(declaration, "initializer", true),
                "virtual_isCompileTimeConstant_1238860258777",
                new Object[] {})
            ? BehaviorReflection.invokeVirtual(
                Object.class,
                SLinkOperations.getTarget(declaration, "initializer", true),
                "virtual_getCompileTimeConstantValue_1238860310638",
                new Object[] {module})
            : null);
      }
    }

    return BehaviorReflection.invokeSuper(
        Object.class,
        thisNode,
        "jetbrains.mps.baseLanguage.structure.Expression",
        "virtual_getCompileTimeConstantValue_1238860310638",
        new Object[] {module});
  }
コード例 #23
0
  public static Object virtual_eval_1213877519769(SNode thisNode, IModule module) {
    if (SNodeOperations.isInstanceOf(
        SLinkOperations.getTarget(thisNode, "variableDeclaration", false),
        "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration")) {
      // todo
      SNode declaration =
          SNodeOperations.cast(
              SLinkOperations.getTarget(thisNode, "variableDeclaration", false),
              "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration");
      SNode classifier =
          SNodeOperations.as(
              SNodeOperations.getParent(declaration),
              "jetbrains.mps.baseLanguage.structure.Classifier");

      IModule m = check_gidzrl_a0e0a0e(SNodeOperations.getModel(declaration).getModelDescriptor());
      if (m != null) {
        Object c = null;
        try {
          c =
              ReflectionUtil.getConstant(
                  m, classifier, SPropertyOperations.getString(declaration, "name"));
        } catch (Throwable t) {
          // do nothing
        }
        if (c != null) {
          return c;
        }
      }
      return ReflectionUtil.getConstant(
          module, classifier, SPropertyOperations.getString(declaration, "name"));
    }

    return BehaviorReflection.invokeSuper(
        Object.class,
        thisNode,
        "jetbrains.mps.baseLanguage.structure.Expression",
        "virtual_eval_1213877519769",
        new Object[] {module});
  }
  private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) {
    if (!(SNodeOperations.isInstanceOf(
        SLinkOperations.getTarget(node, "visibility", true),
        "jetbrains.mps.baseLanguage.structure.PublicVisibility"))) {
      return false;
    }
    SNode classifierType =
        SNodeOperations.as(
            SLinkOperations.getTarget(node, "type", true),
            "jetbrains.mps.baseLanguage.structure.ClassifierType");
    if (classifierType == null
        && SLinkOperations.getTarget(classifierType, "classifier", false) == null) {
      return false;
    }

    Set<SNode> allExtendedClassifiers =
        Classifier_Behavior.call_getAllExtendedClassifiers_2907982978864985482(
            SLinkOperations.getTarget(classifierType, "classifier", false));
    return SetSequence.fromSet(allExtendedClassifiers)
        .contains(
            SNodeOperations.getNode(
                "f:java_stub#67b3c41d-58b3-4756-b971-30bf8a9d63e6#jetbrains.jetpad.projectional.view(jetbrains.jetpad/jetbrains.jetpad.projectional.view@java_stub)",
                "~ViewPropertySpec"));
  }
コード例 #25
0
 /*package*/ static void appendName_internal_id1bWeed$oEMe(
     @NotNull SAbstractConcept __thisConcept__, SNode node, StringBuilder sb) {
   SNode parent =
       SNodeOperations.as(
           SNodeOperations.getParent(node),
           MetaAdapterFactory.getInterfaceConcept(
               0x798100da4f0a421aL,
               0xb99171f8c50ce5d2L,
               0x62ec2ed0f87da183L,
               "jetbrains.mps.build.structure.BuildLayout_PathElement"));
   if (parent != null) {
     BuildLayout_Node__BehaviorDescriptor.appendName_internal_id1bWeed$oEMe.invoke(
         SNodeOperations.asSConcept(
             MetaAdapterFactory.getConcept(
                     0x798100da4f0a421aL,
                     0xb99171f8c50ce5d2L,
                     0x668c6cfbafac4c85L,
                     "jetbrains.mps.build.structure.BuildLayout_Node")
                 .getDeclarationNode()),
         parent,
         sb);
   }
   BuildLayout_PathElement__BehaviorDescriptor.appendName_id1bWeed$ownT.invoke(node, parent, sb);
 }
コード例 #26
0
 public static SNode virtual_getParameterType_342110547581236128(SNode thisNode) {
   return SNodeOperations.as(
       SLinkOperations.getTarget(
           SLinkOperations.getTarget(thisNode, "fieldDeclaration", false), "type", true),
       "jetbrains.mps.baseLanguage.structure.ClassifierType");
 }
コード例 #27
0
  public static void virtual_fetchDependencies_5908258303322131137(
      SNode thisNode, VisibleArtifacts artifacts, RequiredDependenciesBuilder builder) {
    SNode project = artifacts.getProject();
    TemplateQueryContext genContext = artifacts.getGenContext();

    // fetch required plugins
    // we may want to have an option about that?
    // like load plugins: = all (default) | none | <list of plugins>
    ModulePlugins plugins = new ModulePlugins(project, genContext);
    plugins.collect(
        new MPSModulesClosure(
                ListSequence.fromList(SLinkOperations.getTargets(thisNode, "modules", true))
                    .translate(
                        new ITranslator2<SNode, SNode>() {
                          public Iterable<SNode> translate(SNode it) {
                            return BehaviorReflection.invokeVirtual(
                                (Class<Iterable<SNode>>) ((Class) Object.class),
                                it,
                                "virtual_getModules_4560297596904469651",
                                new Object[] {});
                          }
                        }))
            .trackDevkits()
            .runtimeClosure());
    for (SNode plugin : Sequence.fromIterable(plugins.getDependency())) {
      SNode pluginArtifact;
      if (SNodeOperations.getContainingRoot(thisNode)
          != SNodeOperations.getContainingRoot(plugin)) {
        pluginArtifact =
            SNodeOperations.as(
                artifacts.findArtifact(plugin), "jetbrains.mps.build.structure.BuildLayout_Node");
      } else {
        pluginArtifact =
            SNodeOperations.as(
                artifacts.findArtifact(artifacts.toOriginalNode(plugin)),
                "jetbrains.mps.build.structure.BuildLayout_Node");
      }
      if (pluginArtifact != null) {
        builder.add(pluginArtifact, plugin);
      }
    }

    // fetch modules
    Iterable<SNode> originalModules =
        ListSequence.fromList(SLinkOperations.getTargets(thisNode, "modules", true))
            .translate(
                new ITranslator2<SNode, SNode>() {
                  public Iterable<SNode> translate(SNode it) {
                    return BehaviorReflection.invokeVirtual(
                        (Class<Iterable<SNode>>) ((Class) Object.class),
                        it,
                        "virtual_getModules_4560297596904469651",
                        new Object[] {});
                  }
                });
    Iterable<SNode> modules =
        Sequence.fromIterable(
                new MPSModulesClosure(originalModules)
                    .trackDevkits()
                    .designtimeClosure()
                    .getAllModules())
            .union(Sequence.fromIterable(originalModules));
    for (SNode m : Sequence.fromIterable(modules)) {
      SNode artifact;
      SNode originalModule = DependenciesHelper.getOriginalNode(m, genContext);
      VisibleArtifacts currentArtifacts = artifacts;
      artifact =
          SNodeOperations.as(
              currentArtifacts.findArtifact(originalModule),
              "jetbrains.mps.build.structure.BuildLayout_Node");
      if (artifact != null) {
        builder.add(
            SNodeOperations.as(
                DependenciesHelper.getOriginalNode(artifact, genContext),
                "jetbrains.mps.build.structure.BuildLayout_Node"),
            originalModule);
      } else if (SNodeOperations.isInstanceOf(
          originalModule, "jetbrains.mps.build.mps.structure.BuildMps_DevKit")) {
        artifact =
            SNodeOperations.as(
                currentArtifacts.findArtifact(
                    SLinkOperations.getTarget(
                        SNodeOperations.cast(
                            originalModule, "jetbrains.mps.build.mps.structure.BuildMps_DevKit"),
                        "path",
                        true)),
                "jetbrains.mps.build.structure.BuildLayout_Node");
        if (artifact != null) {
          builder.add(
              SNodeOperations.as(
                  DependenciesHelper.getOriginalNode(artifact, genContext),
                  "jetbrains.mps.build.structure.BuildLayout_Node"),
              originalModule);
        }
      }
    }
  }
コード例 #28
0
 public static SNode call_getContainingConcept_4125821269968947769(SNode thisNode) {
   return SNodeOperations.as(
       SNodeOperations.getParent(thisNode),
       "jetbrains.mps.core.structure.structure.SAbstractConcept");
 }
コード例 #29
0
 public static String virtual_location_7117056644539862594(
     SNode thisNode, DependenciesHelper helper, final Object artifactId) {
   if (artifactId instanceof SNode) {
     SNode node = (SNode) artifactId;
     if (SNodeOperations.isInstanceOf(
         node, "jetbrains.mps.build.mps.structure.BuildMps_AbstractModule")) {
       final SNode module =
           SNodeOperations.cast(node, "jetbrains.mps.build.mps.structure.BuildMps_AbstractModule");
       if (ListSequence.fromList(
               SLinkOperations.getTargets(
                   SLinkOperations.getTarget(thisNode, "plugin", false), "content", true))
           .any(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return BehaviorReflection.invokeVirtual(
                       Boolean.TYPE,
                       it,
                       "virtual_exports_6547494638219603457",
                       new Object[] {artifactId});
                 }
               })) {
         SNode group =
             SNodeOperations.as(
                 ListSequence.fromList(
                         SLinkOperations.getTargets(
                             SLinkOperations.getTarget(thisNode, "plugin", false),
                             "content",
                             true))
                     .where(
                         new IWhereFilter<SNode>() {
                           public boolean accept(SNode it) {
                             return SNodeOperations.isInstanceOf(
                                     it,
                                     "jetbrains.mps.build.mps.structure.BuildMps_IdeaPluginGroup")
                                 && ListSequence.fromList(
                                         SLinkOperations.getTargets(
                                             SLinkOperations.getTarget(
                                                 SNodeOperations.cast(
                                                     it,
                                                     "jetbrains.mps.build.mps.structure.BuildMps_IdeaPluginGroup"),
                                                 "group",
                                                 false),
                                             "modules",
                                             true))
                                     .contains(module);
                           }
                         })
                     .first(),
                 "jetbrains.mps.build.mps.structure.BuildMps_IdeaPluginGroup");
         return helper.locations().get(thisNode)
             + "/languages/"
             + ((group != null
                 ? SPropertyOperations.getString(
                         SLinkOperations.getTarget(group, "group", false), "name")
                     + "/"
                 : ""))
             + SPropertyOperations.getString(module, "name")
             + ".jar";
       }
       return null;
     }
   }
   return BehaviorReflection.invokeSuper(
       String.class,
       thisNode,
       "jetbrains.mps.build.structure.BuildLayout_AbstractContainer",
       "virtual_location_7117056644539862594",
       new Object[] {helper, artifactId});
 }
コード例 #30
0
  public void checkNode(
      final SNode node,
      LanguageErrorsComponent component,
      final IOperationContext operationContext,
      IScope scope) {
    final ConstraintsDescriptor newDescriptor =
        ConceptRegistry.getInstance().getConstraintsDescriptorNew(node.getConceptFqName());

    final CheckingNodeContext checkingNodeContext =
        new jetbrains.mps.smodel.structure.CheckingNodeContext();

    if (SNodeOperations.getParent(node) != null) {
      component.addDependency(SNodeOperations.getParent(node));
    }
    if (SNodeOperations.getParent(node) != null
        && !(jetbrains.mps.smodel.SNodeOperations.isUnknown(SNodeOperations.getParent(node)))) {
      final SNode link = SNodeOperations.getContainingLinkDeclaration(node);
      if (link == null) {
        component.addError(node, "Child in a role with unknown link", null);
        return;
      }
      boolean canBeChild =
          component.runCheckingAction(
              new _FunctionTypes._return_P0_E0<Boolean>() {
                public Boolean invoke() {
                  return ModelConstraintsManager.canBeChild(
                      newDescriptor,
                      node.getConceptFqName(),
                      operationContext,
                      SNodeOperations.getParent(node),
                      link,
                      checkingNodeContext);
                }
              });
      if (!(canBeChild)) {
        SNode rule = getBreakingNodeAndClearContext(checkingNodeContext);
        component.addError(
            node,
            "Node " + node + " cannot be child of node " + SNodeOperations.getParent(node),
            rule);
      }
    }

    if (node.isRoot()) {
      boolean canBeRoot =
          component.runCheckingAction(
              new _FunctionTypes._return_P0_E0<Boolean>() {
                public Boolean invoke() {
                  return ModelConstraintsManager.canBeRoot(
                      newDescriptor,
                      operationContext,
                      node.getConceptFqName(),
                      SNodeOperations.getModel(node),
                      checkingNodeContext);
                }
              });
      if (!(canBeRoot)) {
        SNode rule = getBreakingNodeAndClearContext(checkingNodeContext);
        component.addError(node, "Not rootable concept added as root", rule);
      }
    }

    for (SNode child : SNodeOperations.getChildren(node)) {
      component.addDependency(child);
      final SNode childConcept = SNodeOperations.getConceptDeclaration(child);
      final SNode childLink = SNodeOperations.getContainingLinkDeclaration(child);
      if (childLink == null) {
        continue;
      }
      boolean canBeParent =
          component.runCheckingAction(
              new _FunctionTypes._return_P0_E0<Boolean>() {
                public Boolean invoke() {
                  return ModelConstraintsManager.canBeParent(
                      newDescriptor,
                      node,
                      childConcept,
                      childLink,
                      operationContext,
                      checkingNodeContext);
                }
              });
      if (!(canBeParent)) {
        SNode rule = getBreakingNodeAndClearContext(checkingNodeContext);
        component.addError(node, "Node " + node + " cannot be parent of node " + child, rule);
      }

      // todo: do it right, with runCheckingAction!
      if (!(ModelConstraintsManager.canBeAncestor(
          node, childConcept, operationContext, checkingNodeContext))) {
        SNode rule =
            SNodeOperations.cast(
                getBreakingNodeAndClearContext(checkingNodeContext),
                "jetbrains.mps.lang.constraints.structure.ConstraintFunction_CanBeAnAncestor");
        component.addError(
            child,
            "Concept "
                + SLinkOperations.getTarget(
                    SNodeOperations.as(
                        SNodeOperations.getParent(rule),
                        "jetbrains.mps.lang.constraints.structure.ConceptConstraints"),
                    "concept",
                    false)
                + " cannot be ancestor of node "
                + child,
            rule);
      }
    }

    // Properties validation
    SNode concept = SNodeOperations.getConceptDeclaration(node);
    component.addDependency(concept);
    ConceptAndSuperConceptsScope chs = new ConceptAndSuperConceptsScope(concept);
    for (SNode parentConcept : chs.getConcepts()) {
      component.addDependency(parentConcept);
    }
    List<SNode> props =
        ((List<SNode>)
            chs.getNodes(
                new Condition<SNode>() {
                  public boolean met(SNode n) {
                    return SNodeOperations.isInstanceOf(
                        n, "jetbrains.mps.lang.structure.structure.PropertyDeclaration");
                  }
                }));
    for (SNode p : ListSequence.fromList(props)) {
      final PropertySupport ps = PropertySupport.getPropertySupport(p);
      final String propertyName = SPropertyOperations.getString(p, "name");
      if (propertyName == null) {
        LOG.error(
            "Property declaration has a null name, declaration id: "
                + p.getSNodeId()
                + ", model: "
                + SNodeOperations.getModel(p).getSModelFqName());
        continue;
      }
      final String value = ps.fromInternalValue(node.getProperty(propertyName));
      final PropertyConstraintsDescriptor propertyDescriptor =
          newDescriptor.getProperty(propertyName);
      boolean canSetValue =
          component.runCheckingAction(
              new _FunctionTypes._return_P0_E0<Boolean>() {
                public Boolean invoke() {
                  return ps.canSetValue(
                      propertyDescriptor, node, propertyName, value, operationContext.getScope());
                }
              });
      if (!(canSetValue)) {
        // RE-2426 Ñ disabling the "Property constraint violation for property" error messages

        /*
        // TODO this is a hack for anonymous classes
        if ("name".equals(SPropertyOperations.getString(p, "name")) && ("AnonymousClass".equals(SPropertyOperations.getString(concept, "name")) || "InternalAnonymousClass".equals(SPropertyOperations.getString(concept, "name")))) {
          continue;
        }
        // todo find a rule
        component.addError(node, "Property constraint violation for property \"" + SPropertyOperations.getString(p, "name") + "\"", null, new PropertyMessageTarget(SPropertyOperations.getString(p, "name")));
        */
      }
    }
  }