|
43 | 43 | import org.eclipse.jdt.core.CompletionProposal; |
44 | 44 | import org.eclipse.jdt.core.CompletionRequestor; |
45 | 45 | import org.eclipse.jdt.core.Flags; |
| 46 | +import org.eclipse.jdt.core.IAccessRule; |
46 | 47 | import org.eclipse.jdt.core.IAnnotation; |
47 | 48 | import org.eclipse.jdt.core.ICompilationUnit; |
48 | 49 | import org.eclipse.jdt.core.IField; |
|
96 | 97 | import org.eclipse.jdt.core.dom.IfStatement; |
97 | 98 | import org.eclipse.jdt.core.dom.ImportDeclaration; |
98 | 99 | import org.eclipse.jdt.core.dom.InfixExpression; |
| 100 | +import org.eclipse.jdt.core.dom.InfixExpression.Operator; |
99 | 101 | import org.eclipse.jdt.core.dom.Initializer; |
100 | 102 | import org.eclipse.jdt.core.dom.InstanceofExpression; |
101 | 103 | import org.eclipse.jdt.core.dom.Javadoc; |
|
107 | 109 | import org.eclipse.jdt.core.dom.MethodInvocation; |
108 | 110 | import org.eclipse.jdt.core.dom.MethodRef; |
109 | 111 | import org.eclipse.jdt.core.dom.Modifier; |
| 112 | +import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; |
110 | 113 | import org.eclipse.jdt.core.dom.ModuleDeclaration; |
111 | 114 | import org.eclipse.jdt.core.dom.Name; |
112 | 115 | import org.eclipse.jdt.core.dom.NodeFinder; |
|
147 | 150 | import org.eclipse.jdt.core.dom.VariableDeclarationFragment; |
148 | 151 | import org.eclipse.jdt.core.dom.VariableDeclarationStatement; |
149 | 152 | import org.eclipse.jdt.core.dom.WhileStatement; |
150 | | -import org.eclipse.jdt.core.dom.InfixExpression.Operator; |
151 | | -import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; |
152 | 153 | import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; |
153 | 154 | import org.eclipse.jdt.core.search.IJavaSearchConstants; |
154 | 155 | import org.eclipse.jdt.core.search.IJavaSearchScope; |
@@ -814,15 +815,15 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
814 | 815 | if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
815 | 816 | findTypes(this.prefix, null) |
816 | 817 | // don't care about annotations |
817 | | - .filter(type -> { |
| 818 | + .filter(typeMatch -> { |
818 | 819 | try { |
819 | | - return !type.isAnnotation(); |
| 820 | + return !typeMatch.getType().isAnnotation(); |
820 | 821 | } catch (JavaModelException e) { |
821 | 822 | return true; |
822 | 823 | } |
823 | | - }).filter(type -> defaultCompletionBindings.all().map(typeBinding -> typeBinding.getJavaElement()).noneMatch(elt -> type.equals(elt))) |
824 | | - .filter(type -> this.pattern.matchesName(this.prefix.toCharArray(), type.getElementName().toCharArray())) |
825 | | - .filter(type -> filterBasedOnExtendsOrImplementsInfo(type, this.extendsOrImplementsInfo)) |
| 824 | + }).filter(typeMatch -> defaultCompletionBindings.all().map(typeBinding -> typeBinding.getJavaElement()).noneMatch(elt -> typeMatch.getType().equals(elt))) |
| 825 | + .filter(typeMatch -> this.pattern.matchesName(this.prefix.toCharArray(), typeMatch.getType().getElementName().toCharArray())) |
| 826 | + .filter(typeMatch -> filterBasedOnExtendsOrImplementsInfo(typeMatch.getType(), this.extendsOrImplementsInfo)) |
826 | 827 | .map(this::toProposal) |
827 | 828 | .forEach(this.requestor::accept); |
828 | 829 | } |
@@ -936,13 +937,13 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
936 | 937 | if (context.getParent() instanceof SimpleType simpleType && simpleType.getParent() instanceof MethodDeclaration |
937 | 938 | && simpleType.getLocationInParent().getId().equals(MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY.getId())) { |
938 | 939 | findTypes(completeAfter, null) |
939 | | - .filter(type -> this.pattern.matchesName(this.prefix.toCharArray(), |
940 | | - type.getElementName().toCharArray())) |
| 940 | + .filter(typeMatch -> this.pattern.matchesName(this.prefix.toCharArray(), |
| 941 | + typeMatch.getType().getElementName().toCharArray())) |
941 | 942 | // ideally we should filter out all classes that don't descend from Throwable |
942 | 943 | // however JDT doesn't do this yet from what I can tell |
943 | | - .filter(type -> { |
| 944 | + .filter(typeMatch -> { |
944 | 945 | try { |
945 | | - return !type.isAnnotation() && !type.isInterface(); |
| 946 | + return !typeMatch.getType().isAnnotation() && !typeMatch.getType().isInterface(); |
946 | 947 | } catch (JavaModelException e) { |
947 | 948 | return true; |
948 | 949 | } |
@@ -1003,8 +1004,7 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
1003 | 1004 | topLevelTypes(typeCompletionBindings); |
1004 | 1005 | typeCompletionBindings.all() |
1005 | 1006 | .filter(ITypeBinding.class::isInstance) |
1006 | | - .map(typeBinding -> (IType)typeBinding.getJavaElement()) |
1007 | | - .filter(type -> filterBasedOnExtendsOrImplementsInfo(type, this.extendsOrImplementsInfo)) |
| 1007 | + .filter(typeBinding -> filterBasedOnExtendsOrImplementsInfo((IType) typeBinding.getJavaElement(), this.extendsOrImplementsInfo)) |
1008 | 1008 | .map(this::toProposal) |
1009 | 1009 | .forEach(this.requestor::accept); |
1010 | 1010 | } else { |
@@ -1260,7 +1260,7 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
1260 | 1260 | publishFromScope(specificCompletionBindings); |
1261 | 1261 | } else { |
1262 | 1262 | // UnimportedType.| |
1263 | | - List<IType> foundTypes = findTypes(qualifiedName.getQualifier().toString(), null).toList(); |
| 1263 | + List<IType> foundTypes = findTypes(qualifiedName.getQualifier().toString(), null).map(TypeNameMatch::getType).toList(); |
1264 | 1264 | // HACK: We requested exact matches from the search engine but some results aren't exact |
1265 | 1265 | foundTypes = foundTypes.stream().filter(type -> type.getElementName().equals(qualifiedName.getQualifier().toString())).toList(); |
1266 | 1266 | if (!foundTypes.isEmpty()) { |
@@ -1391,18 +1391,18 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
1391 | 1391 | packageName = packageDecl.getName().toString(); |
1392 | 1392 | } |
1393 | 1393 | this.findTypes(this.prefix, packageName) |
1394 | | - .filter(type -> { |
| 1394 | + .filter(typeMatch -> { |
1395 | 1395 | try { |
1396 | | - return !type.isAnnotation(); |
| 1396 | + return !typeMatch.getType().isAnnotation(); |
1397 | 1397 | } catch (JavaModelException e) { |
1398 | 1398 | return true; |
1399 | 1399 | } |
1400 | 1400 | }) // |
1401 | | - .flatMap(type -> { |
| 1401 | + .flatMap(typeMatch -> { |
1402 | 1402 | if (this.prefix.isEmpty()) { |
1403 | | - return Stream.of(toProposal(type)); |
| 1403 | + return Stream.of(toProposal(typeMatch.getType())); |
1404 | 1404 | } else { |
1405 | | - return toConstructorProposals(type, this.toComplete, false).stream(); |
| 1405 | + return toConstructorProposals(typeMatch.getType(), this.toComplete, false).stream(); |
1406 | 1406 | } |
1407 | 1407 | }) // |
1408 | 1408 | .forEach(this.requestor::accept); |
@@ -1532,7 +1532,7 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
1532 | 1532 | packageName = ""; //$NON-NLS-1$ |
1533 | 1533 | } |
1534 | 1534 | } |
1535 | | - List<IType> potentialTypes = findTypes(classToComplete, packageName).toList(); |
| 1535 | + List<IType> potentialTypes = findTypes(classToComplete, packageName).map(TypeNameMatch::getType).toList(); |
1536 | 1536 | List<IType> sourceTypes = potentialTypes.stream().filter(type -> type instanceof SourceType).toList(); |
1537 | 1537 | if (!potentialTypes.isEmpty()) { |
1538 | 1538 | IType typeToComplete; |
@@ -1582,10 +1582,10 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
1582 | 1582 | .map(this::toProposal).forEach(this.requestor::accept); |
1583 | 1583 |
|
1584 | 1584 | findTypes(completeAfter, completeAfter.equals(this.qualifiedPrefix) ? null : this.qualifiedPrefix) |
1585 | | - .filter(type -> { |
1586 | | - return localTypeBindings.all().map(typeBinding -> typeBinding.getJavaElement()).noneMatch(elt -> type.equals(elt)); |
| 1585 | + .filter(typeMatch -> { |
| 1586 | + return localTypeBindings.all().map(typeBinding -> typeBinding.getJavaElement()).noneMatch(elt -> typeMatch.getType().equals(elt)); |
1587 | 1587 | }) |
1588 | | - .filter(type -> this.pattern.matchesName(this.prefix.toCharArray(), type.getElementName().toCharArray())) |
| 1588 | + .filter(typeMatch -> this.pattern.matchesName(this.prefix.toCharArray(), typeMatch.getType().getElementName().toCharArray())) |
1589 | 1589 | .map(this::toProposal).forEach(this.requestor::accept); |
1590 | 1590 |
|
1591 | 1591 | suggestDefaultCompletions = false; |
@@ -1708,7 +1708,7 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
1708 | 1708 | packageName = ""; //$NON-NLS-1$ |
1709 | 1709 | } |
1710 | 1710 | } |
1711 | | - List<IType> potentialTypes = findTypes(classToComplete, packageName).toList(); |
| 1711 | + List<IType> potentialTypes = findTypes(classToComplete, packageName).map(TypeNameMatch::getType).toList(); |
1712 | 1712 | List<IType> sourceTypes = potentialTypes.stream().filter(type -> type instanceof SourceType).toList(); |
1713 | 1713 | if (!potentialTypes.isEmpty()) { |
1714 | 1714 | IType typeToComplete; |
@@ -1861,31 +1861,31 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
1861 | 1861 | AbstractTypeDeclaration typeDecl = DOMCompletionUtil.findParentTypeDeclaration(context); |
1862 | 1862 | ITypeBinding currentTypeBinding = typeDecl == null ? null : typeDecl.resolveBinding(); |
1863 | 1863 | findTypes(completeAfter, null) |
1864 | | - .filter(type -> this.pattern.matchesName(this.prefix.toCharArray(), |
1865 | | - type.getElementName().toCharArray())) |
1866 | | - .filter(type -> { |
| 1864 | + .filter(typeMatch -> this.pattern.matchesName(this.prefix.toCharArray(), |
| 1865 | + typeMatch.getType().getElementName().toCharArray())) |
| 1866 | + .filter(typeMatch -> { |
1867 | 1867 | for (var scrapedBinding : catchExceptionBindings.all().toList()) { |
1868 | 1868 | if (scrapedBinding instanceof ITypeBinding scrapedTypeBinding) { |
1869 | | - if (type.equals(scrapedTypeBinding.getJavaElement()) || type.getKey().equals(scrapedTypeBinding.getKey())) { |
| 1869 | + if (typeMatch.getType().equals(scrapedTypeBinding.getJavaElement()) || typeMatch.getType().getKey().equals(scrapedTypeBinding.getKey())) { |
1870 | 1870 | return false; |
1871 | 1871 | } |
1872 | 1872 | } |
1873 | 1873 | } |
1874 | 1874 | return true; |
1875 | 1875 | }) |
1876 | | - .filter(type -> { |
| 1876 | + .filter(typeMatch -> { |
1877 | 1877 | for (ITypeBinding caughtException : thrownExceptionFinder.getAlreadyCaughtExceptions()) { |
1878 | | - if (type.getKey().equals(caughtException.getKey())) { |
| 1878 | + if (typeMatch.getType().getKey().equals(caughtException.getKey())) { |
1879 | 1879 | return false; |
1880 | 1880 | } |
1881 | 1881 | } |
1882 | 1882 | return true; |
1883 | 1883 | }) |
1884 | | - .filter(type -> { |
1885 | | - if (alreadySuggestedFqn.contains(type.getFullyQualifiedName())) { |
| 1884 | + .filter(typeMatch -> { |
| 1885 | + if (alreadySuggestedFqn.contains(typeMatch.getType().getFullyQualifiedName())) { |
1886 | 1886 | return false; |
1887 | 1887 | } |
1888 | | - alreadySuggestedFqn.add(type.getFullyQualifiedName()); |
| 1888 | + alreadySuggestedFqn.add(typeMatch.getType().getFullyQualifiedName()); |
1889 | 1889 | return true; |
1890 | 1890 | }) |
1891 | 1891 | .map(this::toProposal).forEach(this.requestor::accept); |
@@ -2072,22 +2072,22 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
2072 | 2072 | if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
2073 | 2073 | final Set<String> alreadySuggestedFqn = ConcurrentHashMap.newKeySet(); |
2074 | 2074 | findTypes(completeAfter, -1, typeMatchRule, null) |
2075 | | - .filter(type -> this.pattern.matchesName(this.prefix.toCharArray(), type.getElementName().toCharArray())) |
2076 | | - .filter(type -> { |
| 2075 | + .filter(typeMatch -> this.pattern.matchesName(this.prefix.toCharArray(), typeMatch.getType().getElementName().toCharArray())) |
| 2076 | + .filter(typeMatch -> { |
2077 | 2077 | for (var scrapedBinding : defaultCompletionBindings.all().toList()) { |
2078 | 2078 | if (scrapedBinding instanceof ITypeBinding scrapedTypeBinding) { |
2079 | | - if (type.equals(scrapedTypeBinding.getJavaElement()) || type.getKey().equals(scrapedTypeBinding.getKey())) { |
| 2079 | + if (typeMatch.getType().equals(scrapedTypeBinding.getJavaElement()) || typeMatch.getType().getKey().equals(scrapedTypeBinding.getKey())) { |
2080 | 2080 | return false; |
2081 | 2081 | } |
2082 | 2082 | } |
2083 | 2083 | } |
2084 | 2084 | return true; |
2085 | | - }).filter(type -> filterBasedOnExtendsOrImplementsInfo(type, this.extendsOrImplementsInfo)) |
2086 | | - .filter(type -> { |
2087 | | - if (alreadySuggestedFqn.contains(type.getFullyQualifiedName())) { |
| 2085 | + }).filter(typeMatch -> filterBasedOnExtendsOrImplementsInfo(typeMatch.getType(), this.extendsOrImplementsInfo)) |
| 2086 | + .filter(typeMatch -> { |
| 2087 | + if (alreadySuggestedFqn.contains(typeMatch.getType().getFullyQualifiedName())) { |
2088 | 2088 | return false; |
2089 | 2089 | } |
2090 | | - alreadySuggestedFqn.add(type.getFullyQualifiedName()); |
| 2090 | + alreadySuggestedFqn.add(typeMatch.getType().getFullyQualifiedName()); |
2091 | 2091 | return true; |
2092 | 2092 | }).map(this::toProposal) |
2093 | 2093 | .forEach(this.requestor::accept); |
@@ -2887,13 +2887,19 @@ private void scrapeAccessibleBindings(Bindings scope) { |
2887 | 2887 | favouriteReference = favouriteReference.substring(0, favouriteReference.length() - 2); |
2888 | 2888 | String packageName = favouriteReference.indexOf('.') < 0 ? "" : favouriteReference.substring(0, favouriteReference.lastIndexOf('.')); //$NON-NLS-1$ |
2889 | 2889 | String typeName = favouriteReference.indexOf('.') < 0 ? favouriteReference : favouriteReference.substring(favouriteReference.lastIndexOf('.') + 1); |
2890 | | - findTypes(typeName, SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE, packageName).filter(type -> type.getElementName().equals(typeName)).forEach(keysToResolve::add); |
| 2890 | + findTypes(typeName, SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE, packageName) // |
| 2891 | + .map(TypeNameMatch::getType) |
| 2892 | + .filter(type -> type.getElementName().equals(typeName)) |
| 2893 | + .forEach(keysToResolve::add); |
2891 | 2894 | } else if (favouriteReference.lastIndexOf('.') >= 0) { |
2892 | 2895 | String memberName = favouriteReference.substring(favouriteReference.lastIndexOf('.') + 1); |
2893 | 2896 | String typeFqn = favouriteReference.substring(0, favouriteReference.lastIndexOf('.')); |
2894 | 2897 | String packageName = typeFqn.indexOf('.') < 0 ? "" : typeFqn.substring(0, typeFqn.lastIndexOf('.')); //$NON-NLS-1$ |
2895 | 2898 | String typeName = typeFqn.indexOf('.') < 0 ? typeFqn : typeFqn.substring(typeFqn.lastIndexOf('.') + 1); |
2896 | | - findTypes(typeName, SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE, packageName).filter(type -> type.getElementName().equals(typeName)).findFirst().ifPresent(type -> { |
| 2899 | + findTypes(typeName, SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE, packageName) // |
| 2900 | + .map(TypeNameMatch::getType) |
| 2901 | + .filter(type -> type.getElementName().equals(typeName)) // |
| 2902 | + .findFirst().ifPresent(type -> { |
2897 | 2903 | try { |
2898 | 2904 | for (IMethod method : type.getMethods()) { |
2899 | 2905 | if (method.exists() && (method.getFlags() & Flags.AccStatic) != 0 && memberName.equals(method.getElementName())) { |
@@ -3181,11 +3187,11 @@ private void suggestPackages(ASTNode context) { |
3181 | 3187 |
|
3182 | 3188 | private void suggestTypesInPackage(String packageName) { |
3183 | 3189 | if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
3184 | | - List<IType> foundTypes = findTypes(this.prefix, packageName).toList(); |
| 3190 | + List<TypeNameMatch> foundTypes = findTypes(this.prefix, packageName).toList(); |
3185 | 3191 | AbstractTypeDeclaration typeDecl = DOMCompletionUtil.findParentTypeDeclaration(this.toComplete); |
3186 | | - for (IType foundType : foundTypes) { |
3187 | | - if (this.pattern.matchesName(this.prefix.toCharArray(), foundType.getElementName().toCharArray())) { |
3188 | | - if (filterBasedOnExtendsOrImplementsInfo(foundType, this.extendsOrImplementsInfo)) { |
| 3192 | + for (TypeNameMatch foundType : foundTypes) { |
| 3193 | + if (this.pattern.matchesName(this.prefix.toCharArray(), foundType.getType().getElementName().toCharArray())) { |
| 3194 | + if (filterBasedOnExtendsOrImplementsInfo(foundType.getType(), this.extendsOrImplementsInfo)) { |
3189 | 3195 | this.requestor.accept(this.toProposal(foundType)); |
3190 | 3196 | } |
3191 | 3197 | } |
@@ -3340,8 +3346,8 @@ private static boolean extendsOrImplementsGivenType(TypeDeclaration typeDecl, IT |
3340 | 3346 |
|
3341 | 3347 | private void completeMarkerAnnotation(String completeAfter) { |
3342 | 3348 | findTypes(completeAfter, -1, IJavaSearchConstants.ANNOTATION_TYPE, null) |
3343 | | - .filter(type -> this.pattern.matchesName(this.prefix.toCharArray(), |
3344 | | - type.getElementName().toCharArray())) |
| 3349 | + .filter(typeMatch -> this.pattern.matchesName(this.prefix.toCharArray(), |
| 3350 | + typeMatch.getType().getElementName().toCharArray())) |
3345 | 3351 | .map(this::toProposal).forEach(this.requestor::accept); |
3346 | 3352 | } |
3347 | 3353 |
|
@@ -3525,24 +3531,34 @@ private void findOverridableMethods0(ITypeBinding currentType, ITypeBinding type |
3525 | 3531 | } |
3526 | 3532 | } |
3527 | 3533 |
|
3528 | | - private Stream<IType> findTypes(String namePrefix, String packageName) { |
| 3534 | + private Stream<TypeNameMatch> findTypes(String namePrefix, String packageName) { |
3529 | 3535 | return findTypes(namePrefix, -1, IJavaSearchConstants.TYPE, packageName); |
3530 | 3536 | } |
3531 | 3537 |
|
3532 | | - private Stream<IType> findTypes(String namePrefix, int typeMatchRule, int searchFor, String packageName) { |
| 3538 | + private Stream<TypeNameMatch> findTypes(String namePrefix, int typeMatchRule, int searchFor, String packageName) { |
3533 | 3539 | if (namePrefix == null) { |
3534 | 3540 | namePrefix = ""; //$NON-NLS-1$ |
3535 | 3541 | } |
3536 | | - List<IType> types = new ArrayList<>(); |
| 3542 | + List<TypeNameMatch> types = new ArrayList<>(); |
3537 | 3543 | var searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { this.javaProject }); |
3538 | 3544 | TypeNameMatchRequestor typeRequestor = new TypeNameMatchRequestor() { |
3539 | 3545 | @Override |
3540 | | - public void acceptTypeNameMatch(org.eclipse.jdt.core.search.TypeNameMatch match) { |
| 3546 | + public void acceptTypeNameMatch(TypeNameMatch match) { |
3541 | 3547 | if (isVisible(match)) { |
3542 | | - types.add(match.getType()); |
| 3548 | + types.add(match); |
3543 | 3549 | } |
3544 | 3550 | } |
3545 | 3551 | private boolean isVisible(TypeNameMatch match) { |
| 3552 | + if (!DOMCompletionEngine.this.settings.get(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE).equals(JavaCore.IGNORE) |
| 3553 | + && DOMCompletionEngine.this.assistOptions.checkForbiddenReference |
| 3554 | + && match.getAccessibility() == IAccessRule.K_NON_ACCESSIBLE) { |
| 3555 | + return false; |
| 3556 | + } |
| 3557 | + if (!DOMCompletionEngine.this.settings.get(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE).equals(JavaCore.IGNORE) |
| 3558 | + && DOMCompletionEngine.this.assistOptions.checkDiscouragedReference |
| 3559 | + && match.getAccessibility() == IAccessRule.K_DISCOURAGED) { |
| 3560 | + return false; |
| 3561 | + } |
3546 | 3562 | if (match.getPackageName().isEmpty() && !currentTypeBinding().getPackage().getName().isEmpty()) { |
3547 | 3563 | // can only access classes in the default package from the default package |
3548 | 3564 | return false; |
@@ -3793,7 +3809,7 @@ private CompletionProposal toProposal(IBinding binding) { |
3793 | 3809 |
|
3794 | 3810 | private CompletionProposal toProposal(IBinding binding, String completion) { |
3795 | 3811 | if (binding instanceof ITypeBinding && binding.getJavaElement() instanceof IType type) { |
3796 | | - return toProposal(type); |
| 3812 | + return toProposal(type, IAccessRule.K_ACCESSIBLE); |
3797 | 3813 | } |
3798 | 3814 |
|
3799 | 3815 | int kind = -1; |
@@ -4066,8 +4082,12 @@ private String qualifiedTypeName(ITypeBinding typeBinding) { |
4066 | 4082 | return typeBinding.getQualifiedName(); |
4067 | 4083 | } |
4068 | 4084 | } |
| 4085 | + |
| 4086 | + private CompletionProposal toProposal(TypeNameMatch typeNameMatch) { |
| 4087 | + return toProposal(typeNameMatch.getType(), typeNameMatch.getAccessibility()); |
| 4088 | + } |
4069 | 4089 |
|
4070 | | - private CompletionProposal toProposal(IType type) { |
| 4090 | + private CompletionProposal toProposal(IType type, int access) { |
4071 | 4091 | DOMInternalCompletionProposal res = createProposal(CompletionProposal.TYPE_REF); |
4072 | 4092 | char[] simpleName = type.getElementName().toCharArray(); |
4073 | 4093 | char[] signature = SignatureUtils.createSignature(type).toCharArray(); |
@@ -4177,7 +4197,7 @@ private CompletionProposal toProposal(IType type) { |
4177 | 4197 | int relevance = RelevanceConstants.R_DEFAULT |
4178 | 4198 | + RelevanceConstants.R_RESOLVED |
4179 | 4199 | + RelevanceUtils.computeRelevanceForInteresting(type, expectedTypes) |
4180 | | - + RelevanceConstants.R_NON_RESTRICTED |
| 4200 | + + RelevanceUtils.computeRelevanceForRestrictions(access, this.settings) |
4181 | 4201 | + (inCatchClause && DOMCompletionUtil.findInSupers(type, "Ljava/lang/Exception;", this.workingCopyOwner, this.typeHierarchyCache) ? RelevanceConstants.R_EXCEPTION : 0) |
4182 | 4202 | + RelevanceUtils.computeRelevanceForInheritance(this.qualifyingType, type) |
4183 | 4203 | + RelevanceUtils.computeRelevanceForQualification(!"java.lang".equals(type.getPackageFragment().getElementName()) && !nodeInImports && !fromCurrentCU && !inSamePackage && !typeIsImported, this.prefix, this.qualifiedPrefix) |
@@ -4266,7 +4286,7 @@ private CompletionProposal toSuperConstructorProposal(IMethodBinding superConstr |
4266 | 4286 |
|
4267 | 4287 | private CompletionProposal toProposal(IJavaElement element) { |
4268 | 4288 | if (element instanceof IType type) { |
4269 | | - return toProposal(type); |
| 4289 | + return toProposal(type, IAccessRule.K_ACCESSIBLE); |
4270 | 4290 | } |
4271 | 4291 | DOMInternalCompletionProposal res = null; |
4272 | 4292 | IType parentType = (IType)element.getAncestor(IJavaElement.TYPE); |
|
0 commit comments