redhat-developer / redhat-developer/vscode-java

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

Đang mở
#682 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

codegen
Ngôn ngữ chính
TypeScript
Star
2.3k
Fork
546
Merge trung bình
20 giờ 1 phút
Pull request đã merge (30 ngày)
11

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với đường dẫn xử lý annotation của Java extension và đầu ra generated-sources/annotations/... được mô tả trong báo cáo; tái hiện sự khác biệt giữa Maven và IDE bằng annotation processor được tham chiếu cùng GeneratedInterfaceSpecificMapper. Cần có một project rút gọn hoặc một bản tái hiện tương đương, và được xem là hoàn tất khi Maven vẫn build thành công trong khi IDE không còn báo type được sinh ra là unresolved.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java, typescript, vscode
Lĩnh vực
developer-experience, devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.