redhat-developer / redhat-developer/vscode-java
Annotation processor in project incorrectly yields "[Java] <generated type> cannot be resolved to a type"
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
I have access to a specific (large) project here which makes use of
@SupportedAnnotationTypes({"the.namespace.TheAnnotation"})
@SupportedSourceVersion(SourceVersion.RELEASE_10)
to create an annotation processor
public class TheAnnotationProcessor extends AbstractProcessor {
for an annotation the.namespace.TheAnnotation in that project
public @interface TheAnnotation {
which produces an interface (e.g. GeneratedInterfaceSpecificMapper, see below) with plenty of default. In the very same project, this annotation is also applied to some classes,
@TheAnnotation(Specific.class)
public class SpecificMapper implements GeneratedInterfaceSpecificMapper {
Evidently, maven discovers the annotation, the annotation processor, runs code generation through the processor (files appear in generated-sources/annotations/...) and is able to also compile the source files that make use of the GeneratedInterfaceSpecificMapper.
The vscode plugin flags the type GeneratedInterfaceSpecificMapper as faulty, with "[Java] cannot be resolved to a type". This seems to indicate that the vscode plugin is not aware of the generated artefacts in generated-sources/annotations/...
I have had a look at https://www.baeldung.com/java-annotation-processing-builder to see whether this produces the error - alas, that setup there seems to be too clean / too simplistic to trigger the problem.
Environment
- Operating System: Linux Fedora 28
- JDK version: 10.0.2
- Visual Studio Code version: 1.28.2
- Java extension version: java-0.33.0-1252.vsix
Steps To Reproduce
<large project, will try to find time to reduce>
Current Result
- builds fine in maven
- red squiggles in IDE / syntax check failure
Expected Result
- builds fine in maven
- no red squiggles in IDE
Additional Informations
Not sure whether this related to the issues reported for Lombok - e.g #580 or #458
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
Beginnen Sie mit dem Annotation-Processing-Pfad der Java-Erweiterung und der im Bericht beschriebenen Ausgabe unter generated-sources/annotations/...; reproduzieren Sie die Abweichung zwischen Maven und IDE mithilfe des referenzierten Annotation Processors und GeneratedInterfaceSpecificMapper. Ein reduziertes Projekt oder eine gleichwertige Reproduktion ist erforderlich, und als abgeschlossen gilt die Aufgabe, wenn Maven weiterhin baut, während die IDE den generierten Typ nicht mehr als nicht aufgelöst meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java, typescript, vscode
- Bereich
- developer-experience, devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 30/100