示例#1
0
 public void update() {
   if (this.myState.getAvailableText() != null) {
     return;
   }
   String loseTest = this.myState.getLoseClass();
   String loseMethod = this.myState.getLoseMethod();
   String test = this.myState.getCurrentClass();
   String method = this.myState.getCurrentMethod();
   final Wrappers._T<TestMethodTreeNode> methodNode = new Wrappers._T<TestMethodTreeNode>();
   if (loseTest != null && loseMethod != null) {
     methodNode.value = this.get(loseTest, loseMethod);
     TestCaseTreeNode testCaseNode = this.get(loseTest);
     if (methodNode.value != null && testCaseNode != null) {
       this.updateState(methodNode.value, testCaseNode, TestState.ERROR);
     }
   } else {
     TestCaseTreeNode testCaseNode = this.get(test);
     methodNode.value = this.get(test, method);
     if (methodNode.value != null && testCaseNode != null) {
       if (this.myState.isTerminated()) {
         this.updateState(methodNode.value, testCaseNode, TestState.TERMINATED);
         this.myAnimator.stopMovie();
       } else if (TestEvent.START_TEST_PREFIX.equals(this.myState.getToken())) {
         this.updateState(methodNode.value, testCaseNode, TestState.IN_PROGRESS);
         SwingUtilities.invokeLater(
             new Runnable() {
               public void run() {
                 TestTree.this.myAnimator.scheduleRepaint();
               }
             });
         if (this.getPreferences().getStateObject().isTrackRunning) {
           SwingUtilities.invokeLater(
               new Runnable() {
                 public void run() {
                   TestTree.this.setCurrentNode(methodNode.value);
                 }
               });
         }
       } else if (TestEvent.END_TEST_PREFIX.equals(this.myState.getToken())) {
         if (TestState.IN_PROGRESS.equals(methodNode.value.getState())) {
           this.updateState(methodNode.value, testCaseNode, TestState.PASSED);
         }
       } else if (TestEvent.FAILURE_TEST_PREFIX.equals(this.myState.getToken())) {
         this.updateState(methodNode.value, testCaseNode, TestState.FAILED);
       } else if (TestEvent.ERROR_TEST_PREFIX.equals(this.myState.getToken())) {
         methodNode.value.setState(TestState.ERROR);
         this.updateState(methodNode.value, testCaseNode, TestState.ERROR);
       }
     }
   }
   if (isFailed(methodNode.value) && this.getPreferences().getStateObject().isSelectFirstFailed) {
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             TestTree.this.selectFirstDefectNode();
           }
         });
   }
   if (this.getPreferences().getStateObject().isHidePassed) {
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             TestTree.this.hidePassed(true);
           }
         });
   }
 }
示例#2
0
  private void update(boolean force) {
    final Wrappers._boolean _force = new Wrappers._boolean(force);
    myQueue.assertSoftlyIsCommandThread();
    if (!(myDifference.isEnabled())) {
      return;
    }

    IFile modelFile = myModelDescriptor.getSource().getFile();
    if (!(modelFile.exists())) {
      return;
    }
    VirtualFile modelVFile = VirtualFileUtils.getVirtualFile(modelFile);
    if (modelVFile == null
        || ProjectLevelVcsManager.getInstance(myProject).getVcsFor(modelVFile) == null) {
      return;
    }
    FileStatus status = FileStatusManager.getInstance(myProject).getStatus(modelVFile);
    if (ConflictsUtil.isModelOrModuleConflicting(myModelDescriptor, myProject)) {
      status = FileStatus.MERGED_WITH_CONFLICTS;
    }

    if (myDifference.getChangeSet() != null) {
      ModelAccess.instance()
          .runReadAction(
              new Runnable() {
                public void run() {
                  if (myDifference.getChangeSet().getNewModel() != myModelDescriptor.getSModel()) {
                    _force.value = true;
                  }
                }
              });
    }

    if (myStatusOnLastUpdate == status && !(_force.value)) {
      return;
    }
    myDifference.removeChangeSet();
    myStatusOnLastUpdate = status;
    if (FileStatus.NOT_CHANGED == status && !(_force.value)) {
      return;
    }
    final Wrappers._T<SModel> baseVersionModel = new Wrappers._T<SModel>(null);
    if (BaseVersionUtil.isAddedFileStatus(status)
        || ConflictsUtil.isModelOrModuleConflicting(myModelDescriptor, myProject)) {
      baseVersionModel.value =
          new jetbrains.mps.smodel.SModel(myModelDescriptor.getSModelReference());
    } else {
      String content = BaseVersionUtil.getBaseVersionContent(modelVFile, myProject);
      if (content == null && status != FileStatus.NOT_CHANGED) {
        LOG.error("Base version content is null while file status is " + status);
      }
      if (content == null) {
        return;
      }
      try {
        baseVersionModel.value = ModelPersistence.readModel(content, false);
      } catch (ModelReadException e) {
        LOG.warning("", e);
        return;
      }
    }
    ModelAccess.instance()
        .runReadAction(
            new Runnable() {
              public void run() {
                synchronized (ChangesTracking.this) {
                  if (!(myDisposed)) {
                    ChangeSet changeSet =
                        ChangeSetBuilder.buildChangeSet(
                            baseVersionModel.value, myModelDescriptor.getSModel(), true);
                    myDifference.setChangeSet((ChangeSetImpl) changeSet);
                    buildCaches();
                  }
                }
              }
            });
  }
示例#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;
  }
 public static void replaceBendsByNodes(
     EmbeddedGraph embeddedGraph, Map<Dart, Integer> bends, Map<Dart, Integer> angles) {
   for (Edge edge : ListSequence.fromList(embeddedGraph.getGraph().getEdges())) {
     List<Dart> darts = embeddedGraph.getDarts(edge);
     final Wrappers._T<Dart> dartToSplit = new Wrappers._T<Dart>(null);
     Dart opposite = null;
     if (MapSequence.fromMap(bends).get(ListSequence.fromList(darts).getElement(0)) > 0) {
       dartToSplit.value = ListSequence.fromList(darts).getElement(0);
       opposite = ListSequence.fromList(darts).getElement(1);
     }
     if (MapSequence.fromMap(bends).get(ListSequence.fromList(darts).getElement(1)) > 0) {
       dartToSplit.value = ListSequence.fromList(darts).getElement(1);
       opposite = ListSequence.fromList(darts).getElement(0);
     }
     if (dartToSplit.value != null) {
       while (MapSequence.fromMap(bends).get(dartToSplit.value) > 0) {
         List<Edge> newEdges = ListSequence.fromList(new ArrayList<Edge>());
         final Node addedNode = embeddedGraph.splitEdge(dartToSplit.value.getEdge(), newEdges);
         Edge first =
             ListSequence.fromList(newEdges)
                 .findFirst(
                     new IWhereFilter<Edge>() {
                       public boolean accept(Edge it) {
                         return it.getOpposite(addedNode) == dartToSplit.value.getSource();
                       }
                     });
         Edge second =
             ListSequence.fromList(newEdges)
                 .findFirst(
                     new IWhereFilter<Edge>() {
                       public boolean accept(Edge it) {
                         return it.getOpposite(addedNode) == dartToSplit.value.getTarget();
                       }
                     });
         for (Dart firstDart : ListSequence.fromList(embeddedGraph.getDarts(first))) {
           MapSequence.fromMap(bends).put(firstDart, 0);
           if (firstDart.getSource() == addedNode) {
             MapSequence.fromMap(angles).put(firstDart, 3);
           } else {
             MapSequence.fromMap(angles)
                 .put(firstDart, MapSequence.fromMap(angles).get(dartToSplit.value));
           }
         }
         Dart nextToSplit = null;
         Dart nextOpposite = null;
         for (Dart secondDart : ListSequence.fromList(embeddedGraph.getDarts(second))) {
           if (secondDart.getSource() == addedNode) {
             nextToSplit = secondDart;
             MapSequence.fromMap(bends)
                 .put(secondDart, MapSequence.fromMap(bends).get(dartToSplit.value) - 1);
             MapSequence.fromMap(angles).put(secondDart, 1);
           } else {
             nextOpposite = secondDart;
             MapSequence.fromMap(bends).put(secondDart, 0);
             MapSequence.fromMap(angles)
                 .put(secondDart, MapSequence.fromMap(angles).get(opposite));
           }
         }
         MapSequence.fromMap(bends).removeKey(dartToSplit.value);
         MapSequence.fromMap(angles).removeKey(dartToSplit.value);
         MapSequence.fromMap(bends).removeKey(opposite);
         MapSequence.fromMap(angles).removeKey(opposite);
         dartToSplit.value = nextToSplit;
         opposite = nextOpposite;
       }
     }
   }
 }