Lines 40-45
Link Here
|
40 |
import org.eclipse.jdt.internal.codeassist.impl.Keywords; |
40 |
import org.eclipse.jdt.internal.codeassist.impl.Keywords; |
41 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
41 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
42 |
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; |
42 |
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; |
|
|
43 |
import org.eclipse.jdt.internal.compiler.ExtraFlags; |
43 |
import org.eclipse.jdt.internal.compiler.ast.*; |
44 |
import org.eclipse.jdt.internal.compiler.ast.*; |
44 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
45 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
45 |
import org.eclipse.jdt.internal.compiler.env.*; |
46 |
import org.eclipse.jdt.internal.compiler.env.*; |
Lines 60-71
Link Here
|
60 |
import org.eclipse.jdt.internal.core.BasicCompilationUnit; |
61 |
import org.eclipse.jdt.internal.core.BasicCompilationUnit; |
61 |
import org.eclipse.jdt.internal.core.INamingRequestor; |
62 |
import org.eclipse.jdt.internal.core.INamingRequestor; |
62 |
import org.eclipse.jdt.internal.core.InternalNamingConventions; |
63 |
import org.eclipse.jdt.internal.core.InternalNamingConventions; |
|
|
64 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
63 |
import org.eclipse.jdt.internal.core.SourceMethod; |
65 |
import org.eclipse.jdt.internal.core.SourceMethod; |
64 |
import org.eclipse.jdt.internal.core.SourceMethodElementInfo; |
66 |
import org.eclipse.jdt.internal.core.SourceMethodElementInfo; |
65 |
import org.eclipse.jdt.internal.core.SourceType; |
67 |
import org.eclipse.jdt.internal.core.SourceType; |
66 |
import org.eclipse.jdt.internal.core.BinaryTypeConverter; |
68 |
import org.eclipse.jdt.internal.core.BinaryTypeConverter; |
67 |
import org.eclipse.jdt.internal.core.SearchableEnvironment; |
69 |
import org.eclipse.jdt.internal.core.SearchableEnvironment; |
68 |
import org.eclipse.jdt.internal.core.SourceTypeElementInfo; |
70 |
import org.eclipse.jdt.internal.core.SourceTypeElementInfo; |
|
|
71 |
import org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment; |
69 |
import org.eclipse.jdt.internal.core.util.Messages; |
72 |
import org.eclipse.jdt.internal.core.util.Messages; |
70 |
|
73 |
|
71 |
/** |
74 |
/** |
Lines 77-82
Link Here
|
77 |
extends Engine |
80 |
extends Engine |
78 |
implements ISearchRequestor, TypeConstants , TerminalTokens , RelevanceConstants, SuffixConstants { |
81 |
implements ISearchRequestor, TypeConstants , TerminalTokens , RelevanceConstants, SuffixConstants { |
79 |
|
82 |
|
|
|
83 |
private static class AcceptedConstructor { |
84 |
public int modifiers; |
85 |
public char[] simpleTypeName; |
86 |
public int parameterCount; |
87 |
public char[] signature; |
88 |
public char[][] parameterTypes; |
89 |
public char[][] parameterNames; |
90 |
public int typeModifiers; |
91 |
public char[] packageName; |
92 |
public int extraFlags; |
93 |
public int accessibility; |
94 |
public boolean proposeType = false; |
95 |
public boolean proposeConstructor = false; |
96 |
public char[] fullyQualifiedName = null; |
97 |
|
98 |
public boolean mustBeQualified = false; |
99 |
|
100 |
public AcceptedConstructor( |
101 |
int modifiers, |
102 |
char[] simpleTypeName, |
103 |
int parameterCount, |
104 |
char[] signature, |
105 |
char[][] parameterTypes, |
106 |
char[][] parameterNames, |
107 |
int typeModifiers, |
108 |
char[] packageName, |
109 |
int extraFlags, |
110 |
int accessibility) { |
111 |
this.modifiers = modifiers; |
112 |
this.simpleTypeName = simpleTypeName; |
113 |
this.parameterCount = parameterCount; |
114 |
this.signature = signature; |
115 |
this.parameterTypes = parameterTypes; |
116 |
this.parameterNames = parameterNames; |
117 |
this.typeModifiers = typeModifiers; |
118 |
this.packageName = packageName; |
119 |
this.extraFlags = extraFlags; |
120 |
this.accessibility = accessibility; |
121 |
} |
122 |
|
123 |
public String toString() { |
124 |
StringBuffer buffer = new StringBuffer(); |
125 |
buffer.append('{'); |
126 |
buffer.append(this.packageName); |
127 |
buffer.append(','); |
128 |
buffer.append(this.simpleTypeName); |
129 |
buffer.append('}'); |
130 |
return buffer.toString(); |
131 |
} |
132 |
} |
133 |
|
80 |
private static class AcceptedType { |
134 |
private static class AcceptedType { |
81 |
public char[] packageName; |
135 |
public char[] packageName; |
82 |
public char[] simpleTypeName; |
136 |
public char[] simpleTypeName; |
Lines 226-232
Link Here
|
226 |
this.checkProblems = false; |
280 |
this.checkProblems = false; |
227 |
} |
281 |
} |
228 |
} |
282 |
} |
|
|
283 |
|
284 |
public static char[] createBindingKey(char[] packageName, char[] typeName) { |
285 |
return createTypeSignature(packageName, typeName); |
286 |
} |
229 |
|
287 |
|
|
|
288 |
public static char[][] createDefaultParameterNames(int length) { |
289 |
char[][] parameters; |
290 |
switch (length) { |
291 |
case 0 : |
292 |
parameters = new char[length][]; |
293 |
break; |
294 |
case 1 : |
295 |
parameters = ARGS1; |
296 |
break; |
297 |
case 2 : |
298 |
parameters = ARGS2; |
299 |
break; |
300 |
case 3 : |
301 |
parameters = ARGS3; |
302 |
break; |
303 |
case 4 : |
304 |
parameters = ARGS4; |
305 |
break; |
306 |
default : |
307 |
parameters = new char[length][]; |
308 |
for (int i = 0; i < length; i++) { |
309 |
parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray()); |
310 |
} |
311 |
break; |
312 |
} |
313 |
return parameters; |
314 |
} |
230 |
public static char[] createMethodSignature(char[][] parameterPackageNames, char[][] parameterTypeNames, char[] returnTypeSignature) { |
315 |
public static char[] createMethodSignature(char[][] parameterPackageNames, char[][] parameterTypeNames, char[] returnTypeSignature) { |
231 |
char[][] parameterTypeSignature = new char[parameterTypeNames.length][]; |
316 |
char[][] parameterTypeSignature = new char[parameterTypeNames.length][]; |
232 |
for (int i = 0; i < parameterTypeSignature.length; i++) { |
317 |
for (int i = 0; i < parameterTypeSignature.length; i++) { |
Lines 302-313
Link Here
|
302 |
result = CharOperation.replaceOnCopy(result, '/', '.'); |
387 |
result = CharOperation.replaceOnCopy(result, '/', '.'); |
303 |
return result; |
388 |
return result; |
304 |
} |
389 |
} |
|
|
390 |
|
391 |
private static boolean hasStaticMemberTypes(ReferenceBinding typeBinding, SourceTypeBinding invocationType, CompilationUnitScope unitScope) { |
392 |
ReferenceBinding[] memberTypes = typeBinding.memberTypes(); |
393 |
int length = memberTypes == null ? 0 : memberTypes.length; |
394 |
next : for (int i = 0; i < length; i++) { |
395 |
ReferenceBinding memberType = memberTypes[i]; |
396 |
if (invocationType != null && !memberType.canBeSeenBy(typeBinding, invocationType)) { |
397 |
continue next; |
398 |
} else if(invocationType == null && !memberType.canBeSeenBy(unitScope.fPackage)) { |
399 |
continue next; |
400 |
} |
401 |
|
402 |
if ((memberType.modifiers & ClassFileConstants.AccStatic) != 0) { |
403 |
return true; |
404 |
} |
405 |
} |
406 |
return false; |
407 |
} |
305 |
public HashtableOfObject typeCache; |
408 |
public HashtableOfObject typeCache; |
306 |
|
409 |
|
307 |
public static boolean DEBUG = false; |
410 |
public static boolean DEBUG = false; |
308 |
public static boolean PERF = false; |
411 |
public static boolean PERF = false; |
309 |
|
412 |
|
310 |
private final static int CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES = 50; |
413 |
private static final char[] KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS = new char[]{}; |
|
|
414 |
private static final char[] KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS = new char[]{}; |
415 |
|
416 |
private static final char[] ARG = "arg".toCharArray(); //$NON-NLS-1$ |
417 |
private static final char[] ARG0 = "arg0".toCharArray(); //$NON-NLS-1$ |
418 |
private static final char[] ARG1 = "arg1".toCharArray(); //$NON-NLS-1$ |
419 |
private static final char[] ARG2 = "arg2".toCharArray(); //$NON-NLS-1$ |
420 |
private static final char[] ARG3 = "arg3".toCharArray(); //$NON-NLS-1$ |
421 |
private static final char[][] ARGS1 = new char[][]{ARG0}; |
422 |
private static final char[][] ARGS2 = new char[][]{ARG0, ARG1}; |
423 |
private static final char[][] ARGS3 = new char[][]{ARG0, ARG1, ARG2}; |
424 |
private static final char[][] ARGS4 = new char[][]{ARG0, ARG1, ARG2, ARG3}; |
425 |
|
426 |
private final static int CHECK_CANCEL_FREQUENCY = 50; |
311 |
|
427 |
|
312 |
// temporary constants to quickly disabled polish features if necessary |
428 |
// temporary constants to quickly disabled polish features if necessary |
313 |
public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false; |
429 |
public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false; |
Lines 323-328
Link Here
|
323 |
private final static char[] VALUE = "value".toCharArray(); //$NON-NLS-1$ |
439 |
private final static char[] VALUE = "value".toCharArray(); //$NON-NLS-1$ |
324 |
private final static char[] EXTENDS = "extends".toCharArray(); //$NON-NLS-1$ |
440 |
private final static char[] EXTENDS = "extends".toCharArray(); //$NON-NLS-1$ |
325 |
private final static char[] SUPER = "super".toCharArray(); //$NON-NLS-1$ |
441 |
private final static char[] SUPER = "super".toCharArray(); //$NON-NLS-1$ |
|
|
442 |
private final static char[] DEFAULT_CONSTRUCTOR_SIGNATURE = "()V".toCharArray(); //$NON-NLS-1$ |
326 |
|
443 |
|
327 |
private final static char[] DOT = ".".toCharArray(); //$NON-NLS-1$ |
444 |
private final static char[] DOT = ".".toCharArray(); //$NON-NLS-1$ |
328 |
|
445 |
|
Lines 374-379
Link Here
|
374 |
CompletionRequestor requestor; |
491 |
CompletionRequestor requestor; |
375 |
CompletionProblemFactory problemFactory; |
492 |
CompletionProblemFactory problemFactory; |
376 |
ProblemReporter problemReporter; |
493 |
ProblemReporter problemReporter; |
|
|
494 |
private JavaSearchNameEnvironment noCacheNameEnvironment; |
377 |
char[] source; |
495 |
char[] source; |
378 |
char[] completionToken; |
496 |
char[] completionToken; |
379 |
char[] qualifiedCompletionToken; |
497 |
char[] qualifiedCompletionToken; |
Lines 458-463
Link Here
|
458 |
|
576 |
|
459 |
private int foundTypesCount; |
577 |
private int foundTypesCount; |
460 |
private ObjectVector acceptedTypes; |
578 |
private ObjectVector acceptedTypes; |
|
|
579 |
|
580 |
private int foundConstructorsCount; |
581 |
private ObjectVector acceptedConstructors; |
461 |
|
582 |
|
462 |
/** |
583 |
/** |
463 |
* The CompletionEngine is responsible for computing source completions. |
584 |
* The CompletionEngine is responsible for computing source completions. |
Lines 510-515
Link Here
|
510 |
this.owner = owner; |
631 |
this.owner = owner; |
511 |
this.monitor = monitor; |
632 |
this.monitor = monitor; |
512 |
} |
633 |
} |
|
|
634 |
|
635 |
public void acceptConstructor( |
636 |
int modifiers, |
637 |
char[] simpleTypeName, |
638 |
int parameterCount, |
639 |
char[] signature, |
640 |
char[][] parameterTypes, |
641 |
char[][] parameterNames, |
642 |
int typeModifiers, |
643 |
char[] packageName, |
644 |
int extraFlags, |
645 |
String path, |
646 |
AccessRestriction accessRestriction) { |
647 |
|
648 |
// does not check cancellation for every types to avoid performance loss |
649 |
if ((this.foundConstructorsCount % (CHECK_CANCEL_FREQUENCY)) == 0) checkCancel(); |
650 |
this.foundConstructorsCount++; |
651 |
|
652 |
if ((typeModifiers & ClassFileConstants.AccEnum) != 0) return; |
653 |
|
654 |
if (this.options.checkDeprecation && (typeModifiers & ClassFileConstants.AccDeprecated) != 0) return; |
655 |
|
656 |
if (this.options.checkVisibility) { |
657 |
if((typeModifiers & ClassFileConstants.AccPublic) == 0) { |
658 |
if((typeModifiers & ClassFileConstants.AccPrivate) != 0) return; |
659 |
|
660 |
if (this.currentPackageName == null) { |
661 |
initializePackageCache(); |
662 |
} |
663 |
|
664 |
if(!CharOperation.equals(packageName, this.currentPackageName)) return; |
665 |
} |
666 |
} |
667 |
|
668 |
int accessibility = IAccessRule.K_ACCESSIBLE; |
669 |
if(accessRestriction != null) { |
670 |
switch (accessRestriction.getProblemId()) { |
671 |
case IProblem.ForbiddenReference: |
672 |
if (this.options.checkForbiddenReference) { |
673 |
return; |
674 |
} |
675 |
accessibility = IAccessRule.K_NON_ACCESSIBLE; |
676 |
break; |
677 |
case IProblem.DiscouragedReference: |
678 |
if (this.options.checkDiscouragedReference) { |
679 |
return; |
680 |
} |
681 |
accessibility = IAccessRule.K_DISCOURAGED; |
682 |
break; |
683 |
} |
684 |
} |
685 |
|
686 |
if(this.acceptedConstructors == null) { |
687 |
this.acceptedConstructors = new ObjectVector(); |
688 |
} |
689 |
this.acceptedConstructors.add( |
690 |
new AcceptedConstructor( |
691 |
modifiers, |
692 |
simpleTypeName, |
693 |
parameterCount, |
694 |
signature, |
695 |
parameterTypes, |
696 |
parameterNames, |
697 |
typeModifiers, |
698 |
packageName, |
699 |
extraFlags, |
700 |
accessibility)); |
701 |
} |
702 |
|
703 |
private void acceptConstructors(Scope scope) { |
704 |
final boolean DEFER_QUALIFIED_PROPOSALS = false; |
705 |
|
706 |
this.checkCancel(); |
707 |
|
708 |
if(this.acceptedConstructors == null) return; |
709 |
|
710 |
int length = this.acceptedConstructors.size(); |
711 |
|
712 |
if(length == 0) return; |
713 |
|
714 |
HashtableOfObject onDemandFound = new HashtableOfObject(); |
715 |
|
716 |
ArrayList deferredProposals = new ArrayList(); |
717 |
|
718 |
try { |
719 |
next : for (int i = 0; i < length; i++) { |
720 |
|
721 |
// does not check cancellation for every types to avoid performance loss |
722 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
723 |
|
724 |
AcceptedConstructor acceptedConstructor = (AcceptedConstructor)this.acceptedConstructors.elementAt(i); |
725 |
final int typeModifiers = acceptedConstructor.typeModifiers; |
726 |
final char[] packageName = acceptedConstructor.packageName; |
727 |
final char[] simpleTypeName = acceptedConstructor.simpleTypeName; |
728 |
final int modifiers = acceptedConstructor.modifiers; |
729 |
final int parameterCount = acceptedConstructor.parameterCount; |
730 |
final char[] signature = acceptedConstructor.signature; |
731 |
final char[][] parameterTypes = acceptedConstructor.parameterTypes; |
732 |
final char[][] parameterNames = acceptedConstructor.parameterNames; |
733 |
final int extraFlags = acceptedConstructor.extraFlags; |
734 |
final int accessibility = acceptedConstructor.accessibility; |
735 |
|
736 |
boolean proposeType = (extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0; |
737 |
|
738 |
char[] fullyQualifiedName = CharOperation.concat(packageName, simpleTypeName, '.'); |
739 |
|
740 |
Object knownTypeKind = this.knownTypes.get(fullyQualifiedName); |
741 |
if (knownTypeKind != null) { |
742 |
if (knownTypeKind == KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS) { |
743 |
// the type and its constructors are already accepted |
744 |
continue next; |
745 |
} |
746 |
// this type is already accepted |
747 |
proposeType = false; |
748 |
} else { |
749 |
this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS); |
750 |
} |
751 |
|
752 |
boolean proposeConstructor = true; |
753 |
|
754 |
if (this.options.checkVisibility) { |
755 |
if((modifiers & ClassFileConstants.AccPublic) == 0) { |
756 |
if((modifiers & ClassFileConstants.AccPrivate) != 0) { |
757 |
if (!proposeType) continue next; |
758 |
proposeConstructor = false; |
759 |
} else { |
760 |
if (this.currentPackageName == null) { |
761 |
initializePackageCache(); |
762 |
} |
763 |
|
764 |
if(!CharOperation.equals(packageName, this.currentPackageName)) { |
765 |
if (!proposeType) continue next; |
766 |
proposeConstructor = false; |
767 |
} |
768 |
} |
769 |
} |
770 |
} |
771 |
|
772 |
acceptedConstructor.fullyQualifiedName = fullyQualifiedName; |
773 |
acceptedConstructor.proposeType = proposeType; |
774 |
acceptedConstructor.proposeConstructor = proposeConstructor; |
775 |
|
776 |
|
777 |
if(!this.importCachesInitialized) { |
778 |
initializeImportCaches(); |
779 |
} |
780 |
|
781 |
for (int j = 0; j < this.importCacheCount; j++) { |
782 |
char[][] importName = this.importsCache[j]; |
783 |
if(CharOperation.equals(simpleTypeName, importName[0])) { |
784 |
if (proposeType) { |
785 |
proposeType( |
786 |
packageName, |
787 |
simpleTypeName, |
788 |
typeModifiers, |
789 |
accessibility, |
790 |
simpleTypeName, |
791 |
fullyQualifiedName, |
792 |
!CharOperation.equals(fullyQualifiedName, importName[1]), |
793 |
scope); |
794 |
} |
795 |
|
796 |
if (proposeConstructor && !Flags.isEnum(typeModifiers)) { |
797 |
boolean isQualified = !CharOperation.equals(fullyQualifiedName, importName[1]); |
798 |
if (!isQualified) { |
799 |
proposeConstructor( |
800 |
simpleTypeName, |
801 |
parameterCount, |
802 |
signature, |
803 |
parameterTypes, |
804 |
parameterNames, |
805 |
modifiers, |
806 |
packageName, |
807 |
typeModifiers, |
808 |
accessibility, |
809 |
simpleTypeName, |
810 |
fullyQualifiedName, |
811 |
isQualified, |
812 |
scope, |
813 |
extraFlags); |
814 |
} else { |
815 |
acceptedConstructor.mustBeQualified = true; |
816 |
if (DEFER_QUALIFIED_PROPOSALS) { |
817 |
deferredProposals.add(acceptedConstructor); |
818 |
} else { |
819 |
proposeConstructor(acceptedConstructor, scope); |
820 |
} |
821 |
} |
822 |
} |
823 |
continue next; |
824 |
} |
825 |
} |
826 |
|
827 |
|
828 |
if (CharOperation.equals(this.currentPackageName, packageName)) { |
829 |
if (proposeType) { |
830 |
proposeType( |
831 |
packageName, |
832 |
simpleTypeName, |
833 |
typeModifiers, |
834 |
accessibility, |
835 |
simpleTypeName, |
836 |
fullyQualifiedName, |
837 |
false, |
838 |
scope); |
839 |
} |
840 |
|
841 |
if (proposeConstructor && !Flags.isEnum(typeModifiers)) { |
842 |
proposeConstructor( |
843 |
simpleTypeName, |
844 |
parameterCount, |
845 |
signature, |
846 |
parameterTypes, |
847 |
parameterNames, |
848 |
modifiers, |
849 |
packageName, |
850 |
typeModifiers, |
851 |
accessibility, |
852 |
simpleTypeName, |
853 |
fullyQualifiedName, |
854 |
false, |
855 |
scope, |
856 |
extraFlags); |
857 |
} |
858 |
continue next; |
859 |
} else { |
860 |
char[] fullyQualifiedEnclosingTypeOrPackageName = null; |
861 |
|
862 |
AcceptedConstructor foundConstructor = null; |
863 |
if((foundConstructor = (AcceptedConstructor)onDemandFound.get(simpleTypeName)) == null) { |
864 |
for (int j = 0; j < this.onDemandImportCacheCount; j++) { |
865 |
ImportBinding importBinding = this.onDemandImportsCache[j]; |
866 |
|
867 |
char[][] importName = importBinding.compoundName; |
868 |
char[] importFlatName = CharOperation.concatWith(importName, '.'); |
869 |
|
870 |
if(fullyQualifiedEnclosingTypeOrPackageName == null) { |
871 |
fullyQualifiedEnclosingTypeOrPackageName = packageName; |
872 |
} |
873 |
if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) { |
874 |
if(importBinding.isStatic()) { |
875 |
if((typeModifiers & ClassFileConstants.AccStatic) != 0) { |
876 |
onDemandFound.put( |
877 |
simpleTypeName, |
878 |
acceptedConstructor); |
879 |
continue next; |
880 |
} |
881 |
} else { |
882 |
onDemandFound.put( |
883 |
simpleTypeName, |
884 |
acceptedConstructor); |
885 |
continue next; |
886 |
} |
887 |
} |
888 |
} |
889 |
} else if(!foundConstructor.mustBeQualified){ |
890 |
done : for (int j = 0; j < this.onDemandImportCacheCount; j++) { |
891 |
ImportBinding importBinding = this.onDemandImportsCache[j]; |
892 |
|
893 |
char[][] importName = importBinding.compoundName; |
894 |
char[] importFlatName = CharOperation.concatWith(importName, '.'); |
895 |
|
896 |
if(fullyQualifiedEnclosingTypeOrPackageName == null) { |
897 |
fullyQualifiedEnclosingTypeOrPackageName = packageName; |
898 |
} |
899 |
if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) { |
900 |
if(importBinding.isStatic()) { |
901 |
if((typeModifiers & ClassFileConstants.AccStatic) != 0) { |
902 |
foundConstructor.mustBeQualified = true; |
903 |
break done; |
904 |
} |
905 |
} else { |
906 |
foundConstructor.mustBeQualified = true; |
907 |
break done; |
908 |
} |
909 |
} |
910 |
} |
911 |
} |
912 |
if (proposeType) { |
913 |
proposeType( |
914 |
packageName, |
915 |
simpleTypeName, |
916 |
typeModifiers, |
917 |
accessibility, |
918 |
simpleTypeName, |
919 |
fullyQualifiedName, |
920 |
true, |
921 |
scope); |
922 |
} |
923 |
|
924 |
if (proposeConstructor && !Flags.isEnum(typeModifiers)) { |
925 |
acceptedConstructor.mustBeQualified = true; |
926 |
if (DEFER_QUALIFIED_PROPOSALS) { |
927 |
deferredProposals.add(acceptedConstructor); |
928 |
} else { |
929 |
proposeConstructor(acceptedConstructor, scope); |
930 |
} |
931 |
} |
932 |
} |
933 |
} |
934 |
|
935 |
char[][] keys = onDemandFound.keyTable; |
936 |
Object[] values = onDemandFound.valueTable; |
937 |
int max = keys.length; |
938 |
for (int i = 0; i < max; i++) { |
939 |
|
940 |
// does not check cancellation for every types to avoid performance loss |
941 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
942 |
|
943 |
if(keys[i] != null) { |
944 |
AcceptedConstructor value = (AcceptedConstructor) values[i]; |
945 |
if(value != null) { |
946 |
if (value.proposeType) { |
947 |
proposeType( |
948 |
value.packageName, |
949 |
value.simpleTypeName, |
950 |
value.typeModifiers, |
951 |
value.accessibility, |
952 |
value.simpleTypeName, |
953 |
value.fullyQualifiedName, |
954 |
value.mustBeQualified, |
955 |
scope); |
956 |
} |
957 |
|
958 |
if (value.proposeConstructor && !Flags.isEnum(value.modifiers)) { |
959 |
if (!value.mustBeQualified) { |
960 |
proposeConstructor( |
961 |
value.simpleTypeName, |
962 |
value.parameterCount, |
963 |
value.signature, |
964 |
value.parameterTypes, |
965 |
value.parameterNames, |
966 |
value.modifiers, |
967 |
value.packageName, |
968 |
value.typeModifiers, |
969 |
value.accessibility, |
970 |
value.simpleTypeName, |
971 |
value.fullyQualifiedName, |
972 |
value.mustBeQualified, |
973 |
scope, |
974 |
value.extraFlags); |
975 |
} else { |
976 |
if (DEFER_QUALIFIED_PROPOSALS) { |
977 |
deferredProposals.add(value); |
978 |
} else { |
979 |
proposeConstructor(value, scope); |
980 |
} |
981 |
} |
982 |
} |
983 |
} |
984 |
} |
985 |
} |
986 |
|
987 |
if (DEFER_QUALIFIED_PROPOSALS) { |
988 |
int size = deferredProposals.size(); |
989 |
for (int i = 0; i < size; i++) { |
990 |
|
991 |
// does not check cancellation for every types to avoid performance loss |
992 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
993 |
|
994 |
AcceptedConstructor deferredProposal = (AcceptedConstructor)deferredProposals.get(i); |
995 |
|
996 |
if (deferredProposal.proposeConstructor) { |
997 |
proposeConstructor( |
998 |
deferredProposal.simpleTypeName, |
999 |
deferredProposal.parameterCount, |
1000 |
deferredProposal.signature, |
1001 |
deferredProposal.parameterTypes, |
1002 |
deferredProposal.parameterNames, |
1003 |
deferredProposal.modifiers, |
1004 |
deferredProposal.packageName, |
1005 |
deferredProposal.typeModifiers, |
1006 |
deferredProposal.accessibility, |
1007 |
deferredProposal.simpleTypeName, |
1008 |
deferredProposal.fullyQualifiedName, |
1009 |
deferredProposal.mustBeQualified, |
1010 |
scope, |
1011 |
deferredProposal.extraFlags); |
1012 |
} |
1013 |
} |
1014 |
} |
1015 |
} finally { |
1016 |
this.acceptedTypes = null; // reset |
1017 |
} |
1018 |
} |
513 |
|
1019 |
|
514 |
/** |
1020 |
/** |
515 |
* One result of the search consists of a new package. |
1021 |
* One result of the search consists of a new package. |
Lines 576-582
Link Here
|
576 |
AccessRestriction accessRestriction) { |
1082 |
AccessRestriction accessRestriction) { |
577 |
|
1083 |
|
578 |
// does not check cancellation for every types to avoid performance loss |
1084 |
// does not check cancellation for every types to avoid performance loss |
579 |
if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel(); |
1085 |
if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
580 |
this.foundTypesCount++; |
1086 |
this.foundTypesCount++; |
581 |
|
1087 |
|
582 |
if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return; |
1088 |
if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return; |
Lines 629-635
Link Here
|
629 |
next : for (int i = 0; i < length; i++) { |
1135 |
next : for (int i = 0; i < length; i++) { |
630 |
|
1136 |
|
631 |
// does not check cancellation for every types to avoid performance loss |
1137 |
// does not check cancellation for every types to avoid performance loss |
632 |
if ((i % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel(); |
1138 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
633 |
|
1139 |
|
634 |
AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i); |
1140 |
AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i); |
635 |
char[] packageName = acceptedType.packageName; |
1141 |
char[] packageName = acceptedType.packageName; |
Lines 651-657
Link Here
|
651 |
|
1157 |
|
652 |
if (this.knownTypes.containsKey(fullyQualifiedName)) continue next; |
1158 |
if (this.knownTypes.containsKey(fullyQualifiedName)) continue next; |
653 |
|
1159 |
|
654 |
this.knownTypes.put(fullyQualifiedName, this); |
1160 |
this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS); |
655 |
|
1161 |
|
656 |
if (this.resolvingImports) { |
1162 |
if (this.resolvingImports) { |
657 |
if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) { |
1163 |
if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) { |
Lines 807-812
Link Here
|
807 |
Object[] values = onDemandFound.valueTable; |
1313 |
Object[] values = onDemandFound.valueTable; |
808 |
int max = keys.length; |
1314 |
int max = keys.length; |
809 |
for (int i = 0; i < max; i++) { |
1315 |
for (int i = 0; i < max; i++) { |
|
|
1316 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
810 |
if(keys[i] != null) { |
1317 |
if(keys[i] != null) { |
811 |
AcceptedType value = (AcceptedType) values[i]; |
1318 |
AcceptedType value = (AcceptedType) values[i]; |
812 |
if(value != null) { |
1319 |
if(value != null) { |
Lines 2447-2452
Link Here
|
2447 |
this.assistNodeIsClass = ref.isClass(); |
2954 |
this.assistNodeIsClass = ref.isClass(); |
2448 |
this.assistNodeIsException = ref.isException(); |
2955 |
this.assistNodeIsException = ref.isException(); |
2449 |
this.assistNodeIsInterface = ref.isInterface(); |
2956 |
this.assistNodeIsInterface = ref.isInterface(); |
|
|
2957 |
this.assistNodeIsConstructor = ref.isConstructorType; |
2450 |
this.assistNodeIsSuperType = ref.isSuperType(); |
2958 |
this.assistNodeIsSuperType = ref.isSuperType(); |
2451 |
|
2959 |
|
2452 |
this.completionToken = ref.completionIdentifier; |
2960 |
this.completionToken = ref.completionIdentifier; |
Lines 3200-3206
Link Here
|
3200 |
TypeBinding caughtException = catchArguments[i].type.resolvedType; |
3708 |
TypeBinding caughtException = catchArguments[i].type.resolvedType; |
3201 |
if (caughtException != null) { |
3709 |
if (caughtException != null) { |
3202 |
addForbiddenBindings(caughtException); |
3710 |
addForbiddenBindings(caughtException); |
3203 |
this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), this); |
3711 |
this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS); |
3204 |
} |
3712 |
} |
3205 |
} |
3713 |
} |
3206 |
this.forbbidenBindingsFilter = SUBTYPE; |
3714 |
this.forbbidenBindingsFilter = SUBTYPE; |
Lines 3942-3986
Link Here
|
3942 |
} |
4450 |
} |
3943 |
} |
4451 |
} |
3944 |
private void findAnonymousType( |
4452 |
private void findAnonymousType( |
|
|
4453 |
ReferenceBinding currentType, |
4454 |
TypeBinding[] argTypes, |
4455 |
Scope scope, |
4456 |
InvocationSite invocationSite) { |
4457 |
|
4458 |
int relevance = computeBaseRelevance(); |
4459 |
relevance += computeRelevanceForResolution(); |
4460 |
relevance += computeRelevanceForInterestingProposal(); |
4461 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4462 |
|
4463 |
findAnonymousType(currentType, argTypes, scope, invocationSite, true, false, relevance); |
4464 |
} |
4465 |
private void findAnonymousType( |
3945 |
ReferenceBinding currentType, |
4466 |
ReferenceBinding currentType, |
3946 |
TypeBinding[] argTypes, |
4467 |
TypeBinding[] argTypes, |
3947 |
Scope scope, |
4468 |
Scope scope, |
3948 |
InvocationSite invocationSite) { |
4469 |
InvocationSite invocationSite, |
|
|
4470 |
boolean exactMatch, |
4471 |
boolean isQualified, |
4472 |
int relevance) { |
3949 |
|
4473 |
|
3950 |
if (currentType.isInterface()) { |
4474 |
if (currentType.isInterface()) { |
3951 |
char[] completion = CharOperation.NO_CHAR; |
4475 |
char[] completion = CharOperation.NO_CHAR; |
3952 |
int relevance = computeBaseRelevance(); |
4476 |
|
3953 |
relevance += computeRelevanceForResolution(); |
4477 |
if (!exactMatch) { |
3954 |
relevance += computeRelevanceForInterestingProposal(); |
4478 |
char[] typeName = |
3955 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4479 |
isQualified ? |
|
|
4480 |
CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') : |
4481 |
currentType.sourceName(); |
4482 |
completion = CharOperation.concat(typeName, new char[]{'(', ')'}); |
4483 |
} |
3956 |
|
4484 |
|
3957 |
this.noProposal = false; |
4485 |
this.noProposal = false; |
3958 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { |
4486 |
if (!exactMatch) { |
3959 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); |
4487 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) { |
3960 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4488 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
3961 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4489 |
proposal.setDeclarationSignature(getSignature(currentType)); |
3962 |
proposal.setSignature( |
4490 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
3963 |
createMethodSignature( |
4491 |
proposal.setSignature( |
3964 |
CharOperation.NO_CHAR_CHAR, |
4492 |
createMethodSignature( |
3965 |
CharOperation.NO_CHAR_CHAR, |
4493 |
CharOperation.NO_CHAR_CHAR, |
3966 |
CharOperation.NO_CHAR, |
4494 |
CharOperation.NO_CHAR_CHAR, |
3967 |
CharOperation.NO_CHAR)); |
4495 |
CharOperation.NO_CHAR, |
3968 |
//proposal.setOriginalSignature(null); |
4496 |
CharOperation.NO_CHAR)); |
3969 |
//proposal.setUniqueKey(null); |
4497 |
//proposal.setOriginalSignature(null); |
3970 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4498 |
//proposal.setUniqueKey(null); |
3971 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4499 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
3972 |
//proposal.setParameterPackageNames(null); |
4500 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
3973 |
//proposal.setParameterTypeNames(null); |
4501 |
//proposal.setParameterPackageNames(null); |
3974 |
//proposal.setPackageName(null); |
4502 |
//proposal.setParameterTypeNames(null); |
3975 |
//proposal.setTypeName(null); |
4503 |
//proposal.setPackageName(null); |
3976 |
proposal.setCompletion(completion); |
4504 |
//proposal.setTypeName(null); |
3977 |
proposal.setFlags(Flags.AccPublic); |
4505 |
proposal.setCompletion(completion); |
3978 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4506 |
proposal.setFlags(Flags.AccPublic); |
3979 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4507 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
3980 |
proposal.setRelevance(relevance); |
4508 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
3981 |
this.requestor.accept(proposal); |
4509 |
proposal.setRelevance(relevance); |
3982 |
if(DEBUG) { |
4510 |
this.requestor.accept(proposal); |
3983 |
this.printDebug(proposal); |
4511 |
if(DEBUG) { |
|
|
4512 |
this.printDebug(proposal); |
4513 |
} |
4514 |
} |
4515 |
} else { |
4516 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { |
4517 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); |
4518 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4519 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4520 |
proposal.setSignature( |
4521 |
createMethodSignature( |
4522 |
CharOperation.NO_CHAR_CHAR, |
4523 |
CharOperation.NO_CHAR_CHAR, |
4524 |
CharOperation.NO_CHAR, |
4525 |
CharOperation.NO_CHAR)); |
4526 |
//proposal.setOriginalSignature(null); |
4527 |
//proposal.setUniqueKey(null); |
4528 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4529 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4530 |
//proposal.setParameterPackageNames(null); |
4531 |
//proposal.setParameterTypeNames(null); |
4532 |
//proposal.setPackageName(null); |
4533 |
//proposal.setTypeName(null); |
4534 |
proposal.setCompletion(completion); |
4535 |
proposal.setFlags(Flags.AccPublic); |
4536 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4537 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4538 |
proposal.setRelevance(relevance); |
4539 |
this.requestor.accept(proposal); |
4540 |
if(DEBUG) { |
4541 |
this.printDebug(proposal); |
4542 |
} |
3984 |
} |
4543 |
} |
3985 |
} |
4544 |
} |
3986 |
} else { |
4545 |
} else { |
Lines 3989-3995
Link Here
|
3989 |
argTypes, |
4548 |
argTypes, |
3990 |
scope, |
4549 |
scope, |
3991 |
invocationSite, |
4550 |
invocationSite, |
3992 |
true); |
4551 |
true, |
|
|
4552 |
exactMatch, |
4553 |
isQualified, |
4554 |
relevance); |
3993 |
} |
4555 |
} |
3994 |
} |
4556 |
} |
3995 |
private void findClassField( |
4557 |
private void findClassField( |
Lines 4074-4079
Link Here
|
4074 |
Scope scope, |
4636 |
Scope scope, |
4075 |
InvocationSite invocationSite, |
4637 |
InvocationSite invocationSite, |
4076 |
boolean forAnonymousType) { |
4638 |
boolean forAnonymousType) { |
|
|
4639 |
|
4640 |
int relevance = computeBaseRelevance(); |
4641 |
relevance += computeRelevanceForResolution(); |
4642 |
relevance += computeRelevanceForInterestingProposal(); |
4643 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4644 |
|
4645 |
findConstructors(currentType, argTypes, scope, invocationSite, forAnonymousType, true, false, relevance); |
4646 |
} |
4647 |
|
4648 |
private void findConstructors( |
4649 |
ReferenceBinding currentType, |
4650 |
TypeBinding[] argTypes, |
4651 |
Scope scope, |
4652 |
InvocationSite invocationSite, |
4653 |
boolean forAnonymousType, |
4654 |
boolean exactMatch, |
4655 |
boolean isQualified, |
4656 |
int relevance) { |
4077 |
|
4657 |
|
4078 |
// No visibility checks can be performed without the scope & invocationSite |
4658 |
// No visibility checks can be performed without the scope & invocationSite |
4079 |
MethodBinding[] methods = currentType.availableMethods(); |
4659 |
MethodBinding[] methods = currentType.availableMethods(); |
Lines 4116-4161
Link Here
|
4116 |
char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames); |
4696 |
char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames); |
4117 |
|
4697 |
|
4118 |
char[] completion = CharOperation.NO_CHAR; |
4698 |
char[] completion = CharOperation.NO_CHAR; |
|
|
4699 |
|
4119 |
if(forAnonymousType){ |
4700 |
if(forAnonymousType){ |
4120 |
int relevance = computeBaseRelevance(); |
4701 |
if (!exactMatch) { |
4121 |
relevance += computeRelevanceForResolution(); |
4702 |
char[] typeName = |
4122 |
relevance += computeRelevanceForInterestingProposal(); |
4703 |
isQualified ? |
4123 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4704 |
CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') : |
4124 |
|
4705 |
currentType.sourceName(); |
|
|
4706 |
completion = CharOperation.concat(typeName, new char[]{'(', ')'}); |
4707 |
} |
4708 |
|
4125 |
this.noProposal = false; |
4709 |
this.noProposal = false; |
4126 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { |
4710 |
if (!exactMatch) { |
4127 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); |
4711 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) { |
4128 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4712 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
4129 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4713 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4130 |
proposal.setSignature(getSignature(constructor)); |
4714 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4131 |
MethodBinding original = constructor.original(); |
4715 |
proposal.setSignature(getSignature(constructor)); |
4132 |
if(original != constructor) { |
4716 |
MethodBinding original = constructor.original(); |
4133 |
proposal.setOriginalSignature(getSignature(original)); |
4717 |
if(original != constructor) { |
|
|
4718 |
proposal.setOriginalSignature(getSignature(original)); |
4719 |
} |
4720 |
proposal.setKey(constructor.computeUniqueKey()); |
4721 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4722 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4723 |
proposal.setParameterPackageNames(parameterPackageNames); |
4724 |
proposal.setParameterTypeNames(parameterTypeNames); |
4725 |
//proposal.setPackageName(null); |
4726 |
//proposal.setTypeName(null); |
4727 |
proposal.setCompletion(completion); |
4728 |
proposal.setFlags(constructor.modifiers); |
4729 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
4730 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4731 |
proposal.setRelevance(relevance); |
4732 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4733 |
this.requestor.accept(proposal); |
4734 |
if(DEBUG) { |
4735 |
this.printDebug(proposal); |
4736 |
} |
4134 |
} |
4737 |
} |
4135 |
proposal.setKey(constructor.computeUniqueKey()); |
4738 |
} else { |
4136 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4739 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { |
4137 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4740 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); |
4138 |
proposal.setParameterPackageNames(parameterPackageNames); |
4741 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4139 |
proposal.setParameterTypeNames(parameterTypeNames); |
4742 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4140 |
//proposal.setPackageName(null); |
4743 |
proposal.setSignature(getSignature(constructor)); |
4141 |
//proposal.setTypeName(null); |
4744 |
MethodBinding original = constructor.original(); |
4142 |
proposal.setCompletion(completion); |
4745 |
if(original != constructor) { |
4143 |
proposal.setFlags(constructor.modifiers); |
4746 |
proposal.setOriginalSignature(getSignature(original)); |
4144 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4747 |
} |
4145 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4748 |
proposal.setKey(constructor.computeUniqueKey()); |
4146 |
proposal.setRelevance(relevance); |
4749 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4147 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4750 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4148 |
this.requestor.accept(proposal); |
4751 |
proposal.setParameterPackageNames(parameterPackageNames); |
4149 |
if(DEBUG) { |
4752 |
proposal.setParameterTypeNames(parameterTypeNames); |
4150 |
this.printDebug(proposal); |
4753 |
//proposal.setPackageName(null); |
|
|
4754 |
//proposal.setTypeName(null); |
4755 |
proposal.setCompletion(completion); |
4756 |
proposal.setFlags(constructor.modifiers); |
4757 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4758 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4759 |
proposal.setRelevance(relevance); |
4760 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4761 |
this.requestor.accept(proposal); |
4762 |
if(DEBUG) { |
4763 |
this.printDebug(proposal); |
4764 |
} |
4151 |
} |
4765 |
} |
4152 |
} |
4766 |
} |
4153 |
} else { |
4767 |
} else { |
4154 |
int relevance = computeBaseRelevance(); |
|
|
4155 |
relevance += computeRelevanceForResolution(); |
4156 |
relevance += computeRelevanceForInterestingProposal(); |
4157 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4158 |
|
4159 |
// Special case for completion in javadoc |
4768 |
// Special case for completion in javadoc |
4160 |
if (this.assistNodeInJavadoc > 0) { |
4769 |
if (this.assistNodeInJavadoc > 0) { |
4161 |
Expression receiver = null; |
4770 |
Expression receiver = null; |
Lines 4207-4277
Link Here
|
4207 |
javadocCompletion.append(')'); |
4816 |
javadocCompletion.append(')'); |
4208 |
completion = javadocCompletion.toString().toCharArray(); |
4817 |
completion = javadocCompletion.toString().toCharArray(); |
4209 |
} |
4818 |
} |
|
|
4819 |
} else { |
4820 |
if (!exactMatch) { |
4821 |
char[] typeName = |
4822 |
isQualified ? |
4823 |
CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') : |
4824 |
currentType.sourceName(); |
4825 |
completion = CharOperation.concat(typeName, new char[]{'(', ')'}); |
4826 |
} |
4210 |
} |
4827 |
} |
4211 |
|
4828 |
|
4212 |
// Create standard proposal |
4829 |
// Create standard proposal |
4213 |
this.noProposal = false; |
4830 |
this.noProposal = false; |
4214 |
if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { |
4831 |
if (!exactMatch) { |
4215 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); |
4832 |
if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) { |
4216 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4833 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
4217 |
proposal.setSignature(getSignature(constructor)); |
4834 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4218 |
MethodBinding original = constructor.original(); |
4835 |
proposal.setSignature(getSignature(constructor)); |
4219 |
if(original != constructor) { |
4836 |
MethodBinding original = constructor.original(); |
4220 |
proposal.setOriginalSignature(getSignature(original)); |
4837 |
if(original != constructor) { |
|
|
4838 |
proposal.setOriginalSignature(getSignature(original)); |
4839 |
} |
4840 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4841 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4842 |
proposal.setParameterPackageNames(parameterPackageNames); |
4843 |
proposal.setParameterTypeNames(parameterTypeNames); |
4844 |
//proposal.setPackageName(null); |
4845 |
//proposal.setTypeName(null); |
4846 |
proposal.setName(currentType.sourceName()); |
4847 |
proposal.setIsContructor(true); |
4848 |
proposal.setCompletion(completion); |
4849 |
proposal.setFlags(constructor.modifiers); |
4850 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
4851 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4852 |
proposal.setRelevance(relevance); |
4853 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4854 |
this.requestor.accept(proposal); |
4855 |
if(DEBUG) { |
4856 |
this.printDebug(proposal); |
4857 |
} |
4221 |
} |
4858 |
} |
4222 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4859 |
} else { |
4223 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4860 |
if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { |
4224 |
proposal.setParameterPackageNames(parameterPackageNames); |
4861 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); |
4225 |
proposal.setParameterTypeNames(parameterTypeNames); |
4862 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4226 |
//proposal.setPackageName(null); |
4863 |
proposal.setSignature(getSignature(constructor)); |
4227 |
//proposal.setTypeName(null); |
4864 |
MethodBinding original = constructor.original(); |
4228 |
proposal.setName(currentType.sourceName()); |
4865 |
if(original != constructor) { |
4229 |
proposal.setIsContructor(true); |
4866 |
proposal.setOriginalSignature(getSignature(original)); |
4230 |
proposal.setCompletion(completion); |
4867 |
} |
4231 |
proposal.setFlags(constructor.modifiers); |
4868 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4232 |
int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition; |
4869 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4233 |
proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); |
4870 |
proposal.setParameterPackageNames(parameterPackageNames); |
4234 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4871 |
proposal.setParameterTypeNames(parameterTypeNames); |
4235 |
proposal.setRelevance(relevance); |
4872 |
//proposal.setPackageName(null); |
4236 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4873 |
//proposal.setTypeName(null); |
4237 |
this.requestor.accept(proposal); |
4874 |
proposal.setName(currentType.sourceName()); |
4238 |
if(DEBUG) { |
4875 |
proposal.setIsContructor(true); |
4239 |
this.printDebug(proposal); |
4876 |
proposal.setCompletion(completion); |
|
|
4877 |
proposal.setFlags(constructor.modifiers); |
4878 |
int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition; |
4879 |
proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); |
4880 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4881 |
proposal.setRelevance(relevance); |
4882 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4883 |
this.requestor.accept(proposal); |
4884 |
if(DEBUG) { |
4885 |
this.printDebug(proposal); |
4886 |
} |
4240 |
} |
4887 |
} |
4241 |
} |
4888 |
if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) { |
4242 |
if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) { |
4889 |
char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK); |
4243 |
char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK); |
4890 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition); |
4244 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition); |
4891 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4245 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4892 |
proposal.setSignature(getSignature(constructor)); |
4246 |
proposal.setSignature(getSignature(constructor)); |
4893 |
MethodBinding original = constructor.original(); |
4247 |
MethodBinding original = constructor.original(); |
4894 |
if(original != constructor) { |
4248 |
if(original != constructor) { |
4895 |
proposal.setOriginalSignature(getSignature(original)); |
4249 |
proposal.setOriginalSignature(getSignature(original)); |
4896 |
} |
|
|
4897 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4898 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4899 |
proposal.setParameterPackageNames(parameterPackageNames); |
4900 |
proposal.setParameterTypeNames(parameterTypeNames); |
4901 |
//proposal.setPackageName(null); |
4902 |
//proposal.setTypeName(null); |
4903 |
proposal.setName(currentType.sourceName()); |
4904 |
proposal.setIsContructor(true); |
4905 |
proposal.setCompletion(javadocCompletion); |
4906 |
proposal.setFlags(constructor.modifiers); |
4907 |
int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition; |
4908 |
proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); |
4909 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4910 |
proposal.setRelevance(relevance+R_INLINE_TAG); |
4911 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4912 |
this.requestor.accept(proposal); |
4913 |
if(DEBUG) { |
4914 |
this.printDebug(proposal); |
4915 |
} |
4250 |
} |
4916 |
} |
4251 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4917 |
} |
4252 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4918 |
} |
4253 |
proposal.setParameterPackageNames(parameterPackageNames); |
4919 |
} |
4254 |
proposal.setParameterTypeNames(parameterTypeNames); |
4920 |
} |
4255 |
//proposal.setPackageName(null); |
4921 |
} |
4256 |
//proposal.setTypeName(null); |
4922 |
} |
4257 |
proposal.setName(currentType.sourceName()); |
4923 |
|
4258 |
proposal.setIsContructor(true); |
4924 |
private char[] getResolvedSignature(char[][] parameterTypes, char[] fullyQualifiedTypeName, int parameterCount, Scope scope) { |
4259 |
proposal.setCompletion(javadocCompletion); |
4925 |
char[][] cn = CharOperation.splitOn('.', fullyQualifiedTypeName); |
4260 |
proposal.setFlags(constructor.modifiers); |
4926 |
|
4261 |
int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition; |
4927 |
TypeReference ref; |
4262 |
proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); |
4928 |
if (cn.length == 1) { |
4263 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4929 |
ref = new SingleTypeReference(cn[0], 0); |
4264 |
proposal.setRelevance(relevance+R_INLINE_TAG); |
4930 |
} else { |
4265 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4931 |
ref = new QualifiedTypeReference(cn,new long[cn.length]); |
4266 |
this.requestor.accept(proposal); |
4932 |
} |
4267 |
if(DEBUG) { |
4933 |
|
4268 |
this.printDebug(proposal); |
4934 |
TypeBinding guessedType = null; |
|
|
4935 |
INameEnvironment oldNameEnvironment = this.lookupEnvironment.nameEnvironment; |
4936 |
this.lookupEnvironment.nameEnvironment = getNoCacheNameEnvironment(); |
4937 |
try { |
4938 |
switch (scope.kind) { |
4939 |
case Scope.METHOD_SCOPE : |
4940 |
case Scope.BLOCK_SCOPE : |
4941 |
guessedType = ref.resolveType((BlockScope)scope); |
4942 |
break; |
4943 |
case Scope.CLASS_SCOPE : |
4944 |
guessedType = ref.resolveType((ClassScope)scope); |
4945 |
break; |
4946 |
} |
4947 |
} finally { |
4948 |
this.lookupEnvironment.nameEnvironment = oldNameEnvironment; |
4949 |
} |
4950 |
|
4951 |
if (guessedType != null && guessedType.isValidBinding()) { |
4952 |
if (guessedType instanceof ReferenceBinding) { |
4953 |
ReferenceBinding refBinding = (ReferenceBinding) guessedType; |
4954 |
|
4955 |
MethodBinding bestConstructor = null; |
4956 |
int[] bestMatchingLengths = null; |
4957 |
|
4958 |
MethodBinding[] methods = refBinding.methods(); |
4959 |
next : for (int i = 0; i < methods.length; i++) { |
4960 |
MethodBinding method = methods[i]; |
4961 |
|
4962 |
if (!method.isConstructor()) break next; |
4963 |
|
4964 |
TypeBinding[] parameters = method.parameters; |
4965 |
//TODO take careful of member types |
4966 |
int parametersLength = parameters == null ? 0 : parameters.length; |
4967 |
if (parameterCount != parametersLength) continue next; |
4968 |
|
4969 |
int[] matchingLengths = new int[parameterCount]; |
4970 |
for (int j = 0; j < parametersLength; j++) { |
4971 |
TypeBinding parameter = parameters[j]; |
4972 |
|
4973 |
char[] parameterTypeName; |
4974 |
if (parameter instanceof ReferenceBinding) { |
4975 |
parameterTypeName = CharOperation.concatWith(((ReferenceBinding)parameter).compoundName, '.'); |
4976 |
} else { |
4977 |
parameterTypeName = parameter.sourceName(); |
4978 |
} |
4979 |
|
4980 |
if (!CharOperation.endsWith(parameterTypeName, parameterTypes[j])) { |
4981 |
break next; |
4982 |
} |
4983 |
|
4984 |
int matchingLength = parameterTypes[j].length; |
4985 |
|
4986 |
if (bestMatchingLengths != null) { |
4987 |
if (bestMatchingLengths[j] > matchingLength) { |
4988 |
continue next; |
4269 |
} |
4989 |
} |
4270 |
} |
4990 |
} |
|
|
4991 |
|
4992 |
matchingLengths[j] = matchingLength; |
4271 |
} |
4993 |
} |
|
|
4994 |
|
4995 |
|
4996 |
bestConstructor = method; |
4997 |
bestMatchingLengths = matchingLengths; |
4272 |
} |
4998 |
} |
|
|
4999 |
|
5000 |
if (bestConstructor == null) return null; |
5001 |
return getSignature(bestConstructor); |
4273 |
} |
5002 |
} |
4274 |
} |
5003 |
} |
|
|
5004 |
|
5005 |
return null; |
5006 |
} |
5007 |
|
5008 |
private void findConstructorsOrAnonymousTypes( |
5009 |
ReferenceBinding currentType, |
5010 |
Scope scope, |
5011 |
InvocationSite invocationSite, |
5012 |
boolean isQualified, |
5013 |
int relevance) { |
5014 |
|
5015 |
if (!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION) |
5016 |
&& currentType.isClass() |
5017 |
&& !currentType.isAbstract()) { |
5018 |
findConstructors( |
5019 |
currentType, |
5020 |
null, |
5021 |
scope, |
5022 |
invocationSite, |
5023 |
false, |
5024 |
false, |
5025 |
isQualified, |
5026 |
relevance); |
5027 |
} |
5028 |
|
5029 |
// This code is disabled because there is too much proposals when constructors and anonymous are proposed |
5030 |
if (!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) |
5031 |
&& !currentType.isFinal() |
5032 |
&& (currentType.isInterface() || (currentType.isClass() && currentType.isAbstract()))){ |
5033 |
findAnonymousType( |
5034 |
currentType, |
5035 |
null, |
5036 |
scope, |
5037 |
invocationSite, |
5038 |
false, |
5039 |
isQualified, |
5040 |
relevance); |
5041 |
} |
4275 |
} |
5042 |
} |
4276 |
private char[][] findEnclosingTypeNames(Scope scope){ |
5043 |
private char[][] findEnclosingTypeNames(Scope scope){ |
4277 |
char[][] excludedNames = new char[10][]; |
5044 |
char[][] excludedNames = new char[10][]; |
Lines 8229-8245
Link Here
|
8229 |
relevance += computeRelevanceForMissingElements(missingElementsHaveProblems); |
8996 |
relevance += computeRelevanceForMissingElements(missingElementsHaveProblems); |
8230 |
} |
8997 |
} |
8231 |
|
8998 |
|
|
|
8999 |
boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals(); |
9000 |
|
8232 |
this.noProposal = false; |
9001 |
this.noProposal = false; |
8233 |
createTypeProposal( |
9002 |
if (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(memberType, invocationType, this.unitScope)) { |
8234 |
memberType, |
9003 |
createTypeProposal( |
8235 |
memberType.qualifiedSourceName(), |
9004 |
memberType, |
8236 |
IAccessRule.K_ACCESSIBLE, |
9005 |
memberType.qualifiedSourceName(), |
8237 |
completionName, |
9006 |
IAccessRule.K_ACCESSIBLE, |
8238 |
relevance, |
9007 |
completionName, |
8239 |
missingElements, |
9008 |
relevance, |
8240 |
missingElementsStarts, |
9009 |
missingElements, |
8241 |
missingElementsEnds, |
9010 |
missingElementsStarts, |
8242 |
missingElementsHaveProblems); |
9011 |
missingElementsEnds, |
|
|
9012 |
missingElementsHaveProblems); |
9013 |
} |
9014 |
|
9015 |
if (this.assistNodeIsConstructor && allowingLongComputationProposals) { |
9016 |
findConstructorsOrAnonymousTypes( |
9017 |
memberType, |
9018 |
scope, |
9019 |
FakeInvocationSite, |
9020 |
isQualified, |
9021 |
relevance); |
9022 |
} |
8243 |
} |
9023 |
} |
8244 |
} |
9024 |
} |
8245 |
private void findMemberTypesFromMissingType( |
9025 |
private void findMemberTypesFromMissingType( |
Lines 8658-8675
Link Here
|
8658 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type |
9438 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type |
8659 |
relevance += computeRelevanceForAnnotationTarget(localType); |
9439 |
relevance += computeRelevanceForAnnotationTarget(localType); |
8660 |
|
9440 |
|
8661 |
this.noProposal = false; |
9441 |
boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals(); |
8662 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
9442 |
if (!this.assistNodeIsConstructor || !allowingLongComputationProposals) { |
8663 |
createTypeProposal( |
9443 |
this.noProposal = false; |
|
|
9444 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
9445 |
createTypeProposal( |
9446 |
localType, |
9447 |
localType.sourceName, |
9448 |
IAccessRule.K_ACCESSIBLE, |
9449 |
localType.sourceName, |
9450 |
relevance, |
9451 |
null, |
9452 |
null, |
9453 |
null, |
9454 |
false); |
9455 |
} |
9456 |
} |
9457 |
|
9458 |
if (this.assistNodeIsConstructor && allowingLongComputationProposals) { |
9459 |
findConstructorsOrAnonymousTypes( |
8664 |
localType, |
9460 |
localType, |
8665 |
localType.sourceName, |
9461 |
blockScope, |
8666 |
IAccessRule.K_ACCESSIBLE, |
9462 |
FakeInvocationSite, |
8667 |
localType.sourceName, |
9463 |
false, |
8668 |
relevance, |
9464 |
relevance); |
8669 |
null, |
|
|
8670 |
null, |
8671 |
null, |
8672 |
false); |
8673 |
} |
9465 |
} |
8674 |
} |
9466 |
} |
8675 |
} |
9467 |
} |
Lines 8917-8930
Link Here
|
8917 |
|
9709 |
|
8918 |
if (token == null) |
9710 |
if (token == null) |
8919 |
return; |
9711 |
return; |
8920 |
|
9712 |
|
|
|
9713 |
boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals(); |
9714 |
|
8921 |
boolean proposeType = |
9715 |
boolean proposeType = |
8922 |
!this.requestor.isIgnored(CompletionProposal.TYPE_REF) || |
9716 |
!this.requestor.isIgnored(CompletionProposal.TYPE_REF) || |
8923 |
((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)); |
9717 |
((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)); |
8924 |
|
9718 |
|
8925 |
boolean proposeAllMemberTypes = !this.assistNodeIsConstructor; |
9719 |
boolean proposeAllMemberTypes = !this.assistNodeIsConstructor; |
|
|
9720 |
|
9721 |
boolean proposeConstructor = |
9722 |
allowingLongComputationProposals && |
9723 |
this.assistNodeIsConstructor && |
9724 |
(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION) || !this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)); |
9725 |
|
8926 |
|
9726 |
|
8927 |
if (proposeType && scope.enclosingSourceType() != null) { |
9727 |
if ((proposeType || proposeConstructor) && scope.enclosingSourceType() != null) { |
8928 |
|
9728 |
|
8929 |
checkCancel(); |
9729 |
checkCancel(); |
8930 |
|
9730 |
|
Lines 8943-8949
Link Here
|
8943 |
|
9743 |
|
8944 |
boolean isEmptyPrefix = token.length == 0; |
9744 |
boolean isEmptyPrefix = token.length == 0; |
8945 |
|
9745 |
|
8946 |
if (proposeType && this.unitScope != null) { |
9746 |
if ((proposeType || proposeConstructor) && this.unitScope != null) { |
8947 |
|
9747 |
|
8948 |
ReferenceBinding outerInvocationType = scope.enclosingSourceType(); |
9748 |
ReferenceBinding outerInvocationType = scope.enclosingSourceType(); |
8949 |
if(outerInvocationType != null) { |
9749 |
if(outerInvocationType != null) { |
Lines 8984-8990
Link Here
|
8984 |
if (typeLength > sourceType.sourceName.length) continue next; |
9784 |
if (typeLength > sourceType.sourceName.length) continue next; |
8985 |
|
9785 |
|
8986 |
if (!CharOperation.prefixEquals(token, sourceType.sourceName, false) |
9786 |
if (!CharOperation.prefixEquals(token, sourceType.sourceName, false) |
8987 |
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue; |
9787 |
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue next; |
8988 |
|
9788 |
|
8989 |
if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) { |
9789 |
if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) { |
8990 |
continue next; |
9790 |
continue next; |
Lines 8995-9002
Link Here
|
8995 |
|
9795 |
|
8996 |
if (sourceType == otherType) continue next; |
9796 |
if (sourceType == otherType) continue next; |
8997 |
} |
9797 |
} |
8998 |
|
9798 |
|
8999 |
this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this); |
9799 |
typesFound.add(sourceType); |
9000 |
|
9800 |
|
9001 |
if(this.assistNodeIsClass) { |
9801 |
if(this.assistNodeIsClass) { |
9002 |
if(!sourceType.isClass()) continue next; |
9802 |
if(!sourceType.isClass()) continue next; |
Lines 9027-9034
Link Here
|
9027 |
relevance += computeRelevanceForClass(); |
9827 |
relevance += computeRelevanceForClass(); |
9028 |
relevance += computeRelevanceForException(sourceType.sourceName); |
9828 |
relevance += computeRelevanceForException(sourceType.sourceName); |
9029 |
} |
9829 |
} |
|
|
9830 |
|
9831 |
|
9030 |
this.noProposal = false; |
9832 |
this.noProposal = false; |
9031 |
if(proposeType) { |
9833 |
if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) { |
9032 |
char[] typeName = sourceType.sourceName(); |
9834 |
char[] typeName = sourceType.sourceName(); |
9033 |
createTypeProposal( |
9835 |
createTypeProposal( |
9034 |
sourceType, |
9836 |
sourceType, |
Lines 9041-9181
Link Here
|
9041 |
null, |
9843 |
null, |
9042 |
false); |
9844 |
false); |
9043 |
} |
9845 |
} |
|
|
9846 |
|
9847 |
if (proposeConstructor) { |
9848 |
findConstructorsOrAnonymousTypes( |
9849 |
sourceType, |
9850 |
scope, |
9851 |
FakeInvocationSite, |
9852 |
false, |
9853 |
relevance); |
9854 |
} |
9044 |
} |
9855 |
} |
9045 |
} |
9856 |
} |
9046 |
|
9857 |
|
9047 |
if(proposeType) { |
9858 |
if (proposeConstructor && !isEmptyPrefix) { |
|
|
9859 |
|
9860 |
checkCancel(); |
9861 |
|
9862 |
findTypesFromImports(token, scope, proposeType, typesFound); |
9863 |
} else if(proposeType) { |
9048 |
|
9864 |
|
9049 |
checkCancel(); |
9865 |
checkCancel(); |
9050 |
|
9866 |
|
9051 |
findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound); |
9867 |
findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound); |
9052 |
} |
9868 |
} |
|
|
9869 |
|
9870 |
if (proposeConstructor) { |
9871 |
|
9872 |
checkCancel(); |
9873 |
|
9874 |
findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor); |
9875 |
} |
9053 |
|
9876 |
|
9054 |
if (isEmptyPrefix && !this.assistNodeIsAnnotation) { |
9877 |
if (isEmptyPrefix && !this.assistNodeIsAnnotation) { |
9055 |
if(proposeType && this.expectedTypesPtr > -1) { |
9878 |
if (!proposeConstructor) { |
9056 |
next : for (int i = 0; i <= this.expectedTypesPtr; i++) { |
9879 |
findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor); |
9057 |
|
9880 |
} |
9058 |
checkCancel(); |
9881 |
} else { |
9059 |
|
9882 |
if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
9060 |
if(this.expectedTypes[i] instanceof ReferenceBinding) { |
9883 |
if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) { |
9061 |
ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i]; |
9884 |
if (proposeBaseTypes) { |
9062 |
|
9885 |
if (proposeVoidType) { |
9063 |
if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) { |
9886 |
findKeywords(token, BASE_TYPE_NAMES, false, false); |
9064 |
// don't propose type variable if the completion is a constructor ('new |') |
9887 |
} else { |
9065 |
continue next; |
9888 |
findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false); |
9066 |
} |
|
|
9067 |
if (this.options.checkDeprecation && |
9068 |
refBinding.isViewedAsDeprecated() && |
9069 |
!scope.isDefinedInSameUnit(refBinding)) |
9070 |
continue next; |
9071 |
|
9072 |
int accessibility = IAccessRule.K_ACCESSIBLE; |
9073 |
if(refBinding.hasRestrictedAccess()) { |
9074 |
AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding); |
9075 |
if(accessRestriction != null) { |
9076 |
switch (accessRestriction.getProblemId()) { |
9077 |
case IProblem.ForbiddenReference: |
9078 |
if (this.options.checkForbiddenReference) { |
9079 |
continue next; |
9080 |
} |
9081 |
accessibility = IAccessRule.K_NON_ACCESSIBLE; |
9082 |
break; |
9083 |
case IProblem.DiscouragedReference: |
9084 |
if (this.options.checkDiscouragedReference) { |
9085 |
continue next; |
9086 |
} |
9087 |
accessibility = IAccessRule.K_DISCOURAGED; |
9088 |
break; |
9089 |
} |
9090 |
} |
9091 |
} |
9092 |
|
9093 |
for (int j = 0; j < typesFound.size(); j++) { |
9094 |
ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j); |
9095 |
if (typeFound == refBinding) { |
9096 |
continue next; |
9097 |
} |
9098 |
} |
9099 |
|
9100 |
boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding); |
9101 |
|
9102 |
// top level types of the current unit are already proposed. |
9103 |
if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) { |
9104 |
char[] packageName = refBinding.qualifiedPackageName(); |
9105 |
char[] typeName = refBinding.sourceName(); |
9106 |
char[] completionName = typeName; |
9107 |
|
9108 |
boolean isQualified = false; |
9109 |
if (!this.insideQualifiedReference && !refBinding.isMemberType()) { |
9110 |
if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) { |
9111 |
if (packageName == null || packageName.length == 0) |
9112 |
if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR) |
9113 |
continue next; // ignore types from the default package from outside it |
9114 |
completionName = CharOperation.concat(packageName, typeName, '.'); |
9115 |
isQualified = true; |
9116 |
} |
9117 |
} |
9118 |
|
9119 |
if(this.assistNodeIsClass) { |
9120 |
if(!refBinding.isClass()) continue next; |
9121 |
} else if(this.assistNodeIsInterface) { |
9122 |
if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next; |
9123 |
} else if (this.assistNodeIsAnnotation) { |
9124 |
if(!refBinding.isAnnotationType()) continue next; |
9125 |
} |
9126 |
|
9127 |
int relevance = computeBaseRelevance(); |
9128 |
relevance += computeRelevanceForResolution(); |
9129 |
relevance += computeRelevanceForInterestingProposal(); |
9130 |
relevance += computeRelevanceForCaseMatching(token, typeName); |
9131 |
relevance += computeRelevanceForExpectingType(refBinding); |
9132 |
relevance += computeRelevanceForQualification(isQualified); |
9133 |
relevance += computeRelevanceForRestrictions(accessibility); |
9134 |
|
9135 |
if(refBinding.isClass()) { |
9136 |
relevance += computeRelevanceForClass(); |
9137 |
relevance += computeRelevanceForException(typeName); |
9138 |
} else if(refBinding.isEnum()) { |
9139 |
relevance += computeRelevanceForEnum(); |
9140 |
} else if(refBinding.isInterface()) { |
9141 |
relevance += computeRelevanceForInterface(); |
9142 |
} |
9143 |
|
9144 |
this.noProposal = false; |
9145 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
9146 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
9147 |
proposal.setDeclarationSignature(packageName); |
9148 |
proposal.setSignature(getSignature(refBinding)); |
9149 |
proposal.setPackageName(packageName); |
9150 |
proposal.setTypeName(typeName); |
9151 |
proposal.setCompletion(completionName); |
9152 |
proposal.setFlags(refBinding.modifiers); |
9153 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
9154 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
9155 |
proposal.setRelevance(relevance); |
9156 |
proposal.setAccessibility(accessibility); |
9157 |
this.requestor.accept(proposal); |
9158 |
if(DEBUG) { |
9159 |
this.printDebug(proposal); |
9160 |
} |
9161 |
} |
9162 |
} |
9889 |
} |
9163 |
} |
9890 |
} |
9164 |
} |
9891 |
} |
9165 |
} |
9892 |
} |
9166 |
} else { |
9893 |
|
9167 |
if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
9894 |
if (proposeConstructor) { |
9168 |
if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) { |
9895 |
int l = typesFound.size(); |
9169 |
if (proposeBaseTypes) { |
9896 |
for (int i = 0; i < l; i++) { |
9170 |
if (proposeVoidType) { |
9897 |
ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i); |
9171 |
findKeywords(token, BASE_TYPE_NAMES, false, false); |
9898 |
char[] fullyQualifiedTypeName = |
9172 |
} else { |
9899 |
CharOperation.concat( |
9173 |
findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false); |
9900 |
typeFound.qualifiedPackageName(), |
9174 |
} |
9901 |
typeFound.qualifiedSourceName(), |
9175 |
} |
9902 |
'.'); |
|
|
9903 |
this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS); |
9176 |
} |
9904 |
} |
9177 |
} |
9905 |
|
9178 |
if(proposeType) { |
9906 |
checkCancel(); |
|
|
9907 |
|
9908 |
this.foundConstructorsCount = 0; |
9909 |
this.nameEnvironment.findConstructorDeclarations( |
9910 |
token, |
9911 |
this.options.camelCaseMatch, |
9912 |
this, |
9913 |
this.monitor); |
9914 |
acceptConstructors(scope); |
9915 |
} else if (proposeType) { |
9179 |
int l = typesFound.size(); |
9916 |
int l = typesFound.size(); |
9180 |
for (int i = 0; i < l; i++) { |
9917 |
for (int i = 0; i < l; i++) { |
9181 |
ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i); |
9918 |
ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i); |
Lines 9184-9190
Link Here
|
9184 |
typeFound.qualifiedPackageName(), |
9921 |
typeFound.qualifiedPackageName(), |
9185 |
typeFound.qualifiedSourceName(), |
9922 |
typeFound.qualifiedSourceName(), |
9186 |
'.'); |
9923 |
'.'); |
9187 |
this.knownTypes.put(fullyQualifiedTypeName, this); |
9924 |
this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS); |
9188 |
} |
9925 |
} |
9189 |
int searchFor = IJavaSearchConstants.TYPE; |
9926 |
int searchFor = IJavaSearchConstants.TYPE; |
9190 |
if(this.assistNodeIsClass) { |
9927 |
if(this.assistNodeIsClass) { |
Lines 9222-9231
Link Here
|
9222 |
char[] token, |
9959 |
char[] token, |
9223 |
PackageBinding packageBinding, |
9960 |
PackageBinding packageBinding, |
9224 |
Scope scope) { |
9961 |
Scope scope) { |
|
|
9962 |
|
9963 |
boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals(); |
9225 |
|
9964 |
|
9226 |
boolean proposeType = |
9965 |
boolean proposeType = |
9227 |
!this.requestor.isIgnored(CompletionProposal.TYPE_REF) || |
9966 |
!this.requestor.isIgnored(CompletionProposal.TYPE_REF) || |
9228 |
((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)); |
9967 |
((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)); |
|
|
9968 |
|
9969 |
boolean proposeConstructor = |
9970 |
allowingLongComputationProposals && |
9971 |
this.assistNodeIsConstructor && |
9972 |
(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION) || !this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)); |
9229 |
|
9973 |
|
9230 |
char[] qualifiedName = |
9974 |
char[] qualifiedName = |
9231 |
CharOperation.concatWith(packageBinding.compoundName, token, '.'); |
9975 |
CharOperation.concatWith(packageBinding.compoundName, token, '.'); |
Lines 9243-9249
Link Here
|
9243 |
|
9987 |
|
9244 |
this.qualifiedCompletionToken = qualifiedName; |
9988 |
this.qualifiedCompletionToken = qualifiedName; |
9245 |
|
9989 |
|
9246 |
if (proposeType && this.unitScope != null) { |
9990 |
if ((proposeType || proposeConstructor) && this.unitScope != null) { |
9247 |
int typeLength = qualifiedName.length; |
9991 |
int typeLength = qualifiedName.length; |
9248 |
SourceTypeBinding[] types = this.unitScope.topLevelTypes; |
9992 |
SourceTypeBinding[] types = this.unitScope.topLevelTypes; |
9249 |
|
9993 |
|
Lines 9289-9295
Link Here
|
9289 |
} |
10033 |
} |
9290 |
} |
10034 |
} |
9291 |
|
10035 |
|
9292 |
this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this); |
10036 |
this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS); |
9293 |
|
10037 |
|
9294 |
int relevance = computeBaseRelevance(); |
10038 |
int relevance = computeBaseRelevance(); |
9295 |
relevance += computeRelevanceForResolution(); |
10039 |
relevance += computeRelevanceForResolution(); |
Lines 9307-9314
Link Here
|
9307 |
relevance += computeRelevanceForClass(); |
10051 |
relevance += computeRelevanceForClass(); |
9308 |
relevance += computeRelevanceForException(sourceType.sourceName); |
10052 |
relevance += computeRelevanceForException(sourceType.sourceName); |
9309 |
} |
10053 |
} |
|
|
10054 |
|
9310 |
this.noProposal = false; |
10055 |
this.noProposal = false; |
9311 |
if(proposeType) { |
10056 |
if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) { |
9312 |
char[] typeName = sourceType.sourceName(); |
10057 |
char[] typeName = sourceType.sourceName(); |
9313 |
createTypeProposal( |
10058 |
createTypeProposal( |
9314 |
sourceType, |
10059 |
sourceType, |
Lines 9321-9330
Link Here
|
9321 |
null, |
10066 |
null, |
9322 |
false); |
10067 |
false); |
9323 |
} |
10068 |
} |
|
|
10069 |
|
10070 |
if (proposeConstructor) { |
10071 |
findConstructorsOrAnonymousTypes( |
10072 |
sourceType, |
10073 |
scope, |
10074 |
FakeInvocationSite, |
10075 |
false, |
10076 |
relevance); |
10077 |
} |
9324 |
} |
10078 |
} |
9325 |
} |
10079 |
} |
9326 |
|
10080 |
|
9327 |
if(proposeType) { |
10081 |
if (proposeConstructor) { |
|
|
10082 |
|
10083 |
|
10084 |
checkCancel(); |
10085 |
|
10086 |
this.foundConstructorsCount = 0; |
10087 |
this.nameEnvironment.findConstructorDeclarations( |
10088 |
qualifiedName, |
10089 |
this.options.camelCaseMatch, |
10090 |
this, |
10091 |
this.monitor); |
10092 |
acceptConstructors(scope); |
10093 |
} if(proposeType) { |
9328 |
int searchFor = IJavaSearchConstants.TYPE; |
10094 |
int searchFor = IJavaSearchConstants.TYPE; |
9329 |
if(this.assistNodeIsClass) { |
10095 |
if(this.assistNodeIsClass) { |
9330 |
searchFor = IJavaSearchConstants.CLASS; |
10096 |
searchFor = IJavaSearchConstants.CLASS; |
Lines 9348-9358
Link Here
|
9348 |
this.monitor); |
10114 |
this.monitor); |
9349 |
acceptTypes(scope); |
10115 |
acceptTypes(scope); |
9350 |
} |
10116 |
} |
|
|
10117 |
|
9351 |
if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { |
10118 |
if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { |
9352 |
this.nameEnvironment.findPackages(qualifiedName, this); |
10119 |
this.nameEnvironment.findPackages(qualifiedName, this); |
9353 |
} |
10120 |
} |
9354 |
} |
10121 |
} |
|
|
10122 |
|
10123 |
private void findTypesFromExpectedTypes(char[] token, Scope scope, ObjectVector typesFound, boolean proposeType, boolean proposeConstructor) { |
10124 |
if(this.expectedTypesPtr > -1) { |
10125 |
boolean allowingLongComputationProposals = this.requestor.isAllowingLongComputationProposals(); |
10126 |
|
10127 |
int typeLength = token == null ? 0 : token.length; |
10128 |
|
10129 |
next : for (int i = 0; i <= this.expectedTypesPtr; i++) { |
10130 |
|
10131 |
checkCancel(); |
10132 |
|
10133 |
if(this.expectedTypes[i] instanceof ReferenceBinding) { |
10134 |
ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i]; |
10135 |
|
10136 |
if (typeLength > 0) { |
10137 |
if (typeLength > refBinding.sourceName.length) continue next; |
10138 |
|
10139 |
if (!CharOperation.prefixEquals(token, refBinding.sourceName, false) |
10140 |
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, refBinding.sourceName))) continue next; |
10141 |
} |
10142 |
|
10143 |
|
10144 |
if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) { |
10145 |
// don't propose type variable if the completion is a constructor ('new |') |
10146 |
continue next; |
10147 |
} |
10148 |
if (this.options.checkDeprecation && |
10149 |
refBinding.isViewedAsDeprecated() && |
10150 |
!scope.isDefinedInSameUnit(refBinding)) |
10151 |
continue next; |
10152 |
|
10153 |
int accessibility = IAccessRule.K_ACCESSIBLE; |
10154 |
if(refBinding.hasRestrictedAccess()) { |
10155 |
AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding); |
10156 |
if(accessRestriction != null) { |
10157 |
switch (accessRestriction.getProblemId()) { |
10158 |
case IProblem.ForbiddenReference: |
10159 |
if (this.options.checkForbiddenReference) { |
10160 |
continue next; |
10161 |
} |
10162 |
accessibility = IAccessRule.K_NON_ACCESSIBLE; |
10163 |
break; |
10164 |
case IProblem.DiscouragedReference: |
10165 |
if (this.options.checkDiscouragedReference) { |
10166 |
continue next; |
10167 |
} |
10168 |
accessibility = IAccessRule.K_DISCOURAGED; |
10169 |
break; |
10170 |
} |
10171 |
} |
10172 |
} |
10173 |
|
10174 |
for (int j = 0; j < typesFound.size(); j++) { |
10175 |
ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j); |
10176 |
if (typeFound == refBinding) { |
10177 |
continue next; |
10178 |
} |
10179 |
} |
10180 |
|
10181 |
typesFound.add(refBinding); |
10182 |
|
10183 |
boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding); |
10184 |
|
10185 |
// top level types of the current unit are already proposed. |
10186 |
if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) { |
10187 |
char[] packageName = refBinding.qualifiedPackageName(); |
10188 |
char[] typeName = refBinding.sourceName(); |
10189 |
char[] completionName = typeName; |
10190 |
|
10191 |
boolean isQualified = false; |
10192 |
if (!this.insideQualifiedReference && !refBinding.isMemberType()) { |
10193 |
if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) { |
10194 |
if (packageName == null || packageName.length == 0) |
10195 |
if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR) |
10196 |
continue next; // ignore types from the default package from outside it |
10197 |
completionName = CharOperation.concat(packageName, typeName, '.'); |
10198 |
isQualified = true; |
10199 |
} |
10200 |
} |
10201 |
|
10202 |
if(this.assistNodeIsClass) { |
10203 |
if(!refBinding.isClass()) continue next; |
10204 |
} else if(this.assistNodeIsInterface) { |
10205 |
if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next; |
10206 |
} else if (this.assistNodeIsAnnotation) { |
10207 |
if(!refBinding.isAnnotationType()) continue next; |
10208 |
} |
10209 |
|
10210 |
int relevance = computeBaseRelevance(); |
10211 |
relevance += computeRelevanceForResolution(); |
10212 |
relevance += computeRelevanceForInterestingProposal(); |
10213 |
relevance += computeRelevanceForCaseMatching(token, typeName); |
10214 |
relevance += computeRelevanceForExpectingType(refBinding); |
10215 |
relevance += computeRelevanceForQualification(isQualified); |
10216 |
relevance += computeRelevanceForRestrictions(accessibility); |
10217 |
|
10218 |
if(refBinding.isClass()) { |
10219 |
relevance += computeRelevanceForClass(); |
10220 |
relevance += computeRelevanceForException(typeName); |
10221 |
} else if(refBinding.isEnum()) { |
10222 |
relevance += computeRelevanceForEnum(); |
10223 |
} else if(refBinding.isInterface()) { |
10224 |
relevance += computeRelevanceForInterface(); |
10225 |
} |
10226 |
|
10227 |
if (proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(refBinding, scope.enclosingSourceType() ,this.unitScope))) { |
10228 |
this.noProposal = false; |
10229 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
10230 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
10231 |
proposal.setDeclarationSignature(packageName); |
10232 |
proposal.setSignature(getSignature(refBinding)); |
10233 |
proposal.setPackageName(packageName); |
10234 |
proposal.setTypeName(typeName); |
10235 |
proposal.setCompletion(completionName); |
10236 |
proposal.setFlags(refBinding.modifiers); |
10237 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
10238 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
10239 |
proposal.setRelevance(relevance); |
10240 |
proposal.setAccessibility(accessibility); |
10241 |
this.requestor.accept(proposal); |
10242 |
if(DEBUG) { |
10243 |
this.printDebug(proposal); |
10244 |
} |
10245 |
} |
10246 |
} |
10247 |
|
10248 |
if (proposeConstructor) { |
10249 |
findConstructorsOrAnonymousTypes( |
10250 |
refBinding, |
10251 |
scope, |
10252 |
FakeInvocationSite, |
10253 |
isQualified, |
10254 |
relevance); |
10255 |
} |
10256 |
} |
10257 |
} |
10258 |
} |
10259 |
} |
10260 |
} |
10261 |
|
10262 |
private void findTypesFromImports(char[] token, Scope scope, boolean proposeType, ObjectVector typesFound) { |
10263 |
ImportBinding[] importBindings = scope.compilationUnitScope().imports; |
10264 |
next : for (int i = 0; i < importBindings.length; i++) { |
10265 |
ImportBinding importBinding = importBindings[i]; |
10266 |
if(importBinding.isValidBinding()) { |
10267 |
Binding binding = importBinding.resolvedImport; |
10268 |
if(binding != null && binding.isValidBinding()) { |
10269 |
if(importBinding.onDemand) { |
10270 |
if (importBinding.isStatic()) { |
10271 |
if((binding.kind() & Binding.TYPE) != 0) { |
10272 |
this.findMemberTypes( |
10273 |
token, |
10274 |
(ReferenceBinding) binding, |
10275 |
scope, |
10276 |
scope.enclosingSourceType(), |
10277 |
true, |
10278 |
false, |
10279 |
true, |
10280 |
true, |
10281 |
false, |
10282 |
null, |
10283 |
typesFound, |
10284 |
null, |
10285 |
null, |
10286 |
null, |
10287 |
false); |
10288 |
} |
10289 |
} |
10290 |
} else { |
10291 |
if ((binding.kind() & Binding.TYPE) != 0) { |
10292 |
ReferenceBinding typeBinding = (ReferenceBinding) binding; |
10293 |
int typeLength = token.length; |
9355 |
|
10294 |
|
|
|
10295 |
if (!typeBinding.isStatic()) continue next; |
10296 |
|
10297 |
if (typeLength > typeBinding.sourceName.length) continue next; |
10298 |
|
10299 |
if (!CharOperation.prefixEquals(token, typeBinding.sourceName, false) |
10300 |
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, typeBinding.sourceName))) continue next; |
10301 |
|
10302 |
int accessibility = IAccessRule.K_ACCESSIBLE; |
10303 |
if(typeBinding.hasRestrictedAccess()) { |
10304 |
AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(typeBinding); |
10305 |
if(accessRestriction != null) { |
10306 |
switch (accessRestriction.getProblemId()) { |
10307 |
case IProblem.ForbiddenReference: |
10308 |
if (this.options.checkForbiddenReference) { |
10309 |
continue next; |
10310 |
} |
10311 |
accessibility = IAccessRule.K_NON_ACCESSIBLE; |
10312 |
break; |
10313 |
case IProblem.DiscouragedReference: |
10314 |
if (this.options.checkDiscouragedReference) { |
10315 |
continue next; |
10316 |
} |
10317 |
accessibility = IAccessRule.K_DISCOURAGED; |
10318 |
break; |
10319 |
} |
10320 |
} |
10321 |
} |
10322 |
|
10323 |
if (typesFound.contains(typeBinding)) continue next; |
10324 |
|
10325 |
typesFound.add(typeBinding); |
10326 |
|
10327 |
if(this.assistNodeIsClass) { |
10328 |
if(!typeBinding.isClass()) continue; |
10329 |
} else if(this.assistNodeIsInterface) { |
10330 |
if(!typeBinding.isInterface() && !typeBinding.isAnnotationType()) continue; |
10331 |
} else if (this.assistNodeIsAnnotation) { |
10332 |
if(!typeBinding.isAnnotationType()) continue; |
10333 |
} |
10334 |
|
10335 |
int relevance = computeBaseRelevance(); |
10336 |
relevance += computeRelevanceForResolution(); |
10337 |
relevance += computeRelevanceForInterestingProposal(); |
10338 |
relevance += computeRelevanceForCaseMatching(token, typeBinding.sourceName); |
10339 |
relevance += computeRelevanceForExpectingType(typeBinding); |
10340 |
relevance += computeRelevanceForQualification(false); |
10341 |
relevance += computeRelevanceForRestrictions(accessibility); |
10342 |
|
10343 |
if (typeBinding.isAnnotationType()) { |
10344 |
relevance += computeRelevanceForAnnotation(); |
10345 |
relevance += computeRelevanceForAnnotationTarget(typeBinding); |
10346 |
} else if (typeBinding.isInterface()) { |
10347 |
relevance += computeRelevanceForInterface(); |
10348 |
} else if(typeBinding.isClass()){ |
10349 |
relevance += computeRelevanceForClass(); |
10350 |
relevance += computeRelevanceForException(typeBinding.sourceName); |
10351 |
} |
10352 |
|
10353 |
if (proposeType && hasStaticMemberTypes(typeBinding, scope.enclosingSourceType(), this.unitScope)) { |
10354 |
this.noProposal = false; |
10355 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
10356 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
10357 |
proposal.setDeclarationSignature(typeBinding.qualifiedPackageName()); |
10358 |
proposal.setSignature(getSignature(typeBinding)); |
10359 |
proposal.setPackageName(typeBinding.qualifiedPackageName()); |
10360 |
proposal.setTypeName(typeBinding.qualifiedSourceName()); |
10361 |
proposal.setCompletion(typeBinding.sourceName()); |
10362 |
proposal.setFlags(typeBinding.modifiers); |
10363 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
10364 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
10365 |
proposal.setRelevance(relevance); |
10366 |
this.requestor.accept(proposal); |
10367 |
if(DEBUG) { |
10368 |
this.printDebug(proposal); |
10369 |
} |
10370 |
} |
10371 |
} |
10372 |
|
10373 |
findConstructorsOrAnonymousTypes( |
10374 |
typeBinding, |
10375 |
scope, |
10376 |
FakeInvocationSite, |
10377 |
false, |
10378 |
relevance); |
10379 |
} |
10380 |
} |
10381 |
} |
10382 |
} |
10383 |
} |
10384 |
} |
10385 |
|
9356 |
private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) { |
10386 |
private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) { |
9357 |
ImportBinding[] importBindings = scope.compilationUnitScope().imports; |
10387 |
ImportBinding[] importBindings = scope.compilationUnitScope().imports; |
9358 |
for (int i = 0; i < importBindings.length; i++) { |
10388 |
for (int i = 0; i < importBindings.length; i++) { |
Lines 10205-10210
Link Here
|
10205 |
|
11235 |
|
10206 |
return this.favoriteReferenceBindings = resolvedImports; |
11236 |
return this.favoriteReferenceBindings = resolvedImports; |
10207 |
} |
11237 |
} |
|
|
11238 |
|
11239 |
private INameEnvironment getNoCacheNameEnvironment() { |
11240 |
if (this.noCacheNameEnvironment == null) { |
11241 |
this.noCacheNameEnvironment = new JavaSearchNameEnvironment(this.javaProject, this.owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(this.owner, true/*add primary WCs*/)); |
11242 |
} |
11243 |
return this.noCacheNameEnvironment; |
11244 |
} |
10208 |
|
11245 |
|
10209 |
public AssistParser getParser() { |
11246 |
public AssistParser getParser() { |
10210 |
|
11247 |
|
Lines 10468-10473
Link Here
|
10468 |
case CompletionProposal.TYPE_IMPORT : |
11505 |
case CompletionProposal.TYPE_IMPORT : |
10469 |
buffer.append("TYPE_IMPORT"); //$NON-NLS-1$ |
11506 |
buffer.append("TYPE_IMPORT"); //$NON-NLS-1$ |
10470 |
break; |
11507 |
break; |
|
|
11508 |
case CompletionProposal.CONSTRUCTOR_INVOCATION : |
11509 |
buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$ |
11510 |
break; |
11511 |
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION : |
11512 |
buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$ |
11513 |
break; |
10471 |
default : |
11514 |
default : |
10472 |
buffer.append("PROPOSAL"); //$NON-NLS-1$ |
11515 |
buffer.append("PROPOSAL"); //$NON-NLS-1$ |
10473 |
break; |
11516 |
break; |
Lines 10539-10544
Link Here
|
10539 |
buffer.append('\t'); |
11582 |
buffer.append('\t'); |
10540 |
} |
11583 |
} |
10541 |
} |
11584 |
} |
|
|
11585 |
|
11586 |
private void proposeConstructor(AcceptedConstructor deferredProposal, Scope scope) { |
11587 |
if (deferredProposal.proposeConstructor) { |
11588 |
proposeConstructor( |
11589 |
deferredProposal.simpleTypeName, |
11590 |
deferredProposal.parameterCount, |
11591 |
deferredProposal.signature, |
11592 |
deferredProposal.parameterTypes, |
11593 |
deferredProposal.parameterNames, |
11594 |
deferredProposal.modifiers, |
11595 |
deferredProposal.packageName, |
11596 |
deferredProposal.typeModifiers, |
11597 |
deferredProposal.accessibility, |
11598 |
deferredProposal.simpleTypeName, |
11599 |
deferredProposal.fullyQualifiedName, |
11600 |
deferredProposal.mustBeQualified, |
11601 |
scope, |
11602 |
deferredProposal.extraFlags); |
11603 |
} |
11604 |
} |
11605 |
|
11606 |
private void proposeConstructor( |
11607 |
char[] simpleTypeName, |
11608 |
int parameterCount, |
11609 |
char[] signature, |
11610 |
char[][] parameterTypes, |
11611 |
char[][] parameterNames, |
11612 |
int modifiers, |
11613 |
char[] packageName, |
11614 |
int typeModifiers, |
11615 |
int accessibility, |
11616 |
char[] typeName, |
11617 |
char[] fullyQualifiedName, |
11618 |
boolean isQualified, |
11619 |
Scope scope, |
11620 |
int extraFlags) { |
11621 |
char[] completionName = fullyQualifiedName; |
11622 |
if(isQualified) { |
11623 |
if (packageName == null || packageName.length == 0) |
11624 |
if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR) |
11625 |
return; // ignore types from the default package from outside it |
11626 |
} else { |
11627 |
completionName = simpleTypeName; |
11628 |
} |
11629 |
|
11630 |
int relevance = computeBaseRelevance(); |
11631 |
relevance += computeRelevanceForResolution(); |
11632 |
relevance += computeRelevanceForInterestingProposal(); |
11633 |
relevance += computeRelevanceForRestrictions(accessibility); |
11634 |
relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName); |
11635 |
relevance += computeRelevanceForExpectingType(packageName, simpleTypeName); |
11636 |
relevance += computeRelevanceForQualification(isQualified); |
11637 |
|
11638 |
boolean isInterface = false; |
11639 |
int kind = typeModifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccEnum | ClassFileConstants.AccAnnotation); |
11640 |
switch (kind) { |
11641 |
case ClassFileConstants.AccAnnotation: |
11642 |
case ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface: |
11643 |
relevance += computeRelevanceForAnnotation(); |
11644 |
relevance += computeRelevanceForInterface(); |
11645 |
isInterface = true; |
11646 |
break; |
11647 |
case ClassFileConstants.AccEnum: |
11648 |
relevance += computeRelevanceForEnum(); |
11649 |
break; |
11650 |
case ClassFileConstants.AccInterface: |
11651 |
relevance += computeRelevanceForInterface(); |
11652 |
isInterface = true; |
11653 |
break; |
11654 |
default: |
11655 |
relevance += computeRelevanceForClass(); |
11656 |
relevance += computeRelevanceForException(simpleTypeName); |
11657 |
break; |
11658 |
} |
11659 |
|
11660 |
char[] completion; |
11661 |
if (this.source != null |
11662 |
&& this.source.length > this.endPosition |
11663 |
&& this.source[this.endPosition] == '(') { |
11664 |
completion = completionName; |
11665 |
} else { |
11666 |
completion = CharOperation.concat(completionName, new char[] { '(', ')' }); |
11667 |
} |
11668 |
|
11669 |
switch (parameterCount) { |
11670 |
case -1: // default constructor |
11671 |
int flags = Flags.AccPublic; |
11672 |
if (Flags.isDeprecated(typeModifiers)) { |
11673 |
flags |= Flags.AccDeprecated; |
11674 |
} |
11675 |
|
11676 |
if (isInterface || (typeModifiers & ClassFileConstants.AccAbstract) != 0) { |
11677 |
this.noProposal = false; |
11678 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) { |
11679 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11680 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11681 |
proposal.setDeclarationKey(createBindingKey(packageName, typeName)); |
11682 |
proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE); |
11683 |
proposal.setDeclarationPackageName(packageName); |
11684 |
proposal.setDeclarationTypeName(typeName); |
11685 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11686 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11687 |
proposal.setName(simpleTypeName); |
11688 |
proposal.setIsContructor(true); |
11689 |
proposal.setCompletion(completion); |
11690 |
proposal.setFlags(flags); |
11691 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
11692 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11693 |
proposal.setRelevance(relevance); |
11694 |
this.requestor.accept(proposal); |
11695 |
if(DEBUG) { |
11696 |
this.printDebug(proposal); |
11697 |
} |
11698 |
} |
11699 |
} else { |
11700 |
this.noProposal = false; |
11701 |
if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) { |
11702 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11703 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11704 |
proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE); |
11705 |
proposal.setDeclarationPackageName(packageName); |
11706 |
proposal.setDeclarationTypeName(typeName); |
11707 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11708 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11709 |
proposal.setName(simpleTypeName); |
11710 |
proposal.setIsContructor(true); |
11711 |
proposal.setCompletion(completion); |
11712 |
proposal.setFlags(flags); |
11713 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
11714 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11715 |
proposal.setRelevance(relevance); |
11716 |
this.requestor.accept(proposal); |
11717 |
if(DEBUG) { |
11718 |
this.printDebug(proposal); |
11719 |
} |
11720 |
} |
11721 |
} |
11722 |
break; |
11723 |
case 0: // constructor with no parameter |
11724 |
|
11725 |
if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) { |
11726 |
this.noProposal = false; |
11727 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) { |
11728 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11729 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11730 |
proposal.setDeclarationKey(createBindingKey(packageName, typeName)); |
11731 |
proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE); |
11732 |
proposal.setDeclarationPackageName(packageName); |
11733 |
proposal.setDeclarationTypeName(typeName); |
11734 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11735 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11736 |
proposal.setName(simpleTypeName); |
11737 |
proposal.setIsContructor(true); |
11738 |
proposal.setCompletion(completion); |
11739 |
proposal.setFlags(modifiers); |
11740 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
11741 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11742 |
proposal.setRelevance(relevance); |
11743 |
this.requestor.accept(proposal); |
11744 |
if(DEBUG) { |
11745 |
this.printDebug(proposal); |
11746 |
} |
11747 |
} |
11748 |
} else { |
11749 |
this.noProposal = false; |
11750 |
if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) { |
11751 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11752 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11753 |
proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE); |
11754 |
proposal.setDeclarationPackageName(packageName); |
11755 |
proposal.setDeclarationTypeName(typeName); |
11756 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11757 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11758 |
proposal.setName(simpleTypeName); |
11759 |
proposal.setIsContructor(true); |
11760 |
proposal.setCompletion(completion); |
11761 |
proposal.setFlags(modifiers); |
11762 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
11763 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11764 |
proposal.setRelevance(relevance); |
11765 |
this.requestor.accept(proposal); |
11766 |
if(DEBUG) { |
11767 |
this.printDebug(proposal); |
11768 |
} |
11769 |
} |
11770 |
} |
11771 |
break; |
11772 |
default: // constructor with parameter |
11773 |
if (signature == null) { |
11774 |
// resolve type to found parameter types |
11775 |
signature = getResolvedSignature(parameterTypes, fullyQualifiedName, parameterCount, scope); |
11776 |
if (signature == null) return; |
11777 |
} else { |
11778 |
signature = CharOperation.replaceOnCopy(signature, '/', '.'); |
11779 |
} |
11780 |
|
11781 |
int parameterNamesLength = parameterNames == null ? 0 : parameterNames.length; |
11782 |
if (parameterCount != parameterNamesLength) { |
11783 |
parameterNames = createDefaultParameterNames(parameterCount); |
11784 |
} |
11785 |
|
11786 |
if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) { |
11787 |
this.noProposal = false; |
11788 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION)) { |
11789 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11790 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11791 |
proposal.setDeclarationKey(createBindingKey(packageName, typeName)); |
11792 |
proposal.setSignature(signature); |
11793 |
proposal.setDeclarationPackageName(packageName); |
11794 |
proposal.setDeclarationTypeName(typeName); |
11795 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11796 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11797 |
proposal.setParameterNames(parameterNames); |
11798 |
proposal.setName(simpleTypeName); |
11799 |
proposal.setIsContructor(true); |
11800 |
proposal.setCompletion(completion); |
11801 |
proposal.setFlags(modifiers); |
11802 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
11803 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11804 |
proposal.setRelevance(relevance); |
11805 |
this.requestor.accept(proposal); |
11806 |
if(DEBUG) { |
11807 |
this.printDebug(proposal); |
11808 |
} |
11809 |
} |
11810 |
} else { |
11811 |
this.noProposal = false; |
11812 |
if(!this.requestor.isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION)) { |
11813 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11814 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11815 |
proposal.setSignature(signature); |
11816 |
proposal.setDeclarationPackageName(packageName); |
11817 |
proposal.setDeclarationTypeName(typeName); |
11818 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11819 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11820 |
proposal.setParameterNames(parameterNames); |
11821 |
proposal.setName(simpleTypeName); |
11822 |
proposal.setIsContructor(true); |
11823 |
proposal.setCompletion(completion); |
11824 |
proposal.setFlags(modifiers); |
11825 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
11826 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11827 |
proposal.setRelevance(relevance); |
11828 |
|
11829 |
this.requestor.accept(proposal); |
11830 |
if(DEBUG) { |
11831 |
this.printDebug(proposal); |
11832 |
} |
11833 |
} |
11834 |
} |
11835 |
break; |
11836 |
} |
11837 |
} |
10542 |
|
11838 |
|
10543 |
private void proposeNewMethod(char[] token, ReferenceBinding reference) { |
11839 |
private void proposeNewMethod(char[] token, ReferenceBinding reference) { |
10544 |
if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) { |
11840 |
if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) { |