kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
170 stars 57 forks source link

Ctrl-click on keywords no longer opens sources #196

Closed shevek closed 7 years ago

shevek commented 9 years ago

For some reason, control-clicking on keywords no longer opens sources in another module on which I depend. Instead, I get the binary disassembly.

This seems to be true in some (large/complex) multi-module projects, but not others. I can't correlate it with anything.

I have gradle 2.2.1 and netbeans 8.0.2 with plugin 1.3.4, and there aren't many differences between the build systems.

Any suggestions about how to debug?

shevek commented 9 years ago

Also, ctrl-shift-i to fix imports didn't work in the broken project when trying to import a newly written class in a dependency (sibling) module.

shevek commented 9 years ago

Bug confirmed across all inter-subproject dependencies, from test to test or test to main. Bug does NOT exist when clicking into the JDK, or the sources of a library from Maven Central. Bug does NOT exist when clicking from test sources into main sources WITHIN a subproject.

Build configuration has not (noticeably) changed since this last worked.

kelemen commented 9 years ago

Have you tried downloading the sources again?

shevek commented 9 years ago

It's a multi-module project, module B depends on module A. If I click on an A class in module B, it doesn't open it. So they're my own sources which are currently open in the IDE from the srcdir in the sibling module.

Downloaded sources work fine. JDK sources work fine. The broken ones are my OWN sources from a sibling source submodule. I have to use ^1^O to navigate manually.

kelemen commented 9 years ago

I see, can you try deleting NetBeans' cache? (you can find the cache path in the about dialog)

shevek commented 9 years ago

Exit netbeans, reboot, clear cache, restart netbeans. Still broken. :-(

kelemen commented 9 years ago

Can you give me an example project with which I can reproduce your issue? Also, do you have symlinks somewhere in the paths?

kelemen commented 9 years ago

One another thing: What is the name of source set whose source you cannot find and how exactly do you declare dependency on it?

shevek commented 9 years ago

I don't think I can give you access to this project without an NDA.

The sourceset is "main", and it's declared as:

project(':sub1') {
  dependencies { compile project(':sub0') }
}
shevek commented 9 years ago

No symlinks, I learned that lesson.

shevek commented 9 years ago

I'm happy to take a debug build of your plugin which collects extra information and submit a support bundle.

kelemen commented 9 years ago

What I actually need to see are the build scripts. More specifically the Jar tasks, sourcesets and dependency definitions. Would it be possible for you to send me the stripped down version of those scripts? You can remove any tasks which is not a Jar or a compile task (send me an e-mail if you want to).

shevek commented 9 years ago

Oh, I did recently update to Azul Zulu JDK8. I'll back to 7 and see what happens.

shevek commented 9 years ago
WARNING [org.netbeans.modules.java.source.indexing.JavaIndex]: Ignoring root with no ClassPath: /home/shevek/java/<myproject>/<myproject>-engine/src/main/java
WARNING [org.netbeans.modules.java.source.parsing.JavacParser]: ClassPath identity changed for /home/shevek/java/<myproject>/<myproject>-engine/src/main/java/org/<myproject/.../...>/Locator.java@9f883616:71a477df, class path owner: /home/shevek/java/<myproject>/<myproject>-engine (class org.netbeans.gradle.project.NbGradleProject) original sourcePath:  new sourcePath: null
INFO [org.netbeans.modules.java.hints.WrongPackageSuggestion]: source cp is either null or does not contain the compiled source cp=

That "ignoring root with no ClassPath" is probably our bunny. Why has it got no ClassPath?

shevek commented 9 years ago

This project uses gradle-sablecc-plugin but so do several other projects which are not broken.

shevek commented 9 years ago

Probably related:

INFO: Source root found by FileOwnerQuery points to a different project for the following URL: file:/home/shevek/java/<myproject>/<myproject>-samples/build/libs/
java.lang.IllegalStateException: Source root found by FileOwnerQuery points to a different project for the following URL: file:/home/shevek/java/<myproject>/<myproject>-samples/build/libs/
        at org.netbeans.modules.java.testrunner.CommonTestUtil.getTestTargets(CommonTestUtil.java:183)
        at org.netbeans.modules.java.testrunner.providers.JavaCommonTestUtilProvider.getTestTargets(JavaCommonTestUtilProvider.java:61)
        at org.netbeans.modules.java.testrunner.hints.Utils.populateLocations(Utils.java:146)
        at org.netbeans.modules.java.testrunner.hints.Utils.getValidCombinations(Utils.java:86)
        at org.netbeans.modules.java.testrunner.hints.CreateTestMethodsHint.computeWarning(CreateTestMethodsHint.java:127)
        at sun.reflect.GeneratedMethodAccessor195.invoke(Unknown Source) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.netbeans.modules.java.hints.providers.code.CodeHintProviderImpl$WorkerImpl.createErrors(CodeHintProviderImpl.java:336)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.runHint(HintsInvoker.java:798)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.access$400(HintsInvoker.java:111)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker$ScannerImpl.runAndAdd(HintsInvoker.java:657)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker$ScannerImpl.scanDoNotGoDeeper(HintsInvoker.java:711)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeSuggestions(HintsInvoker.java:396)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:232)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:209)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:182)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:149)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsTask.run(HintsTask.java:114)
        at org.netbeans.modules.java.hints.spiimpl.hints.HintsTask.run(HintsTask.java:83)
        at org.netbeans.modules.java.source.JavaSourceAccessor$CancelableTaskWrapper.run(JavaSourceAccessor.java:298)
        at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:573)
        at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:744)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

This is because I put the build/libs dir of one project into the resource classpath of another. Will try removing, and see.

shevek commented 9 years ago

This might be the line:

    project.sourceSets.test.resources.srcDir project.project(':<myproject>-samples').file('build/libs')

I'll rearchitect to run without that and see. Right now, removing that line and reloading did not fix it, but I will try a full cache-clear.

shevek commented 9 years ago

Now ctrl-shift-1 works, but ctrl-click across projects still does not.

shevek commented 9 years ago

It may have been caused by a construct like htis:

project('A') {
  testCompile project('B')
}

project('B') {
  compile project('A')
}
shevek commented 9 years ago

I think that project construct was the culprit. :-(

shevek commented 9 years ago

Nope, still broken. ARGH.

shevek commented 9 years ago

Clicking on a file reliably generates the following records in messages.log:

WARNING [org.netbeans.modules.java.source.parsing.JavacParser]: ClassPath identity changed for /home/shevek/.cache/netbeans/8.0.2/index/s44/java/14/gensrc/org/<myproject>/common/engine/CompilerErrorHandler.java@82c35c3c:43434993, class path owner: null original sourcePath: /home/shevek/java/<myproject>/<myproject>-server/src/main/java:/home/shevek/java/<myproject>/<myproject>-server/src/main/resources:/home/shevek/java/<myproject>/<myproject>-server/src/main/webapp new sourcePath: null
WARNING [org.netbeans.modules.java.source.parsing.JavacParser]: ClassPath identity changed for /home/shevek/.cache/netbeans/8.0.2/index/s44/java/14/gensrc/org/<myproject>/common/engine/CompilerErrorHandler.java@82c35c3c:43434993, class path owner: null original sourcePath:  new sourcePath: null
WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: Incorrect error badges detected, file=/home/shevek/.cache/netbeans/8.0.2/index/s44/java/14/gensrc/org/<myproject>/common/engine/CompilerErrorHandler.java.
WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: The file is not on its own source classpath, ignoring.

WARNING [org.netbeans.modules.java.source.parsing.JavacParser]: ClassPath identity changed for /home/shevek/.cache/netbeans/8.0.2/index/s44/java/14/gensrc/org/<myproject>/common/engine/CompilerTask.java@e97c78bb:2fa091f1, class path owner: null original sourcePath: /home/shevek/java/<myproject>/<myproject>-server/src/main/java:/home/shevek/java/<myproject>/<myproject>-server/src/main/resources:/home/shevek/java/<myproject>/<myproject>-server/src/main/webapp new sourcePath: null
WARNING [org.netbeans.modules.java.source.parsing.JavacParser]: ClassPath identity changed for /home/shevek/.cache/netbeans/8.0.2/index/s44/java/14/gensrc/org/<myproject>/common/engine/CompilerTask.java@e97c78bb:2fa091f1, class path owner: null original sourcePath:  new sourcePath: null
WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: Incorrect error badges detected, file=/home/shevek/.cache/netbeans/8.0.2/index/s44/java/14/gensrc/org/<myproject>/common/engine/CompilerTask.java.
WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: The file is not on its own source classpath, ignoring.

And most annoyingly of all, after doing a git bisect to try to find the issue, it went away. Let me put some code back in and see if it recurs. :-(

kelemen commented 9 years ago

The logs simply mean that the Gradle plugin did provide any classpath for the directory "webapp". I'm not sure if it should though. I guess you are also using the Gradle Java-EE plugin, and that plugin should provide classpath for this directory.

shevek commented 9 years ago

No J2EE plugin(s). I just used its convention. My package has a builtin Jetty server and does use JSP, etc, but I don't use any J2EE support code or plugins.

shevek commented 9 years ago

.nb-gradle is in email ; thank you!

ChristopheFerreboeuf commented 7 years ago

I had a same issue with netbeans on ubuntu 16.04 and I applied the solution given in here

And it solved my problem !

shevek commented 7 years ago

Closing as no longer affects me.