Skip to content

Commit 5d11746

Browse files
authored
Fix Unresolved type to sometimes ignore a guessed Object type binding (#2966)
* Fix Unresolved type to ignore a guessed type binding to Object - add check in UnresolvedElementsBaseSubProcessor.addSimilarTypeProposal method to ignore a guessed binding of Object for unresolved type when there are possible types to look at - fix relevance when importing and adding to module so it will be offered sooner - for eclipse-jdt/eclipse.jdt.core#5039
1 parent 17f8fa5 commit 5d11746

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsBaseSubProcessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,8 @@ private void addSimilarTypeProposals(int kind, ICompilationUnit cu, Name node, i
957957
String resolvedTypeName= null;
958958
ITypeBinding binding= ASTResolving.guessBindingForTypeReference(node);
959959
ITypeBinding simpleBinding= null;
960-
if (binding != null) {
960+
if (binding != null &&
961+
(!binding.getQualifiedName().equals("java.lang.Object") || elements.length == 0)) { //$NON-NLS-1$
961962
simpleBinding= binding;
962963
if (simpleBinding.isArray()) {
963964
simpleBinding= simpleBinding.getElementType();
@@ -1045,7 +1046,7 @@ private void addSimilarTypeProposals(int kind, ICompilationUnit cu, Name node, i
10451046
}
10461047
}
10471048
if (elements.length == 0) {
1048-
collectRequiresModuleProposals(cu, node, IProposalRelevance.IMPORT_NOT_FOUND_ADD_REQUIRES_MODULE, proposals, true);
1049+
collectRequiresModuleProposals(cu, node, IProposalRelevance.IMPORT_NOT_FOUND_ADD_REQUIRES_MODULE + 100, proposals, true);
10491050
}
10501051
}
10511052

@@ -1094,7 +1095,7 @@ private T getCompositeChangeProposal(ChangeCorrectionProposalCore proposal) thro
10941095
String moduleRequiresChangeName= change.getName();
10951096
moduleRequiresChangeName= moduleRequiresChangeName.substring(0, 1).toLowerCase() + moduleRequiresChangeName.substring(1);
10961097
String changeName= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_combine_two_proposals_info, new String[] { importChangeName, moduleRequiresChangeName });
1097-
compositeProposal= new ChangeCorrectionProposalCore(changeName, null, IProposalRelevance.IMPORT_NOT_FOUND_ADD_REQUIRES_MODULE) {
1098+
compositeProposal= new ChangeCorrectionProposalCore(changeName, null, aicpc.getRelevance()) {
10981099
@Override
10991100
protected Change createChange() throws CoreException {
11001101
return new CompositeChange(changeName, new Change[] { change, importChange });

0 commit comments

Comments
 (0)