0

I'm reviewing an isolated Java project in VSCode. By that I mean that I have the project itself, but not any of the projects that it depends on. From what I can tell, the result is that Intellisense has been turned off for the project, which makes navigating around the code a pain.

For example, you can see below that VSCode can't find the definition of a method, even though it's just 3 lines down. On the side, you can see the errors it's encountered trying to load various artifacts.

enter image description here

Is there a way to turn Intellisense back on, at least for the objects that are defined within the project itself? I have the MS Java extension pack installed.

To clarify, these are internal projects that it depends on and I don't have on my machine.

Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
  • Are your dependencies configured through the Java Project Manager and is the setting `"java.project.referencedLibraries"` set? – Carson May 06 '21 at 19:06
  • @carson can you expand on that? This is the first time I've dealt with Java in VSCode – Hong Ooi May 07 '21 at 04:20
  • Also, to clarify, these are internal projects that it depends on and I don't have on my machine. – Hong Ooi May 07 '21 at 07:30
  • Can you share the project in github if convenient for me to reproduce your question? – Molly Wang-MSFT May 07 '21 at 09:24
  • @MollyWang it's tricky because it's one of those sprawling enterprise IT projects – Hong Ooi May 10 '21 at 06:21
  • All those unresolvable errors in your image are making me think there's a problem with your project building on your machine. Try taking your IDE out of the picture and just drop to the shell/command prompt and build it with just maven, i.e. mvn clean compile. If you can't build the project stand-alone, then you need to fix your mvn settings so you can properly resolve all the artifacts (presumably from one of your sprawling enterprise repositories where they are published). Once you get to that point, I think you'll have much better success at Intellisense working. – Atmas May 10 '21 at 16:57
  • @atmas that's the problem, I don't have access to those other repos. I've only got this project, which the devs cloned for me, essentially. I'm reviewing the code, ie I'm not a member of the dev team so I don't have access to any of their other stuff – Hong Ooi May 10 '21 at 16:59
  • I see. Any chance you can get maven installed and the appropriate dev group's settings.xml files from them? If this is an enterprise environment, it seems fair for them to give you the actual tools to build the project they're asking you to review. – Atmas May 10 '21 at 17:04
  • @atmas that's possible, but will take time. I was just looking for a quick way to get Intellisense working for the objects defined in this package. Just being able to jump to a definition would be great, rather than having to do a search – Hong Ooi May 10 '21 at 17:06
  • I hear you. Sorry I couldn't be of immediate help. If you're willing to, you can try a different ide (i.e. maybe Eclipse) and see if it works better with your project out of the box. If you do try eclipse, just use File -> Import -> Existing Maven Projects to load your project up. – Atmas May 10 '21 at 17:18

2 Answers2

2

I just noticed there's a feature that might help you get around this. Check out "Lightweight Mode" here: https://code.visualstudio.com/docs/java/java-project

Maybe this will get away from having access to mvn full resources and just get the quick-n-dirty navigation as the docs seem to indicate!

Lightweight Mode

VS Code for Java supports two modes, lightweight and standard. With lightweight mode, only source files and JDK are resolved by the language server; with standard mode, imported dependencies are resolved and the project is built by the language server.

...works best when you need a super quick-to-start and lightweight environment to work with your source files, for example, reading source code, navigating among source code and JDK, viewing outline and Javadoc, and detecting and fixing syntax errors. Also, code completion is supported within the scope of source files and JDK... Lightweight mode doesn't resolve imported dependencies nor build the project.

Atmas
  • 2,389
  • 5
  • 13
  • Thanks for finding that! Unfortunately it doesn't look like it supports go to definition, which is the main thing I was hoping for. Still, at least it's got rid of the build error notifications. – Hong Ooi May 12 '21 at 00:05
  • That's too bad. It looked too promising as the final answer. I started to fool around with my VsCode to add the extensions and try to do it myself, but I'm already used to Eclipse and setup that way and then it wanted me to start downloading a new JDK.. It was just a bridge too far. I will leave this answer up though since it looks like it helped a little and may help others in the future. – Atmas May 12 '21 at 01:24
0

Your project throwed project build error: Non resolved parent pom for com.....

When errors are resolved, the intellisense should work as normal.

Please have a look at this question. Try and see if error goes away.

Project build error: Non-resolvable parent POM.

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22