Examples of DiagnosticSource


Examples of com.sun.tools.javac.util.DiagnosticSource

   }
}

static void resetEndPosMap(JavaCompiler compiler, JavaFileObject sourceFile) {
   try {
     DiagnosticSource diagnosticSource = (DiagnosticSource)
         ABSTRACT_LOG__GET_SOURCE.invoke(compiler.log, sourceFile);
     DIAGNOSTIC_SOURCE__END_POS_TABLE.set(diagnosticSource, null);
   } catch (Exception e) {
     throw new LinkageError(e.getMessage());
   }
View Full Code Here

Examples of com.sun.tools.javac.util.DiagnosticSource

    /**
     * Gets the source code corresponding to the given node
     */
    private String getSourceCode(Node node) {
        StringBuilder sb = new StringBuilder();
        DiagnosticSource source = new DiagnosticSource(gen().getFileObject(), Log.instance(gen().getContext()));
        int startLine = node.getToken().getLine();
        int endLine = node.getEndToken().getLine();
        for (int lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
            int startPos = gen().getMap().getPosition(lineNumber, 1);
            String line = source.getLine(startPos);
            if (lineNumber == endLine) {
                line = line.substring(0,  node.getEndToken().getCharPositionInLine() + node.getEndToken().getText().length());
            }
            if (lineNumber == startLine) {
                line = line.substring(node.getToken().getCharPositionInLine());
View Full Code Here

Examples of com.sun.tools.javac.util.DiagnosticSource

        } else if (sourceLanguage.isCeylon()) {
            numCeylonCodegenGarbage++;
        } else {
            numNonCeylonErrors++;
        }
        DiagnosticSource source = diagnostic.getDiagnosticSource();
        if(source != null){
            JavaFileObject file = source.getFile();
            if(file instanceof CeylonFileObject && diagnostic.getType() == DiagnosticType.ERROR){
                ((CeylonFileObject)file).addError(diagnostic);
            }
        }
        super.report(diagnostic);
View Full Code Here

Examples of com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource

    String format(JCDiagnostic d) {
        return (raw ? format_raw(d) : format_std(d));
    }

    private String format_raw(JCDiagnostic d) {
        DiagnosticSource source = d.getDiagnosticSource();
        int position = d.getIntPosition();

        StringBuilder sb = new StringBuilder();
        if (position == Position.NOPOS)
            sb.append("-");
        else {
            sb.append(source.getName() + ":" + source.getLineNumber(position) + ":" + source.getColumnNumber(position) + ":");
        }
        sb.append(" ");
        sb.append(d.getCode());
        String sep = ": ";
        for (Object arg: d.getArgs()) {
View Full Code Here

Examples of com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource

        }
        return sb.toString();
    }

    private String format_std(JCDiagnostic d) {
        DiagnosticSource source = d.getDiagnosticSource();
        DiagnosticType type = d.getType();
        int position = d.getIntPosition();


        String format = noPosFormat;
        if (source != null) {
            if (position != Position.NOPOS) {
                format = posFormat;
            } else if (source.getFile() != null &&
                       source.getFile().getKind() == JavaFileObject.Kind.CLASS) {
                format = classFormat;
            }
        }

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < format.length(); i++) {
            char c = format.charAt(i);
            if (c == '%' && i < format.length() - 1) {
                c = format.charAt(++i);
                switch (c) {
                case 'b':
                    sb.append(source == null ? "-" : source.getName());
                    break;

                case 'e':
                    sb.append(position == Position.NOPOS ? "-" : String.valueOf(d.getEndPosition()));
                    break;
View Full Code Here

Examples of com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource

    String format(JCDiagnostic d) {
        return (raw ? format_raw(d) : format_std(d));
    }

    private String format_raw(JCDiagnostic d) {
        DiagnosticSource source = d.getDiagnosticSource();
        int position = d.getIntPosition();

        StringBuilder sb = new StringBuilder();
        if (position == Position.NOPOS)
            sb.append("-");
        else {
            sb.append(source.getName() + ":" + source.getLineNumber(position) + ":" + source.getColumnNumber(position) + ":");
        }
        sb.append(" ");
        sb.append(d.getCode());
        String sep = ": ";
        for (Object arg: d.getArgs()) {
View Full Code Here

Examples of com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource

        }
        return sb.toString();
    }

    private String format_std(JCDiagnostic d) {
        DiagnosticSource source = d.getDiagnosticSource();
        DiagnosticType type = d.getType();
        int position = d.getIntPosition();


        String format = noPosFormat;
        if (source != null) {
            if (position != Position.NOPOS) {
                format = posFormat;
            } else if (source.getFile() != null &&
                       source.getFile().getKind() == JavaFileObject.Kind.CLASS) {
                format = classFormat;
            }
        }

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < format.length(); i++) {
            char c = format.charAt(i);
            if (c == '%' && i < format.length() - 1) {
                c = format.charAt(++i);
                switch (c) {
                case 'b':
                    sb.append(source == null ? "-" : source.getName());
                    break;

                case 'e':
                    sb.append(position == Position.NOPOS ? "-" : String.valueOf(d.getEndPosition()));
                    break;
View Full Code Here

Examples of com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource

    String format(JCDiagnostic d) {
    return (raw ? format_raw(d) : format_std(d));
    }

    private String format_raw(JCDiagnostic d) {
    DiagnosticSource source = d.getDiagnosticSource();
    int position = d.getIntPosition();

    StringBuilder sb = new StringBuilder();
    if (position == Position.NOPOS)
      sb.append("-");
    else {
      sb.append(source.getName() + ":" + source.getLineNumber(position) + ":" + source.getColumnNumber(position) + ":");
    }
    sb.append(" ");
    sb.append(d.getCode());
    String sep = ": ";
    for (Object arg: d.getArgs()) {
View Full Code Here

Examples of com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource

    private String format_std(JCDiagnostic d) {
    DEBUG.P(this,"format_std(1)");
    //DEBUG.P("d="+d);//这会引起无限调用,引起JCDiagnostic.toString()==>format==>format_std
   
    DiagnosticSource source = d.getDiagnosticSource();
    DiagnosticType type = d.getType();
    int position = d.getIntPosition();

   
    String format = noPosFormat;
    if (source != null) {
      if (position != Position.NOPOS) {
        format = posFormat;
      } else if (source.getFile() != null &&
           source.getFile().getKind() == JavaFileObject.Kind.CLASS) {
        format = classFormat;
      }
    }

    StringBuilder sb = new StringBuilder();

    DEBUG.P("format="+format);

    for (int i = 0; i < format.length(); i++) {
      char c = format.charAt(i);
      if (c == '%' && i < format.length() - 1) {
        c = format.charAt(++i);
        switch (c) {
        case 'b':
          sb.append(source == null ? "-" : source.getName());
          break;

        case 'e':
          sb.append(position == Position.NOPOS ? "-" : String.valueOf(d.getEndPosition()));
          break;
View Full Code Here

Examples of com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource

    String format(JCDiagnostic d) {
  return (raw ? format_raw(d) : format_std(d));
    }

    private String format_raw(JCDiagnostic d) {
  DiagnosticSource source = d.getDiagnosticSource();
  int position = d.getIntPosition();

  StringBuilder sb = new StringBuilder();
  if (position == Position.NOPOS)
      sb.append("-");
  else {
      sb.append(source.getName() + ":" + source.getLineNumber(position) + ":" + source.getColumnNumber(position) + ":");
  }
  sb.append(" ");
  sb.append(d.getCode());
  String sep = ": ";
  for (Object arg: d.getArgs()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.