Ejemplo n.º 1
0
  private void renderErrors(PrintWriter writer, Collection<CompilationError> errors)
      throws IOException {
    sendJuzuCSS(writer);

    //
    writer.append("<div class=\"juzu\">");
    for (CompilationError error : errors) {
      writer.append("<div class=\"juzu-box\">");
      writer.append("<div class=\"juzu-message\">").append(error.getMessage()).append("</div>");

      // Display the source code
      File source = error.getSourceFile();
      if (source != null) {
        int line = error.getLocation().getLine();
        int from = line - 2;
        int to = line + 3;
        BufferedReader reader = new BufferedReader(new FileReader(source));
        int count = 1;
        writer.append("<pre><ol start=\"").append(String.valueOf(from)).append("\">");
        for (String s = reader.readLine(); s != null; s = reader.readLine()) {
          if (count >= from && count < to) {
            if (count == line) {
              writer.append("<li><span class=\"error\">").append(s).append("</span></li>");
            } else {
              writer.append("<li><span>").append(s).append("</span></li>");
            }
          }
          count++;
        }
        writer.append("</ol></pre>");
      }
      writer.append("</div>");
    }
    writer.append("</div>");
  }
Ejemplo n.º 2
0
 @Test
 public void testAbstractClass() throws Exception {
   CompilerAssert<?, ?> compiler = compiler("plugin", "binding", "provider", "abstractclass");
   compiler.formalErrorReporting(true);
   List<CompilationError> errors = compiler.failCompile();
   assertEquals(1, errors.size());
   CompilationError error = errors.get(0);
   assertEquals(BindingMetaModelPlugin.IMPLEMENTATION_NOT_ABSTRACT, error.getCode());
   assertEquals("/plugin/binding/provider/abstractclass/package-info.java", error.getSource());
 }
Ejemplo n.º 3
0
 @Test
 public void testNotAssignable() throws Exception {
   CompilerAssert<?, ?> compiler = compiler("plugin", "binding", "provider", "notassignable");
   compiler.formalErrorReporting(true);
   List<CompilationError> errors = compiler.failCompile();
   assertEquals(1, errors.size());
   CompilationError error = errors.get(0);
   assertEquals(BindingMetaModelPlugin.PROVIDER_NOT_ASSIGNABLE, error.getCode());
   assertEquals("/plugin/binding/provider/notassignable/package-info.java", error.getSource());
 }