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