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