/**
   * Builds the FSTModel of the feature project and creates a list of all directives with valid
   * colors
   *
   * @return the directive list
   */
  private void createDirectiveList() {
    directiveMap.clear();
    validDirectiveList.clear();
    FSTModel model = project.getFSTModel();
    if (model == null) {
      composer.buildFSTModel();
      model = project.getFSTModel();
    }
    if (model == null) {
      return;
    }

    int index = 0;
    for (FSTFeature fstFeature : model.getFeatures()) {
      for (FSTRole role : fstFeature.getRoles()) {
        if (file.equals(role.getFile())) {
          for (FSTDirective dir : role.getDirectives()) {
            directiveMap.put(dir.getId(), dir);
            index++;
          }
        }
      }
    }

    for (int i = 0; i < index; i++) {
      FSTDirective dir = directiveMap.get(i);
      if (dir != null && ColorList.isValidColor(dir.getColor())) {
        validDirectiveList.add(dir);
      }
    }
  }
  /**
   * Assigns the mapped colors to the FSTDirectives from the changed document.
   *
   * @return the directive list
   */
  private void updateDirectives() {
    ListIterator<FSTDirective> newDirIt = getNewDirectives().listIterator(0);

    while (newDirIt.hasNext()) {
      FSTDirective newDir = newDirIt.next();
      FSTDirective oldDir = directiveMap.get(newDir.getId());

      if (oldDir != null
          && newDir.getCommand() == oldDir.getCommand()
          && newDir.getFeatureName().equals(oldDir.getFeatureName())) {

        oldDir.setStartLine(newDir.getStartLine(), newDir.getStartOffset());
        oldDir.setEndLine(newDir.getEndLine(), newDir.getEndLength());
      } else {
        directiveMap.clear();
        return;
      }

      if (newDir.hasChildren()) {
        for (FSTDirective newDirChild : newDir.getChildrenList()) {
          newDirIt.add(newDirChild);
          newDirIt.previous();
        }
      }
    }
  }
Пример #3
0
  /**
   * Builds the FSTModel of the feature project and creates a list of all directives with valid
   * colors
   *
   * @return the directive list
   */
  private void createDirectiveList() {
    directiveMap.clear();
    validDirectiveList.clear();
    FSTModel model = project.getFSTModel();
    if (model == null || model.getClasses().isEmpty()) {
      composer.buildFSTModel();
      model = project.getFSTModel();
    }
    if (model == null) {
      return;
    }

    for (FSTFeature fstFeature : model.getFeatures()) {
      for (FSTRole role : fstFeature.getRoles()) {
        if (file.equals(role.getFile())) {
          for (FSTDirective dir : role.getDirectives()) {
            directiveMap.put(dir.getId(), dir);
            validDirectiveList.add(dir);
          }
        }
      }
    }
  }