Exemple #1
0
 public static String virtual_getPresentation_1213877396640(SNode thisNode) {
   return "From "
       + SPropertyOperations.getString_def(
           thisNode,
           MetaAdapterFactory.getProperty(
               0xa7d67633e8d9473bL,
               0x98ce995a7aa66941L,
               0x40bcae6c0e6bc56bL,
               0x40bcae6c0e6bc59fL,
               "start"),
           "monday")
       + " to "
       + SPropertyOperations.getString_def(
           thisNode,
           MetaAdapterFactory.getProperty(
               0xa7d67633e8d9473bL,
               0x98ce995a7aa66941L,
               0x40bcae6c0e6bc56bL,
               0x40bcae6c0e6bc5a1L,
               "end"),
           "monday");
 }
 public void handleAction(
     SNode node,
     SModel model,
     IScope scope,
     IOperationContext operationContext,
     EditorContext editorContext) {
   SNode tagWrapper =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.editor.structure.RightTransformAnchorTagWrapper", null);
   SPropertyOperations.set(
       tagWrapper, "tag", SPropertyOperations.getString_def(node, "tag", null));
   ListSequence.fromList(SLinkOperations.getTargets(node, "tags", true)).addElement(tagWrapper);
   SPropertyOperations.set(node, "tag", null);
 }
 public static String virtual_getPresentation_1213877396640(SNode thisNode) {
   return SPropertyOperations.getString_def(thisNode, "day", "monday");
 }
 private static boolean renderingCondition_1tjmxy_a3a0(
     SNode node, EditorContext editorContext, IScope scope) {
   return "FILL".equals(SPropertyOperations.getString_def(node, "value", "LEFT"));
 }
  public void applyRule(
      final SNode enumerationDataTypeDeclaration,
      final TypeCheckingContext typeCheckingContext,
      IsApplicableStatus status) {
    final boolean deriveFromExternal =
        eq_t6q6ek_a0a0a1(
            SPropertyOperations.getString_def(
                enumerationDataTypeDeclaration,
                MetaAdapterFactory.getProperty(
                    0xc72da2b97cce4447L,
                    0x8389f407dc1158b7L,
                    0xfc26875dfbL,
                    0x116d5fed0c2L,
                    "memberIdentifierPolicy"),
                "derive_from_presentation"),
            "derive_from_presentation");
    final boolean deriveFromInternal =
        eq_t6q6ek_a0a1a1(
            SPropertyOperations.getString_def(
                enumerationDataTypeDeclaration,
                MetaAdapterFactory.getProperty(
                    0xc72da2b97cce4447L,
                    0x8389f407dc1158b7L,
                    0xfc26875dfbL,
                    0x116d5fed0c2L,
                    "memberIdentifierPolicy"),
                "derive_from_presentation"),
            "derive_from_internal_value");

    // Suggest using internal values, if they are present in all members
    if (deriveFromExternal
        && ListSequence.fromList(
                SLinkOperations.getChildren(
                    enumerationDataTypeDeclaration,
                    MetaAdapterFactory.getContainmentLink(
                        0xc72da2b97cce4447L,
                        0x8389f407dc1158b7L,
                        0xfc26875dfbL,
                        0xfc32151efeL,
                        "member")))
            .all(
                new IWhereFilter<SNode>() {
                  public boolean accept(SNode it) {
                    return SPropertyOperations.getString(
                            it,
                            MetaAdapterFactory.getProperty(
                                0xc72da2b97cce4447L,
                                0x8389f407dc1158b7L,
                                0xfc321331b2L,
                                0xfc5ee06663L,
                                "internalValue"))
                        != null;
                  }
                })) {
      {
        MessageTarget errorTarget = new NodeMessageTarget();
        IErrorReporter _reporter_2309309498 =
            typeCheckingContext.reportWarning(
                enumerationDataTypeDeclaration,
                "Member identifiers could be derived from internal values, since they are specified for all enumeration members",
                "r:00000000-0000-4000-0000-011c8959028f(jetbrains.mps.lang.structure.typesystem)",
                "1447401809585273479",
                null,
                errorTarget);
        {
          BaseQuickFixProvider intentionProvider =
              new BaseQuickFixProvider(
                  "jetbrains.mps.lang.structure.typesystem.EnableDeriveFromInternalValues_QuickFix",
                  false);
          _reporter_2309309498.addIntentionProvider(intentionProvider);
        }
      }
    }

    ListSequence.fromList(
            SLinkOperations.getChildren(
                enumerationDataTypeDeclaration,
                MetaAdapterFactory.getContainmentLink(
                    0xc72da2b97cce4447L,
                    0x8389f407dc1158b7L,
                    0xfc26875dfbL,
                    0xfc32151efeL,
                    "member")))
        .visitAll(
            new IVisitor<SNode>() {
              public void visit(final SNode member) {
                // Warn about duplication in presentation
                if (!(deriveFromExternal)
                    && ListSequence.fromList(SNodeOperations.getAllSiblings(member, false))
                        .where(
                            new IWhereFilter<SNode>() {
                              public boolean accept(SNode it) {
                                return eq_t6q6ek_a0a0a0a0a0a0b0a0a0a0g0b(
                                    SPropertyOperations.getString(
                                        SNodeOperations.cast(
                                            it,
                                            MetaAdapterFactory.getConcept(
                                                0xc72da2b97cce4447L,
                                                0x8389f407dc1158b7L,
                                                0xfc321331b2L,
                                                "jetbrains.mps.lang.structure.structure.EnumerationMemberDeclaration")),
                                        MetaAdapterFactory.getProperty(
                                            0xc72da2b97cce4447L,
                                            0x8389f407dc1158b7L,
                                            0xfc321331b2L,
                                            0xfc5ee06664L,
                                            "externalValue")),
                                    SPropertyOperations.getString(
                                        member,
                                        MetaAdapterFactory.getProperty(
                                            0xc72da2b97cce4447L,
                                            0x8389f407dc1158b7L,
                                            0xfc321331b2L,
                                            0xfc5ee06664L,
                                            "externalValue")));
                              }
                            })
                        .isNotEmpty()) {
                  {
                    MessageTarget errorTarget = new NodeMessageTarget();
                    IErrorReporter _reporter_2309309498 =
                        typeCheckingContext.reportWarning(
                            member,
                            "Duplicate value of a presentation value",
                            "r:00000000-0000-4000-0000-011c8959028f(jetbrains.mps.lang.structure.typesystem)",
                            "1447401809584866838",
                            null,
                            errorTarget);
                  }
                }

                // Report duplicate values
                if (!(deriveFromInternal)
                    && SPropertyOperations.getString(
                            member,
                            MetaAdapterFactory.getProperty(
                                0xc72da2b97cce4447L,
                                0x8389f407dc1158b7L,
                                0xfc321331b2L,
                                0xfc5ee06663L,
                                "internalValue"))
                        != null
                    && ListSequence.fromList(SNodeOperations.getAllSiblings(member, false))
                        .where(
                            new IWhereFilter<SNode>() {
                              public boolean accept(SNode it) {
                                return eq_t6q6ek_a0a0a0a0a0a0e0a0a0a0g0b(
                                    SPropertyOperations.getString(
                                        SNodeOperations.cast(
                                            it,
                                            MetaAdapterFactory.getConcept(
                                                0xc72da2b97cce4447L,
                                                0x8389f407dc1158b7L,
                                                0xfc321331b2L,
                                                "jetbrains.mps.lang.structure.structure.EnumerationMemberDeclaration")),
                                        MetaAdapterFactory.getProperty(
                                            0xc72da2b97cce4447L,
                                            0x8389f407dc1158b7L,
                                            0xfc321331b2L,
                                            0xfc5ee06663L,
                                            "internalValue")),
                                    SPropertyOperations.getString(
                                        member,
                                        MetaAdapterFactory.getProperty(
                                            0xc72da2b97cce4447L,
                                            0x8389f407dc1158b7L,
                                            0xfc321331b2L,
                                            0xfc5ee06663L,
                                            "internalValue")));
                              }
                            })
                        .isNotEmpty()) {
                  {
                    MessageTarget errorTarget = new NodeMessageTarget();
                    IErrorReporter _reporter_2309309498 =
                        typeCheckingContext.reportTypeError(
                            member,
                            "Duplicate value of an internal value",
                            "r:00000000-0000-4000-0000-011c8959028f(jetbrains.mps.lang.structure.typesystem)",
                            "1447401809584872588",
                            null,
                            errorTarget);
                  }
                }

                // Report duplicate derived identifiers, be it presentation, internal value or java
                // identifiers
                final String memberValidId =
                    EnumerationMemberDeclaration_BehaviorDescriptor.getConstantName_idi2Z$rBf
                        .invoke(member);
                if (memberValidId == null) {
                  {
                    MessageTarget errorTarget = new NodeMessageTarget();
                    IErrorReporter _reporter_2309309498 =
                        typeCheckingContext.reportTypeError(
                            member,
                            "A derived identifier is null",
                            "r:00000000-0000-4000-0000-011c8959028f(jetbrains.mps.lang.structure.typesystem)",
                            "1447401809585113262",
                            null,
                            errorTarget);
                  }
                } else {
                  if (ListSequence.fromList(SNodeOperations.getAllSiblings(member, false))
                      .where(
                          new IWhereFilter<SNode>() {
                            public boolean accept(SNode it) {
                              return eq_t6q6ek_a0a0a0a0a0a0a0i0a0a0a0g0b(
                                  EnumerationMemberDeclaration_BehaviorDescriptor
                                      .getConstantName_idi2Z$rBf.invoke(
                                      SNodeOperations.cast(
                                          it,
                                          MetaAdapterFactory.getConcept(
                                              0xc72da2b97cce4447L,
                                              0x8389f407dc1158b7L,
                                              0xfc321331b2L,
                                              "jetbrains.mps.lang.structure.structure.EnumerationMemberDeclaration"))),
                                  memberValidId);
                            }
                          })
                      .isNotEmpty()) {
                    String msg =
                        (deriveFromExternal
                            ? "presentation value"
                            : (deriveFromInternal ? "internal value" : "java identifier"));
                    {
                      MessageTarget errorTarget = new NodeMessageTarget();
                      IErrorReporter _reporter_2309309498 =
                          typeCheckingContext.reportTypeError(
                              member,
                              "Cannot derive unique member identifier from the "
                                  + msg
                                  + ". Duplicate derived value of an identifier - "
                                  + memberValidId
                                  + ". You may consider using a different strategy for 'member identifier'",
                              "r:00000000-0000-4000-0000-011c8959028f(jetbrains.mps.lang.structure.typesystem)",
                              "1447401809583290065",
                              null,
                              errorTarget);
                    }
                  }
                }
              }
            });
  }