feat: add annotation type support to parser and autocomplete#112
Open
abanchev wants to merge 1 commit intobobbylight:masterfrom
Open
feat: add annotation type support to parser and autocomplete#112abanchev wants to merge 1 commit intobobbylight:masterfrom
abanchev wants to merge 1 commit intobobbylight:masterfrom
Conversation
- Parse @interface declarations in ASTFactory (previously threw IOException) - Filter completions after '@' to show only annotation types - Add annotation parameter completion inside @annotation(...) - Resolve annotation element Javadoc from source attachments
3fb428d to
cd12700
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@interfacedeclarations inASTFactory— previously the parser threw anIOExceptionwhen encountering annotation type declarations, preventing the entire source file from being parsed@to show only annotation types, not methods/fields/local variables@Annotation(...)with element names and Javadoc from source attachmentsisAnnotationType()helper toClassCompletionusingACC_ANNOTATIONaccess flagMotivation
The parser had no support for
@interfacedeclarations at all. When a source file contained an annotation type definition (e.g.@interface Serialize), theASTFactorythrew anIOExceptionwhich was caught and treated as a parse error — meaning the entire file couldn't be parsed and no completions were available.Additionally, typing
@before an annotation name showed all completions (methods, fields, local variables) instead of filtering to just annotation types. And inside annotation parentheses like@Serialize(tooltip=..., readOnly=...), there was no completion for the annotation's element names.Changes
Parser (
ASTFactory.java):getClassOrInterfaceDeclaration:ANNOTATION_STARTcase consumes@+interfacekeyword, delegates togetNormalInterfaceDeclarationgetInterfaceMemberDecl: toleratesdefaultclauses on annotation elementsAutocomplete (
SourceCompletionProvider.java):isAnnotationContext(): detects@character before entered text@context, removes non-annotation completionsgetAnnotationClassName(): scans backward through balanced parens to detect@Name(...)contextaddAnnotationElementCompletions(): resolves annotationClassFile, iterates element methods, creates completions with Javadoc from sourceClassCompletion.java:isAnnotationType(): checksACC_ANNOTATIONbit on class access flagsTest plan
AnnotationTypeDeclarationTestcases: simple@interface, with defaults, with imports, body elementsSourceCompletionProviderTestcases:@prefix detection@Sershows only annotation types,@Serialize(shows element names with Javadoc