redhat-developer / redhat-developer/vscode-java

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

未关闭
#682 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

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

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 Java 扩展的注解处理路径以及报告中描述的 generated-sources/annotations/... 输出开始;使用所引用的注解处理器和 GeneratedInterfaceSpecificMapper 重现 Maven 与 IDE 之间的差异。需要一个精简项目或等效的复现,并且完成的标准是 Maven 仍能构建,而 IDE 不再将生成的类型报告为无法解析。

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

评估

技术栈
java, typescript, vscode
领域
developer-experience, devtools
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
30/100

把新 issue 发到你的邮箱

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