2626import org .eclipse .jdt .core .Signature ;
2727import org .eclipse .jdt .core .compiler .CharOperation ;
2828import org .eclipse .jdt .core .dom .ASTNode ;
29+ import org .eclipse .jdt .core .dom .ASTVisitor ;
2930import org .eclipse .jdt .core .dom .AbstractTypeDeclaration ;
3031import org .eclipse .jdt .core .dom .AnonymousClassDeclaration ;
3132import org .eclipse .jdt .core .dom .Block ;
3839import org .eclipse .jdt .core .dom .ITypeBinding ;
3940import org .eclipse .jdt .core .dom .IVariableBinding ;
4041import org .eclipse .jdt .core .dom .ImportDeclaration ;
42+ import org .eclipse .jdt .core .dom .MarkerAnnotation ;
4143import org .eclipse .jdt .core .dom .MethodDeclaration ;
4244import org .eclipse .jdt .core .dom .NodeFinder ;
4345import org .eclipse .jdt .core .dom .NumberLiteral ;
@@ -72,7 +74,7 @@ class DOMCompletionContext extends CompletionContext {
7274 this .textContent = textContent ;
7375 this .offset = offset ;
7476 int adjustedOffset = this .offset ;
75- boolean isGenerated = DOMCodeSelector .isGenerated (domUnit );
77+ boolean isGenerated = DOMCompletionContext .isGenerated (domUnit );
7678 if (!isGenerated ) {
7779 if (adjustedOffset > 0 && Character .isJavaIdentifierPart (textContent .charAt (adjustedOffset - 1 ))) {
7880 // workaround for cases where right node is empty and reported (wrongly) as starting at same offset
@@ -482,4 +484,27 @@ private static boolean castCompatable(ITypeBinding typeBinding, String sig2) {
482484 }
483485 return false ;
484486 }
487+
488+ /// Checks if the node is generated
489+ /// @param node the AST node
490+ /// @return `true` if the node is generated.
491+ private static boolean isGenerated (ASTNode node ) {
492+ if (node != null ) {
493+ boolean [] isGenerated = {false };
494+ node .accept (new ASTVisitor () {
495+
496+ @ Override
497+ public void endVisit (MarkerAnnotation markerAnnotation ) {
498+ if (!isGenerated [0 ]) {
499+ // check lombok only for now
500+ isGenerated [0 ] = "lombok.Generated" .equals (markerAnnotation .getTypeName ().getFullyQualifiedName ()); //$NON-NLS-1$
501+ super .endVisit (markerAnnotation );
502+ }
503+ }
504+
505+ });
506+ return isGenerated [0 ];
507+ }
508+ return false ;
509+ }
485510}
0 commit comments