Lines 438-444
Link Here
|
438 |
acceptedTypes.add(new AcceptedType(packageName, simpleTypeName, enclosingTypeNames, modifiers, accessibility)); |
438 |
acceptedTypes.add(new AcceptedType(packageName, simpleTypeName, enclosingTypeNames, modifiers, accessibility)); |
439 |
} |
439 |
} |
440 |
|
440 |
|
441 |
private void acceptTypes(Scope scope) { |
441 |
private void acceptTypes(boolean proposeConstructor, InvocationSite invocationSite, Scope scope) { |
442 |
if(this.acceptedTypes == null) return; |
442 |
if(this.acceptedTypes == null) return; |
443 |
|
443 |
|
444 |
int length = this.acceptedTypes.size(); |
444 |
int length = this.acceptedTypes.size(); |
Lines 515-520
Link Here
|
515 |
typeName, |
515 |
typeName, |
516 |
fullyQualifiedName, |
516 |
fullyQualifiedName, |
517 |
!CharOperation.equals(fullyQualifiedName, importName[1]), |
517 |
!CharOperation.equals(fullyQualifiedName, importName[1]), |
|
|
518 |
proposeConstructor, |
519 |
invocationSite, |
518 |
scope); |
520 |
scope); |
519 |
continue next; |
521 |
continue next; |
520 |
} |
522 |
} |
Lines 530-535
Link Here
|
530 |
typeName, |
532 |
typeName, |
531 |
fullyQualifiedName, |
533 |
fullyQualifiedName, |
532 |
false, |
534 |
false, |
|
|
535 |
proposeConstructor, |
536 |
invocationSite, |
533 |
scope); |
537 |
scope); |
534 |
continue next; |
538 |
continue next; |
535 |
} else { |
539 |
} else { |
Lines 615-620
Link Here
|
615 |
typeName, |
619 |
typeName, |
616 |
fullyQualifiedName, |
620 |
fullyQualifiedName, |
617 |
true, |
621 |
true, |
|
|
622 |
proposeConstructor, |
623 |
invocationSite, |
618 |
scope); |
624 |
scope); |
619 |
} |
625 |
} |
620 |
} |
626 |
} |
Lines 634-639
Link Here
|
634 |
value.qualifiedTypeName, |
640 |
value.qualifiedTypeName, |
635 |
value.fullyQualifiedName, |
641 |
value.fullyQualifiedName, |
636 |
value.mustBeQualified, |
642 |
value.mustBeQualified, |
|
|
643 |
proposeConstructor, |
644 |
invocationSite, |
637 |
scope); |
645 |
scope); |
638 |
} |
646 |
} |
639 |
} |
647 |
} |
Lines 697-703
Link Here
|
697 |
return true; |
705 |
return true; |
698 |
} |
706 |
} |
699 |
|
707 |
|
700 |
private void proposeType(char[] packageName, char[] simpleTypeName, int modifiers, int accessibility, char[] typeName, char[] fullyQualifiedName, boolean isQualified, Scope scope) { |
708 |
private void proposeType( |
|
|
709 |
char[] packageName, |
710 |
char[] simpleTypeName, |
711 |
int modifiers, |
712 |
int accessibility, |
713 |
char[] typeName, |
714 |
char[] fullyQualifiedName, |
715 |
boolean isQualified, |
716 |
boolean proposeConstructor, |
717 |
InvocationSite invocationSite, |
718 |
Scope scope) { |
701 |
char[] completionName = fullyQualifiedName; |
719 |
char[] completionName = fullyQualifiedName; |
702 |
if(isQualified) { |
720 |
if(isQualified) { |
703 |
if (packageName == null || packageName.length == 0) |
721 |
if (packageName == null || packageName.length == 0) |
Lines 707-713
Link Here
|
707 |
completionName = simpleTypeName; |
725 |
completionName = simpleTypeName; |
708 |
} |
726 |
} |
709 |
|
727 |
|
710 |
TypeBinding guessedType = null; |
728 |
TypeBinding guessedAnnotationType = null; |
711 |
if ((modifiers & ClassFileConstants.AccAnnotation) != 0 && |
729 |
if ((modifiers & ClassFileConstants.AccAnnotation) != 0 && |
712 |
this.assistNodeIsAnnotation && |
730 |
this.assistNodeIsAnnotation && |
713 |
(this.targetedElement & TagBits.AnnotationTargetMASK) != 0) { |
731 |
(this.targetedElement & TagBits.AnnotationTargetMASK) != 0) { |
Lines 723-738
Link Here
|
723 |
switch (scope.kind) { |
741 |
switch (scope.kind) { |
724 |
case Scope.METHOD_SCOPE : |
742 |
case Scope.METHOD_SCOPE : |
725 |
case Scope.BLOCK_SCOPE : |
743 |
case Scope.BLOCK_SCOPE : |
726 |
guessedType = ref.resolveType((BlockScope)scope); |
744 |
guessedAnnotationType = ref.resolveType((BlockScope)scope); |
727 |
break; |
745 |
break; |
728 |
case Scope.CLASS_SCOPE : |
746 |
case Scope.CLASS_SCOPE : |
729 |
guessedType = ref.resolveType((ClassScope)scope); |
747 |
guessedAnnotationType = ref.resolveType((ClassScope)scope); |
730 |
break; |
748 |
break; |
731 |
} |
749 |
} |
732 |
|
750 |
|
733 |
if (!guessedType.isValidBinding()) return; |
751 |
if (!guessedAnnotationType.isValidBinding()) return; |
734 |
|
752 |
|
735 |
if (!hasPossibleAnnotationTarget(guessedType, scope)) return; |
753 |
if (!hasPossibleAnnotationTarget(guessedAnnotationType, scope)) return; |
736 |
} |
754 |
} |
737 |
|
755 |
|
738 |
int relevance = computeBaseRelevance(); |
756 |
int relevance = computeBaseRelevance(); |
Lines 748-754
Link Here
|
748 |
case ClassFileConstants.AccAnnotation: |
766 |
case ClassFileConstants.AccAnnotation: |
749 |
case ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface: |
767 |
case ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface: |
750 |
relevance += computeRelevanceForAnnotation(); |
768 |
relevance += computeRelevanceForAnnotation(); |
751 |
if (guessedType != null) relevance += computeRelevanceForAnnotationTarget(guessedType); |
769 |
if (guessedAnnotationType != null) relevance += computeRelevanceForAnnotationTarget(guessedAnnotationType); |
752 |
relevance += computeRelevanceForInterface(); |
770 |
relevance += computeRelevanceForInterface(); |
753 |
break; |
771 |
break; |
754 |
case ClassFileConstants.AccEnum: |
772 |
case ClassFileConstants.AccEnum: |
Lines 767-772
Link Here
|
767 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
785 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
768 |
createTypeProposal(packageName, typeName, modifiers, accessibility, completionName, relevance); |
786 |
createTypeProposal(packageName, typeName, modifiers, accessibility, completionName, relevance); |
769 |
} |
787 |
} |
|
|
788 |
|
789 |
if (proposeConstructor && CharOperation.equals(this.completionToken, simpleTypeName)) { |
790 |
char[][] compoundName = CharOperation.splitOn('.', fullyQualifiedName); |
791 |
TypeReference convertedType; |
792 |
if (compoundName.length == 1) { |
793 |
convertedType = new SingleTypeReference(compoundName[0], 0); |
794 |
} else { |
795 |
convertedType = new QualifiedTypeReference(compoundName, new long[compoundName.length]); |
796 |
} |
797 |
|
798 |
this.problemFactory.startCheckingProblems(); |
799 |
TypeBinding guessedType = null; |
800 |
switch (scope.kind) { |
801 |
case Scope.METHOD_SCOPE : |
802 |
case Scope.BLOCK_SCOPE : |
803 |
guessedType = convertedType.resolveType((BlockScope)scope); |
804 |
break; |
805 |
case Scope.CLASS_SCOPE : |
806 |
guessedType = convertedType.resolveType((ClassScope)scope); |
807 |
break; |
808 |
} |
809 |
this.problemFactory.stopCheckingProblems(); |
810 |
if (!this.problemFactory.hasForbiddenProblems && |
811 |
guessedType != null && |
812 |
guessedType instanceof ReferenceBinding && |
813 |
!guessedType.isTypeVariable()) { |
814 |
|
815 |
TypeBinding erasure = guessedType.erasure(); |
816 |
|
817 |
findConstructors( |
818 |
(ReferenceBinding)erasure, |
819 |
null, |
820 |
scope, |
821 |
invocationSite, |
822 |
false, |
823 |
true, |
824 |
isQualified); |
825 |
} |
826 |
} |
770 |
} |
827 |
} |
771 |
|
828 |
|
772 |
/** |
829 |
/** |
Lines 900-906
Link Here
|
900 |
this.completionToken = type.token; |
957 |
this.completionToken = type.token; |
901 |
setSourceRange(type.sourceStart, type.sourceEnd); |
958 |
setSourceRange(type.sourceStart, type.sourceEnd); |
902 |
|
959 |
|
903 |
findTypesAndPackages(this.completionToken, scope, new ObjectVector()); |
960 |
findTypesAndPackages(this.completionToken, scope, null, new ObjectVector()); |
904 |
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
961 |
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
905 |
findKeywordsForMember(this.completionToken, field.modifiers); |
962 |
findKeywordsForMember(this.completionToken, field.modifiers); |
906 |
} |
963 |
} |
Lines 922-928
Link Here
|
922 |
SingleTypeReference type = (CompletionOnSingleTypeReference) method.returnType; |
979 |
SingleTypeReference type = (CompletionOnSingleTypeReference) method.returnType; |
923 |
this.completionToken = type.token; |
980 |
this.completionToken = type.token; |
924 |
setSourceRange(type.sourceStart, type.sourceEnd); |
981 |
setSourceRange(type.sourceStart, type.sourceEnd); |
925 |
findTypesAndPackages(this.completionToken, scope.parent, new ObjectVector()); |
982 |
findTypesAndPackages(this.completionToken, scope.parent, null, new ObjectVector()); |
926 |
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
983 |
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
927 |
findKeywordsForMember(this.completionToken, method.modifiers); |
984 |
findKeywordsForMember(this.completionToken, method.modifiers); |
928 |
} |
985 |
} |
Lines 951-957
Link Here
|
951 |
this.findEnumConstant(this.completionToken, (SwitchStatement) astNodeParent); |
1008 |
this.findEnumConstant(this.completionToken, (SwitchStatement) astNodeParent); |
952 |
} |
1009 |
} |
953 |
} else if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) { |
1010 |
} else if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) { |
954 |
findTypesAndPackages(this.completionToken, scope, new ObjectVector()); |
1011 |
findTypesAndPackages(this.completionToken, scope, null, new ObjectVector()); |
955 |
} else { |
1012 |
} else { |
956 |
if (scope instanceof BlockScope && !this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) { |
1013 |
if (scope instanceof BlockScope && !this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) { |
957 |
char[][] alreadyDefinedName = computeAlreadyDefinedName((BlockScope)scope, singleNameReference); |
1014 |
char[][] alreadyDefinedName = computeAlreadyDefinedName((BlockScope)scope, singleNameReference); |
Lines 970-976
Link Here
|
970 |
insideTypeAnnotation, |
1027 |
insideTypeAnnotation, |
971 |
singleNameReference.isInsideAnnotationAttribute); |
1028 |
singleNameReference.isInsideAnnotationAttribute); |
972 |
// can be the start of a qualified type name |
1029 |
// can be the start of a qualified type name |
973 |
findTypesAndPackages(this.completionToken, scope, new ObjectVector()); |
1030 |
findTypesAndPackages(this.completionToken, scope, null, new ObjectVector()); |
974 |
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
1031 |
if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
975 |
if (this.completionToken != null && this.completionToken.length != 0) { |
1032 |
if (this.completionToken != null && this.completionToken.length != 0) { |
976 |
findKeywords(this.completionToken, singleNameReference.possibleKeywords, false, false); |
1033 |
findKeywords(this.completionToken, singleNameReference.possibleKeywords, false, false); |
Lines 1019-1025
Link Here
|
1019 |
(BlockScope)scope, |
1076 |
(BlockScope)scope, |
1020 |
typesFound); |
1077 |
typesFound); |
1021 |
} |
1078 |
} |
1022 |
findTypesAndPackages(this.completionToken, scope, typesFound); |
1079 |
findTypesAndPackages( |
|
|
1080 |
this.completionToken, |
1081 |
scope, |
1082 |
this.assistNodeIsConstructor ? FakeInvocationSite : null, |
1083 |
typesFound); |
1023 |
} |
1084 |
} |
1024 |
} else if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
1085 |
} else if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
1025 |
findMemberTypes( |
1086 |
findMemberTypes( |
Lines 1032-1037
Link Here
|
1032 |
false, |
1093 |
false, |
1033 |
false, |
1094 |
false, |
1034 |
!this.assistNodeIsConstructor, |
1095 |
!this.assistNodeIsConstructor, |
|
|
1096 |
false, |
1097 |
null, |
1035 |
null, |
1098 |
null, |
1036 |
new ObjectVector()); |
1099 |
new ObjectVector()); |
1037 |
} |
1100 |
} |
Lines 1322-1327
Link Here
|
1322 |
argTypes, |
1385 |
argTypes, |
1323 |
scope, |
1386 |
scope, |
1324 |
constructorCall, |
1387 |
constructorCall, |
|
|
1388 |
false, |
1389 |
false, |
1325 |
false); |
1390 |
false); |
1326 |
} |
1391 |
} |
1327 |
} else if (astNode instanceof CompletionOnQualifiedAllocationExpression) { |
1392 |
} else if (astNode instanceof CompletionOnQualifiedAllocationExpression) { |
Lines 1340-1345
Link Here
|
1340 |
argTypes, |
1405 |
argTypes, |
1341 |
scope, |
1406 |
scope, |
1342 |
allocExpression, |
1407 |
allocExpression, |
|
|
1408 |
false, |
1409 |
false, |
1343 |
false); |
1410 |
false); |
1344 |
} |
1411 |
} |
1345 |
if (!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION) |
1412 |
if (!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION) |
Lines 1479-1485
Link Here
|
1479 |
this.completionToken = type.token; |
1546 |
this.completionToken = type.token; |
1480 |
setSourceRange(type.sourceStart, type.sourceEnd); |
1547 |
setSourceRange(type.sourceStart, type.sourceEnd); |
1481 |
|
1548 |
|
1482 |
findTypesAndPackages(this.completionToken, scope, new ObjectVector()); |
1549 |
findTypesAndPackages(this.completionToken, scope, null, new ObjectVector()); |
1483 |
} else if (annot.type instanceof CompletionOnQualifiedTypeReference) { |
1550 |
} else if (annot.type instanceof CompletionOnQualifiedTypeReference) { |
1484 |
this.insideQualifiedReference = true; |
1551 |
this.insideQualifiedReference = true; |
1485 |
|
1552 |
|
Lines 1518-1524
Link Here
|
1518 |
} |
1585 |
} |
1519 |
if (this.assistNodeCanBeSingleMemberAnnotation) { |
1586 |
if (this.assistNodeCanBeSingleMemberAnnotation) { |
1520 |
if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) { |
1587 |
if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) { |
1521 |
findTypesAndPackages(this.completionToken, scope, new ObjectVector()); |
1588 |
findTypesAndPackages(this.completionToken, scope, null, new ObjectVector()); |
1522 |
} else { |
1589 |
} else { |
1523 |
if (scope instanceof BlockScope && !this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) { |
1590 |
if (scope instanceof BlockScope && !this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) { |
1524 |
char[][] alreadyDefinedName = computeAlreadyDefinedName((BlockScope)scope, FakeInvocationSite); |
1591 |
char[][] alreadyDefinedName = computeAlreadyDefinedName((BlockScope)scope, FakeInvocationSite); |
Lines 1537-1543
Link Here
|
1537 |
insideTypeAnnotation, |
1604 |
insideTypeAnnotation, |
1538 |
true); |
1605 |
true); |
1539 |
// can be the start of a qualified type name |
1606 |
// can be the start of a qualified type name |
1540 |
findTypesAndPackages(this.completionToken, scope, new ObjectVector()); |
1607 |
findTypesAndPackages(this.completionToken, scope, null, new ObjectVector()); |
1541 |
} |
1608 |
} |
1542 |
} |
1609 |
} |
1543 |
} |
1610 |
} |
Lines 1598-1604
Link Here
|
1598 |
this.completionToken = typeRef.token; |
1665 |
this.completionToken = typeRef.token; |
1599 |
this.javadocTagPosition = typeRef.tagSourceStart; |
1666 |
this.javadocTagPosition = typeRef.tagSourceStart; |
1600 |
setSourceRange(typeRef.sourceStart, typeRef.sourceEnd); |
1667 |
setSourceRange(typeRef.sourceStart, typeRef.sourceEnd); |
1601 |
findTypesAndPackages(this.completionToken, scope, new ObjectVector()); |
1668 |
findTypesAndPackages(this.completionToken, scope, null, new ObjectVector()); |
1602 |
|
1669 |
|
1603 |
} else if (astNode instanceof CompletionOnJavadocQualifiedTypeReference) { |
1670 |
} else if (astNode instanceof CompletionOnJavadocQualifiedTypeReference) { |
1604 |
|
1671 |
|
Lines 1692-1698
Link Here
|
1692 |
if (this.completionToken == null |
1759 |
if (this.completionToken == null |
1693 |
|| CharOperation.prefixEquals(this.completionToken, refBinding.sourceName) |
1760 |
|| CharOperation.prefixEquals(this.completionToken, refBinding.sourceName) |
1694 |
|| (this.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionToken, refBinding.sourceName))) { |
1761 |
|| (this.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionToken, refBinding.sourceName))) { |
1695 |
findConstructors(refBinding, null, scope, fieldRef, false); |
1762 |
findConstructors(refBinding, null, scope, fieldRef, false, false, false); |
1696 |
} |
1763 |
} |
1697 |
} |
1764 |
} |
1698 |
} |
1765 |
} |
Lines 1758-1764
Link Here
|
1758 |
|
1825 |
|
1759 |
ReferenceBinding ref = (ReferenceBinding) qualifiedBinding; |
1826 |
ReferenceBinding ref = (ReferenceBinding) qualifiedBinding; |
1760 |
if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && ref.isClass()) { |
1827 |
if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && ref.isClass()) { |
1761 |
findConstructors(ref, argTypes, scope, allocExpression, false); |
1828 |
findConstructors(ref, argTypes, scope, allocExpression, false, false, false); |
1762 |
} |
1829 |
} |
1763 |
} else if (astNode instanceof CompletionOnJavadocParamNameReference) { |
1830 |
} else if (astNode instanceof CompletionOnJavadocParamNameReference) { |
1764 |
if (!this.requestor.isIgnored(CompletionProposal.JAVADOC_PARAM_REF)) { |
1831 |
if (!this.requestor.isIgnored(CompletionProposal.JAVADOC_PARAM_REF)) { |
Lines 2289-2295
Link Here
|
2289 |
argTypes, |
2356 |
argTypes, |
2290 |
scope, |
2357 |
scope, |
2291 |
invocationSite, |
2358 |
invocationSite, |
2292 |
true); |
2359 |
true, |
|
|
2360 |
false, |
2361 |
false); |
2293 |
} |
2362 |
} |
2294 |
} |
2363 |
} |
2295 |
|
2364 |
|
Lines 2691-2697
Link Here
|
2691 |
TypeBinding[] argTypes, |
2760 |
TypeBinding[] argTypes, |
2692 |
Scope scope, |
2761 |
Scope scope, |
2693 |
InvocationSite invocationSite, |
2762 |
InvocationSite invocationSite, |
2694 |
boolean forAnonymousType) { |
2763 |
boolean forAnonymousType, |
|
|
2764 |
boolean forExactConstructors, |
2765 |
boolean isQualified) { |
2766 |
|
2767 |
if (forExactConstructors) { |
2768 |
if (currentType.isEnum() || currentType.isInterface() || currentType.isAnnotationType()) return; |
2769 |
|
2770 |
if (isQualified && isIgnored(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_IMPORT)) return; |
2771 |
} |
2772 |
|
2773 |
boolean hasConstructors = false; |
2695 |
|
2774 |
|
2696 |
// No visibility checks can be performed without the scope & invocationSite |
2775 |
// No visibility checks can be performed without the scope & invocationSite |
2697 |
MethodBinding[] methods = currentType.availableMethods(); |
2776 |
MethodBinding[] methods = currentType.availableMethods(); |
Lines 2702-2708
Link Here
|
2702 |
if (constructor.isConstructor()) { |
2781 |
if (constructor.isConstructor()) { |
2703 |
|
2782 |
|
2704 |
if (constructor.isSynthetic()) continue next; |
2783 |
if (constructor.isSynthetic()) continue next; |
2705 |
|
2784 |
|
|
|
2785 |
hasConstructors = true; |
2786 |
|
2706 |
if (this.options.checkDeprecation && |
2787 |
if (this.options.checkDeprecation && |
2707 |
constructor.isViewedAsDeprecated() && |
2788 |
constructor.isViewedAsDeprecated() && |
2708 |
!scope.isDefinedInSameUnit(constructor.declaringClass)) |
2789 |
!scope.isDefinedInSameUnit(constructor.declaringClass)) |
Lines 2767-2772
Link Here
|
2767 |
this.printDebug(proposal); |
2848 |
this.printDebug(proposal); |
2768 |
} |
2849 |
} |
2769 |
} |
2850 |
} |
|
|
2851 |
} else if (forExactConstructors) { |
2852 |
char[] signature = getSignature(constructor); |
2853 |
char[] originalSignature = null; |
2854 |
MethodBinding original = constructor.original(); |
2855 |
if(original != constructor) { |
2856 |
originalSignature = getSignature(original); |
2857 |
} |
2858 |
|
2859 |
proposeExactConstructor( |
2860 |
currentType, |
2861 |
signature, |
2862 |
originalSignature, |
2863 |
constructor.modifiers, |
2864 |
parameterPackageNames, |
2865 |
parameterTypeNames, |
2866 |
parameterNames, |
2867 |
isQualified); |
2770 |
} else { |
2868 |
} else { |
2771 |
int relevance = computeBaseRelevance(); |
2869 |
int relevance = computeBaseRelevance(); |
2772 |
relevance += computeRelevanceForResolution(); |
2870 |
relevance += computeRelevanceForResolution(); |
Lines 2888-2893
Link Here
|
2888 |
} |
2986 |
} |
2889 |
} |
2987 |
} |
2890 |
} |
2988 |
} |
|
|
2989 |
|
2990 |
if (forExactConstructors && !hasConstructors) { |
2991 |
char[] signature = |
2992 |
createMethodSignature( |
2993 |
CharOperation.NO_CHAR_CHAR, |
2994 |
CharOperation.NO_CHAR_CHAR, |
2995 |
null, |
2996 |
VOID); |
2997 |
|
2998 |
proposeExactConstructor( |
2999 |
currentType, |
3000 |
signature, |
3001 |
null, |
3002 |
Flags.AccPublic, |
3003 |
CharOperation.NO_CHAR_CHAR, |
3004 |
CharOperation.NO_CHAR_CHAR, |
3005 |
null, |
3006 |
isQualified); |
3007 |
} |
2891 |
} |
3008 |
} |
2892 |
|
3009 |
|
2893 |
private char[][] findEnclosingTypeNames(Scope scope){ |
3010 |
private char[][] findEnclosingTypeNames(Scope scope){ |
Lines 3857-3863
Link Here
|
3857 |
this.options.camelCaseMatch, |
3974 |
this.options.camelCaseMatch, |
3858 |
IJavaSearchConstants.TYPE, |
3975 |
IJavaSearchConstants.TYPE, |
3859 |
this); |
3976 |
this); |
3860 |
acceptTypes(null); |
3977 |
acceptTypes(false, null, null); |
3861 |
} |
3978 |
} |
3862 |
} |
3979 |
} |
3863 |
|
3980 |
|
Lines 4295-4301
Link Here
|
4295 |
boolean staticFieldsAndMethodOnly, |
4412 |
boolean staticFieldsAndMethodOnly, |
4296 |
boolean fromStaticImport, |
4413 |
boolean fromStaticImport, |
4297 |
boolean checkQualification, |
4414 |
boolean checkQualification, |
4298 |
Scope scope) { |
4415 |
boolean proposeConstrutor, |
|
|
4416 |
Scope scope, |
4417 |
InvocationSite invocationSite) { |
4299 |
|
4418 |
|
4300 |
// Inherited member types which are hidden by subclasses are filtered out |
4419 |
// Inherited member types which are hidden by subclasses are filtered out |
4301 |
// No visibility checks can be performed without the scope & invocationSite |
4420 |
// No visibility checks can be performed without the scope & invocationSite |
Lines 4412-4417
Link Here
|
4412 |
|
4531 |
|
4413 |
this.noProposal = false; |
4532 |
this.noProposal = false; |
4414 |
createTypeProposal(memberType, memberType.qualifiedSourceName(), IAccessRule.K_ACCESSIBLE, completionName, relevance); |
4533 |
createTypeProposal(memberType, memberType.qualifiedSourceName(), IAccessRule.K_ACCESSIBLE, completionName, relevance); |
|
|
4534 |
if (proposeConstrutor && CharOperation.equals(typeName, memberType.sourceName)) { |
4535 |
findConstructors( |
4536 |
memberType, |
4537 |
null, |
4538 |
scope, |
4539 |
invocationSite, |
4540 |
false, |
4541 |
true, |
4542 |
isQualified); |
4543 |
} |
4415 |
} |
4544 |
} |
4416 |
} |
4545 |
} |
4417 |
|
4546 |
|
Lines 4433-4438
Link Here
|
4433 |
false, |
4562 |
false, |
4434 |
false, |
4563 |
false, |
4435 |
false, |
4564 |
false, |
|
|
4565 |
false, |
4566 |
null, |
4436 |
null, |
4567 |
null, |
4437 |
typesFound); |
4568 |
typesFound); |
4438 |
} |
4569 |
} |
Lines 4446-4451
Link Here
|
4446 |
boolean fromStaticImport, |
4577 |
boolean fromStaticImport, |
4447 |
boolean checkQualification, |
4578 |
boolean checkQualification, |
4448 |
boolean proposeAllMemberTypes, |
4579 |
boolean proposeAllMemberTypes, |
|
|
4580 |
boolean proposeConstrutor, |
4581 |
InvocationSite invocationSite, |
4449 |
SourceTypeBinding typeToIgnore, |
4582 |
SourceTypeBinding typeToIgnore, |
4450 |
ObjectVector typesFound) { |
4583 |
ObjectVector typesFound) { |
4451 |
|
4584 |
|
Lines 4470-4476
Link Here
|
4470 |
staticFieldsAndMethodOnly, |
4603 |
staticFieldsAndMethodOnly, |
4471 |
fromStaticImport, |
4604 |
fromStaticImport, |
4472 |
checkQualification, |
4605 |
checkQualification, |
4473 |
scope); |
4606 |
proposeConstrutor, |
|
|
4607 |
scope, |
4608 |
invocationSite); |
4474 |
return; |
4609 |
return; |
4475 |
} |
4610 |
} |
4476 |
|
4611 |
|
Lines 4506-4512
Link Here
|
4506 |
staticFieldsAndMethodOnly, |
4641 |
staticFieldsAndMethodOnly, |
4507 |
fromStaticImport, |
4642 |
fromStaticImport, |
4508 |
checkQualification, |
4643 |
checkQualification, |
4509 |
scope); |
4644 |
proposeConstrutor, |
|
|
4645 |
scope, |
4646 |
invocationSite); |
4510 |
|
4647 |
|
4511 |
currentType = currentType.superclass(); |
4648 |
currentType = currentType.superclass(); |
4512 |
} while (currentType != null); |
4649 |
} while (currentType != null); |
Lines 4541-4547
Link Here
|
4541 |
staticFieldsAndMethodOnly, |
4678 |
staticFieldsAndMethodOnly, |
4542 |
fromStaticImport, |
4679 |
fromStaticImport, |
4543 |
checkQualification, |
4680 |
checkQualification, |
4544 |
scope); |
4681 |
proposeConstrutor, |
|
|
4682 |
scope, |
4683 |
invocationSite); |
4545 |
|
4684 |
|
4546 |
ReferenceBinding[] itsInterfaces = anInterface.superInterfaces(); |
4685 |
ReferenceBinding[] itsInterfaces = anInterface.superInterfaces(); |
4547 |
if (itsInterfaces != Binding.NO_SUPERINTERFACES) { |
4686 |
if (itsInterfaces != Binding.NO_SUPERINTERFACES) { |
Lines 4624-4630
Link Here
|
4624 |
staticFieldsAndMethodOnly, |
4763 |
staticFieldsAndMethodOnly, |
4625 |
fromStaticImport, |
4764 |
fromStaticImport, |
4626 |
true, |
4765 |
true, |
4627 |
scope); |
4766 |
false, |
|
|
4767 |
scope, |
4768 |
null); |
4628 |
|
4769 |
|
4629 |
ReferenceBinding[] memberTypes = receiverType.memberTypes(); |
4770 |
ReferenceBinding[] memberTypes = receiverType.memberTypes(); |
4630 |
next : for (int i = 0; i < memberTypes.length; i++) { |
4771 |
next : for (int i = 0; i < memberTypes.length; i++) { |
Lines 6290-6295
Link Here
|
6290 |
SourceTypeBinding currentType, |
6431 |
SourceTypeBinding currentType, |
6291 |
Scope scope, |
6432 |
Scope scope, |
6292 |
boolean proposeAllMemberTypes, |
6433 |
boolean proposeAllMemberTypes, |
|
|
6434 |
boolean proposeConstrutor, |
6435 |
InvocationSite invocationSite, |
6293 |
ObjectVector typesFound) { |
6436 |
ObjectVector typesFound) { |
6294 |
if (typeName == null) |
6437 |
if (typeName == null) |
6295 |
return; |
6438 |
return; |
Lines 6351-6356
Link Here
|
6351 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
6494 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
6352 |
createTypeProposal(localType, localType.sourceName, IAccessRule.K_ACCESSIBLE, localType.sourceName, relevance); |
6495 |
createTypeProposal(localType, localType.sourceName, IAccessRule.K_ACCESSIBLE, localType.sourceName, relevance); |
6353 |
} |
6496 |
} |
|
|
6497 |
|
6498 |
if (proposeConstrutor && CharOperation.equals(typeName, localType.sourceName)) { |
6499 |
findConstructors( |
6500 |
localType, |
6501 |
null, |
6502 |
scope, |
6503 |
invocationSite, |
6504 |
false, |
6505 |
true, |
6506 |
false); |
6507 |
} |
6354 |
} |
6508 |
} |
6355 |
} |
6509 |
} |
6356 |
} |
6510 |
} |
Lines 6358-6364
Link Here
|
6358 |
|
6512 |
|
6359 |
case Scope.CLASS_SCOPE : |
6513 |
case Scope.CLASS_SCOPE : |
6360 |
SourceTypeBinding enclosingSourceType = scope.enclosingSourceType(); |
6514 |
SourceTypeBinding enclosingSourceType = scope.enclosingSourceType(); |
6361 |
findMemberTypes(typeName, enclosingSourceType, scope, currentType, false, false, false, false, proposeAllMemberTypes, nextTypeToIgnore, typesFound); |
6515 |
findMemberTypes( |
|
|
6516 |
typeName, |
6517 |
enclosingSourceType, |
6518 |
scope, |
6519 |
currentType, |
6520 |
false, |
6521 |
false, |
6522 |
false, |
6523 |
false, |
6524 |
proposeAllMemberTypes, |
6525 |
proposeConstrutor, |
6526 |
invocationSite, |
6527 |
nextTypeToIgnore, |
6528 |
typesFound); |
6362 |
nextTypeToIgnore = enclosingSourceType; |
6529 |
nextTypeToIgnore = enclosingSourceType; |
6363 |
if (typeLength == 0) |
6530 |
if (typeLength == 0) |
6364 |
return; // do not search outside the class scope if no prefix was provided |
6531 |
return; // do not search outside the class scope if no prefix was provided |
Lines 6477-6483
Link Here
|
6477 |
scope = scope.parent; |
6644 |
scope = scope.parent; |
6478 |
} |
6645 |
} |
6479 |
} |
6646 |
} |
6480 |
private void findTypesAndPackages(char[] token, Scope scope, ObjectVector typesFound) { |
6647 |
private void findTypesAndPackages(char[] token, Scope scope, InvocationSite invocationSite, ObjectVector typesFound) { |
6481 |
|
6648 |
|
6482 |
if (token == null) |
6649 |
if (token == null) |
6483 |
return; |
6650 |
return; |
Lines 6497-6504
Link Here
|
6497 |
|
6664 |
|
6498 |
boolean proposeAllMemberTypes = !this.assistNodeIsConstructor; |
6665 |
boolean proposeAllMemberTypes = !this.assistNodeIsConstructor; |
6499 |
|
6666 |
|
6500 |
if (!skip && proposeType && scope.enclosingSourceType() != null) { |
6667 |
boolean proposeConstructor =//false; |
6501 |
findNestedTypes(token, scope.enclosingSourceType(), scope, proposeAllMemberTypes, typesFound); |
6668 |
assistNodeIsConstructor && |
|
|
6669 |
!this.requestor.isIgnored(CompletionProposal.METHOD_REF); |
6670 |
|
6671 |
if (!skip && (proposeType || proposeConstructor) && scope.enclosingSourceType() != null) { |
6672 |
findNestedTypes( |
6673 |
token, |
6674 |
scope.enclosingSourceType(), |
6675 |
scope, |
6676 |
proposeAllMemberTypes, |
6677 |
proposeConstructor, |
6678 |
invocationSite, |
6679 |
typesFound); |
6502 |
if(!assistNodeIsConstructor && !assistNodeIsAnnotation) { |
6680 |
if(!assistNodeIsConstructor && !assistNodeIsAnnotation) { |
6503 |
// don't propose type parameters if the completion is a constructor ('new |') |
6681 |
// don't propose type parameters if the completion is a constructor ('new |') |
6504 |
findTypeParameters(token, scope); |
6682 |
findTypeParameters(token, scope); |
Lines 6507-6513
Link Here
|
6507 |
|
6685 |
|
6508 |
boolean isEmptyPrefix = token.length == 0; |
6686 |
boolean isEmptyPrefix = token.length == 0; |
6509 |
|
6687 |
|
6510 |
if (!skip && proposeType && this.unitScope != null) { |
6688 |
if (!skip && (proposeType || proposeConstructor) && this.unitScope != null) { |
6511 |
ReferenceBinding outerInvocationType = scope.enclosingSourceType(); |
6689 |
ReferenceBinding outerInvocationType = scope.enclosingSourceType(); |
6512 |
if(outerInvocationType != null) { |
6690 |
if(outerInvocationType != null) { |
6513 |
ReferenceBinding temp = outerInvocationType.enclosingType(); |
6691 |
ReferenceBinding temp = outerInvocationType.enclosingType(); |
Lines 6588-6597
Link Here
|
6588 |
relevance += computeRelevanceForException(sourceType.sourceName); |
6766 |
relevance += computeRelevanceForException(sourceType.sourceName); |
6589 |
} |
6767 |
} |
6590 |
this.noProposal = false; |
6768 |
this.noProposal = false; |
6591 |
if(proposeType) { |
6769 |
if (proposeType) { |
6592 |
char[] typeName = sourceType.sourceName(); |
6770 |
char[] typeName = sourceType.sourceName(); |
6593 |
createTypeProposal(sourceType, typeName, IAccessRule.K_ACCESSIBLE, typeName, relevance); |
6771 |
createTypeProposal(sourceType, typeName, IAccessRule.K_ACCESSIBLE, typeName, relevance); |
6594 |
} |
6772 |
} |
|
|
6773 |
|
6774 |
if (proposeConstructor && CharOperation.equals(token, sourceType.sourceName)) { |
6775 |
findConstructors( |
6776 |
sourceType, |
6777 |
null, |
6778 |
scope, |
6779 |
invocationSite, |
6780 |
false, |
6781 |
true, |
6782 |
false); |
6783 |
} |
6595 |
} |
6784 |
} |
6596 |
} |
6785 |
} |
6597 |
|
6786 |
|
Lines 6713-6719
Link Here
|
6713 |
findKeywords(token, BASE_TYPE_NAMES, false, false); |
6902 |
findKeywords(token, BASE_TYPE_NAMES, false, false); |
6714 |
} |
6903 |
} |
6715 |
} |
6904 |
} |
6716 |
if(proposeType) { |
6905 |
if(proposeType || proposeConstructor) { |
6717 |
int l = typesFound.size(); |
6906 |
int l = typesFound.size(); |
6718 |
for (int i = 0; i < l; i++) { |
6907 |
for (int i = 0; i < l; i++) { |
6719 |
ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i); |
6908 |
ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i); |
Lines 6734-6746
Link Here
|
6734 |
} else if(this.assistNodeIsAnnotation) { |
6923 |
} else if(this.assistNodeIsAnnotation) { |
6735 |
searchFor = IJavaSearchConstants.ANNOTATION_TYPE; |
6924 |
searchFor = IJavaSearchConstants.ANNOTATION_TYPE; |
6736 |
} |
6925 |
} |
6737 |
this.nameEnvironment.findTypes( |
6926 |
if (proposeType) { |
6738 |
token, |
6927 |
this.nameEnvironment.findTypes( |
6739 |
proposeAllMemberTypes, |
6928 |
token, |
6740 |
this.options.camelCaseMatch, |
6929 |
proposeAllMemberTypes, |
6741 |
searchFor, |
6930 |
this.options.camelCaseMatch, |
6742 |
this); |
6931 |
searchFor, |
6743 |
acceptTypes(scope); |
6932 |
this); |
|
|
6933 |
} else { |
6934 |
this.nameEnvironment.findExactTypes( |
6935 |
token, |
6936 |
proposeAllMemberTypes, |
6937 |
searchFor, |
6938 |
this); |
6939 |
} |
6940 |
acceptTypes(proposeConstructor, invocationSite, scope); |
6744 |
} |
6941 |
} |
6745 |
if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { |
6942 |
if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { |
6746 |
this.nameEnvironment.findPackages(token, this); |
6943 |
this.nameEnvironment.findPackages(token, this); |
Lines 6859-6865
Link Here
|
6859 |
this.options.camelCaseMatch, |
7056 |
this.options.camelCaseMatch, |
6860 |
searchFor, |
7057 |
searchFor, |
6861 |
this); |
7058 |
this); |
6862 |
acceptTypes(scope); |
7059 |
acceptTypes(false, null, null); |
6863 |
} |
7060 |
} |
6864 |
if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { |
7061 |
if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { |
6865 |
this.nameEnvironment.findPackages(qualifiedName, this); |
7062 |
this.nameEnvironment.findPackages(qualifiedName, this); |
Lines 6885-6890
Link Here
|
6885 |
true, |
7082 |
true, |
6886 |
true, |
7083 |
true, |
6887 |
proposeAllMemberTypes, |
7084 |
proposeAllMemberTypes, |
|
|
7085 |
false, |
7086 |
null, |
6888 |
null, |
7087 |
null, |
6889 |
typesFound); |
7088 |
typesFound); |
6890 |
} |
7089 |
} |
Lines 8357-8363
Link Here
|
8357 |
|
8556 |
|
8358 |
return completion.toString().toCharArray(); |
8557 |
return completion.toString().toCharArray(); |
8359 |
} |
8558 |
} |
8360 |
|
8559 |
private void proposeExactConstructor( |
|
|
8560 |
ReferenceBinding currentType, |
8561 |
char[] signature, |
8562 |
char[] originalSignature, |
8563 |
int modifiers, |
8564 |
char[][] parameterPackageNames, |
8565 |
char[][] parameterTypeNames, |
8566 |
char[][] parameterNames, |
8567 |
boolean isQualified) { |
8568 |
|
8569 |
char[] simpleTypename = currentType.sourceName; |
8570 |
|
8571 |
char[] completion; |
8572 |
if (this.source != null |
8573 |
&& this.source.length > this.endPosition |
8574 |
&& this.source[this.endPosition] == '(') { |
8575 |
completion = simpleTypename; |
8576 |
} else { |
8577 |
completion = CharOperation.concat(simpleTypename, new char[] { '(', ')' }); |
8578 |
} |
8579 |
|
8580 |
int relevance = computeBaseRelevance(); |
8581 |
relevance += computeRelevanceForResolution(); |
8582 |
relevance += computeRelevanceForInterestingProposal(); |
8583 |
relevance += computeRelevanceForCaseMatching(simpleTypename, simpleTypename); |
8584 |
relevance += computeRelevanceForExpectingType(currentType); |
8585 |
relevance += computeRelevanceForQualification(isQualified); |
8586 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for type in the current unit |
8587 |
relevance += R_CONSTRUCTOR; |
8588 |
|
8589 |
// Create standard proposal |
8590 |
this.noProposal = false; |
8591 |
if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { |
8592 |
CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); |
8593 |
proposal.setDeclarationSignature(getSignature(currentType)); |
8594 |
proposal.setSignature(signature); |
8595 |
if(originalSignature != null) { |
8596 |
proposal.setOriginalSignature(originalSignature); |
8597 |
} |
8598 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
8599 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
8600 |
proposal.setParameterPackageNames(parameterPackageNames); |
8601 |
proposal.setParameterTypeNames(parameterTypeNames); |
8602 |
proposal.setName(currentType.sourceName()); |
8603 |
proposal.setIsContructor(true); |
8604 |
proposal.setCompletion(completion); |
8605 |
proposal.setFlags(modifiers); |
8606 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
8607 |
proposal.setRelevance(relevance); |
8608 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
8609 |
if (isQualified) { |
8610 |
char[] typeName = CharOperation.concatWith(currentType.compoundName, '.'); |
8611 |
|
8612 |
CompilationUnitDeclaration cu = this.unitScope.referenceContext; |
8613 |
int importStart = cu.types[0].declarationSourceStart; |
8614 |
int importEnd = importStart; |
8615 |
|
8616 |
char[] typeImportCompletion = createImportCharArray(typeName, false, false); |
8617 |
|
8618 |
CompletionProposal typeImportProposal = this.createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition); |
8619 |
typeImportProposal.nameLookup = this.nameEnvironment.nameLookup; |
8620 |
typeImportProposal.completionEngine = this; |
8621 |
char[] packageName = currentType.qualifiedPackageName(); |
8622 |
typeImportProposal.setDeclarationSignature(packageName); |
8623 |
typeImportProposal.setSignature(getSignature(currentType)); |
8624 |
typeImportProposal.setPackageName(packageName); |
8625 |
typeImportProposal.setTypeName(currentType.qualifiedSourceName()); |
8626 |
typeImportProposal.setCompletion(typeImportCompletion); |
8627 |
typeImportProposal.setFlags(currentType.modifiers); |
8628 |
typeImportProposal.setAdditionalFlags(CompletionFlags.Default); |
8629 |
typeImportProposal.setReplaceRange(importStart - this.offset, importEnd - this.offset); |
8630 |
typeImportProposal.setRelevance(relevance); |
8631 |
|
8632 |
proposal.setRequiredProposals(new CompletionProposal[]{typeImportProposal}); |
8633 |
} |
8634 |
|
8635 |
this.requestor.accept(proposal); |
8636 |
if(DEBUG) { |
8637 |
this.printDebug(proposal); |
8638 |
} |
8639 |
} |
8640 |
|
8641 |
} |
8361 |
private void proposeNewMethod(char[] token, ReferenceBinding reference) { |
8642 |
private void proposeNewMethod(char[] token, ReferenceBinding reference) { |
8362 |
if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) { |
8643 |
if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) { |
8363 |
int relevance = computeBaseRelevance(); |
8644 |
int relevance = computeBaseRelevance(); |