Skip to content

Commit

Permalink
Performance improvement:publish diagnostics
Browse files Browse the repository at this point in the history
Remove CoreASTProvider.getAST(...) from BaseDocumentLifeCycleHandler.publishDiagnostics(IProgressMonitor)
- #2535

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
  • Loading branch information
snjeza committed Apr 4, 2023
1 parent 90215ef commit 7479e68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,7 @@ public IStatus publishDiagnostics(IProgressMonitor monitor) throws JavaModelExce
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
CompilationUnit astRoot = this.sharedASTProvider.getAST(rootToValidate, CoreASTProvider.WAIT_YES, monitor);
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (astRoot != null) {
// report errors, even if there are no problems in the file: The client need to know that they got fixed.
ICompilationUnit unit = (ICompilationUnit) astRoot.getTypeRoot();
publishDiagnostics(unit, progress.newChild(1));
}
publishDiagnostics(rootToValidate, progress.newChild(1));
}
JavaLanguageServerPlugin.logInfo("Validated " + toValidate.size() + ". Took " + (System.currentTimeMillis() - start) + " ms");
return Status.OK_STATUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ public void testBasicBufferLifeCycle() throws Exception {
assertEquals(true, cu1.isWorkingCopy());
assertEquals(false, cu1.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu1, 0));
assertEquals(1, getCacheSize());
// https://github.com/eclipse/eclipse.jdt.ls/pull/2535
assertEquals(0, getCacheSize());
assertNewASTsCreated(1);

buf = new StringBuilder();
Expand All @@ -244,15 +245,15 @@ public void testBasicBufferLifeCycle() throws Exception {
assertEquals(true, cu1.isWorkingCopy());
assertEquals(true, cu1.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu1, 1));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(1);

saveDocument(cu1);

assertEquals(true, cu1.isWorkingCopy());
assertEquals(false, cu1.hasUnsavedChanges());
assertNewProblemReported();
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(0);

closeDocument(cu1);
Expand Down Expand Up @@ -284,7 +285,7 @@ public void testBasicBufferLifeCycleWithoutSave() throws Exception {
assertEquals(true, cu1.isWorkingCopy());
assertEquals(false, cu1.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu1, 1));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(1);

buf = new StringBuilder();
Expand All @@ -300,7 +301,7 @@ public void testBasicBufferLifeCycleWithoutSave() throws Exception {
assertEquals(true, cu1.isWorkingCopy());
assertEquals(true, cu1.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu1, 0));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(1);

closeDocument(cu1);
Expand Down Expand Up @@ -395,7 +396,7 @@ public void testIncrementalChangeDocument() throws Exception {
assertEquals(true, cu1.isWorkingCopy());
assertEquals(false, cu1.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu1, 0));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(1);

buf = new StringBuilder();
Expand All @@ -407,15 +408,15 @@ public void testIncrementalChangeDocument() throws Exception {
assertEquals(true, cu1.isWorkingCopy());
assertEquals(true, cu1.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu1, 1));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(1);

saveDocument(cu1);

assertEquals(true, cu1.isWorkingCopy());
assertEquals(false, cu1.hasUnsavedChanges());
assertNewProblemReported();
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(0);

closeDocument(cu1);
Expand Down Expand Up @@ -461,7 +462,7 @@ public void testFixInDependencyScenario() throws Exception {
assertEquals(true, cu2.isWorkingCopy());
assertEquals(false, cu2.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu2, 1));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(1);

openDocument(cu1, cu1.getSource(), 1);
Expand All @@ -471,7 +472,7 @@ public void testFixInDependencyScenario() throws Exception {
assertEquals(true, cu2.isWorkingCopy());
assertEquals(false, cu2.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu2, 1), new ExpectedProblemReport(cu1, 0));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(2);

buf = new StringBuilder();
Expand All @@ -487,7 +488,7 @@ public void testFixInDependencyScenario() throws Exception {
assertEquals(true, cu2.isWorkingCopy());
assertEquals(false, cu2.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu2, 0), new ExpectedProblemReport(cu1, 0));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(2);

saveDocument(cu1);
Expand All @@ -497,7 +498,7 @@ public void testFixInDependencyScenario() throws Exception {
assertEquals(true, cu2.isWorkingCopy());
assertEquals(false, cu2.hasUnsavedChanges());
assertNewProblemReported();
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(0);

closeDocument(cu1);
Expand Down Expand Up @@ -800,7 +801,7 @@ public void testCloseMissingResource() throws Exception {
assertEquals(true, cu1.isWorkingCopy());
assertEquals(false, cu1.hasUnsavedChanges());
assertNewProblemReported(new ExpectedProblemReport(cu1, 1));
assertEquals(1, getCacheSize());
assertEquals(0, getCacheSize());
assertNewASTsCreated(1);

StringBuilder buf2 = new StringBuilder();
Expand Down

0 comments on commit 7479e68

Please sign in to comment.