redhat-developer / redhat-developer/vscode-java

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

オープン
#1,785 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

同じ package の 2 つの Java 型と、Maven classpath 上の別の TypeA で衝突を再現し、その後、型解決、import の整理、ctrl-click ナビゲーションを比較します。ローカル package の TypeA が import なしで解決され、名前の似たライブラリ型を区別できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。