@Override public Void visitErroneous(ErroneousTree erroneousTree, Void unused) { JCDiagnostic diagnostic = ((DCErroneous) erroneousTree).diag; if (!diagnostic.getCode().equals("compiler.err.dc.bad.inline.tag")) { return null; } JavadocTag tag = inlineTag(erroneousTree.toString().replace("@", "")); SuggestedFix fix = validTags.contains(tag) ? replace(erroneousTree, String.format("{%s}", erroneousTree), state) : SuggestedFix.builder().build(); String message = String.format( "%s is not a valid block tag. Should it be an inline tag instead?", erroneousTree); state.reportMatch( buildDescription(diagnosticPosition(getCurrentPath(), state)) .setMessage(message) .addFix(fix) .build()); return null; }
@Override public String format(JCDiagnostic diagnostic, Locale locale) { if (diagnostic.getKind() == Kind.ERROR) { if (!(context.options.isIgnoreJavaFileNameError() && "compiler.err.class.public.should.be.in.file".equals(diagnostic.getCode()))) { reportJavaError(diagnostic, locale); } } switch (diagnostic.getKind()) { case ERROR: logger.error(diagnostic); break; case WARNING: case MANDATORY_WARNING: logger.debug(diagnostic); break; case NOTE: case OTHER: default: logger.trace(diagnostic); break; } if (diagnostic.getSource() != null) { return diagnostic.getMessage(locale) + " at " + diagnostic.getSource().getName() + "(" + diagnostic.getLineNumber() + ")"; } else { return diagnostic.getMessage(locale); } }
@Override public String getCode() { return this.delegate.getCode(); }
@Override public String getCode() { return delegate.getCode(); }
public String getCode() { return d.getCode(); }
public String getCode() { return d.getCode(); }
@Override public void report( JCDiagnostic jcDiagnostic ) { if( jcDiagnostic. getCode().equals( "compiler.err.illegal.esc.char" ) ) { String source = getSource( jcDiagnostic ); int pos = (int)jcDiagnostic.getPosition(); char escaped = source.charAt( pos ); if( escaped == '$' ) { _escapedPos.add( pos ); return; } } prev.report( jcDiagnostic ); }
public String formatMessage(JCDiagnostic d, Locale l) { StringBuilder buf = new StringBuilder(); Collection<String> args = formatArguments(d, l); buf.append(localize(null, d.getCode(), args.toArray())); if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { List<String> subDiags = formatSubdiagnostics(d, null); if (subDiags.nonEmpty()) { String sep = ""; buf.append(",{"); for (String sub : formatSubdiagnostics(d, null)) { buf.append(sep); buf.append("("); buf.append(sub); buf.append(")"); sep = ","; } buf.append('}'); } } return buf.toString(); }
public String formatMessage(JCDiagnostic d, Locale l) { StringBuilder buf = new StringBuilder(); Collection<String> args = formatArguments(d, l); buf.append(localize(null, d.getCode(), args.toArray())); if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { List<String> subDiags = formatSubdiagnostics(d, null); if (subDiags.nonEmpty()) { String sep = ""; buf.append(",{"); for (String sub : formatSubdiagnostics(d, null)) { buf.append(sep); buf.append("("); buf.append(sub); buf.append(")"); sep = ","; } buf.append('}'); } } return buf.toString(); }
/** * Returns true if the regex matches the diagnostic key and if * all diagnostic arguments are matches by corresponding sub-templates. */ boolean matches(Object o) { JCDiagnostic d = (JCDiagnostic)o; Object[] args = d.getArgs(); if (!d.getCode().matches(regex) || subTemplates.length != d.getArgs().length) { return false; } for (int i = 0; i < args.length ; i++) { if (!subTemplates[i].matches(args[i])) { return false; } } return true; } }
/** * Returns true if the regex matches the diagnostic key and if * all diagnostic arguments are matches by corresponding sub-templates. */ boolean matches(Object o) { JCDiagnostic d = (JCDiagnostic)o; Object[] args = d.getArgs(); if (!d.getCode().matches(regex) || subTemplates.length != d.getArgs().length) { return false; } for (int i = 0; i < args.length ; i++) { if (!subTemplates[i].matches(args[i])) { return false; } } return true; } }
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(); }
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; }
public String formatMessage(JCDiagnostic d, Locale l) { int currentIndentation = 0; StringBuilder buf = new StringBuilder(); Collection<String> args = formatArguments(d, l); String msg = localize(l, d.getCode(), args.toArray()); String[] lines = msg.split("\n"); if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) { currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY); buf.append(indent(lines[0], currentIndentation)); //summary } if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) { currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS); for (int i = 1;i < lines.length; i++) { buf.append("\n" + indent(lines[i], currentIndentation)); } } if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS); for (String sub : formatSubdiagnostics(d, l)) { buf.append("\n" + indent(sub, currentIndentation)); } } return buf.toString(); }
public String formatMessage(JCDiagnostic d, Locale l) { int currentIndentation = 0; StringBuilder buf = new StringBuilder(); Collection<String> args = formatArguments(d, l); String msg = localize(l, d.getCode(), args.toArray()); String[] lines = msg.split("\n"); if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) { currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY); buf.append(indent(lines[0], currentIndentation)); //summary } if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) { currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS); for (int i = 1;i < lines.length; i++) { buf.append("\n" + indent(lines[i], currentIndentation)); } } if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) { currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS); for (String sub : formatSubdiagnostics(d, l)) { buf.append("\n" + indent(sub, currentIndentation)); } } return buf.toString(); }
public void report(JCDiagnostic diagnostic) { if (expectDiagKeys != null) expectDiagKeys.remove(diagnostic.getCode());
public void report(JCDiagnostic diagnostic) { if (expectDiagKeys != null) expectDiagKeys.remove(diagnostic.getCode());