/** * Override this method to tune how JSweet reports the errors. * * @param diagnostic * a Java-reported diagnostic (errors, warning, etc.) * @param locale * a locale */ protected void reportJavaError(JCDiagnostic diagnostic, Locale locale) { transpilationHandler.report( JSweetProblem.INTERNAL_JAVA_ERROR, new SourcePosition(new File(diagnostic.getSource().getName()), null, (int) diagnostic.getLineNumber(), (int) diagnostic.getColumnNumber()), diagnostic.getMessage(locale)); }
@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 Object getSource() { return this.delegate.getSource(); }
@Override public Object getSource() { return delegate.getSource(); }
/** * Get the name of the source file referred to by this diagnostic. * @return the name of the source referred to with this diagnostic, or null if none */ public String getSourceName() { JavaFileObject s = getSource(); return s == null ? null : s.getName(); }
/** * Get the name of the source file referred to by this diagnostic. * @return the name of the source referred to with this diagnostic, or null if none */ public String getSourceName() { JavaFileObject s = getSource(); return s == null ? null : JavacFileManager.getJavacFileName(s); }
public JavaFileObject getSource() { return unwrap(d.getSource()); }
public JavaFileObject getSource() { return unwrap(d.getSource()); }
private String getSource( JCDiagnostic jcDiagnostic ) { if( _source == null ) { try { Reader reader = jcDiagnostic.getSource().openReader( true ); _source = StreamUtil.getContent( reader ); } catch( IOException e ) { throw new RuntimeException( e ); } } return _source; } }
public String formatSource(JCDiagnostic d, boolean fullname, Locale l) { JavaFileObject fo = d.getSource(); if (fo == null) throw new IllegalArgumentException(); // d should have source set if (fullname) return fo.getName(); else if (fo instanceof BaseFileObject) return ((BaseFileObject) fo).getShortName(); else return BaseFileObject.getSimpleName(fo); }
public String formatSource(JCDiagnostic d, boolean fullname, Locale l) { JavaFileObject fo = d.getSource(); if (fo == null) throw new IllegalArgumentException(); // d should have source set if (fullname) return fo.getName(); else if (fo instanceof BaseFileObject) return ((BaseFileObject) fo).getShortName(); else return BaseFileObject.getSimpleName(fo); }
public String formatDiagnostic(JCDiagnostic d, Locale l) { try { StringBuilder buf = new StringBuilder(); if (d.getPosition() != Position.NOPOS) { buf.append(formatSource(d, false, null)); buf.append(':'); buf.append(formatPosition(d, LINE, null)); buf.append(':'); buf.append(formatPosition(d, COLUMN, null)); buf.append(':'); } else if (d.getSource() != null && d.getSource().getKind() == JavaFileObject.Kind.CLASS) { buf.append(formatSource(d, false, null)); buf.append(":-:-:"); } else buf.append('-'); buf.append(' '); buf.append(formatMessage(d, null)); if (displaySource(d)) { buf.append("\n"); buf.append(formatSourceLine(d, 0)); } return buf.toString(); } catch (Exception e) { //e.printStackTrace(); return null; } }
public String formatDiagnostic(JCDiagnostic d, Locale l) { try { StringBuilder buf = new StringBuilder(); if (d.getPosition() != Position.NOPOS) { buf.append(formatSource(d, false, null)); buf.append(':'); buf.append(formatPosition(d, LINE, null)); buf.append(':'); buf.append(formatPosition(d, COLUMN, null)); buf.append(':'); } else if (d.getSource() != null && d.getSource().getKind() == JavaFileObject.Kind.CLASS) { buf.append(formatSource(d, false, null)); buf.append(":-:-:"); } else buf.append('-'); buf.append(' '); buf.append(formatMessage(d, null)); if (displaySource(d)) { buf.append("\n"); buf.append(formatSourceLine(d, 0)); } return buf.toString(); } catch (Exception e) { //e.printStackTrace(); return null; } }
int pos = diag.getIntPosition(); if (pos != Position.NOPOS) { JavaFileObject prev = useSource(diag.getSource()); printErrLine(pos, writer); useSource(prev);
int pos = diag.getIntPosition(); if (pos != Position.NOPOS) { JavaFileObject prev = useSource(diag.getSource()); printErrLine(pos, writer); useSource(prev);
&& shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) { writeDiagnostic(diagnostic); nerrors++;
&& shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) { writeDiagnostic(diagnostic); nerrors++;
&& shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) { writeDiagnostic(diagnostic); nerrors++;
&& shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) { writeDiagnostic(diagnostic); nerrors++;