public String getDescription(final SNode node, final EditorContext editorContext) {
   return "Add Comment for "
       + (((SConceptPropertyOperations.getString(node, "alias") != null)
           ? SConceptPropertyOperations.getString(node, "alias")
           : "Node"))
       + " "
       + ((SPropertyOperations.getString(node, "name") != null)
           ? SPropertyOperations.getString(node, "name")
           : "");
 }
Ejemplo n.º 2
0
 public static String getCompareType(SNode operation) {
   String result = null;
   if (SConceptPropertyOperations.getString(operation, "alias").equals("==")) {
     result = "EQ";
   }
   if (SConceptPropertyOperations.getString(operation, "alias").equals("!=")) {
     result = "NE";
   }
   if (SConceptPropertyOperations.getString(operation, "alias").equals(">")) {
     result = "GT";
   }
   if (SConceptPropertyOperations.getString(operation, "alias").equals("<")) {
     result = "LT";
   }
   if (SConceptPropertyOperations.getString(operation, "alias").equals(">=")) {
     result = "GE";
   }
   if (SConceptPropertyOperations.getString(operation, "alias").equals("<=")) {
     result = "LE";
   }
   return result;
 }
Ejemplo n.º 3
0
  public SNode convertClass(PsiClass x) {

    final Wrappers._T<SNode> classifier = new Wrappers._T<SNode>();

    if (x.isAnnotationType()) {
      classifier.value =
          SConceptOperations.createNewNode("jetbrains.mps.baseLanguage.structure.Annotation", null);
    } else if (x.isEnum()) {
      classifier.value =
          SConceptOperations.createNewNode("jetbrains.mps.baseLanguage.structure.EnumClass", null);
    } else if (x.isInterface()) {
      classifier.value =
          SConceptOperations.createNewNode("jetbrains.mps.baseLanguage.structure.Interface", null);
    } else {
      classifier.value =
          SConceptOperations.createNewNode(
              "jetbrains.mps.baseLanguage.structure.ClassConcept", null);
    }

    final SNode ourConcept = SNodeOperations.getConceptDeclaration(classifier.value);

    SPropertyOperations.set(classifier.value, "name", x.getName());
    SLinkOperations.setTarget(classifier.value, "visibility", getVisibility(x), true);
    SConceptPropertyOperations.setBoolean(classifier.value, "final", isFinal(x));
    addTypeParams(x, classifier.value);

    if (isNotEmpty_rbndtb_a0m0a(SPropertyOperations.getString(classifier.value, "name"))) {
      String id =
          SNodeId.Foreign.ID_PREFIX + SPropertyOperations.getString(classifier.value, "name");
      classifier.value.setId(new SNodeId.Foreign(id));
    }

    Sequence.fromIterable(Sequence.fromArray(x.getFields()))
        .visitAll(
            new IVisitor<PsiField>() {
              public void visit(PsiField it) {
                SNode node = convertField(it, ourConcept);

                if (SNodeOperations.isInstanceOf(
                    node, "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration")) {
                  ListSequence.fromList(
                          SLinkOperations.getTargets(classifier.value, "staticField", true))
                      .addElement(
                          SNodeOperations.cast(
                              node, "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration"));
                } else if (SNodeOperations.isInstanceOf(
                    node, "jetbrains.mps.baseLanguage.structure.FieldDeclaration")) {
                  ListSequence.fromList(
                          SLinkOperations.getTargets(
                              SNodeOperations.cast(
                                  classifier.value,
                                  "jetbrains.mps.baseLanguage.structure.ClassConcept"),
                              "field",
                              true))
                      .addElement(
                          SNodeOperations.cast(
                              node, "jetbrains.mps.baseLanguage.structure.FieldDeclaration"));
                }
              }
            });

    Sequence.fromIterable(Sequence.fromArray(x.getMethods()))
        .visitAll(
            new IVisitor<PsiMethod>() {
              public void visit(PsiMethod it) {
                SNode node = convertMethod(it, ourConcept);

                if (SNodeOperations.isInstanceOf(
                    node, "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration")) {
                  ListSequence.fromList(
                          SLinkOperations.getTargets(classifier.value, "method", true))
                      .addElement(
                          SNodeOperations.cast(
                              node,
                              "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration"));
                } else if (SNodeOperations.isInstanceOf(
                    node, "jetbrains.mps.baseLanguage.structure.StaticMethodDeclaration")) {
                  ListSequence.fromList(
                          SLinkOperations.getTargets(
                              SNodeOperations.cast(
                                  classifier.value,
                                  "jetbrains.mps.baseLanguage.structure.ClassConcept"),
                              "staticMethod",
                              true))
                      .addElement(
                          SNodeOperations.cast(
                              node,
                              "jetbrains.mps.baseLanguage.structure.StaticMethodDeclaration"));
                } else if (SNodeOperations.isInstanceOf(
                    node, "jetbrains.mps.baseLanguage.structure.ConstructorDeclaration")) {
                  ListSequence.fromList(
                          SLinkOperations.getTargets(
                              SNodeOperations.cast(
                                  classifier.value,
                                  "jetbrains.mps.baseLanguage.structure.ClassConcept"),
                              "constructor",
                              true))
                      .addElement(
                          SNodeOperations.cast(
                              node, "jetbrains.mps.baseLanguage.structure.ConstructorDeclaration"));
                }
              }
            });

    return classifier.value;
  }