@@ -893,8 +893,12 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour
893893 IBinding qualifiedNameBinding = qualifiedName .getQualifier ().resolveBinding ();
894894 ExtendsOrImplementsInfo info = isInExtendsOrImplements (qualifiedName );
895895 if (qualifiedNameBinding instanceof ITypeBinding qualifierTypeBinding && !qualifierTypeBinding .isRecovered ()) {
896+
897+ boolean isTypeInVariableDeclaration = isTypeInVariableDeclaration (context );
898+
896899 processMembers (qualifiedName , qualifierTypeBinding , specificCompletionBindings , true );
897- if (info == null ) {
900+ if (info == null && !isTypeInVariableDeclaration ) {
901+ this .qualifyingType = qualifierTypeBinding ;
898902 publishFromScope (specificCompletionBindings );
899903 } else {
900904 specificCompletionBindings .all () //
@@ -1522,6 +1526,26 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour
15221526 }
15231527 }
15241528 }
1529+
1530+ private boolean isTypeInVariableDeclaration (ASTNode context ) {
1531+ ASTNode cursor = context .getParent ();
1532+ ASTNode childCursor = context ;
1533+ while (cursor != null
1534+ && !(cursor instanceof FieldDeclaration )
1535+ && !(cursor instanceof VariableDeclarationStatement )
1536+ && !(cursor instanceof SingleVariableDeclaration )) {
1537+ childCursor = cursor ;
1538+ cursor = cursor .getParent ();
1539+ }
1540+ if (cursor instanceof FieldDeclaration fieldDecl ) {
1541+ return fieldDecl .getType () == childCursor ;
1542+ } else if (cursor instanceof VariableDeclarationStatement varDecl ) {
1543+ return varDecl .getType () == childCursor ;
1544+ } else if (cursor instanceof SingleVariableDeclaration varDecl ) {
1545+ return varDecl .getType () == childCursor ;
1546+ }
1547+ return false ;
1548+ }
15251549
15261550 private void suggestSuperConstructors () {
15271551 if (this .requestor .isIgnored (CompletionProposal .METHOD_REF ) || this .requestor .isIgnored (CompletionProposal .CONSTRUCTOR_INVOCATION )) {
@@ -2680,7 +2704,6 @@ private CompletionProposal toProposal(IBinding binding, String completion) {
26802704 RelevanceConstants .R_NON_RESTRICTED +
26812705 RelevanceUtils .computeRelevanceForInheritance (this .qualifyingType , binding ) +
26822706 ((insideQualifiedReference () && !staticOnly () && !Modifier .isStatic (binding .getModifiers ())) || (inJavadoc && !res .isConstructor ()) ? RelevanceConstants .R_NON_STATIC : 0 ) +
2683- (!staticOnly () || inheritedValue ? 0 : RelevanceConstants .R_NON_INHERITED ) + // TODO: when is this active?
26842707 (binding instanceof IVariableBinding field && field .isEnumConstant () ? RelevanceConstants .R_ENUM + RelevanceConstants .R_ENUM_CONSTANT : 0 )
26852708 );
26862709 if (res .getRequiredProposals () != null ) {
0 commit comments