Package org.eclipse.jdt.core.compiler

Examples of org.eclipse.jdt.core.compiler.CategorizedProblem


        MethodBinding methodBinding = methodDeclaration.binding;
         String readableName = new String(methodBinding.readableName());
         CategorizedProblem[] problems = compilationResult.problems;
         int problemsCount = compilationResult.problemCount;
        for (int j = 0; j < problemsCount; j++) {
          CategorizedProblem problem = problems[j];
          if (problem != null
              && problem.getID() == IProblem.AbstractMethodMustBeImplemented
              && problem.getMessage().indexOf(readableName) != -1
              && problem.getSourceStart() >= typeDeclarationSourceStart
              && problem.getSourceEnd() <= typeDeclarationSourceEnd) {
            // we found a match
            addMissingAbstractProblemMethod(methodDeclaration, methodBinding, problem, compilationResult);
          }
        }
      }
View Full Code Here


* either of which may be null.
*/
protected void updateProblemCounts(IMarker[] oldProblems, CategorizedProblem[] newProblems) {
  if (newProblems != null) {
    next : for (int i = 0, l = newProblems.length; i < l; i++) {
      CategorizedProblem newProblem = newProblems[i];
      if (newProblem.getID() == IProblem.Task) continue; // skip task
      boolean isError = newProblem.isError();
      String message = newProblem.getMessage();

      if (oldProblems != null) {
        for (int j = 0, m = oldProblems.length; j < m; j++) {
          IMarker pb = oldProblems[j];
          if (pb == null) continue; // already matched up with a new problem
          boolean wasError = IMarker.SEVERITY_ERROR
            == pb.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
          if (isError == wasError && message.equals(pb.getAttribute(IMarker.MESSAGE, ""))) { //$NON-NLS-1$
            oldProblems[j] = null;
            continue next;
          }
        }
      }
      if (isError) this.newErrorCount++; else this.newWarningCount++;
    }
  }
  if (oldProblems != null) {
    next : for (int i = 0, l = oldProblems.length; i < l; i++) {
      IMarker oldProblem = oldProblems[i];
      if (oldProblem == null) continue next; // already matched up with a new problem
      boolean wasError = IMarker.SEVERITY_ERROR
        == oldProblem.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
      String message = oldProblem.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$

      if (newProblems != null) {
        for (int j = 0, m = newProblems.length; j < m; j++) {
          CategorizedProblem pb = newProblems[j];
          if (pb.getID() == IProblem.Task) continue; // skip task
          if (wasError == pb.isError() && message.equals(pb.getMessage()))
            continue next;
        }
      }
      if (wasError) this.fixedErrorCount++; else this.fixedWarningCount++;
    }
View Full Code Here

  }

  private boolean checkAndTagAsMalformed(ASTNode node) {
    boolean tagWithErrors = false;
    search: for (int i = 0, max = this.problems.length; i < max; i++) {
      CategorizedProblem problem = this.problems[i];
      switch(problem.getID()) {
        case IProblem.ParsingErrorOnKeywordNoSuggestion :
        case IProblem.ParsingErrorOnKeyword :
        case IProblem.ParsingError :
        case IProblem.ParsingErrorNoSuggestion :
        case IProblem.ParsingErrorInsertTokenBefore :
        case IProblem.ParsingErrorInsertTokenAfter :
        case IProblem.ParsingErrorDeleteToken :
        case IProblem.ParsingErrorDeleteTokens :
        case IProblem.ParsingErrorMergeTokens :
        case IProblem.ParsingErrorInvalidToken :
        case IProblem.ParsingErrorMisplacedConstruct :
        case IProblem.ParsingErrorReplaceTokens :
        case IProblem.ParsingErrorNoSuggestionForTokens :
        case IProblem.ParsingErrorUnexpectedEOF :
        case IProblem.ParsingErrorInsertToComplete :
        case IProblem.ParsingErrorInsertToCompleteScope :
        case IProblem.ParsingErrorInsertToCompletePhrase :
        case IProblem.EndOfSource :
        case IProblem.InvalidHexa :
        case IProblem.InvalidOctal :
        case IProblem.InvalidCharacterConstant :
        case IProblem.InvalidEscape :
        case IProblem.InvalidInput :
        case IProblem.InvalidUnicodeEscape :
        case IProblem.InvalidFloat :
        case IProblem.NullSourceString :
        case IProblem.UnterminatedString :
        case IProblem.UnterminatedComment :
        case IProblem.InvalidDigit :
          break;
        default:
          continue search;
      }
      int position = problem.getSourceStart();
      int start = node.getStartPosition();
      int end = start + node.getLength();
      if ((start <= position) && (position <= end)) {
        node.setFlags(node.getFlags() | ASTNode.MALFORMED);
        // clear the bits on parent
View Full Code Here

        end = methodDeclaration.bodyEnd;
        // try to get the best end position
        CategorizedProblem[] problems = methodDeclaration.compilationResult().problems;
        if (problems != null) {
          for (int i = 0, max = methodDeclaration.compilationResult().problemCount; i < max; i++) {
            CategorizedProblem currentProblem = problems[i];
            if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) {
              end = currentProblem.getSourceEnd();
              break;
            }
          }
        }
        int startPosition = methodDecl.getStartPosition();
View Full Code Here

      int localProblemCount = 0;
      if (count != 0) {
        int errors = 0;
        int warnings = 0;
        for (int i = 0; i < count; i++) {
          CategorizedProblem problem = (CategorizedProblem) problems.get(i);
          if (problem != null) {
            currentMain.globalProblemsCount++;
            logExtraProblem(problem, localProblemCount, currentMain.globalProblemsCount);
            localProblemCount++;
            if (problem.isError()) {
              errors++;
              currentMain.globalErrorsCount++;
            } else if (problem.isWarning()) {
              currentMain.globalWarningsCount++;
              warnings++;
            }
          }
        }
        if ((this.tagBits & Logger.XML) != 0) {
          if ((errors + warnings) != 0) {
            startLoggingExtraProblems(count);
            for (int i = 0; i < count; i++) {
              CategorizedProblem problem = (CategorizedProblem) problems.get(i);
              if (problem!= null) {
                if (problem.getID() != IProblem.Task) {
                  logXmlExtraProblem(problem, localProblemCount, currentMain.globalProblemsCount);
                }
              }
            }
            endLoggingExtraProblems();
View Full Code Here

      if (count != 0) {
        int errors = 0;
        int warnings = 0;
        int tasks = 0;
        for (int i = 0; i < count; i++) {
          CategorizedProblem problem = problems[i];
          if (problem != null) {
            currentMain.globalProblemsCount++;
            logProblem(problem, localProblemCount, currentMain.globalProblemsCount, unitSource);
            localProblemCount++;
            if (problem.isError()) {
              localErrorCount++;
              errors++;
              currentMain.globalErrorsCount++;
            } else if (problem.getID() == IProblem.Task) {
              currentMain.globalTasksCount++;
              tasks++;
            } else {
              currentMain.globalWarningsCount++;
              warnings++;
            }
          }
        }
        if ((this.tagBits & Logger.XML) != 0) {
          if ((errors + warnings) != 0) {
            startLoggingProblems(errors, warnings);
            for (int i = 0; i < count; i++) {
              CategorizedProblem problem = problems[i];
              if (problem!= null) {
                if (problem.getID() != IProblem.Task) {
                  logXmlProblem(problem, unitSource);
                }
              }
            }
            endLoggingProblems();
          }
          if (tasks != 0) {
            startLoggingTasks(tasks);
            for (int i = 0; i < count; i++) {
              CategorizedProblem problem = problems[i];
              if (problem!= null) {
                if (problem.getID() == IProblem.Task) {
                  logXmlTask(problem, unitSource);
                }
              }
            }
            endLoggingTasks();
View Full Code Here

  }

  // if no reference context, we need to abort from the current compilation process
  if (referenceContext == null) {
    if ((severity & ProblemSeverities.Error) != 0) { // non reportable error is fatal
      CategorizedProblem problem = this.createProblem(null, problemId, problemArguments, elaborationId, messageArguments, severity, 0, 0, 0, 0);
      throw new AbortCompilation(null, problem);
    } else {
      return; // ignore non reportable warning
    }
  }

  int[] lineEnds;
  int lineNumber = problemStartPosition >= 0
      ? Util.getLineNumber(problemStartPosition, lineEnds = unitResult.getLineSeparatorPositions(), 0, lineEnds.length-1)
      : 0;
  int columnNumber = problemStartPosition >= 0
      ? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition)
      : 0;
  CategorizedProblem problem =
    this.createProblem(
      unitResult.getFileName(),
      problemId,
      problemArguments,
      elaborationId,
View Full Code Here

  }

  private boolean markIncludedProblems(int start, int end) {
    boolean foundProblems = false;
    next: for (int i = 0, max = this.problems.length; i < max; i++) {
      CategorizedProblem problem = this.problems[i];

      if(this.usedOrIrrelevantProblems[i]) continue next;

      switch(problem.getID()) {
        case IProblem.ParsingErrorOnKeywordNoSuggestion :
        case IProblem.ParsingErrorOnKeyword :
        case IProblem.ParsingError :
        case IProblem.ParsingErrorNoSuggestion :
        case IProblem.ParsingErrorInsertTokenBefore :
        case IProblem.ParsingErrorInsertTokenAfter :
        case IProblem.ParsingErrorDeleteToken :
        case IProblem.ParsingErrorDeleteTokens :
        case IProblem.ParsingErrorMergeTokens :
        case IProblem.ParsingErrorInvalidToken :
        case IProblem.ParsingErrorMisplacedConstruct :
        case IProblem.ParsingErrorReplaceTokens :
        case IProblem.ParsingErrorNoSuggestionForTokens :
        case IProblem.ParsingErrorUnexpectedEOF :
        case IProblem.ParsingErrorInsertToComplete :
        case IProblem.ParsingErrorInsertToCompleteScope :
        case IProblem.ParsingErrorInsertToCompletePhrase :
        case IProblem.EndOfSource :
        case IProblem.InvalidHexa :
        case IProblem.InvalidOctal :
        case IProblem.InvalidCharacterConstant :
        case IProblem.InvalidEscape :
        case IProblem.InvalidInput :
        case IProblem.InvalidUnicodeEscape :
        case IProblem.InvalidFloat :
        case IProblem.NullSourceString :
        case IProblem.UnterminatedString :
        case IProblem.UnterminatedComment :
        case IProblem.InvalidDigit :
          break;
        default:
          this.usedOrIrrelevantProblems[i] = true;
          continue next;

      }

      int problemStart = problem.getSourceStart();
      int problemEnd = problem.getSourceEnd();
      if ((start <= problemStart) && (problemStart <= end) ||
          (start <= problemEnd) && (problemEnd <= end)) {
        this.usedOrIrrelevantProblems[i] = true;
        foundProblems = true;
      }
View Full Code Here

  CategorizedProblem[] allProblems = new CategorizedProblem[totalNumberOfProblem];
  int allProblemIndex = 0;
  int taskIndex = 0;
  int problemIndex = 0;
  while (taskIndex + problemIndex < totalNumberOfProblem) {
    CategorizedProblem nextTask = null;
    CategorizedProblem nextProblem = null;
    if (taskIndex < onlyTaskCount) {
      nextTask = onlyTasks[taskIndex];
    }
    if (problemIndex < onlyProblemCount) {
      nextProblem = onlyProblems[problemIndex];
    }
    // select the next problem
    CategorizedProblem currentProblem = null;
    if (nextProblem != null) {
      if (nextTask != null) {
        if (nextProblem.getSourceStart() < nextTask.getSourceStart()) {
          currentProblem = nextProblem;
          problemIndex++;
View Full Code Here

  // Re-adjust the size of the problems if necessary and filter package problems
  if (this.problems != null) {
    CategorizedProblem[] filteredProblems = new CategorizedProblem[this.problemCount];
    int keep = 0;
    for (int i=0; i< this.problemCount; i++) {
      CategorizedProblem problem = this.problems[i];
      if (problem.getID() != IProblem.MissingNonNullByDefaultAnnotationOnPackage) {
        filteredProblems[keep++] = problem;
      } else if (this.compilationUnit != null) {
        if (CharOperation.equals(this.compilationUnit.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)) {
          filteredProblems[keep++] = problem;
        }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.compiler.CategorizedProblem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.