You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by Eirik Bakke <eb...@ultorg.com> on 2021/09/01 16:16:11 UTC

RE: Broken refactoring operations

Usually I do a clean build of everything after first starting the IDE (mvn clean install), and subsequently I rely on Compile-on-Save (using nbjavac until recently, but using vanilla javac going forward now). The problems I have seen are all after indexing has finished.

Yesterday I actually saw a case again where Go to Symbol failed to find a class. I manually opened the java file for the class, and saw a red line under the class name "Bundle" in the following code excerpt (indicating that the generated Bundle class could not be found):

======================================
@NbBundle.Messages("CTL_RefreshDerivatives=Refresh Derived Properties")
public void runViewUpdater() {
  mutate(Bundle.CTL_RefreshDerivatives(), false, true, (MutableView view) -> { });
}
======================================

I've had problems like this with NetBeans annotations such as @NbBundle.Messages for many years (see https://bz.apache.org/netbeans/show_bug.cgi?id=221781 ). Normally the problem happens when the annotation is changed and the file saved via compile-on-save, but every now and then the failure occurs when the java file for the class is changed in other ways, or even when the java file isn't changed at all. In any case, whenever this happens, I have to do a clean maven build.

So perhaps the indexing/refactoring problems are actually a result of other bugs like the one above, which cause classes to not compile correctly. I bet there are several such bugs--not just the one above. For example, I bet bugs like https://issues.apache.org/jira/browse/NETBEANS-531 and https://bugs.openjdk.java.net/browse/JDK-8024694 might also cause background indexing to fail in the same way.

> I.e. sometimes some project dependencies aren’t compile yet resulting in some related projects to have unfound class dependencies and shows with red errors

Yeah, I've seen that too. Whenever there are classes with red error badges on them--legitimate or not--I would expect indexing to be messed up as well. But I believe I have seen cases where indexing was not working even when no errors where indicated in the project tree. I'll watch more carefully for these badges in the future.

-- Eirik

-----Original Message-----
From: Eric Bresie <eb...@gmail.com> 
Sent: Tuesday, August 31, 2021 12:06 PM
To: dev@netbeans.apache.org
Subject: Re: Broken refactoring operations

Did the complete projects get built (and index) fully yet?

I recall in some cases (like the whole Netbeans projects) if everything has been built and indexed yet (stale state) sometimes things don’t work out cleanly (I.e. sometimes some project dependencies aren’t compile yet resulting in some related projects to have unfound class dependencies and shows with red errors).  Could this be happening here?


On Sun, Aug 29, 2021 at 12:21 PM Eirik Bakke <eb...@ultorg.com> wrote:

> Nowadays I clear my cache directory frequently, and always use "Go to 
> File" instead of "Go to Symbol", so it's been a few releases since I 
> have observed these bugs. But I can start looking out for them again, 
> and report more detailed information.
>
> There are also some issues with the order in which results are shown 
> in Go to Symbol, which I reported here:
> https://issues.apache.org/jira/browse/NETBEANS-3808
> (Should be easy to fix, but I never got around to it. I wonder if 
> something changed with the Go to Symbol action... I seem to remember 
> it worked perfectly in NetBeans 8.2.)
>
> I'm working with maven-based NetBeans Platform modules, a few thousand 
> classes spread over ~25 modules. In some cases there are NetBeans 
> Platform annotations to register actions and such.
>
> -- Eirik
>
> -----Original Message-----
> From: Eric Bresie <eb...@gmail.com>
> Sent: Saturday, August 28, 2021 12:56 PM
> To: Netbeans Developer List <de...@netbeans.apache.org>
> Subject: Re: Broken refactoring operations
>
> What is configuration is in use for this (i.e. Netbeans version, Java 
> version, Netbean...About) ?
>
> What project are you using (i.e. how big is it)?  Not sure if maybe 
> this requires a larger project to trigger more indexing behavior but...
>
>    1. Running with 12.5 Beta2...
>    2. Created a very basic gradle java class with a HelloMain and a
>    dependency HelloWorld class with an execute call defined and used
>    elsewhere.
>    3. Selected the execute method and used "Find Usage" and it seems to
>    work.  ..
>    4. Refectored (renamed)  "execute" method to "run" method and it seems
>    to work
>    5. Created a very basic maven java class, copied the HelloWorld class
>    from gradle to maven project which open Refactor dialog
>    6. Refactor preview showed what was to occur (i.e. change package from
>    old to new)
>    7. Do Refactor executed successfully
>    8. Shift-Alt-O opens dialog and starts looking for "HelloWorld" which
>    shows both projects versions of it.
>
> Possible Unrelated documentation issues,
>
>    1. When selected Find Usage on a given class, the dialog shows the below
>    2. Find out more" takes to
>
> https://netbeans.apache.org/wiki/Find_Usages_in_Compiled_Dependencies.asciidoc
>    (not html version) and the pages does not exist.
>    3. Not sure if the site didn't get built correctly recently, the page is
>    no longer available or the dialog needs to be updated to someplace else.
>
>
> Warning: Disclaimer: Searching for usages in compiled dependencies has 
> certain limitations. Find out more.
> <http://wiki.netbeans.org/Find_Usages_in_Compiled_Dependencies>
>
> Eric Bresie
> ebresie@gmail.com
>
>
> On Fri, Aug 27, 2021 at 3:42 PM Eirik Bakke <eb...@ultorg.com> wrote:
>
> > (Starting a new thread as suggested by Geertjan...)
> >
> > I have seen broken refactoring operations as well. Most notably, 
> > "Find Usages" on a Java method will sometimes miss call sites. I 
> > have also seen methods and classes missing when searching from the 
> > Go to Symbol
> dialog.
> > Probably the same underlying cause. I don't know how to reproduce 
> > this, however.
> >
> > For comparison, NetBeans 8.4 (pre-Apache, and with Java 8) was 
> > always completely reliable.
> >
> > Exiting the IDE, deleting the cache directory, and starting the IDE 
> > again have always fixed these problems for me. So I suspect indexing 
> > errors are the cause.
> >
> > I used to see a lot of error messages relating to the IDE not being 
> > able to parse a java file, although in later releases things have 
> > gotten a lot better. I also have high hopes that the new "vanilla 
> > indexing" system (Java indexing without the nb-javac plugin) may 
> > improve
> things.
> >
> > All of my projects are Maven-based NetBeans Platform module 
> > projects, with Compile-on-Save enabled.
> >
> > -- Eirik
> >
> > -----Original Message-----
> > From: Geertjan Wielenga <ge...@googlemail.com.INVALID>
> > Sent: Monday, August 16, 2021 10:12 AM
> > To: dev <de...@netbeans.apache.org>
> > Subject: Re: VSCode
> >
> > Start a new thread on it and point to the specific issues, or create 
> > new ones with steps to reproduce (I use NetBeans regularly including 
> > refactoring, would like to see these issues), let's get it fixed.
> >
> > Gj
> >
> > -----Original Message-----
> > From: Ty Young <yo...@gmail.com>
> > Sent: Monday, August 16, 2021 10:09 AM
> > To: dev@netbeans.apache.org
> > Subject: Re: VSCode
> >
> > Just going to point out that refactoring(renaming methods, others) 
> > on Netbeans is still broken... as it has been for years.
> >
>
--
Eric Bresie
ebresie@gmail.com