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

How do i get the LSP to pick up protobuf generated classes #270

Open
kstatz12 opened this issue Sep 8, 2020 · 12 comments
Open

How do i get the LSP to pick up protobuf generated classes #270

kstatz12 opened this issue Sep 8, 2020 · 12 comments

Comments

@kstatz12
Copy link

kstatz12 commented Sep 8, 2020

when i generate classes via protobuf i get warnings all over my code with {ClassName} cannot be resolved to a type and there is no code completion. gradle seems fine finding them to compile. is there anything i have to include or a hint i can give the lsp to pick these files up?

@yyoncho
Copy link
Member

yyoncho commented Sep 8, 2020

this: #71

I think that you can manually alter .classpath to do that too.

@kstatz12
Copy link
Author

kstatz12 commented Sep 9, 2020

this: #71

I think that you can manually alter .classpath to do that too.

I dont think that you can manually edit the .classpath file. whenever i put a
<classpathentry> line in mine it gets nuked whenever the server starts/restarts. i would rather avoid installing eclipse to manage the .classpath file

@kingsuntw
Copy link

I have luck with the hint of #270 (comment)

dealing with a project that has generated classes sources to folder target/generated-sources/java

I add the following config in .classpath file in project root

<classpathentry kind="src" output="target/classes" path="target/generated-sources/java">
        <attributes>
                <attribute name="optional" value="true"/>
                <attribute name="maven.pomderived" value="true"/>
        </attributes>
</classpathentry>

after execute lsp-restart-workspace, the auto-completion works.

if the file already opened in buffer and auto-completion not working, I found that revert-buffer helps.

@kstatz12
Copy link
Author

@kingsuntw i have this weird issue where whenever i modify a .project or .classpath file restarting the lsp workspace rewrites the file. Any ideas?

@rrudakov
Copy link
Contributor

@kstatz12 Could you try solution from here?

@goldfita
Copy link

goldfita commented Aug 9, 2022

Was this ever resolved? I've been struggling with this for a while now. I have a multi-module maven project with generated sources. I already built everything from the command line. I can see the artifacts in the m2 repo. But lsp-java does not see them. I'm not sure if it's building everything, but the errors all seem to be due to symbols from generated sources.

The .classpath files appear to have been automatically generated. Is there something else I need to do to tell it where to look?

@goldfita
Copy link

I discovered that I can manually edit the .classpath in the project that can't resolve the missing types like so:

<classpathentry kind="src" path="../../../project_that_generates_types" />

As soon as I save, the number of errors drops. However, then some process immediately overwrites .classpath. I don't have the option of modifying the pom files as suggested in the solution linked above. Another problem is that there are a lot of projects. I would have to go through every one, though I would do it if I could solve the first problem.

@goldfita
Copy link

I can confirm that at least the solution linked to by rrudakov does work. One thing I noticed, though, is sometimes projects that depend on generated files report errors, but as soon as you open the file with errors, the errors immediately go away. The behavior does not seem to be very consistent. I'm still trying to figure out how to add a certificate through vmargs. Maybe the strange behavior will resolve once the rest of the errors have been dealt with.

@goldfita
Copy link

Once I worked through the remaining issues, the funny behavior has disappeared.

@rrudakov
Copy link
Contributor

rrudakov commented Oct 11, 2022 via email

@goldfita
Copy link

After the senior developer updated jaxb and made a few other changes to the pom, the problem went away.

@Celibistrial
Copy link

The suggested fixes didnt work for fabric minecraft mod development
Any progress on this?

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

No branches or pull requests

6 participants