Comments (8)
@kathrynkodama I haven't had issues with the while loop getting stuck, but I will put a timeout condition just in case.
from lsp4jakarta.
The compilation unit being resolved here: https://github.com/MicroShed/jakarta-ls/blob/master/jakarta-eclipse/src/org/jakarta/jdt/JDTUtils.java#L111 is one keystroke behind the current document.
This results in an empty diagnostics list: https://github.com/MicroShed/jakarta-ls/blob/master/jakarta-eclipse/src/org/jakarta/jdt/JDTServicesManager.java#L51-L53
from lsp4jakarta.
I dont have much progress on this bug still.
My thought is that, either
https://github.com/MicroShed/jakarta-ls/blob/26641efb51a3fbd0e2f05118d0d4f1548395418d/jakarta-eclipse/src/org/jakarta/jdt/JDTUtils.java#L117
is returning incorrect Ifile which I am not sure how to verify
or it can possibly be JavaCore.createCompilationUnitFrom(resource);
from
https://github.com/MicroShed/jakarta-ls/blob/26641efb51a3fbd0e2f05118d0d4f1548395418d/jakarta-eclipse/src/org/jakarta/jdt/JDTUtils.java#L125 is not behave properly
from lsp4jakarta.
Adding the following to https://github.com/MicroShed/jakarta-ls/blob/master/jakarta.ls/src/main/java/io/microshed/jakartals/JakartaLanguageServer.java#L41 will update diagnostics on save:
serverCapabilities.setTextDocumentSync(TextDocumentSyncKind.Incremental);
Keystroke delay still exists without saving
from lsp4jakarta.
Adding a delay before createCompilationUnitFrom
is called in JDTUtils.java seems to resolve the keystroke delay, but I'm not quite sure why, yet.
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return JavaCore.createCompilationUnitFrom(resource);
from lsp4jakarta.
It appears ICompilationUnit.
isConsistent
returns false immediately after the unit is created in JDTServicesManager.getJavaDiagnostics()
. Introducing a sufficient delay (like I've shown in my previous comment) will allow the underlying resource to catch up (and then isConsistent
will return true). Therefore, adding a while loop to allow the unit to catch up solves the keystroke delay.
public List<PublishDiagnosticsParams> getJavaDiagnostics(JakartaDiagnosticsParams javaParams) {
[...]
ICompilationUnit unit = JDTUtils.resolveCompilationUnit(u);
try {
while (!unit.isConsistent()) { }
} catch (JavaModelException e) { }
for (DiagnosticsCollector d : diagnosticsCollectors) {
d.collectDiagnostics(unit, diagnostics);
}
[...]
}
Alternatively, the loop can be added to JDTUtils.resolveCompilationUnit
, instead.
from lsp4jakarta.
It appears
ICompilationUnit.
isConsistent
returns false immediately after the unit is created inJDTServicesManager.getJavaDiagnostics()
. Introducing a sufficient delay (like I've shown in my previous comment) will allow the underlying resource to catch up (and thenisConsistent
will return true). Therefore, adding a while loop to allow the unit to catch up solves the keystroke delay.public List<PublishDiagnosticsParams> getJavaDiagnostics(JakartaDiagnosticsParams javaParams) { [...] ICompilationUnit unit = JDTUtils.resolveCompilationUnit(u); try { while (!unit.isConsistent()) { } } catch (JavaModelException e) { } for (DiagnosticsCollector d : diagnosticsCollectors) { d.collectDiagnostics(unit, diagnostics); } [...] }Alternatively, the loop can be added to
JDTUtils.resolveCompilationUnit
, instead.
This looks great, thanks @tiganov! Any concerns with unit.isConsistent()
never returning true and getting stuck in that while loop?
from lsp4jakarta.
Closed with #201
from lsp4jakarta.
Related Issues (20)
- Please provide a p2 repository to install the eclipse plugin
- jakarta faces and servlet support
- Enhancement to dynamically use test project for "no diagnostics" automated tests
- JSF / Faces Suggestions
- Classname not populated from filename when using snippet completion
- Missing codeAction Tests in ResourceClassConstructorTest.java File HOT 2
- Investigate whether LSP4Jakarta consistently processes fully qualified class names. HOT 2
- Should the JakartaProjectLabelProvider return finer grained labels?
- Missing codeAction Tests in JakartaServletTest.java file
- Design Consideration for quick fixes with multiple parameters to ensure they fully resolve errors
- Latest release of Eclipse JDT breaks diagnostics due to usage of internal JDT class HOT 1
- org.eclipse.lsp4jakarta.commons.JavaCursorContextKind.forValue() throws an IllegalArgumentException when passed the value from its own NONE constant. HOT 1
- Tests for InsertImplementsClauseToImplFilterQuickFix and InsertImplementsClauseToImplListenerQuickFix is not available in lsp4jakarta
- Multiple `@BeanParam`s incorrectly reported as error
- Only reports one error when two exist in Bean Validation HOT 1
- Diagnostic missing for `@PositiveOrZero` HOT 2
- Error in Readme doc for Json binding and others
- Support Diagnostics in Java Record fields for Jakarta Validation HOT 1
- Implementations of interfaces should be allowed for Validation annotations HOT 1
- Add unit tests for certain quick fixes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lsp4jakarta.