redhat-developer / redhat-developer/vscode-java

Type resolution fails when namespace collision occurs between local Type and lib reference

未关闭
#1,785 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug
主要语言
TypeScript
星标
2.3k
派生
546
平均合并
20 小时 1 分钟
30 天内合并 PR
11

描述

I have a package private enum that I reference in another class in the same package. Code underlines the enum as unresolved, because there's no import statement. As the two Types exist in the same package, no import is necessary.

The code builds fine with Maven. Also I'm able to use Code to ctrl-click jump to the enum that Code marks as unresolved.

Environment

Operating System: Windows_NT x64 10.0.19042 + WSLv2 + Ubuntu 20.10
JDK version: OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.10)
Visual Studio Code version: 1.52.1, Electron 9.3.5

  • Java extension version: v0.74.0
Steps To Reproduce

package SomePackage
public enum TypeA {
ENUM_DEF(String s);
...//private fields, constructor, etc.
public toString() { return s;}
}

package SomePackage
public TypeB() {
String enumVal = TypeA.ENUM_DEF.toString();
...
}

Code underlines TypeA as unresolved, because there are other classes in my maven classpath that are called "TypeA". If I perform an "organize import" command, I see the other types in the dropdown but I do not see my own.

If I rename my local enum to be a unique name, Code resolves it fine. Seems to be a problem with the lookup algorithm that underlines errors, because it ignores the local package.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用同一 package 中的两个 Java 类型以及 Maven classpath 上的另一个 TypeA 重现冲突,然后比较类型解析、组织 imports 和 ctrl-click 导航。当本地 package 中的 TypeA 无需 import 即可解析,同时仍能区分名称相似的库类型时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。