Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide diagnostics and quickfix when open non-project java file #1366

Closed

Conversation

testforstephen
Copy link
Contributor

@testforstephen testforstephen commented Feb 26, 2020

Signed-off-by: Jinbo Wang [email protected]

Fix redhat-developer/vscode-java#1270

two kinds of non-project file:

  • external Java file
  • Java file not on the classpath of the active project

Improve syntax mode for the non-project Java file:

  • Delete the notification message box about "classpath is incomplete. Only syntax errors will be reported".
  • Add a general non-project warning diagnostic, see screenshot below.
  • Provide quickfix to enable/disable semantic errors. (More quick fixes could be enabled in future, such as Add to source path for those not on classpath.)
    Enable semantic errors:
    image
    Disable semantic errors:
    image

@testforstephen testforstephen force-pushed the jinbo_nonproject branch 2 times, most recently from 510aa04 to a843a07 Compare February 27, 2020 12:57
@testforstephen testforstephen marked this pull request as ready for review February 27, 2020 13:02
@fbricon
Copy link
Contributor

fbricon commented Mar 2, 2020

So if I open ./mvn/wrapper/MavenWrapperDownloader.java in a Maven project, I get no warning, no compilation error, no syntax error, no code action, even though this is technically a "Java file not on the classpath of the active project"

@testforstephen
Copy link
Contributor Author

PR updated.

Did you sync the latest code from my branch? It works as expected in my machine.
nonprojectwarning

@fbricon
Copy link
Contributor

fbricon commented Mar 3, 2020

I figured out why I didn't get anything. If the Maven wrapper is under the parent project (so non-java) of other Maven Java projects, then, we end up returning no CU:

https://github.com/eclipse/eclipse.jdt.ls/blob/c026aafd84e454f77030132b7095b3971bd5a493/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTUtils.java#L175-L177

This is the case of https://github.com/eclipse/eclipse.jdt.ls/blob/master/.mvn/wrapper/MavenWrapperDownloader.java

I think this is a use case we can fix later though

@testforstephen
Copy link
Contributor Author

PR updated.

And create a new PR #1377 to fix the no CU issue about opening file from non-java maven module.

@fbricon
Copy link
Contributor

fbricon commented Mar 4, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve support for "standalone file" use cases
2 participants