/** * Accumulates errors and warning encountered during import. */ @Override public void addDiag(Diag diag) { Location loc = SimpleLocation.UNKNOWN; if (diag.getLocation() == SimpleLocation.UNKNOWN || diag.getLocation() == SimpleLocation.TOPLEVEL) { loc = swaggerFileLocation; } else { loc = new SimpleLocation( String.format("%s: %s", swaggerFileName, diag.getLocation().toString())); } diag = Diag.create(loc, diag.getMessage(), diag.getKind()); diags.add(diag); if (diag.getKind() == Diag.Kind.ERROR) { errorCount++; } }
/** * Accumulates errors and warning encountered during import. */ @Override public void addDiag(Diag diag) { Location loc = SimpleLocation.UNKNOWN; if (diag.getLocation() == SimpleLocation.UNKNOWN || diag.getLocation() == SimpleLocation.TOPLEVEL) { loc = swaggerFileLocation; } else { loc = new SimpleLocation( String.format("%s: %s", swaggerFileName, diag.getLocation().toString())); } diag = Diag.create(loc, diag.getMessage(), diag.getKind()); diags.add(diag); if (diag.getKind() == Diag.Kind.ERROR) { errorCount++; } }
@Override public void addDiag(Diag diag) { switch (diag.getKind()) { case ERROR: error(diag.getLocation(), diag.getMessage()); break; case WARNING: warning(diag.getLocation(), diag.getMessage()); break; } }
@Override public void addDiag(Diag diag) { switch (diag.getKind()) { case ERROR: error(diag.getLocation(), diag.getMessage()); break; case WARNING: warning(diag.getLocation(), diag.getMessage()); break; } }
@Override public String toString() { return String.format("%s: %s: %s", getKind().toString(), getLocation().getDisplayString(), getMessage()); } }
private static String getLocationWithoutFullPath(final Diag diag) { // /tmp/temp_dir/testFile.json becomes testFile.json String location = diag.getLocation().getDisplayString(); int lastSlashIndex = location.lastIndexOf("/"); if (lastSlashIndex != -1) { return location.substring(lastSlashIndex + 1); } return location; }
private String getLocationWithoutFullPath(final Diag diag) { String location = diag.getLocation().getDisplayString(); int firstSlashIndex = location.indexOf("/"); int lastSlashIndex = location.lastIndexOf("/"); if (firstSlashIndex != -1) { String toReplace = location.substring(firstSlashIndex, lastSlashIndex + 1); location = location.replace(toReplace, ""); } return location; }
public void report(Diag diag) { if (diag.getKind() == Kind.WARNING && diagSuppressor.isDiagSuppressed(diag, diag.getLocation())) { return; } diagCollector.addDiag(diag); }
@Override public String toString() { return String.format("%s: %s: %s", getKind().toString(), getLocation().getDisplayString(), getMessage()); } }
public void report(Diag diag) { if (diag.getKind() == Kind.WARNING && diagSuppressor.isDiagSuppressed(diag, diag.getLocation())) { return; } diagCollector.addDiag(diag); }
public static String getDiagToPrint(final Diag diag, boolean trimLocationFullPath) { String message = DiagUtils.getDiagMessage(diag); return String.format( "%s: %s: %s", diag.getKind().toString(), trimLocationFullPath ? getLocationWithoutFullPath(diag) : diag.getLocation().getDisplayString(), message); }
diagToPrint = Diag.create(diag.getLocation(), "%s", diag.getKind(), message);
/** Produce a string for the diagnosis, with optional coloring. */ public static String diagToString(Diag diag, boolean colored) { Doc text; switch (diag.getKind()) { case ERROR: text = Doc.text("ERROR: "); if (colored) { text = Doc.color(AnsiColor.RED, text); } break; case WARNING: text = Doc.text("WARNING: "); if (colored) { text = Doc.color(AnsiColor.YELLOW, text); } break; default: text = Doc.text("HINT:"); break; } text = text.add(Doc.text(diag.getLocation().getDisplayString())) .add(Doc.text(": ")) .add(Doc.text(diag.getMessage())); return text.toString(); }
/** Produce a string for the diagnosis, with optional coloring. */ public static String diagToString(Diag diag, boolean colored) { Doc text; switch (diag.getKind()) { case ERROR: text = Doc.text("ERROR: "); if (colored) { text = Doc.color(AnsiColor.RED, text); } break; case WARNING: text = Doc.text("WARNING: "); if (colored) { text = Doc.color(AnsiColor.YELLOW, text); } break; default: text = Doc.text("HINT:"); break; } text = text.add(Doc.text(diag.getLocation().getDisplayString())) .add(Doc.text(": ")) .add(Doc.text(diag.getMessage())); return text.toString(); }