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()) { sb.append(sep); if (arg instanceof JCDiagnostic) { sb.append('('); sb.append(format_raw((JCDiagnostic) arg)); sb.append(')'); } else if (arg instanceof JavaFileObject) sb.append(JavacFileManager.getJavacBaseFileName((JavaFileObject) arg)); else sb.append(arg); sep = ", "; } return sb.toString(); }
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()) { sb.append(sep); if (arg instanceof JCDiagnostic) { sb.append('('); sb.append(format_raw((JCDiagnostic) arg)); sb.append(')'); } else if (arg instanceof BaseFileObject) sb.append(((BaseFileObject) arg).getShortName()); else if (arg instanceof JavaFileObject) sb.append(BaseFileObject.getSimpleName((JavaFileObject) arg)); else sb.append(arg); sep = ", "; } return sb.toString(); }
/** Format the faulty source code line and point to the error. * @param d The diagnostic for which the error line should be printed */ protected String formatSourceLine(JCDiagnostic d, int nSpaces) { StringBuilder buf = new StringBuilder(); DiagnosticSource source = d.getDiagnosticSource(); int pos = d.getIntPosition(); if (d.getIntPosition() == Position.NOPOS) throw new AssertionError(); String line = (source == null ? null : source.getLine(pos)); if (line == null) return ""; buf.append(indent(line, nSpaces)); int col = source.getColumnNumber(pos, false); if (config.isCaretEnabled()) { buf.append("\n"); for (int i = 0; i < col - 1; i++) { buf.append((line.charAt(i) == '\t') ? "\t" : " "); } buf.append(indent("^", nSpaces)); } return buf.toString(); }
/** Format the faulty source code line and point to the error. * @param d The diagnostic for which the error line should be printed */ protected String formatSourceLine(JCDiagnostic d, int nSpaces) { StringBuilder buf = new StringBuilder(); DiagnosticSource source = d.getDiagnosticSource(); int pos = d.getIntPosition(); if (d.getIntPosition() == Position.NOPOS) throw new AssertionError(); String line = (source == null ? null : source.getLine(pos)); if (line == null) return ""; buf.append(indent(line, nSpaces)); int col = source.getColumnNumber(pos, false); if (config.isCaretEnabled()) { buf.append("\n"); for (int i = 0; i < col - 1; i++) { buf.append((line.charAt(i) == '\t') ? "\t" : " "); } buf.append(indent("^", nSpaces)); } return buf.toString(); }
public MultilineDiagnostic(JCDiagnostic other, List<JCDiagnostic> subdiagnostics) { super(other.defaultFormatter, other.getType(), other.getLintCategory(), other.flags, other.getDiagnosticSource(), other.position, other.getCode(), other.getArgs()); this.subdiagnostics = subdiagnostics; }
public MultilineDiagnostic(JCDiagnostic other, List<JCDiagnostic> subdiagnostics) { super(other.defaultFormatter, other.getType(), other.getLintCategory(), other.flags, other.getDiagnosticSource(), other.position, other.getCode(), other.getArgs()); this.subdiagnostics = subdiagnostics; }
private String format_std(JCDiagnostic d) { DiagnosticSource source = d.getDiagnosticSource(); DiagnosticType type = d.getType(); int position = d.getIntPosition();
private String format_std(JCDiagnostic d) { DiagnosticSource source = d.getDiagnosticSource(); DiagnosticType type = d.getType(); int position = d.getIntPosition();
private String selectFormat(JCDiagnostic d) { DiagnosticSource source = d.getDiagnosticSource(); String format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT); if (source != null && source != DiagnosticSource.NO_SOURCE) { if (d.getIntPosition() != Position.NOPOS) { format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_POS_FORMAT); } else if (source.getFile() != null && source.getFile().getKind() == JavaFileObject.Kind.CLASS) { format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT); } } return format; }
private String selectFormat(JCDiagnostic d) { DiagnosticSource source = d.getDiagnosticSource(); String format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT); if (source != null && source != DiagnosticSource.NO_SOURCE) { if (d.getIntPosition() != Position.NOPOS) { format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_POS_FORMAT); } else if (source.getFile() != null && source.getFile().getKind() == JavaFileObject.Kind.CLASS) { format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT); } } return format; }