netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Navigate to source does not work for annotation with default value of type Class

Open hlavki opened this issue 3 years ago • 4 comments

Apache NetBeans version

Apache NetBeans latest daily build

What happened

When I have code e.g.:


@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface RunWith {

    Class<?> value();
}

@RunWith(String.class)
public class Runner {}

Pressing key Ctrl and click mouse on String.class, netbeans opens source of RunWith.java instead of String.java. Also JavaDoc shows RunWith.java.

How to reproduce

See the description above.

Did this work correctly in an earlier version?

No

Operating System

Linux 5.17.9-1-default, openSUSE Tumbleweed, x86_64

JDK

18.0.1

Apache NetBeans packaging

Own source build

Anything else

No response

Are you willing to submit a pull request?

Yes

Code of Conduct

Yes

hlavki avatar Jun 02 '22 07:06 hlavki

good catch. thanks for the compact reproducer.

mbien avatar Jun 02 '22 23:06 mbien

It is really annoying mainly if you heavily work with annotations e.g. Spring Boot, Quarkus...

Saljack avatar May 13 '24 12:05 Saljack

@hlavki @Saljack could you please test the nightly build available from PR #7378?

Direct link: https://github.com/apache/netbeans/suites/23738068067/artifacts/1498621505

matthiasblaesing avatar May 14 '24 05:05 matthiasblaesing

It works like a charm 👍 Thank you so much. I tested these combinations:

@Import(Something.class)
@Import(value = {Something.class} )
@Import(value = {Something.class, Object.class} )
@Import
@SpringBootApplication(scanBasePackageClasses = Something.class, exclude = Object.class)

and in all cases, it is linked to a correct annotation or a class parameter. I assume it is too late for NetBeans 22 😢

Saljack avatar May 14 '24 06:05 Saljack

@Saljack thank you for the quick check.

I assume it is too late for NetBeans 22 😢

NB22 is still in RC phase. While I wanted to wait for CI/CD to complete and then decide, @mbien beat me to it and went ahead, reviewed and added to NB22 milestone. Meanwhile @ebarboni also merged the change to delivery for the next RC. So yes, it should be released with next version.

matthiasblaesing avatar May 14 '24 17:05 matthiasblaesing