apache / apache/netbeans

import suggestions not working as expected outside the local module in a maven/java project

Open
#5,418 1 comment 0 reactions 0 assignees View on GitHub
Java kind:bug Maven needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 16

### What happened

so, this is on NB 16 with JDK 17 in a Maven project.

I'm trying to have a java module of my own with test classes in the same module/packages.

Now, I have already added org.junit.jupiter.junit-jupiter-api to my dependencies.
So, in my test class I expect to type in TestInfo and be able to hit ALT-ENTER and get a suggestion for the import, but all I get are suggestions to add classes or search for dependencies.

So I remove the manually added dependency and let NB do the job ... still no cookie.
Then I close NB and remove the entire cache directory, restart and it rebuild the cache ... no change.

I can hit CMD-O and type in TestInfo and it actually _finds_ the right interface.
When I manually type in the right import, everything compiles just fine.

Attaching a short project to demonstrate the issue.

[permute.zip](https://github.com/apache/netbeans/files/10579180/permute.zip)

### How to reproduce

- In the attached project go to src/test/java/net/jarre_de_the/permute/PermuteTest.java
- comment out statements like the following and try to get them added back from suggestions of fix imports:

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

MacOS 13.2

### JDK

JDK 17.0.6 as provided by Oracle

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

always

### Are you willing to submit a pull request?

Yes

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

Start with the attached permute.zip project and reproduce the issue in src/test/java/net/jarre_de_the/permute/PermuteTest.java by removing the JUnit imports and invoking fix imports. Compare the import suggestions with the classes found through CMD-O; done means Test and TestInfo receive the expected import suggestions in this Maven test project.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.