Example #1
0
 public List<IParseIssue> getIssuesFromPos(int iPos) {
   List<IParseIssue> pes = getParseIssues();
   List<IParseIssue> matches = new ArrayList<IParseIssue>();
   for (int i = pes.size() - 1; i >= 0; i--) {
     IParseIssue e = pes.get(i);
     if (e.appliesToPosition(iPos)) {
       matches.add(e);
     }
   }
   return matches;
 }
Example #2
0
  public static String getFeedback(
      ICompilableType type, List<IParseIssue> parseExceptions, List<IParseIssue> parseWarnings) {
    StringBuilder feedback = new StringBuilder();

    if (type != null) {
      if (type.getSourceFileHandle() != null && type.getSourceFileHandle().getFileName() != null) {
        feedback.append(type.getSourceFileHandle().getFileName()).append("\n\n");
      } else {
        feedback.append(type.getName()).append("\n\n");
      }
    }
    if (!parseExceptions.isEmpty()) {
      feedback.append("Errors: \n\n");

      for (IParseIssue pe : parseExceptions) {
        feedback.append(pe.getConsoleMessage());
        IType typeExpected = pe.getExpectedType();
        if (typeExpected != null) {
          String strTypesExpected = getExpectedTypeName(typeExpected);
          if (strTypesExpected.length() > 0) {
            feedback.append(" \nExpected Type: ");
            feedback.append(strTypesExpected);
          }
        }
        feedback.append("\nLine Number: ");
        feedback.append(pe.getLine());
        feedback.append("  Column: ");
        feedback.append(pe.getColumn());
        feedback.append("\n\n");
      }
    }

    if (!parseWarnings.isEmpty()) {
      if (feedback.length() > 0) {
        feedback.append("\n\n");
      }
      feedback.append("Warnings: \n\n");
      for (IParseIssue pw : parseWarnings) {
        feedback.append(pw.getConsoleMessage());
        feedback.append("\nLine Number: ");
        feedback.append(pw.getLine());
        feedback.append("  Column: ");
        feedback.append(pw.getColumn());
        feedback.append("\n\n");
      }
    }

    return feedback.toString();
  }