redhat-developer / vscode-java

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

"Cannot find symbol" #551

Open swarnendubiswas opened 6 years ago

swarnendubiswas commented 6 years ago

VS Code shows a "Cannot find symbol" error with the red squigly for several symbols but "Go to definition" works which means the definition is available.

Environment
Steps To Reproduce
  1. Open the attached dummy project in VS Code.
Current Result

You should see several errors related to "cannot find symbol". However, navigation or "Go to definition" works on these symbols.

Expected Result

The red squiggly lines should not appear since I think the symbols are indeed available.

Additional Informations

The VS Code settings.json file is also attached. java-symbols.zip

fbricon commented 6 years ago

Indeed, for some reason LineAddress can't be resolved immediately. but as soon as IntegerVariantTypes.java is opened, the compilation errors disappear. Might be caused by LineAddress being an inner class in a file that's doesn't define the IntegerVariantTypes class. Same project opens fine in Eclipse.

alejandrosaucedo commented 5 years ago

I have the same problem.

What is the solution?

neesonqk commented 5 years ago

I got this similar problem after I disable and enable Maven Plugin, before that everything worked like a charm, firstly I disabled Maven plugin, and restarted, then I started to see those annoying errors, I then re-enabled maven plugin, unlucky, those errors are still there, unable to eliminate no matter what I do. But my code runs without any problem.

yaohaizh commented 5 years ago

@neesonqk Those errors because of the inner classes. Could you call "Java: Force Java Compilation" to see whether your issue persists.

neesonqk commented 5 years ago

@yaohaizh the issue still persists.

image

image

neesonqk commented 5 years ago

My bad, my problem is that, I incidentally installed java linter extension when I disable Maven Plugin...

By uninstalling java linter I am able to eliminate those annoying errors.

ghost commented 3 years ago

@neesonqk Those errors because of the inner classes. Could you call "Java: Force Java Compilation" to see whether your issue persists.

hey, when i try doing mine, it just says a variable is not used. But it should still be working like charm. I'm trying to make my discord bot online with discord jda. Could you maybe review my code? here

my code :

package hoppity.Hops;

import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder;

public class Patootie { public static void main(String[] args) throws Exception { JDA jda = JDABuilder.createDefault("Nzk2ODc0NTU3MjQzOTE2MzQ4.X_eRQw.ALNht8H0ZdCSRYN46rPpoigzMvs").build();

}

}

console log :

Patootie.java:3: error: package net.dv8tion.jda.api does not exist import net.dv8tion.jda.api.JDA; ^ Patootie.java:4: error: package net.dv8tion.jda.api does not exist import net.dv8tion.jda.api.JDABuilder; ^ Patootie.java:8: error: cannot find symbol JDA jda = JDABuilder.createDefault("Nzk2ODc0NTU3MjQzOTE2MzQ4.X_eRQw.ALNht8H0ZdCSRYN46rPpoigzMvs").build(); ^ symbol: class JDA location: class Patootie Patootie.java:8: error: cannot find symbol JDA jda = JDABuilder.createDefault("Nzk2ODc0NTU3MjQzOTE2MzQ4.X_eRQw.ALNht8H0ZdCSRYN46rPpoigzMvs").build(); ^ symbol: variable JDABuilder location: class Patootie 4 errors