Java error highlighting showing errors that are incorrect

已回答

We have a large Java project using gradle and the error highlighting keeps getting in a bad state on Mac.  If I clear away the local ".idea" and setup the project again, it goes away for a bit, but soon appears again.  Is anyone else running into this problem?  Anything I can do in settings to fix it?

I'm using IntelliJ IDEA 2020.1 (Community Edition).  I saw the same problem using the last version of 2019 as well.

1

Please provide screenshots describing the exact issue you see and logs zipped (use Help | Compress Logs and Show in ... action). 

Can you build project by Gradle from command line?

Can you build it by IDE (when switch the Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Build and run using option to to IntelliJ IDEA)?

Try also File | Invalidate Caches/Restart.. | Invalidate and Restart.

For uploading files you can use ftp://ftp.intellij.net/.uploads / https://uploads.services.jetbrains.com or any file sharing service.

0
Avatar
Permanently deleted user

@Andrey thanks for the quick response.  I can't share screenshots or logs as the source code is confidential.  Is there another option?

Re your questions.

1. Yes, the project build from the command line with Gradle.  This is why I said that the error highlighting is incorrect.

2. Yes, the project builds and runs from IDE too.

3. I have tried Invalidate Caches/Restart multiple times.  No effect.

0

What exact error do you see in Editor? Does it happen with only specific file, specific project? Is it reproducible only for you or on other machines as well?

unfortunately without any information I can only guess with the suggestions. Try deleting IDE plugins directory or start with default settings (rename/remove config folder) and do full project re-import selecting to delete existing configuration: File | New | Project from Existing Directory  action.

0
Avatar
Permanently deleted user

@Andrey It happens with multiple files in this project.  The project is large, about 1million lines and heavy use of generics.  I have blown away the ".idea" folder multiple times which fixes the issue, but then it appears again.  It's not always the same files though.  It seems to depend on what I open up in the editor.  I will see if I can post a screenshot without violating our confidentiality, but the error is the red squiggly line.  Often it thinks that a class doesn't exist, and so anything referencing that class also shows red squigglies.  Again, everything compiles and runs properly, just an issue with the editor reporting an issue where there is none.

I will try deleting the plugins and config directories and let you know.

0
Avatar
Permanently deleted user

Deleting the plugin directory didn't fix it.  Next, I tried deleting the config directory which also didn't fix the problem.

0
Avatar
Permanently deleted user

I have the same problem. It's very annoying. Sometimes, it does not recognize imports (which are valid ones). Sometimes, it doesn't even recognize symbols such String. (Showing an error message that says, cannot access java.lang.String). Invalidating cache and restarting solves the issue, but I'm working on a huge project and takes several minutes to perform that process, and the problem is solved just for a little while and the errors come up again. It's frustrating.

I'm running IntelliJ IDEA IntelliJ IDEA 2020.2.3 (Ultimate Edition)
Build #IU-202.7660.26, built on October 6, 2020
Subscription is active until October 19, 2021
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-52-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 1956M
Cores: 4
Registry: debugger.watches.in.variables=false
Non-Bundled Plugins: Lombook Plugin, String Manipulation, com.jetbrains.darkPurpleTheme, com.thvardhan.gradianto, org.sonarlint.idea, Jetbrains TeamCity Plugin, org.jetbrains.kotlin, com.cybrosis.catdea, com.intellij.gwt
Current Desktop: ubuntu:GNOME.

I could isolate a huge stack trace from idea.log, please, let me know if it would help.

0

Hello Damian Fernando Varela,

Can you please create at issue at the YouTrack: https://youtrack.jetbrains.com/issue providing the idea.log file (Help | Show Log in Finder) after the case is reproduced. Thank you 

0
Avatar
Permanently deleted user

Has there been a YouTrack issue created for this?  If so can you please share the link to it?  I am experiencing exactly the same problem and would like to track the progress of this as it greatly hinders productivity.

0

Hello Ecoonradt,

The description of the current issue is not quite clear, please create a separate issue at the YouTrack (https://youtrack.jetbrains.com/issue) providing the details in it (logs and code/project sample if possible). Thank you 

0
Avatar
Permanently deleted user

Hello,

I face the same problem...

IDEA Ultimate 2020.3.1

Problem appeared after I completely removed (functional) project from disk, and clone it again using Azure DevOps GIT integration. 

Project did not cloned due azure auth reasons... so I completely removed it again, and started from scratch again. Now, I have working app (running, responding) but most of java files are red and imports to other classes are marked as not existent. I did "invalidate cache" but without success. 

... I am going to delete and start again ... lets hope

0

Hello Jan,

If possible please share the idea.log files (Help | Show Log in Finder) to the issue created at the YouTrack (https://youtrack.jetbrains.com/issues/IDEA). Thank you 

0
Avatar
Permanently deleted user
0
Avatar
Permanently deleted user

My apologies, but at this time I am not able to provide any sample projects or log files.  I am not able to distribute the project that I work on outside of the firm and I have since deleted the log files.  But, the good news is that I was able to resolve the problem.  Allow me to explain.

This problem initially appeared out of the blue.  I had been using IntelliJ on this project for over 2 years with no issues, upgrading the IDE as new version were released.  Keep this in mind, I believe it is relevant.  Then one day this problem started happening.

First I invalidated the caches and restarted.  No effect.

Then I deleted the ".idea" folder in my project and re-imported it.  No effect.

Then I uninstalled IntelliJ, selecting to remove all settings, caches, and logs, re-installed it, and when I opened it up it automatically loaded my project as if nothing had happened.  The problem was still there too.  At this point I was suspicious.  How could a full re-install preserve all settings and project information even though I explicitly told it to delete them?

Finally, I uninstalled IntelliJ again and also manually deleted all folders used by all prior versions of it as documented in the following two links.

https://www.jetbrains.com/help/idea/2019.3/tuning-the-ide.html#default-dirs

https://www.jetbrains.com/help/idea/tuning-the-ide.html#default-dirs

As I said earlier, I had upgraded many times over the years and there were several directories (each using several GB of space I might add) to delete.  Once these were deleted I installed the latest version once again.  Finally I was met with a clean, vanilla installation.  I was then able to import my project and be free of the erroneous red squiggles and invalid imports.

My theory is that the settings and files from the previous versions somehow got in the way and confused the new version.  But in any case, I am glad that it is resolved and I hope that this comment helps others facing the same problem.

1

请先登录再写评论。