use of org.eclipse.jdt.ls.core.internal.handlers.DiagnosticsHandler in project eclipse.jdt.ls by eclipse.
the class DiagnosticsCommand method publishDiagnostics.
private static void publishDiagnostics(JavaClientConnection connection, ICompilationUnit unit, IProgressMonitor monitor) throws JavaModelException {
final DiagnosticsHandler handler = new DiagnosticsHandler(connection, unit);
WorkingCopyOwner wcOwner = new WorkingCopyOwner() {
@Override
public IBuffer createBuffer(ICompilationUnit workingCopy) {
ICompilationUnit original = workingCopy.getPrimary();
IResource resource = original.getResource();
if (resource instanceof IFile) {
return new DocumentAdapter(workingCopy, (IFile) resource);
}
return DocumentAdapter.Null;
}
@Override
public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) {
return handler;
}
};
int flags = ICompilationUnit.FORCE_PROBLEM_DETECTION | ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY;
unit.reconcile(ICompilationUnit.NO_AST, flags, wcOwner, monitor);
}
use of org.eclipse.jdt.ls.core.internal.handlers.DiagnosticsHandler in project eclipse.jdt.ls by eclipse.
the class MavenClasspathTest method testTest.
@Test
public void testTest() throws Exception {
IProject project = importMavenProject("classpathtest");
IJavaProject javaProject = JavaCore.create(project);
IType type = javaProject.findType("test.AppTest");
ICompilationUnit cu = type.getCompilationUnit();
openDocument(cu, cu.getSource(), 1);
final DiagnosticsHandler handler = new DiagnosticsHandler(javaClient, cu);
WorkingCopyOwner wcOwner = getWorkingCopy(handler);
cu.reconcile(ICompilationUnit.NO_AST, true, wcOwner, null);
assertTrue("There is a problem", handler.getProblems().size() == 0);
}
Aggregations