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

Renaming of methods is not worked possibly due to Gradle plug-in #325

Open gavenkoa opened 7 years ago

gavenkoa commented 7 years ago

Originally I reported bug at https://netbeans.org/bugzilla/show_bug.cgi?id=270046 but further investigation suggest that Gradle plugin may cause it.

From early NetBeans log:

...
WARNING [org.openide.filesystems.Ordering]: Not all children in Services/MIMEResolver/ marked with the position attribute: [org-netbeans-gradle-project-filesupport-GradleDataObject-Extension.xml], but some are: [...]
...
INFO [org.netbeans.gradle.project.lookups.ProjectLookupHack]: Using custom lookup for type org.netbeans.spi.queries.FileEncodingQueryImplementation
INFO [org.netbeans.gradle.project.lookups.ProjectLookupHack]: Using custom lookup for type org.netbeans.spi.queries.SharabilityQueryImplementation2
INFO [null]: Last record repeated again.
INFO [org.netbeans.gradle.project.lookups.ProjectLookupHack]: Using custom lookup for type org.netbeans.spi.java.classpath.ClassPathProvider

On method rename I got trace:

java.lang.IllegalArgumentException: file:/D:/home/.gradle/caches/modules-2/files-2.1/antlr/antlr/2.7.7/da39a3ee5e6b4b0d3255bfef95601890afd80709/antlr-2.7.7-sources.jar is not a valid classpath entry; use a jar-protocol URL.[File: D:\home\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\da39a3ee5e6b4b0d3255bfef95601890afd80709\antlr-2.7.7-sources.jar, exists: true]
at org.netbeans.modules.java.classpath.SimplePathResourceImplementation.verify(SimplePathResourceImplementation.java:104)
at org.netbeans.modules.java.classpath.SimplePathResourceImplementation.verify(SimplePathResourceImplementation.java:68)
at org.netbeans.modules.java.classpath.SimplePathResourceImplementation.<init>(SimplePathResourceImplementation.java:133)
at org.netbeans.spi.java.classpath.support.ClassPathSupport.createResource(ClassPathSupport.java:77)
at org.netbeans.spi.java.classpath.support.ClassPathSupport.createClassPath(ClassPathSupport.java:147)
at org.netbeans.modules.refactoring.java.RefactoringUtils.getClasspathInfoFor(RefactoringUtils.java:706)
at org.netbeans.modules.refactoring.java.ui.RenameRefactoringUI.<init>(RenameRefactoringUI.java:127)
at org.netbeans.modules.refactoring.java.ui.RenameRefactoringUI.<init>(RenameRefactoringUI.java:95)
at org.netbeans.modules.refactoring.java.ui.RenameRefactoringUI$2.create(RenameRefactoringUI.java:493)
kelemen commented 7 years ago

I'm not exactly sure but I remember if something like this was fixed in master. Can you try building the plugin from the sources and see if you still have the issue?

gavenkoa commented 7 years ago

With:

bash# git clone --depth 1 https://github.com/kelemen/netbeans-gradle-project.git
bash# cd netbeans-gradle-project/netbeans-gradle-plugin
bash# gradle build -x test -x check

and updating plug-in with netbeans-gradle-project/netbeans-gradle-plugin/build/nbm/org-netbeans-gradle-project.nbm

I still have errors:

java.lang.IllegalArgumentException: file:/D:/home/.gradle/caches/modules-2/files-2.1/xmlpull/xmlpull/1.1.3.1/da39a3ee5e6b4b0d3255bfef95601890afd80709/xmlpull-1.1.3.1-sources.jar is not a valid classpath entry; use a jar-protocol URL.[File: D:\home\.gradle\caches\modules-2\files-2.1\xmlpull\xmlpull\1.1.3.1\da39a3ee5e6b4b0d3255bfef95601890afd80709\xmlpull-1.1.3.1-sources.jar, exists: true]
at org.netbeans.modules.java.testrunner.CommonTestUtil.getTestTargets(CommonTestUtil.java:155)
at org.netbeans.modules.java.testrunner.providers.JavaCommonTestUtilProvider.getTestTargets(JavaCommonTestUtilProvider.java:60)
at org.netbeans.modules.java.testrunner.ui.hints.Utils.populateLocations(Utils.java:145)
at org.netbeans.modules.java.testrunner.ui.hints.Utils.getValidCombinations(Utils.java:85)
at org.netbeans.modules.java.testrunner.ui.hints.CreateTestClassHint.computeWarning(CreateTestClassHint.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.netbeans.modules.java.hints.providers.code.CodeHintProviderImpl$WorkerImpl.createErrors(CodeHintProviderImpl.java:340)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.runHint(HintsInvoker.java:821)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.access$400(HintsInvoker.java:113)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker$ScannerImpl.runAndAdd(HintsInvoker.java:680)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker$ScannerImpl.scanDoNotGoDeeper(HintsInvoker.java:734)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeSuggestions(HintsInvoker.java:408)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:244)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:216)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:189)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:151)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsTask.run(HintsTask.java:137)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsTask.run(HintsTask.java:88)
at org.netbeans.modules.java.source.JavaSourceAccessor$CancelableTaskWrapper.run(JavaSourceAccessor.java:298)
at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:584)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:809)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:304)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:725)
at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:686)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)

For the record I have another errors, but I am not sure if it is relevant:

INFO: No FileObject found for the following URL: file:/D:/home/my/exp/spring/spring-batch-simple/src/test/resources/
java.lang.IllegalStateException: No FileObject found for the following URL: file:/D:/home/my/exp/spring/spring-batch-simple/src/test/resources/
at org.netbeans.modules.java.testrunner.CommonTestUtil.getTestTargets(CommonTestUtil.java:155)
at org.netbeans.modules.java.testrunner.providers.JavaCommonTestUtilProvider.getTestTargets(JavaCommonTestUtilProvider.java:60)
at org.netbeans.modules.java.testrunner.ui.hints.Utils.populateLocations(Utils.java:145)
at org.netbeans.modules.java.testrunner.ui.hints.Utils.getValidCombinations(Utils.java:85)
at org.netbeans.modules.java.testrunner.ui.hints.CreateTestClassHint.computeWarning(CreateTestClassHint.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.netbeans.modules.java.hints.providers.code.CodeHintProviderImpl$WorkerImpl.createErrors(CodeHintProviderImpl.java:340)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.runHint(HintsInvoker.java:821)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.access$400(HintsInvoker.java:113)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker$ScannerImpl.runAndAdd(HintsInvoker.java:680)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker$ScannerImpl.scanDoNotGoDeeper(HintsInvoker.java:734)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeSuggestions(HintsInvoker.java:408)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:244)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:216)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:189)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:151)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsTask.run(HintsTask.java:137)
at org.netbeans.modules.java.hints.spiimpl.hints.HintsTask.run(HintsTask.java:88)
at org.netbeans.modules.java.source.JavaSourceAccessor$CancelableTaskWrapper.run(JavaSourceAccessor.java:298)
at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:584)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:809)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:304)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:725)
at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:686)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
kelemen commented 7 years ago

I have debugged this issue (while also looking at the sources of NB) and I'm not sure that this issue is directly caused by this plugin. However, I have to admit that what happens is strange. Currently, I have the following guesses:

Anyway, do you have a sample project to share with which I can reproduce this issue? Also, can you reproduce this issue with NB 8.1 too?

The other logged stack trace looks purely informational, so I don't think it is relevant (I'm not sure why it is even logged).

gavenkoa commented 7 years ago

build.gradle:

repositories {    jcenter()    }
apply plugin: 'java'
dependencies {
    compile 'org.springframework.boot:spring-boot-starter-batch:1.4.4.RELEASE'
}

Any .java:

public String init() {
    return hello();
}

public String hello() {
    return "hello";
}

I can't rename public/protected methods (on private works just fine). Dependency on spring-boot-starter-batch somehow important.

To test I created empty project group with single test project and restart IDE.

Commenting out

    compile 'org.springframework.boot:spring-boot-starter-batch:1.4.4.RELEASE'

and "Reload project" make possible to rename. Uncommenting and "Reload project" make impossible to rename.

Simple Maven project with same dependency have no such issue.

gavenkoa commented 7 years ago

I am on mobile Internet access package currently and it is difficult to get NB 8.1, sorry...

Product Version: NetBeans IDE 8.2 (Build 201609300101) and NB says that there are no updates...

gavenkoa commented 7 years ago

Because I have in log:

java.lang.IllegalArgumentException: file:/D:/home/.gradle/caches/modules-2/files-2.1/xmlpull/xmlpull/1.1.3.1/da39a3ee5e6b4b0d3255bfef95601890afd80709/xmlpull-1.1.3.1-sources.jar is not a valid classpath entry; use a jar-protocol URL.[File: D:\home\.gradle\caches\modules-2\files-2.1\xmlpull\xmlpull\1.1.3.1\da39a3ee5e6b4b0d3255bfef95601890afd80709\xmlpull-1.1.3.1-sources.jar, exists: true]

I change dependency to

compile 'xmlpull:xmlpull:1.1.3.1'

and it causes problem.

kelemen commented 7 years ago

I do not have the sources of "xmlpull" but created one manually and cannot reproduce this issue. Do you have any plugin installed which is not bundled with NB (other than this plugin)?

Anyway, I would expect that you are able reproduce this with any dependency which has its sources downloaded by Gradle (say by using "Download sources" on the dependencies node). If this is not the case, I would be even more puzzled.

gavenkoa commented 7 years ago

I able to reproduce only on specific dependencies, not all.

After renaming c:/Users/user/AppData/Roaming/NetBeans to something else and installing updates and Gradle plugin I can't reproduce issue.

I do not know how easily to bisect "bad" plug-in in old setup.

gavenkoa commented 7 years ago

I tried to disable as many as possible plug-ins and it didn't help.

Seems that one of them intrudes into NB configs unconditionally.

I tried several plug-ins to see what they can provide. Actually I need only Gradle plugin and happy with clean setup.

Thanks for support!

kelemen commented 7 years ago

Ok, if you ever experience this issue again: Please reopen as I'm curious what could have caused this behaviour.

gavenkoa commented 7 years ago

Today I able to reproduce bug. I have only Gradle plugin installed (and its dependencies).

I provide full path to Gradle c:\opt\gradle-2.14.1 and to cache: d:\home\.gradle

gavenkoa commented 7 years ago

On rename (by Ctrl+R) of public method I've got error notification with message:

java.lang.IllegalArgumentException: file:/D:/home/.gradle/caches/modules-2/files-2.1/antlr/antlr/2.7.7/da39a3ee5e6b4b0d3255bfef95601890afd80709/antlr-2.7.7-sources.jar is not a valid classpath entry; use a jar-protocol URL.[File: D:\home\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\da39a3ee5e6b4b0d3255bfef95601890afd80709\antlr-2.7.7-sources.jar, exists: true]
    at org.netbeans.modules.java.classpath.SimplePathResourceImplementation.verify(SimplePathResourceImplementation.java:104)
    at org.netbeans.modules.java.classpath.SimplePathResourceImplementation.verify(SimplePathResourceImplementation.java:68)
    at org.netbeans.modules.java.classpath.SimplePathResourceImplementation.<init>(SimplePathResourceImplementation.java:133)
    at org.netbeans.spi.java.classpath.support.ClassPathSupport.createResource(ClassPathSupport.java:77)
    at org.netbeans.spi.java.classpath.support.ClassPathSupport.createClassPath(ClassPathSupport.java:147)
    at org.netbeans.modules.refactoring.java.RefactoringUtils.getClasspathInfoFor(RefactoringUtils.java:706)
    at org.netbeans.modules.refactoring.java.ui.RenameRefactoringUI.<init>(RenameRefactoringUI.java:127)
    at org.netbeans.modules.refactoring.java.ui.RenameRefactoringUI.<init>(RenameRefactoringUI.java:95)
    at org.netbeans.modules.refactoring.java.ui.RenameRefactoringUI$2.create(RenameRefactoringUI.java:493)
    at org.netbeans.modules.refactoring.java.ui.ContextAnalyzer$1.createRefactoringUI(ContextAnalyzer.java:117)
    at org.netbeans.modules.refactoring.java.ui.ContextAnalyzer$TextComponentTask.run(ContextAnalyzer.java:378)
    at org.netbeans.modules.refactoring.java.ui.ContextAnalyzer$TextComponentTask.run(ContextAnalyzer.java:303)
    at org.netbeans.api.java.source.JavaSource$MultiTask.run(JavaSource.java:486)
    at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:609)
    at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:153)
    at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:137)
    at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:204)
    at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:201)
    at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:176)
    at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:360)
    at org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:141)
    at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:88)
    at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:201)
    at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:104)
    at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:436)
    at org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:407)
    at org.netbeans.modules.refactoring.java.ui.ContextAnalyzer$TextComponentTask.run(ContextAnalyzer.java:385)
    at org.netbeans.modules.refactoring.java.ui.UIUtilities.lambda$runWhenScanFinished$0(UIUtilities.java:1211)
    at org.netbeans.api.java.source.ui.ScanDialog.runWhenScanFinished(ScanDialog.java:145)
    at org.netbeans.modules.refactoring.java.ui.UIUtilities.runWhenScanFinished(UIUtilities.java:1206)
    at org.netbeans.modules.refactoring.java.ui.RefactoringActionsProvider.doFullRename(RefactoringActionsProvider.java:153)
    at org.netbeans.modules.refactoring.java.ui.RefactoringActionsProvider.doRename(RefactoringActionsProvider.java:100)
    at org.netbeans.modules.refactoring.api.impl.ActionsImplementationFactory.doRename(ActionsImplementationFactory.java:91)
    at org.netbeans.modules.refactoring.spi.impl.RenameAction.performAction(RenameAction.java:77)
    at org.netbeans.modules.refactoring.spi.impl.RefactoringGlobalAction$ContextAction.actionPerformed(RefactoringGlobalAction.java:197)
    at org.netbeans.modules.java.editor.rename.InstantRenamePerformer.doFullRename(InstantRenamePerformer.java:284)
    at org.netbeans.modules.java.editor.rename.InstantRenamePerformer.invokeInstantRename(InstantRenamePerformer.java:267)
    at org.netbeans.modules.java.editor.rename.InstantRenameAction.actionPerformed(InstantRenameAction.java:62)
    at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:339)
    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1663)
    at javax.swing.JComponent.processKeyBinding(JComponent.java:2882)
    at javax.swing.JComponent.processKeyBindings(JComponent.java:2929)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2845)
    at java.awt.Component.processEvent(Component.java:6310)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
    at java.awt.Component.dispatchEventImpl(Component.java:4760)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
kelemen commented 7 years ago

Can you share a project on GitHub with which you can reproduce the issue with? Because I have never experienced this issue and have no idea how this could happen. (Maybe even the list of plugins you have installed manually)