Java Code Examples for javax.tools.Diagnostic.Kind#ERROR

The following examples show how to use javax.tools.Diagnostic.Kind#ERROR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompilerJavac.java    From takari-lifecycle with Eclipse Public License 1.0 6 votes vote down vote up
private MessageSeverity toSeverity(Diagnostic.Kind kind, boolean success) {
  // javac appears to report errors even when compilation was success.
  // I was only able to reproduce this with annotation processing on java 6
  // for consistency with forked mode, downgrade errors to warning here too
  if (success && kind == Kind.ERROR) {
    kind = Kind.WARNING;
  }

  MessageSeverity severity;
  switch (kind) {
    case ERROR:
      severity = MessageSeverity.ERROR;
      break;
    case NOTE:
      severity = MessageSeverity.INFO;
      break;
    default:
      severity = MessageSeverity.WARNING;
      break;
  }

  return severity;
}
 
Example 2
Source File: ErrorUtil.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public static void parserDiagnostic(Diagnostic<? extends JavaFileObject> diagnostic) {
  Kind kind = diagnostic.getKind();
  if (kind == Kind.ERROR) {
    errorMessages.add(diagnostic.getMessage(null));
    errorCount++;
  } else if (kind == Kind.MANDATORY_WARNING || kind == Kind.WARNING) {
    warningMessages.add(diagnostic.getMessage(null));
    warningCount++;
  } else {
    return;
  }
  String msg;
  if (CLANG_STYLE_ERROR_MSG && diagnostic.getSource() != null) {
    msg = String.format("error: %s:%d: %s", diagnostic.getSource().getName(),
        diagnostic.getLineNumber(), diagnostic.getMessage(null).trim());
  } else {
    msg = diagnostic.toString().trim();
  }
  errorStream.println(msg);
}
 
Example 3
Source File: AnnotatedMixinElementHandlerOverwrite.java    From Mixin with MIT License 5 votes vote down vote up
public void registerOverwrite(AnnotatedElementOverwrite elem) {
    AliasedElementName name = new AliasedElementName(elem.getElement(), elem.getAnnotation());
    this.validateTargetMethod(elem.getElement(), elem.getAnnotation(), name, "@Overwrite", true, false);
    this.checkConstraints(elem.getElement(), elem.getAnnotation());
    
    if (elem.shouldRemap()) {
        for (TypeHandle target : this.mixin.getTargets()) {
            if (!this.registerOverwriteForTarget(elem, target)) {
                return;
            }
        }
    }
    
    if (!"true".equalsIgnoreCase(this.ap.getOption(SupportedOptions.DISABLE_OVERWRITE_CHECKER))) {
        Kind overwriteErrorKind = "error".equalsIgnoreCase(this.ap.getOption(SupportedOptions.OVERWRITE_ERROR_LEVEL))
                ? Kind.ERROR : Kind.WARNING;
        
        String javadoc = this.ap.getJavadocProvider().getJavadoc(elem.getElement());
        if (javadoc == null) {
            this.ap.printMessage(overwriteErrorKind, "@Overwrite is missing javadoc comment", elem.getElement(), SuppressedBy.OVERWRITE);
            return;
        }
        
        if (!javadoc.toLowerCase(Locale.ROOT).contains("@author")) {
            this.ap.printMessage(overwriteErrorKind, "@Overwrite is missing an @author tag", elem.getElement(), SuppressedBy.OVERWRITE);
        }
        
        if (!javadoc.toLowerCase(Locale.ROOT).contains("@reason")) {
            this.ap.printMessage(overwriteErrorKind, "@Overwrite is missing an @reason tag", elem.getElement(), SuppressedBy.OVERWRITE);
        }
    }
}
 
Example 4
Source File: MessagerImpl.java    From takari-lifecycle with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void printMessage(Kind kind, CharSequence msg, Element e, AnnotationMirror a, AnnotationValue v) {
  if (kind == Kind.ERROR) {
    _processingEnv.setErrorRaised(true);
  }
  AptProblem problem = createProblem(kind, msg, e, a, v);
  if (problem != null && problem.getOriginatingFileName() != null) {
    Resource<File> input = context.getProcessedSource(new File(new String(problem.getOriginatingFileName())));
    input.addMessage(problem.getSourceLineNumber(), problem.getSourceColumnNumber(), problem.getMessage(), getSeverity(kind), null);
  } else {
    context.addPomMessage(msg.toString(), getSeverity(kind), null);
  }
}
 
Example 5
Source File: AptException.java    From doma with Apache License 2.0 5 votes vote down vote up
public AptException(
    MessageResource messageResource,
    Element element,
    AnnotationMirror annotationMirror,
    AnnotationValue annotationValue,
    Object[] args) {
  this(messageResource, Kind.ERROR, element, annotationMirror, annotationValue, null, args);
}
 
Example 6
Source File: AptException.java    From doma with Apache License 2.0 5 votes vote down vote up
public AptException(
    MessageResource messageResource,
    Element element,
    AnnotationMirror annotationMirror,
    Object[] args) {
  this(messageResource, Kind.ERROR, element, annotationMirror, null, null, args);
}
 
Example 7
Source File: JavaXToolsCompiler.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void copyErrors(List<String> errors, DiagnosticCollector<JavaFileObject> diagnostics2) {
	for (Diagnostic d : diagnostics2.getDiagnostics()) {
		if (d.getKind() == Kind.ERROR || d.getKind() == Kind.MANDATORY_WARNING) {
			errors.add(d.toString());
		}
	}
}
 
Example 8
Source File: BatchMessagerImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void printMessage(Kind kind, CharSequence msg, Element e,
		AnnotationMirror a, AnnotationValue v) {
	if (kind == Kind.ERROR) {
		_processingEnv.setErrorRaised(true);
	}
	CategorizedProblem problem = createProblem(kind, msg, e, a, v);
	if (problem != null) {
		this._compiler.addExtraProblems(problem);
	}
}
 
Example 9
Source File: CompilationInfoImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void report(Diagnostic<? extends JavaFileObject> message) {
    if (partialReparseErrors != null) {
        if (this.jfo != null && this.jfo == message.getSource()) {
            partialReparseErrors.add(message);
            if (message.getKind() == Kind.ERROR) {
                partialReparseRealErrors = true;
            }
        }
    } else {
        Diagnostics errors = getErrors(message.getSource());
        errors.add((int) message.getPosition(), message);
    }
}
 
Example 10
Source File: CodegenUtils.java    From systemds with Apache License 2.0 4 votes vote down vote up
private static Class<?> compileClassJavac(String name, String src) {
	try
	{
		//create working dir on demand
		if( _workingDir == null )
			createWorkingDir();
		
		//write input file (for debugging / classpath handling)
		File ftmp = new File(_workingDir+"/"+name.replace(".", "/")+".java");
		if( !ftmp.getParentFile().exists() )
			ftmp.getParentFile().mkdirs();
		LocalFileUtils.writeTextFile(ftmp, src);
		
		//get system java compiler
		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
		if( compiler == null )
			throw new RuntimeException("Unable to obtain system java compiler.");
	
		//prepare file manager
		DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>(); 
		try(StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null))
		{
			//prepare input source code
			Iterable<? extends JavaFileObject> sources = fileManager
					.getJavaFileObjectsFromFiles(Arrays.asList(ftmp));
			
			//prepare class path 
			URL runDir = CodegenUtils.class.getProtectionDomain().getCodeSource().getLocation(); 
			String classpath = System.getProperty("java.class.path") + 
					File.pathSeparator + runDir.getPath();
			List<String> options = Arrays.asList("-classpath",classpath);
			
			//compile source code
			CompilationTask task = compiler.getTask(null, fileManager, diagnostics, options, null, sources);
			Boolean success = task.call();
			
			//output diagnostics and error handling
			for(Diagnostic<? extends JavaFileObject> tmp : diagnostics.getDiagnostics())
				if( tmp.getKind()==Kind.ERROR )
					System.err.println("ERROR: "+tmp.toString());
			if( success == null || !success )
				throw new RuntimeException("Failed to compile class "+name);
		
			//dynamically load compiled class
			try (URLClassLoader classLoader = new URLClassLoader(
				new URL[]{new File(_workingDir).toURI().toURL(), runDir}, 
				CodegenUtils.class.getClassLoader()))
			{
				return classLoader.loadClass(name);
			}
		}
	}
	catch(Exception ex) {
		LOG.error("Failed to compile class "+name+": \n"+src);
		throw new DMLRuntimeException("Failed to compile class "+name+".", ex);
	}
}
 
Example 11
Source File: CodegenUtils.java    From systemds with Apache License 2.0 4 votes vote down vote up
private static Class<?> compileClassJavac(String name, String src) {
	try
	{
		//create working dir on demand
		if( _workingDir == null )
			createWorkingDir();
		
		//write input file (for debugging / classpath handling)
		File ftmp = new File(_workingDir+"/"+name.replace(".", "/")+".java");
		if( !ftmp.getParentFile().exists() )
			ftmp.getParentFile().mkdirs();
		LocalFileUtils.writeTextFile(ftmp, src);
		
		//get system java compiler
		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
		if( compiler == null )
			throw new RuntimeException("Unable to obtain system java compiler.");
	
		//prepare file manager
		DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>(); 
		try(StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null))
		{
			//prepare input source code
			Iterable<? extends JavaFileObject> sources = fileManager
					.getJavaFileObjectsFromFiles(Arrays.asList(ftmp));
			
			//prepare class path 
			URL runDir = CodegenUtils.class.getProtectionDomain().getCodeSource().getLocation(); 
			String classpath = System.getProperty("java.class.path") + 
					File.pathSeparator + runDir.getPath();
			List<String> options = Arrays.asList("-classpath",classpath);
			
			//compile source code
			CompilationTask task = compiler.getTask(null, fileManager, diagnostics, options, null, sources);
			Boolean success = task.call();
			
			//output diagnostics and error handling
			for(Diagnostic<? extends JavaFileObject> tmp : diagnostics.getDiagnostics())
				if( tmp.getKind()==Kind.ERROR )
					System.err.println("ERROR: "+tmp.toString());
			if( success == null || !success )
				throw new RuntimeException("Failed to compile class "+name);
		
			//dynamically load compiled class
			try (URLClassLoader classLoader = new URLClassLoader(
				new URL[]{new File(_workingDir).toURI().toURL(), runDir}, 
				CodegenUtils.class.getClassLoader()))
			{
				return classLoader.loadClass(name);
			}
		}
	}
	catch(Exception ex) {
		LOG.error("Failed to compile class "+name+": \n"+src);
		throw new DMLRuntimeException("Failed to compile class "+name+".", ex);
	}
}
 
Example 12
Source File: Warn5.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void check(Result<?> res) {

        EnumSet<WarningKind> foundWarnings = EnumSet.noneOf(WarningKind.class);
        for (Diagnostic.Kind kind : new Kind[] { Kind.ERROR, Kind.MANDATORY_WARNING, Kind.WARNING}) {
            for (Diagnostic<? extends JavaFileObject> diag : res.diagnosticsForKind(kind)) {
                for (WarningKind wk : WarningKind.values()) {
                    if (wk.code.equals(diag.getCode())) {
                        foundWarnings.add(wk);
                    }
                }
            }
        }

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                 modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
                 (modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0)))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                 ((modKind == ModifierKind.NONE ||
                 modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) < 0 ) &&
                 methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
                 (modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0) ||
                 methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(foundWarnings) ||
                !foundWarnings.containsAll(expectedWarnings)) {
            fail("invalid diagnostics for source:\n" +
                    res.compilationInfo() +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nSource Level: " + sourceLevel +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + foundWarnings);
        }
    }
 
Example 13
Source File: JavadocHelperTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void doTestJavadoc(String origJavadoc, Function<JavacTask, Element> getElement, String expectedJavadoc) throws Exception {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    String subClass =
            "package test;\n" +
            "public class Sub extends Super {\n" +
            origJavadoc +
            "    public String test(int p1, int p2, int p3) throws IllegalStateException, IllegalArgumentException, IllegalAccessException { return null;} \n" +
            "}\n";
    String superClass =
            "package test;\n" +
            "/**Top level." +
            " */\n" +
            "public class Super {\n" +
            "    /**\n" +
            "     * javadoc1A\n" +
            "     *\n" +
            "     * @param p1 param1A\n" +
            "     * @param p2 param2A\n" +
            "     * @param p3 param3A\n" +
            "     * @throws IllegalStateException exc1A\n" +
            "     * @throws IllegalArgumentException exc2A\n" +
            "     * @throws IllegalAccessException exc3A\n" +
            "     * @return valueA\n" +
            "     */\n" +
            "    public String test(int p1, int p2, int p3) throws IllegalStateException, IllegalArgumentException, IllegalAccessException { return null;} \n" +
            "}\n";

    Path srcZip = Paths.get("src.zip");

    try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(srcZip))) {
        out.putNextEntry(new JarEntry("test/Sub.java"));
        out.write(subClass.getBytes());
        out.putNextEntry(new JarEntry("test/Super.java"));
        out.write(superClass.getBytes());
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }

    DiagnosticListener<? super JavaFileObject> noErrors = d -> {
        if (d.getKind() == Kind.ERROR) {
            throw new AssertionError(d.getMessage(null));
        }
    };

    assertTrue(compiler.getTask(null, null, noErrors, Arrays.asList("-d", "."), null, Arrays.asList(new JFOImpl("Super", superClass), new JFOImpl("Sub", subClass))).call());

    try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
        fm.setLocationFromPaths(StandardLocation.CLASS_PATH, Arrays.asList(Paths.get(".").toAbsolutePath()));
        JavacTask task = (JavacTask) compiler.getTask(null, fm, noErrors, null, null, null);

        Element el = getElement.apply(task);

        try (JavadocHelper helper = JavadocHelper.create(task, Arrays.asList(srcZip))) {
            String javadoc = helper.getResolvedDocComment(el);

            assertEquals(javadoc, expectedJavadoc);
        }
    }
}
 
Example 14
Source File: AptException.java    From doma with Apache License 2.0 4 votes vote down vote up
public AptException(MessageResource messageResource, Element element, Object[] args) {
  this(messageResource, Kind.ERROR, element, null, null, null, args);
}
 
Example 15
Source File: AptException.java    From doma with Apache License 2.0 4 votes vote down vote up
public AptException(
    MessageResource messageResource, Element element, Throwable cause, Object[] args) {
  this(messageResource, Kind.ERROR, element, null, null, cause, args);
}
 
Example 16
Source File: JavaCustomIndexer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorKind getKind(Diagnostic<?> t) {
    return t.getKind() == Kind.ERROR ? errorKind : ErrorKind.WARNING;
}
 
Example 17
Source File: JavaCustomIndexer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static void brokenPlatform(
        @NonNull final Context ctx,
        @NonNull final Iterable<? extends CompileTuple> files,
        @NullAllowed final Diagnostic<JavaFileObject> diagnostic) {
    if (diagnostic == null) {
        return;
    }
    final Diagnostic<JavaFileObject> error = new Diagnostic<JavaFileObject>() {

        @Override
        public Kind getKind() {
            return Kind.ERROR;
        }

        @Override
        public JavaFileObject getSource() {
            return diagnostic.getSource();
        }

        @Override
        public long getPosition() {
            return diagnostic.getPosition();
        }

        @Override
        public long getStartPosition() {
            return diagnostic.getStartPosition();
        }

        @Override
        public long getEndPosition() {
            return diagnostic.getEndPosition();
        }

        @Override
        public long getLineNumber() {
            return diagnostic.getLineNumber();
        }

        @Override
        public long getColumnNumber() {
            return diagnostic.getColumnNumber();
        }

        @Override
        public String getCode() {
            return diagnostic.getCode();
        }

        @Override
        public String getMessage(Locale locale) {
            return diagnostic.getMessage(locale);
        }
    };
    for (CompileTuple file : files) {
        if (!file.virtual) {
            ErrorsCache.setErrors(
                ctx.getRootURI(),
                file.indexable,
                Collections.<Diagnostic<JavaFileObject>>singleton(error),
                ERROR_CONVERTOR);
        }
    }
}
 
Example 18
Source File: CompilerJavacForked.java    From takari-lifecycle with Eclipse Public License 1.0 4 votes vote down vote up
private static void compile(final CompilerConfiguration config, final CompilerOutput output) {

    final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    if (compiler == null) {
      output.addMessage(".", 0, 0, "No compiler is provided in this environment. " + "Perhaps you are running on a JRE rather than a JDK?", Kind.ERROR);
      return;
    }

    final Charset sourceEncoding = config.getSourceEncoding();
    final DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<JavaFileObject>();
    final StandardJavaFileManager standardFileManager = compiler.getStandardFileManager(diagnosticCollector, null, sourceEncoding);
    final Iterable<? extends JavaFileObject> fileObjects = standardFileManager.getJavaFileObjectsFromFiles(config.getSources());
    final Iterable<String> options = config.getCompilerOptions();
    final RecordingJavaFileManager recordingFileManager = new RecordingJavaFileManager(standardFileManager, sourceEncoding) {
      @Override
      protected void record(File inputFile, File outputFile) {
        output.processOutput(inputFile, outputFile);
      }
    };

    Writer stdout = new PrintWriter(System.out, true);
    final JavaCompiler.CompilationTask task = compiler.getTask(stdout, // Writer out
        recordingFileManager, // file manager
        diagnosticCollector, // diagnostic listener
        options, //
        null, // Iterable<String> classes to process by annotation processor(s)
        fileObjects);

    boolean success = task.call();

    for (Diagnostic<? extends JavaFileObject> diagnostic : diagnosticCollector.getDiagnostics()) {
      JavaFileObject source = diagnostic.getSource();

      // when doing annotation processing, javac 6 reports errors when handwritten sources
      // depend on generated sources even when overall compilation is reported as success
      // to prevent false build failures, never issue ERROR messages after successful compilation
      Kind kind = diagnostic.getKind();
      if (success && kind == Kind.ERROR) {
        kind = Kind.WARNING;
      }

      if (source != null) {
        File file = FileObjects.toFile(source);
        if (file != null) {
          output.addMessage(file.getAbsolutePath(), (int) diagnostic.getLineNumber(), (int) diagnostic.getColumnNumber(), diagnostic.getMessage(null), kind);
        } else {
          output.addLogMessage(String.format("Unsupported compiler message on %s resource %s: %s", source.getKind(), source.toUri(), diagnostic.getMessage(null)));
        }
      } else {
        output.addMessage(".", 0, 0, diagnostic.getMessage(null), kind);
      }
    }
  }
 
Example 19
Source File: RuntimeJavaCompiler.java    From spring-init with Apache License 2.0 4 votes vote down vote up
public CompilationResult compile(InputFileDescriptor[] sources,
		InputFileDescriptor[] resources, CompilationOptions compilationOptions,
		List<File> dependencies) {
	logger.debug("Compiling {} source{}", sources.length,
			sources.length == 1 ? "" : "s");
	DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<JavaFileObject>();
	MemoryBasedJavaFileManager fileManager = new MemoryBasedJavaFileManager();
	fileManager.addResolvedDependencies(dependencies);
	List<JavaFileObject> compilationUnits = new ArrayList<>();
	for (InputFileDescriptor source : sources) {
		compilationUnits.add(InMemoryJavaFileObject
				.getSourceJavaFileObject(source.getClassName(), source.getContent()));
	}
	List<String> options = new ArrayList<>();
	options.add("-processorpath");
	options.add(new File("../processor/target/classes/").toString());
	options.add("-source");
	options.add("1.8");
	options.add("-processor");
	options.add("org.springframework.init.processor.SlimConfigurationProcessor");
	CompilationTask task = compiler.getTask(null, fileManager, diagnosticCollector,
			options, null, compilationUnits);
	boolean success = task.call();
	CompilationResult compilationResult = new CompilationResult(success);
	compilationResult.setDependencies(new ArrayList<>(
			fileManager.getResolvedAdditionalDependencies().values()));
	compilationResult.setInputResources(resources);
	// If successful there may be no errors but there might be info/warnings
	for (Diagnostic<? extends JavaFileObject> diagnostic : diagnosticCollector
			.getDiagnostics()) {
		CompilationMessage.Kind kind = (diagnostic.getKind() == Kind.ERROR
				? CompilationMessage.Kind.ERROR
				: CompilationMessage.Kind.OTHER);
		String sourceCode = null;
		try {
			sourceCode = (String) diagnostic.getSource().getCharContent(true);
		}
		catch (IOException ioe) {
			// Unexpected, but leave sourceCode null to indicate it was not
			// retrievable
		}
		catch (NullPointerException npe) {
			// TODO: should we skip warning diagnostics in the loop altogether?
		}
		int startPosition = (int) diagnostic.getPosition();
		if (startPosition == Diagnostic.NOPOS) {
			startPosition = (int) diagnostic.getStartPosition();
		}
		CompilationMessage compilationMessage = new CompilationMessage(kind,
				diagnostic.getMessage(null), sourceCode, startPosition,
				(int) diagnostic.getEndPosition());
		compilationResult.recordCompilationMessage(compilationMessage);
	}
	compilationResult.setGeneratedFiles(fileManager.getOutputFiles());
	return compilationResult;
}