redhat-developer / redhat-developer/vscode-java
If there's a syntax error inside an arrow function, the entire function is highlighted as an error in the editor
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.3k
- Forks
- 546
- Ø Merge
- 20 Std. 1 Min.
- Gemergte PRs (30 T.)
- 11
Beschreibung
When an arrow function is assigned to a variable with a generic type parameter, and there is a syntax error inside the arrow function, VSCode highlights the entire arrow function as an error. This obscures the location of the syntax error and makes the code difficult to read.
Environment
Version: 1.54.3 (user setup)
Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8
Date: 2021-03-15T10:55:45.459Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.18362
Steps To Reproduce
Repository: https://github.com/AnthonyWeston/java-test
- Add an arrow function with an undefined variable name inside it, and assign the function to a variable with a generic type parameter:
List<Integer> test = Stream.of("1", "2", "3")
.map(s -> {
int result = Integer.parseInt(s);
return oops;
})
.collect(Collectors.toList());
});
Current Result
VSCode highlights the entire arrow function as an error, obscuring the location of the undefined variable and making the code difficult to read. The error message is "Cannot infer type argument(s) for map(Function<? super T,? extends R>)"

Expected Result
Only the variable assignment is highlighted as an error, and the undefined variable is highlighted as an error and clearly visible.
Additional Information
Logs: https://github.com/AnthonyWeston/java-test/blob/main/log.log
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Verwende das verlinkte java-test-Repository und das bereitgestellte arrow-function-Beispiel, um die diagnostische Hervorhebung in VS Code zu reproduzieren. Vergleiche die aktuellen und erwarteten Diagnosen, einschließlich der nicht definierten Variable innerhalb der arrow function; abgeschlossen ist die Aufgabe, wenn der Syntaxfehler lokalisiert wird, anstatt die gesamte Funktion hervorzuheben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java, vscode
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100