redhat-developer / redhat-developer/vscode-java

Java build is failing when trying to import from enum file

Open
#1,529 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

content-assist
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

Environment
  • Operating System: Windows 10 (ssh remote to ubuntu)
  • JDK version: Java 8
  • Visual Studio Code version: 1.47.1
  • Java extension version: 0.9.1
Steps To Reproduce

If you have two enum files with the same package structure, vscode can't figure out which one you are trying to import
Say for example, your source code has an enum (MyEnum), and your test code has the same enum but with an additional value (NON_EXISTING_TYPE), vscode will complain the enum value doesn't exist. Intellij does not have this problem however.

Here com.my.example.MyEnum exists both in source and test folder, and this is how I would import the test enum:

import static com.my.example.MyEnum.NON_EXISTING_TYPE;

It will highlighted with red squigly line, with message:
The import com.my.example.MyEnum.NON_EXISTING_TYPE cannot be resolved Java(268435846)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the static import with duplicate MyEnum files in source and test folders using the environment and versions listed. Trace how the Java extension resolves the source and test types; the work is done when the test enum's NON_EXISTING_TYPE import resolves without a diagnostic.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.