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

Projects with same app name seem to not get full snippet support (Updated) #259

Open
dshimo opened this issue May 30, 2023 · 10 comments
Open
Assignees
Labels
bug Something isn't working language client language server integration should-fix
Milestone

Comments

@dshimo
Copy link
Contributor

dshimo commented May 30, 2023

Choosing a parent dir with multiple projects as the main folder seems to mess with our language server snippet suggestions. Instead, if you open each project's root folder through Add folder to Workspace..., normal behavior resumes.

My project structure has a dir named 'starters' which contain the Maven and Gradle starter apps. Each app gets recognized by the dashboard correctly. Liberty actions work.

image

It seems MicroProfile snippets only appear for one project. In this case, it only appears on my Gradle Java files.

image

image

Attempting to fetch rest_* snippets in Maven yield irrelevant answers, and attempting rest_* in the Gradle project gave me only rest_get.

image

This final screenshot is the expected snippet list for rest_*. Here, only the Maven project is open in the workspace.

image

@TrevCraw TrevCraw added the bug Something isn't working label May 31, 2023
@TrevCraw TrevCraw added this to the GA milestone May 31, 2023
@dshimo
Copy link
Contributor Author

dshimo commented May 31, 2023

Testing on Mac, it seems as if your application names are the same in the Liberty dashboard, then snippets will fail on multi-projects.

Here, both the Maven and Gradle apps were added to the workspace. Snippets fail.
image

In this screenshot, Maven was added after Gradle. rest_class is still not found.
image

And lastly, with newly generated apps with different app names, rest_class returns. Here, I even opened the parent dir 'starters'
image

@dshimo dshimo changed the title Opening projects' parent folder to workspace changes a project's snippet suggestions Projects with same app name seem to not get full snippet support (Updated) May 31, 2023
@cherylking
Copy link
Member

So this only occurs when it is the same app name in more than one project? If so, that does not seem like it would be very common in the real world?

@TrevCraw
Copy link
Contributor

TrevCraw commented Jun 1, 2023

So this only occurs when it is the same app name in more than one project? If so, that does not seem like it would be very common in the real world?

Yes, it appears the app names must be the same to hit this bug. I agree, I don't think this would be a common scenario for users. I don't think this should be a stop ship.

@TrevCraw TrevCraw added the documentation Improvements or additions to documentation label Jun 13, 2023
@TrevCraw TrevCraw added language client language server integration and removed documentation Improvements or additions to documentation labels Jul 24, 2023
@anusreelakshmi934
Copy link
Contributor

anusreelakshmi934 commented Nov 14, 2023

Receiving the following error when opening a Maven project folder:
The Language Support for Java server crashed 5 times in the last 3 minutes. The server will not be restarted.
Tried Java: Clean Java Language Server Workspace, but still error persists.
image

Issue opened to address this: #312

@anusreelakshmi934
Copy link
Contributor

anusreelakshmi934 commented Feb 8, 2024

When we open a directory containing Maven and Gradle starter apps with the same app name, one of the files is recognized as a non-project file, triggering a diagnostic message like "filename.java is a non-project file, only syntax errors are reported." In this file, snippet suggestions is not provided. However, in the other file within the same directory, suggestions are available.

Alternatively, when we open each project's root folder through "Add folder to Workspace," no diagnostic appears even if the app names are the same, and snippet suggestions are provided.
Attaching the screenshot below:
image

when a directory containing files with different app names is opened, the non-project file diagnostic is not displayed and we do get snippets suggestion

@anusreelakshmi934
Copy link
Contributor

Based on my understanding, the issue seems to be that Visual Studio Code treats all Java projects within the same workspace as a single project, causing interference between them. Despite attempting various solutions such as:
cleaning the Java language server workspace, adding folders to the Java source path, and renaming packages, setting sourcePaths in the the settings.json file to src, still the problem persists.

Through my investigation, it appears that the only effective way to avoid the warning and receive snippet suggestions is to individually open each project's root folder by using the "Add folder to Workspace" option. By doing so, we do not receive diagnostics, and we receive snippet suggestions.

@TrevCraw
Copy link
Contributor

@anusreelakshmi934 Can you show the steps to go from a broken project to a working one using the "Add folder to Workspace" option? What does the project/workspace structure look like before and after? Can both projects be added to the same Workspace? And then can both projects be open in VS Code at the same time if they are part of the same Workspace?

On a separate note, what do you mean by "we do not receive diagnostics"?

@anusreelakshmi934
Copy link
Contributor

anusreelakshmi934 commented Feb 19, 2024

When using the "Add folder to Workspace" feature, snippet suggestions become available when opening two projects with the same app name. Here's how it works:

  1. First, open one of the project and then open a file in the project to check for snippet suggestions.
  2. Next, go to File -> Add folder to Workspace, and select the other project with the same app name.
  3. Now, check for snippet suggestions again, and you will receive them.

Now the workspace is UNTITLED (WORKSPACE). Even after saving the workspace, suggestions continue to be available. Both projects can be added to the same workspace and opened.

Regarding diagnostics, when I mentioned "We do not receive diagnostics," I meant that the diagnostic message "filename.java is a non-project file, only syntax errors are reported" is not displayed when adding projects using the "Add folder to Workspace" feature.

@anusreelakshmi934
Copy link
Contributor

I'm currently facing difficulties with the workaround; I'm not receiving suggestions as expected. Additionally, I occasionally encounter a "unit is null" error when trying to open a Java file after adding the project using "Add folder to Workspace". This pertains to Issue #326 on GitHub for further context.

Also I am encountering #312 while trying to start the language server after few attempts.

@anusreelakshmi934
Copy link
Contributor

anusreelakshmi934 commented May 2, 2024

Still the workaround doesnt seem to be working. May need to further investigate some other ways for the issue.
Also encountering #312 while trying to start the language server after few attempts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working language client language server integration should-fix
Projects
Development

No branches or pull requests

4 participants