redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.07k stars 429 forks source link

Update classpath based on java.project.referencedLibraries when modifications in pointed folders #1874

Open apupier opened 3 years ago

apupier commented 3 years ago
Environment
Steps To Reproduce

[Please attach a sample project reproducing the error] Please attach logs

Current Result

the classpath is not refreshed.

Expected Result

Either:

Additional Informations

any light workaround for it? (or already existing API?)

heavy workarounds:

needed for VS Code Camel K https://issues.redhat.com/browse/FUSETOOLS2-826

fbricon commented 3 years ago

AFAIK vscode doesn't watch files outside the current workspace, so doesn't emit file change events.

fbricon commented 3 years ago

How/why does a user modify the contents of redhat.vscode-camelk/java-dependencies-3.7.0/dependencies/?

apupier commented 3 years ago

How/why does a user modify the contents of redhat.vscode-camelk/java-dependencies-3.7.0/dependencies/?

VS Code Camel K is modifying it. The goal is to modify the content depending on the opened java file and also when the file is modified. If there is an API to tell the Java language Server to refresh the classpath/re-read the folder that woudl be fine.

AFAIK vscode doesn't watch files outside the current workspace, so doesn't emit file change events.

Maybe I can send a file change event programmatically even if outside the workspace? if yes, will the java language server refresh the classpath?

fbricon commented 3 years ago

VS Code Camel K is modifying it. The goal is to modify the content depending on the opened java file and also when the file is modified. If there is an API to tell the Java language Server to refresh the classpath/re-read the folder that woudl be fine.

Wow that seems wrong ;-) If you have 2 opened Camel K files in 2 different windows, who wins?

Maybe I can send a file change event programmatically even if outside the workspace? if yes, will the java language server refresh the classpath?

I don't know. Maybe. Maybe not.

apupier commented 3 years ago

VS Code Camel K is modifying it. The goal is to modify the content depending on the opened java file and also when the file is modified. If there is an API to tell the Java language Server to refresh the classpath/re-read the folder that woudl be fine.

Wow that seems wrong ;-) If you have 2 opened Camel K files in 2 different windows, who wins?

Agree that it is not optimal. But rebuilding a project support cannot be done in a single step easily. The plan for this iteration is to ask user to refresh classpath manually so the user is choosing which he/she is interesting in and wins. Having a different folder per Camel K files will solve the problem when switchign between files but still won't refresh the classpath on modification of the file, or on call of the Camel K dependencies refresh command. Also, until symbolic link is nto implemented on Camel K side https://github.com/apache/camel-k/issues/2179 , users that have a lot of files will require a lot of hard disk space.

apupier commented 3 years ago

maybe can try to call "compile" command: https://github.com/redhat-developer/vscode-java/blob/9f32875a67352487f5c414bb7fef04c9b00af89d/src/standardLanguageClient.ts#L319