redhat-developer / redhat-developer/vscode-java

Annotation processor in project incorrectly yields "[Java] <generated type> cannot be resolved to a type"

Aperta
#682 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

codegen
Lingua principale
TypeScript
Stelle
2.3k
Fork
546
Merge medio
20h 1m
PR unite (30g)
11

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Iniziare dal percorso di elaborazione delle annotazioni dell’estensione Java e dall’output generated-sources/annotations/... descritto nel report; riprodurre la discrepanza tra Maven e l’IDE utilizzando il processore di annotazioni indicato e GeneratedInterfaceSpecificMapper. È necessario un progetto ridotto o una riproduzione equivalente, e il lavoro è completato quando Maven continua a eseguire la build mentre l’IDE non segnala più il tipo generato come non risolto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java, typescript, vscode
Ambito
developer-experience, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.