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; |
|
|
411 |
public int openedBinaryTypes; // used during InternalCompletionProposal#findConstructorParameterNames() |
306 |
|
412 |
|
307 |
public static boolean DEBUG = false; |
413 |
public static boolean DEBUG = false; |
308 |
public static boolean PERF = false; |
414 |
public static boolean PERF = false; |
309 |
|
415 |
|
310 |
private final static int CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES = 50; |
416 |
private static final char[] KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS = new char[]{}; |
|
|
417 |
private static final char[] KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS = new char[]{}; |
418 |
|
419 |
private static final char[] ARG = "arg".toCharArray(); //$NON-NLS-1$ |
420 |
private static final char[] ARG0 = "arg0".toCharArray(); //$NON-NLS-1$ |
421 |
private static final char[] ARG1 = "arg1".toCharArray(); //$NON-NLS-1$ |
422 |
private static final char[] ARG2 = "arg2".toCharArray(); //$NON-NLS-1$ |
423 |
private static final char[] ARG3 = "arg3".toCharArray(); //$NON-NLS-1$ |
424 |
private static final char[][] ARGS1 = new char[][]{ARG0}; |
425 |
private static final char[][] ARGS2 = new char[][]{ARG0, ARG1}; |
426 |
private static final char[][] ARGS3 = new char[][]{ARG0, ARG1, ARG2}; |
427 |
private static final char[][] ARGS4 = new char[][]{ARG0, ARG1, ARG2, ARG3}; |
428 |
|
429 |
private final static int CHECK_CANCEL_FREQUENCY = 50; |
311 |
|
430 |
|
312 |
// temporary constants to quickly disabled polish features if necessary |
431 |
// temporary constants to quickly disabled polish features if necessary |
313 |
public final static boolean NO_TYPE_COMPLETION_ON_EMPTY_TOKEN = false; |
432 |
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$ |
442 |
private final static char[] VALUE = "value".toCharArray(); //$NON-NLS-1$ |
324 |
private final static char[] EXTENDS = "extends".toCharArray(); //$NON-NLS-1$ |
443 |
private final static char[] EXTENDS = "extends".toCharArray(); //$NON-NLS-1$ |
325 |
private final static char[] SUPER = "super".toCharArray(); //$NON-NLS-1$ |
444 |
private final static char[] SUPER = "super".toCharArray(); //$NON-NLS-1$ |
|
|
445 |
private final static char[] DEFAULT_CONSTRUCTOR_SIGNATURE = "()V".toCharArray(); //$NON-NLS-1$ |
326 |
|
446 |
|
327 |
private final static char[] DOT = ".".toCharArray(); //$NON-NLS-1$ |
447 |
private final static char[] DOT = ".".toCharArray(); //$NON-NLS-1$ |
328 |
|
448 |
|
Lines 374-379
Link Here
|
374 |
CompletionRequestor requestor; |
494 |
CompletionRequestor requestor; |
375 |
CompletionProblemFactory problemFactory; |
495 |
CompletionProblemFactory problemFactory; |
376 |
ProblemReporter problemReporter; |
496 |
ProblemReporter problemReporter; |
|
|
497 |
private JavaSearchNameEnvironment noCacheNameEnvironment; |
377 |
char[] source; |
498 |
char[] source; |
378 |
char[] completionToken; |
499 |
char[] completionToken; |
379 |
char[] qualifiedCompletionToken; |
500 |
char[] qualifiedCompletionToken; |
Lines 459-464
Link Here
|
459 |
|
580 |
|
460 |
private int foundTypesCount; |
581 |
private int foundTypesCount; |
461 |
private ObjectVector acceptedTypes; |
582 |
private ObjectVector acceptedTypes; |
|
|
583 |
|
584 |
private int foundConstructorsCount; |
585 |
private ObjectVector acceptedConstructors; |
462 |
|
586 |
|
463 |
/** |
587 |
/** |
464 |
* The CompletionEngine is responsible for computing source completions. |
588 |
* The CompletionEngine is responsible for computing source completions. |
Lines 489-494
Link Here
|
489 |
this.requestor = requestor; |
613 |
this.requestor = requestor; |
490 |
this.nameEnvironment = nameEnvironment; |
614 |
this.nameEnvironment = nameEnvironment; |
491 |
this.typeCache = new HashtableOfObject(5); |
615 |
this.typeCache = new HashtableOfObject(5); |
|
|
616 |
this.openedBinaryTypes = 0; |
492 |
|
617 |
|
493 |
this.problemFactory = new CompletionProblemFactory(Locale.getDefault()); |
618 |
this.problemFactory = new CompletionProblemFactory(Locale.getDefault()); |
494 |
this.problemReporter = new ProblemReporter( |
619 |
this.problemReporter = new ProblemReporter( |
Lines 511-516
Link Here
|
511 |
this.owner = owner; |
636 |
this.owner = owner; |
512 |
this.monitor = monitor; |
637 |
this.monitor = monitor; |
513 |
} |
638 |
} |
|
|
639 |
|
640 |
public void acceptConstructor( |
641 |
int modifiers, |
642 |
char[] simpleTypeName, |
643 |
int parameterCount, |
644 |
char[] signature, |
645 |
char[][] parameterTypes, |
646 |
char[][] parameterNames, |
647 |
int typeModifiers, |
648 |
char[] packageName, |
649 |
int extraFlags, |
650 |
String path, |
651 |
AccessRestriction accessRestriction) { |
652 |
|
653 |
// does not check cancellation for every types to avoid performance loss |
654 |
if ((this.foundConstructorsCount % (CHECK_CANCEL_FREQUENCY)) == 0) checkCancel(); |
655 |
this.foundConstructorsCount++; |
656 |
|
657 |
if ((typeModifiers & ClassFileConstants.AccEnum) != 0) return; |
658 |
|
659 |
if (this.options.checkDeprecation && (typeModifiers & ClassFileConstants.AccDeprecated) != 0) return; |
660 |
|
661 |
if (this.options.checkVisibility) { |
662 |
if((typeModifiers & ClassFileConstants.AccPublic) == 0) { |
663 |
if((typeModifiers & ClassFileConstants.AccPrivate) != 0) return; |
664 |
|
665 |
if (this.currentPackageName == null) { |
666 |
initializePackageCache(); |
667 |
} |
668 |
|
669 |
if(!CharOperation.equals(packageName, this.currentPackageName)) return; |
670 |
} |
671 |
} |
672 |
|
673 |
int accessibility = IAccessRule.K_ACCESSIBLE; |
674 |
if(accessRestriction != null) { |
675 |
switch (accessRestriction.getProblemId()) { |
676 |
case IProblem.ForbiddenReference: |
677 |
if (this.options.checkForbiddenReference) { |
678 |
return; |
679 |
} |
680 |
accessibility = IAccessRule.K_NON_ACCESSIBLE; |
681 |
break; |
682 |
case IProblem.DiscouragedReference: |
683 |
if (this.options.checkDiscouragedReference) { |
684 |
return; |
685 |
} |
686 |
accessibility = IAccessRule.K_DISCOURAGED; |
687 |
break; |
688 |
} |
689 |
} |
690 |
|
691 |
if(this.acceptedConstructors == null) { |
692 |
this.acceptedConstructors = new ObjectVector(); |
693 |
} |
694 |
this.acceptedConstructors.add( |
695 |
new AcceptedConstructor( |
696 |
modifiers, |
697 |
simpleTypeName, |
698 |
parameterCount, |
699 |
signature, |
700 |
parameterTypes, |
701 |
parameterNames, |
702 |
typeModifiers, |
703 |
packageName, |
704 |
extraFlags, |
705 |
accessibility)); |
706 |
} |
707 |
|
708 |
private void acceptConstructors(Scope scope) { |
709 |
final boolean DEFER_QUALIFIED_PROPOSALS = false; |
710 |
|
711 |
this.checkCancel(); |
712 |
|
713 |
if(this.acceptedConstructors == null) return; |
714 |
|
715 |
int length = this.acceptedConstructors.size(); |
716 |
|
717 |
if(length == 0) return; |
718 |
|
719 |
HashtableOfObject onDemandFound = new HashtableOfObject(); |
720 |
|
721 |
ArrayList deferredProposals = new ArrayList(); |
722 |
|
723 |
try { |
724 |
next : for (int i = 0; i < length; i++) { |
725 |
|
726 |
// does not check cancellation for every types to avoid performance loss |
727 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
728 |
|
729 |
AcceptedConstructor acceptedConstructor = (AcceptedConstructor)this.acceptedConstructors.elementAt(i); |
730 |
final int typeModifiers = acceptedConstructor.typeModifiers; |
731 |
final char[] packageName = acceptedConstructor.packageName; |
732 |
final char[] simpleTypeName = acceptedConstructor.simpleTypeName; |
733 |
final int modifiers = acceptedConstructor.modifiers; |
734 |
final int parameterCount = acceptedConstructor.parameterCount; |
735 |
final char[] signature = acceptedConstructor.signature; |
736 |
final char[][] parameterTypes = acceptedConstructor.parameterTypes; |
737 |
final char[][] parameterNames = acceptedConstructor.parameterNames; |
738 |
final int extraFlags = acceptedConstructor.extraFlags; |
739 |
final int accessibility = acceptedConstructor.accessibility; |
740 |
|
741 |
boolean proposeType = (extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0; |
742 |
|
743 |
char[] fullyQualifiedName = CharOperation.concat(packageName, simpleTypeName, '.'); |
744 |
|
745 |
Object knownTypeKind = this.knownTypes.get(fullyQualifiedName); |
746 |
if (knownTypeKind != null) { |
747 |
if (knownTypeKind == KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS) { |
748 |
// the type and its constructors are already accepted |
749 |
continue next; |
750 |
} |
751 |
// this type is already accepted |
752 |
proposeType = false; |
753 |
} else { |
754 |
this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS); |
755 |
} |
756 |
|
757 |
boolean proposeConstructor = true; |
758 |
|
759 |
if (this.options.checkVisibility) { |
760 |
if((modifiers & ClassFileConstants.AccPublic) == 0) { |
761 |
if((modifiers & ClassFileConstants.AccPrivate) != 0) { |
762 |
if (!proposeType) continue next; |
763 |
proposeConstructor = false; |
764 |
} else { |
765 |
if (this.currentPackageName == null) { |
766 |
initializePackageCache(); |
767 |
} |
768 |
|
769 |
if(!CharOperation.equals(packageName, this.currentPackageName)) { |
770 |
if (!proposeType) continue next; |
771 |
proposeConstructor = false; |
772 |
} |
773 |
} |
774 |
} |
775 |
} |
776 |
|
777 |
acceptedConstructor.fullyQualifiedName = fullyQualifiedName; |
778 |
acceptedConstructor.proposeType = proposeType; |
779 |
acceptedConstructor.proposeConstructor = proposeConstructor; |
780 |
|
781 |
|
782 |
if(!this.importCachesInitialized) { |
783 |
initializeImportCaches(); |
784 |
} |
785 |
|
786 |
for (int j = 0; j < this.importCacheCount; j++) { |
787 |
char[][] importName = this.importsCache[j]; |
788 |
if(CharOperation.equals(simpleTypeName, importName[0])) { |
789 |
if (proposeType) { |
790 |
proposeType( |
791 |
packageName, |
792 |
simpleTypeName, |
793 |
typeModifiers, |
794 |
accessibility, |
795 |
simpleTypeName, |
796 |
fullyQualifiedName, |
797 |
!CharOperation.equals(fullyQualifiedName, importName[1]), |
798 |
scope); |
799 |
} |
800 |
|
801 |
if (proposeConstructor && !Flags.isEnum(typeModifiers)) { |
802 |
boolean isQualified = !CharOperation.equals(fullyQualifiedName, importName[1]); |
803 |
if (!isQualified) { |
804 |
proposeConstructor( |
805 |
simpleTypeName, |
806 |
parameterCount, |
807 |
signature, |
808 |
parameterTypes, |
809 |
parameterNames, |
810 |
modifiers, |
811 |
packageName, |
812 |
typeModifiers, |
813 |
accessibility, |
814 |
simpleTypeName, |
815 |
fullyQualifiedName, |
816 |
isQualified, |
817 |
scope, |
818 |
extraFlags); |
819 |
} else { |
820 |
acceptedConstructor.mustBeQualified = true; |
821 |
if (DEFER_QUALIFIED_PROPOSALS) { |
822 |
deferredProposals.add(acceptedConstructor); |
823 |
} else { |
824 |
proposeConstructor(acceptedConstructor, scope); |
825 |
} |
826 |
} |
827 |
} |
828 |
continue next; |
829 |
} |
830 |
} |
831 |
|
832 |
|
833 |
if (CharOperation.equals(this.currentPackageName, packageName)) { |
834 |
if (proposeType) { |
835 |
proposeType( |
836 |
packageName, |
837 |
simpleTypeName, |
838 |
typeModifiers, |
839 |
accessibility, |
840 |
simpleTypeName, |
841 |
fullyQualifiedName, |
842 |
false, |
843 |
scope); |
844 |
} |
845 |
|
846 |
if (proposeConstructor && !Flags.isEnum(typeModifiers)) { |
847 |
proposeConstructor( |
848 |
simpleTypeName, |
849 |
parameterCount, |
850 |
signature, |
851 |
parameterTypes, |
852 |
parameterNames, |
853 |
modifiers, |
854 |
packageName, |
855 |
typeModifiers, |
856 |
accessibility, |
857 |
simpleTypeName, |
858 |
fullyQualifiedName, |
859 |
false, |
860 |
scope, |
861 |
extraFlags); |
862 |
} |
863 |
continue next; |
864 |
} else { |
865 |
char[] fullyQualifiedEnclosingTypeOrPackageName = null; |
866 |
|
867 |
AcceptedConstructor foundConstructor = null; |
868 |
if((foundConstructor = (AcceptedConstructor)onDemandFound.get(simpleTypeName)) == null) { |
869 |
for (int j = 0; j < this.onDemandImportCacheCount; j++) { |
870 |
ImportBinding importBinding = this.onDemandImportsCache[j]; |
871 |
|
872 |
char[][] importName = importBinding.compoundName; |
873 |
char[] importFlatName = CharOperation.concatWith(importName, '.'); |
874 |
|
875 |
if(fullyQualifiedEnclosingTypeOrPackageName == null) { |
876 |
fullyQualifiedEnclosingTypeOrPackageName = packageName; |
877 |
} |
878 |
if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) { |
879 |
if(importBinding.isStatic()) { |
880 |
if((typeModifiers & ClassFileConstants.AccStatic) != 0) { |
881 |
onDemandFound.put( |
882 |
simpleTypeName, |
883 |
acceptedConstructor); |
884 |
continue next; |
885 |
} |
886 |
} else { |
887 |
onDemandFound.put( |
888 |
simpleTypeName, |
889 |
acceptedConstructor); |
890 |
continue next; |
891 |
} |
892 |
} |
893 |
} |
894 |
} else if(!foundConstructor.mustBeQualified){ |
895 |
done : for (int j = 0; j < this.onDemandImportCacheCount; j++) { |
896 |
ImportBinding importBinding = this.onDemandImportsCache[j]; |
897 |
|
898 |
char[][] importName = importBinding.compoundName; |
899 |
char[] importFlatName = CharOperation.concatWith(importName, '.'); |
900 |
|
901 |
if(fullyQualifiedEnclosingTypeOrPackageName == null) { |
902 |
fullyQualifiedEnclosingTypeOrPackageName = packageName; |
903 |
} |
904 |
if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) { |
905 |
if(importBinding.isStatic()) { |
906 |
if((typeModifiers & ClassFileConstants.AccStatic) != 0) { |
907 |
foundConstructor.mustBeQualified = true; |
908 |
break done; |
909 |
} |
910 |
} else { |
911 |
foundConstructor.mustBeQualified = true; |
912 |
break done; |
913 |
} |
914 |
} |
915 |
} |
916 |
} |
917 |
if (proposeType) { |
918 |
proposeType( |
919 |
packageName, |
920 |
simpleTypeName, |
921 |
typeModifiers, |
922 |
accessibility, |
923 |
simpleTypeName, |
924 |
fullyQualifiedName, |
925 |
true, |
926 |
scope); |
927 |
} |
928 |
|
929 |
if (proposeConstructor && !Flags.isEnum(typeModifiers)) { |
930 |
acceptedConstructor.mustBeQualified = true; |
931 |
if (DEFER_QUALIFIED_PROPOSALS) { |
932 |
deferredProposals.add(acceptedConstructor); |
933 |
} else { |
934 |
proposeConstructor(acceptedConstructor, scope); |
935 |
} |
936 |
} |
937 |
} |
938 |
} |
939 |
|
940 |
char[][] keys = onDemandFound.keyTable; |
941 |
Object[] values = onDemandFound.valueTable; |
942 |
int max = keys.length; |
943 |
for (int i = 0; i < max; i++) { |
944 |
|
945 |
// does not check cancellation for every types to avoid performance loss |
946 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
947 |
|
948 |
if(keys[i] != null) { |
949 |
AcceptedConstructor value = (AcceptedConstructor) values[i]; |
950 |
if(value != null) { |
951 |
if (value.proposeType) { |
952 |
proposeType( |
953 |
value.packageName, |
954 |
value.simpleTypeName, |
955 |
value.typeModifiers, |
956 |
value.accessibility, |
957 |
value.simpleTypeName, |
958 |
value.fullyQualifiedName, |
959 |
value.mustBeQualified, |
960 |
scope); |
961 |
} |
962 |
|
963 |
if (value.proposeConstructor && !Flags.isEnum(value.modifiers)) { |
964 |
if (!value.mustBeQualified) { |
965 |
proposeConstructor( |
966 |
value.simpleTypeName, |
967 |
value.parameterCount, |
968 |
value.signature, |
969 |
value.parameterTypes, |
970 |
value.parameterNames, |
971 |
value.modifiers, |
972 |
value.packageName, |
973 |
value.typeModifiers, |
974 |
value.accessibility, |
975 |
value.simpleTypeName, |
976 |
value.fullyQualifiedName, |
977 |
value.mustBeQualified, |
978 |
scope, |
979 |
value.extraFlags); |
980 |
} else { |
981 |
if (DEFER_QUALIFIED_PROPOSALS) { |
982 |
deferredProposals.add(value); |
983 |
} else { |
984 |
proposeConstructor(value, scope); |
985 |
} |
986 |
} |
987 |
} |
988 |
} |
989 |
} |
990 |
} |
991 |
|
992 |
if (DEFER_QUALIFIED_PROPOSALS) { |
993 |
int size = deferredProposals.size(); |
994 |
for (int i = 0; i < size; i++) { |
995 |
|
996 |
// does not check cancellation for every types to avoid performance loss |
997 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
998 |
|
999 |
AcceptedConstructor deferredProposal = (AcceptedConstructor)deferredProposals.get(i); |
1000 |
|
1001 |
if (deferredProposal.proposeConstructor) { |
1002 |
proposeConstructor( |
1003 |
deferredProposal.simpleTypeName, |
1004 |
deferredProposal.parameterCount, |
1005 |
deferredProposal.signature, |
1006 |
deferredProposal.parameterTypes, |
1007 |
deferredProposal.parameterNames, |
1008 |
deferredProposal.modifiers, |
1009 |
deferredProposal.packageName, |
1010 |
deferredProposal.typeModifiers, |
1011 |
deferredProposal.accessibility, |
1012 |
deferredProposal.simpleTypeName, |
1013 |
deferredProposal.fullyQualifiedName, |
1014 |
deferredProposal.mustBeQualified, |
1015 |
scope, |
1016 |
deferredProposal.extraFlags); |
1017 |
} |
1018 |
} |
1019 |
} |
1020 |
} finally { |
1021 |
this.acceptedTypes = null; // reset |
1022 |
} |
1023 |
} |
514 |
|
1024 |
|
515 |
/** |
1025 |
/** |
516 |
* One result of the search consists of a new package. |
1026 |
* One result of the search consists of a new package. |
Lines 577-583
Link Here
|
577 |
AccessRestriction accessRestriction) { |
1087 |
AccessRestriction accessRestriction) { |
578 |
|
1088 |
|
579 |
// does not check cancellation for every types to avoid performance loss |
1089 |
// does not check cancellation for every types to avoid performance loss |
580 |
if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel(); |
1090 |
if ((this.foundTypesCount % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
581 |
this.foundTypesCount++; |
1091 |
this.foundTypesCount++; |
582 |
|
1092 |
|
583 |
if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return; |
1093 |
if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return; |
Lines 630-636
Link Here
|
630 |
next : for (int i = 0; i < length; i++) { |
1140 |
next : for (int i = 0; i < length; i++) { |
631 |
|
1141 |
|
632 |
// does not check cancellation for every types to avoid performance loss |
1142 |
// does not check cancellation for every types to avoid performance loss |
633 |
if ((i % CHECK_CANCEL_FREQUENCY_IN_FIND_TYPES) == 0) checkCancel(); |
1143 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
634 |
|
1144 |
|
635 |
AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i); |
1145 |
AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i); |
636 |
char[] packageName = acceptedType.packageName; |
1146 |
char[] packageName = acceptedType.packageName; |
Lines 652-658
Link Here
|
652 |
|
1162 |
|
653 |
if (this.knownTypes.containsKey(fullyQualifiedName)) continue next; |
1163 |
if (this.knownTypes.containsKey(fullyQualifiedName)) continue next; |
654 |
|
1164 |
|
655 |
this.knownTypes.put(fullyQualifiedName, this); |
1165 |
this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS); |
656 |
|
1166 |
|
657 |
if (this.resolvingImports) { |
1167 |
if (this.resolvingImports) { |
658 |
if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) { |
1168 |
if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) { |
Lines 808-813
Link Here
|
808 |
Object[] values = onDemandFound.valueTable; |
1318 |
Object[] values = onDemandFound.valueTable; |
809 |
int max = keys.length; |
1319 |
int max = keys.length; |
810 |
for (int i = 0; i < max; i++) { |
1320 |
for (int i = 0; i < max; i++) { |
|
|
1321 |
if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel(); |
811 |
if(keys[i] != null) { |
1322 |
if(keys[i] != null) { |
812 |
AcceptedType value = (AcceptedType) values[i]; |
1323 |
AcceptedType value = (AcceptedType) values[i]; |
813 |
if(value != null) { |
1324 |
if(value != null) { |
Lines 2448-2453
Link Here
|
2448 |
this.assistNodeIsClass = ref.isClass(); |
2959 |
this.assistNodeIsClass = ref.isClass(); |
2449 |
this.assistNodeIsException = ref.isException(); |
2960 |
this.assistNodeIsException = ref.isException(); |
2450 |
this.assistNodeIsInterface = ref.isInterface(); |
2961 |
this.assistNodeIsInterface = ref.isInterface(); |
|
|
2962 |
this.assistNodeIsConstructor = ref.isConstructorType; |
2451 |
this.assistNodeIsSuperType = ref.isSuperType(); |
2963 |
this.assistNodeIsSuperType = ref.isSuperType(); |
2452 |
|
2964 |
|
2453 |
this.completionToken = ref.completionIdentifier; |
2965 |
this.completionToken = ref.completionIdentifier; |
Lines 3201-3207
Link Here
|
3201 |
TypeBinding caughtException = catchArguments[i].type.resolvedType; |
3713 |
TypeBinding caughtException = catchArguments[i].type.resolvedType; |
3202 |
if (caughtException != null) { |
3714 |
if (caughtException != null) { |
3203 |
addForbiddenBindings(caughtException); |
3715 |
addForbiddenBindings(caughtException); |
3204 |
this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), this); |
3716 |
this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS); |
3205 |
} |
3717 |
} |
3206 |
} |
3718 |
} |
3207 |
this.forbbidenBindingsFilter = SUBTYPE; |
3719 |
this.forbbidenBindingsFilter = SUBTYPE; |
Lines 3943-3987
Link Here
|
3943 |
} |
4455 |
} |
3944 |
} |
4456 |
} |
3945 |
private void findAnonymousType( |
4457 |
private void findAnonymousType( |
|
|
4458 |
ReferenceBinding currentType, |
4459 |
TypeBinding[] argTypes, |
4460 |
Scope scope, |
4461 |
InvocationSite invocationSite) { |
4462 |
|
4463 |
int relevance = computeBaseRelevance(); |
4464 |
relevance += computeRelevanceForResolution(); |
4465 |
relevance += computeRelevanceForInterestingProposal(); |
4466 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4467 |
|
4468 |
findAnonymousType(currentType, argTypes, scope, invocationSite, true, false, relevance); |
4469 |
} |
4470 |
private void findAnonymousType( |
3946 |
ReferenceBinding currentType, |
4471 |
ReferenceBinding currentType, |
3947 |
TypeBinding[] argTypes, |
4472 |
TypeBinding[] argTypes, |
3948 |
Scope scope, |
4473 |
Scope scope, |
3949 |
InvocationSite invocationSite) { |
4474 |
InvocationSite invocationSite, |
|
|
4475 |
boolean exactMatch, |
4476 |
boolean isQualified, |
4477 |
int relevance) { |
3950 |
|
4478 |
|
3951 |
if (currentType.isInterface()) { |
4479 |
if (currentType.isInterface()) { |
3952 |
char[] completion = CharOperation.NO_CHAR; |
4480 |
char[] completion = CharOperation.NO_CHAR; |
3953 |
int relevance = computeBaseRelevance(); |
4481 |
char[] typeCompletion = null; |
3954 |
relevance += computeRelevanceForResolution(); |
4482 |
if (!exactMatch) { |
3955 |
relevance += computeRelevanceForInterestingProposal(); |
4483 |
typeCompletion = |
3956 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4484 |
isQualified ? |
|
|
4485 |
CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') : |
4486 |
currentType.sourceName(); |
4487 |
if (this.source != null |
4488 |
&& this.source.length > this.endPosition |
4489 |
&& this.source[this.endPosition] == '(') { |
4490 |
completion = CharOperation.NO_CHAR; |
4491 |
} else { |
4492 |
completion = new char[] { '(', ')' }; |
4493 |
} |
4494 |
} |
3957 |
|
4495 |
|
3958 |
this.noProposal = false; |
4496 |
this.noProposal = false; |
3959 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { |
4497 |
if (!exactMatch) { |
3960 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); |
4498 |
if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
3961 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4499 |
char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName(); |
3962 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4500 |
char[] typeName = currentType.qualifiedSourceName(); |
3963 |
proposal.setSignature( |
4501 |
|
3964 |
createMethodSignature( |
4502 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
3965 |
CharOperation.NO_CHAR_CHAR, |
4503 |
proposal.setDeclarationSignature(getSignature(currentType)); |
3966 |
CharOperation.NO_CHAR_CHAR, |
4504 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
3967 |
CharOperation.NO_CHAR, |
4505 |
proposal.setSignature( |
3968 |
CharOperation.NO_CHAR)); |
4506 |
createMethodSignature( |
3969 |
//proposal.setOriginalSignature(null); |
4507 |
CharOperation.NO_CHAR_CHAR, |
3970 |
//proposal.setUniqueKey(null); |
4508 |
CharOperation.NO_CHAR_CHAR, |
3971 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4509 |
CharOperation.NO_CHAR, |
3972 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4510 |
CharOperation.NO_CHAR)); |
3973 |
//proposal.setParameterPackageNames(null); |
4511 |
//proposal.setOriginalSignature(null); |
3974 |
//proposal.setParameterTypeNames(null); |
4512 |
//proposal.setUniqueKey(null); |
3975 |
//proposal.setPackageName(null); |
4513 |
proposal.setDeclarationPackageName(packageName); |
3976 |
//proposal.setTypeName(null); |
4514 |
proposal.setDeclarationTypeName(typeName); |
3977 |
proposal.setCompletion(completion); |
4515 |
//proposal.setParameterPackageNames(null); |
3978 |
proposal.setFlags(Flags.AccPublic); |
4516 |
//proposal.setParameterTypeNames(null); |
3979 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4517 |
//proposal.setPackageName(null); |
3980 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4518 |
//proposal.setTypeName(null); |
3981 |
proposal.setRelevance(relevance); |
4519 |
proposal.setName(currentType.sourceName()); |
3982 |
this.requestor.accept(proposal); |
4520 |
|
3983 |
if(DEBUG) { |
4521 |
InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
3984 |
this.printDebug(proposal); |
4522 |
typeProposal.nameLookup = this.nameEnvironment.nameLookup; |
|
|
4523 |
typeProposal.completionEngine = this; |
4524 |
typeProposal.setDeclarationSignature(packageName); |
4525 |
typeProposal.setSignature(getRequiredTypeSignature(currentType)); |
4526 |
typeProposal.setPackageName(packageName); |
4527 |
typeProposal.setTypeName(typeName); |
4528 |
typeProposal.setCompletion(typeCompletion); |
4529 |
typeProposal.setFlags(currentType.modifiers); |
4530 |
typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
4531 |
typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset); |
4532 |
typeProposal.setRelevance(relevance); |
4533 |
proposal.setRequiredProposals( new CompletionProposal[]{typeProposal}); |
4534 |
|
4535 |
proposal.setCompletion(completion); |
4536 |
proposal.setFlags(Flags.AccPublic); |
4537 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4538 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4539 |
proposal.setRelevance(relevance); |
4540 |
this.requestor.accept(proposal); |
4541 |
if(DEBUG) { |
4542 |
this.printDebug(proposal); |
4543 |
} |
4544 |
} |
4545 |
} else { |
4546 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { |
4547 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); |
4548 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4549 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4550 |
proposal.setSignature( |
4551 |
createMethodSignature( |
4552 |
CharOperation.NO_CHAR_CHAR, |
4553 |
CharOperation.NO_CHAR_CHAR, |
4554 |
CharOperation.NO_CHAR, |
4555 |
CharOperation.NO_CHAR)); |
4556 |
//proposal.setOriginalSignature(null); |
4557 |
//proposal.setUniqueKey(null); |
4558 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4559 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4560 |
//proposal.setParameterPackageNames(null); |
4561 |
//proposal.setParameterTypeNames(null); |
4562 |
//proposal.setPackageName(null); |
4563 |
//proposal.setTypeName(null); |
4564 |
proposal.setCompletion(completion); |
4565 |
proposal.setFlags(Flags.AccPublic); |
4566 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4567 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4568 |
proposal.setRelevance(relevance); |
4569 |
this.requestor.accept(proposal); |
4570 |
if(DEBUG) { |
4571 |
this.printDebug(proposal); |
4572 |
} |
3985 |
} |
4573 |
} |
3986 |
} |
4574 |
} |
3987 |
} else { |
4575 |
} else { |
Lines 3990-3996
Link Here
|
3990 |
argTypes, |
4578 |
argTypes, |
3991 |
scope, |
4579 |
scope, |
3992 |
invocationSite, |
4580 |
invocationSite, |
3993 |
true); |
4581 |
true, |
|
|
4582 |
exactMatch, |
4583 |
isQualified, |
4584 |
relevance); |
3994 |
} |
4585 |
} |
3995 |
} |
4586 |
} |
3996 |
private void findClassField( |
4587 |
private void findClassField( |
Lines 4075-4080
Link Here
|
4075 |
Scope scope, |
4666 |
Scope scope, |
4076 |
InvocationSite invocationSite, |
4667 |
InvocationSite invocationSite, |
4077 |
boolean forAnonymousType) { |
4668 |
boolean forAnonymousType) { |
|
|
4669 |
|
4670 |
int relevance = computeBaseRelevance(); |
4671 |
relevance += computeRelevanceForResolution(); |
4672 |
relevance += computeRelevanceForInterestingProposal(); |
4673 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4674 |
|
4675 |
findConstructors(currentType, argTypes, scope, invocationSite, forAnonymousType, true, false, relevance); |
4676 |
} |
4677 |
|
4678 |
private void findConstructors( |
4679 |
ReferenceBinding currentType, |
4680 |
TypeBinding[] argTypes, |
4681 |
Scope scope, |
4682 |
InvocationSite invocationSite, |
4683 |
boolean forAnonymousType, |
4684 |
boolean exactMatch, |
4685 |
boolean isQualified, |
4686 |
int relevance) { |
4078 |
|
4687 |
|
4079 |
// No visibility checks can be performed without the scope & invocationSite |
4688 |
// No visibility checks can be performed without the scope & invocationSite |
4080 |
MethodBinding[] methods = currentType.availableMethods(); |
4689 |
MethodBinding[] methods = currentType.availableMethods(); |
Lines 4117-4162
Link Here
|
4117 |
char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames); |
4726 |
char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames); |
4118 |
|
4727 |
|
4119 |
char[] completion = CharOperation.NO_CHAR; |
4728 |
char[] completion = CharOperation.NO_CHAR; |
|
|
4729 |
|
4120 |
if(forAnonymousType){ |
4730 |
if(forAnonymousType){ |
4121 |
int relevance = computeBaseRelevance(); |
4731 |
char[] typeCompletion = null; |
4122 |
relevance += computeRelevanceForResolution(); |
4732 |
if (!exactMatch) { |
4123 |
relevance += computeRelevanceForInterestingProposal(); |
4733 |
typeCompletion = |
4124 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4734 |
isQualified ? |
4125 |
|
4735 |
CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') : |
|
|
4736 |
currentType.sourceName(); |
4737 |
if (this.source != null |
4738 |
&& this.source.length > this.endPosition |
4739 |
&& this.source[this.endPosition] == '(') { |
4740 |
completion = CharOperation.NO_CHAR; |
4741 |
} else { |
4742 |
completion = new char[] { '(', ')' }; |
4743 |
} |
4744 |
} |
4745 |
|
4126 |
this.noProposal = false; |
4746 |
this.noProposal = false; |
4127 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { |
4747 |
if (!exactMatch) { |
4128 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); |
4748 |
if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
4129 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4749 |
char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName(); |
4130 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4750 |
char[] typeName = currentType.qualifiedSourceName(); |
4131 |
proposal.setSignature(getSignature(constructor)); |
4751 |
|
4132 |
MethodBinding original = constructor.original(); |
4752 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
4133 |
if(original != constructor) { |
4753 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4134 |
proposal.setOriginalSignature(getSignature(original)); |
4754 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
|
|
4755 |
proposal.setSignature(getSignature(constructor)); |
4756 |
MethodBinding original = constructor.original(); |
4757 |
if(original != constructor) { |
4758 |
proposal.setOriginalSignature(getSignature(original)); |
4759 |
} |
4760 |
proposal.setKey(constructor.computeUniqueKey()); |
4761 |
proposal.setDeclarationPackageName(packageName); |
4762 |
proposal.setDeclarationTypeName(typeName); |
4763 |
proposal.setParameterPackageNames(parameterPackageNames); |
4764 |
proposal.setParameterTypeNames(parameterTypeNames); |
4765 |
//proposal.setPackageName(null); |
4766 |
//proposal.setTypeName(null); |
4767 |
proposal.setName(currentType.sourceName()); |
4768 |
|
4769 |
InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
4770 |
typeProposal.nameLookup = this.nameEnvironment.nameLookup; |
4771 |
typeProposal.completionEngine = this; |
4772 |
typeProposal.setDeclarationSignature(packageName); |
4773 |
typeProposal.setSignature(getRequiredTypeSignature(currentType)); |
4774 |
typeProposal.setPackageName(packageName); |
4775 |
typeProposal.setTypeName(typeName); |
4776 |
typeProposal.setCompletion(typeCompletion); |
4777 |
typeProposal.setFlags(currentType.modifiers); |
4778 |
typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
4779 |
typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset); |
4780 |
typeProposal.setRelevance(relevance); |
4781 |
proposal.setRequiredProposals( new CompletionProposal[]{typeProposal}); |
4782 |
|
4783 |
proposal.setCompletion(completion); |
4784 |
proposal.setFlags(constructor.modifiers); |
4785 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4786 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4787 |
proposal.setRelevance(relevance); |
4788 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4789 |
this.requestor.accept(proposal); |
4790 |
if(DEBUG) { |
4791 |
this.printDebug(proposal); |
4792 |
} |
4135 |
} |
4793 |
} |
4136 |
proposal.setKey(constructor.computeUniqueKey()); |
4794 |
} else { |
4137 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4795 |
if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { |
4138 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4796 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); |
4139 |
proposal.setParameterPackageNames(parameterPackageNames); |
4797 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4140 |
proposal.setParameterTypeNames(parameterTypeNames); |
4798 |
proposal.setDeclarationKey(currentType.computeUniqueKey()); |
4141 |
//proposal.setPackageName(null); |
4799 |
proposal.setSignature(getSignature(constructor)); |
4142 |
//proposal.setTypeName(null); |
4800 |
MethodBinding original = constructor.original(); |
4143 |
proposal.setCompletion(completion); |
4801 |
if(original != constructor) { |
4144 |
proposal.setFlags(constructor.modifiers); |
4802 |
proposal.setOriginalSignature(getSignature(original)); |
4145 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4803 |
} |
4146 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4804 |
proposal.setKey(constructor.computeUniqueKey()); |
4147 |
proposal.setRelevance(relevance); |
4805 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4148 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4806 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4149 |
this.requestor.accept(proposal); |
4807 |
proposal.setParameterPackageNames(parameterPackageNames); |
4150 |
if(DEBUG) { |
4808 |
proposal.setParameterTypeNames(parameterTypeNames); |
4151 |
this.printDebug(proposal); |
4809 |
//proposal.setPackageName(null); |
|
|
4810 |
//proposal.setTypeName(null); |
4811 |
proposal.setCompletion(completion); |
4812 |
proposal.setFlags(constructor.modifiers); |
4813 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4814 |
proposal.setTokenRange(this.tokenEnd - this.offset, this.tokenEnd - this.offset); |
4815 |
proposal.setRelevance(relevance); |
4816 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4817 |
this.requestor.accept(proposal); |
4818 |
if(DEBUG) { |
4819 |
this.printDebug(proposal); |
4820 |
} |
4152 |
} |
4821 |
} |
4153 |
} |
4822 |
} |
4154 |
} else { |
4823 |
} else { |
4155 |
int relevance = computeBaseRelevance(); |
4824 |
char[] typeCompletion = null; |
4156 |
relevance += computeRelevanceForResolution(); |
|
|
4157 |
relevance += computeRelevanceForInterestingProposal(); |
4158 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); |
4159 |
|
4160 |
// Special case for completion in javadoc |
4825 |
// Special case for completion in javadoc |
4161 |
if (this.assistNodeInJavadoc > 0) { |
4826 |
if (this.assistNodeInJavadoc > 0) { |
4162 |
Expression receiver = null; |
4827 |
Expression receiver = null; |
Lines 4208-4278
Link Here
|
4208 |
javadocCompletion.append(')'); |
4873 |
javadocCompletion.append(')'); |
4209 |
completion = javadocCompletion.toString().toCharArray(); |
4874 |
completion = javadocCompletion.toString().toCharArray(); |
4210 |
} |
4875 |
} |
|
|
4876 |
} else { |
4877 |
if (!exactMatch) { |
4878 |
typeCompletion = |
4879 |
isQualified ? |
4880 |
CharOperation.concat(currentType.qualifiedPackageName(), currentType.qualifiedSourceName(), '.') : |
4881 |
currentType.sourceName(); |
4882 |
|
4883 |
if (this.source != null |
4884 |
&& this.source.length > this.endPosition |
4885 |
&& this.source[this.endPosition] == '(') { |
4886 |
completion = CharOperation.NO_CHAR; |
4887 |
} else { |
4888 |
completion = new char[] { '(', ')' }; |
4889 |
} |
4890 |
} |
4211 |
} |
4891 |
} |
4212 |
|
4892 |
|
4213 |
// Create standard proposal |
4893 |
// Create standard proposal |
4214 |
this.noProposal = false; |
4894 |
this.noProposal = false; |
4215 |
if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { |
4895 |
if (!exactMatch) { |
4216 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); |
4896 |
if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
4217 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4897 |
char[] packageName = currentType.isLocalType() ? null : currentType.qualifiedPackageName(); |
4218 |
proposal.setSignature(getSignature(constructor)); |
4898 |
char[] typeName = currentType.qualifiedSourceName(); |
4219 |
MethodBinding original = constructor.original(); |
4899 |
|
4220 |
if(original != constructor) { |
4900 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
4221 |
proposal.setOriginalSignature(getSignature(original)); |
4901 |
proposal.setDeclarationSignature(getSignature(currentType)); |
|
|
4902 |
proposal.setSignature(getSignature(constructor)); |
4903 |
MethodBinding original = constructor.original(); |
4904 |
if(original != constructor) { |
4905 |
proposal.setOriginalSignature(getSignature(original)); |
4906 |
} |
4907 |
proposal.setDeclarationPackageName(packageName); |
4908 |
proposal.setDeclarationTypeName(typeName); |
4909 |
proposal.setParameterPackageNames(parameterPackageNames); |
4910 |
proposal.setParameterTypeNames(parameterTypeNames); |
4911 |
//proposal.setPackageName(null); |
4912 |
//proposal.setTypeName(null); |
4913 |
proposal.setName(currentType.sourceName()); |
4914 |
|
4915 |
InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
4916 |
typeProposal.nameLookup = this.nameEnvironment.nameLookup; |
4917 |
typeProposal.completionEngine = this; |
4918 |
typeProposal.setDeclarationSignature(packageName); |
4919 |
typeProposal.setSignature(getRequiredTypeSignature(currentType)); |
4920 |
typeProposal.setPackageName(packageName); |
4921 |
typeProposal.setTypeName(typeName); |
4922 |
typeProposal.setCompletion(typeCompletion); |
4923 |
typeProposal.setFlags(currentType.modifiers); |
4924 |
typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
4925 |
typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset); |
4926 |
typeProposal.setRelevance(relevance); |
4927 |
proposal.setRequiredProposals( new CompletionProposal[]{typeProposal}); |
4928 |
|
4929 |
proposal.setIsContructor(true); |
4930 |
proposal.setCompletion(completion); |
4931 |
proposal.setFlags(constructor.modifiers); |
4932 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
4933 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4934 |
proposal.setRelevance(relevance); |
4935 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4936 |
this.requestor.accept(proposal); |
4937 |
if(DEBUG) { |
4938 |
this.printDebug(proposal); |
4939 |
} |
4222 |
} |
4940 |
} |
4223 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4941 |
} else { |
4224 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4942 |
if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { |
4225 |
proposal.setParameterPackageNames(parameterPackageNames); |
4943 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); |
4226 |
proposal.setParameterTypeNames(parameterTypeNames); |
4944 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4227 |
//proposal.setPackageName(null); |
4945 |
proposal.setSignature(getSignature(constructor)); |
4228 |
//proposal.setTypeName(null); |
4946 |
MethodBinding original = constructor.original(); |
4229 |
proposal.setName(currentType.sourceName()); |
4947 |
if(original != constructor) { |
4230 |
proposal.setIsContructor(true); |
4948 |
proposal.setOriginalSignature(getSignature(original)); |
4231 |
proposal.setCompletion(completion); |
4949 |
} |
4232 |
proposal.setFlags(constructor.modifiers); |
4950 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4233 |
int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition; |
4951 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4234 |
proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); |
4952 |
proposal.setParameterPackageNames(parameterPackageNames); |
4235 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4953 |
proposal.setParameterTypeNames(parameterTypeNames); |
4236 |
proposal.setRelevance(relevance); |
4954 |
//proposal.setPackageName(null); |
4237 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4955 |
//proposal.setTypeName(null); |
4238 |
this.requestor.accept(proposal); |
4956 |
proposal.setName(currentType.sourceName()); |
4239 |
if(DEBUG) { |
4957 |
proposal.setIsContructor(true); |
4240 |
this.printDebug(proposal); |
4958 |
proposal.setCompletion(completion); |
|
|
4959 |
proposal.setFlags(constructor.modifiers); |
4960 |
int start = (this.assistNodeInJavadoc > 0) ? this.startPosition : this.endPosition; |
4961 |
proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); |
4962 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4963 |
proposal.setRelevance(relevance); |
4964 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4965 |
this.requestor.accept(proposal); |
4966 |
if(DEBUG) { |
4967 |
this.printDebug(proposal); |
4968 |
} |
4241 |
} |
4969 |
} |
4242 |
} |
4970 |
if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) { |
4243 |
if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) { |
4971 |
char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK); |
4244 |
char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK); |
4972 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition); |
4245 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition); |
4973 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4246 |
proposal.setDeclarationSignature(getSignature(currentType)); |
4974 |
proposal.setSignature(getSignature(constructor)); |
4247 |
proposal.setSignature(getSignature(constructor)); |
4975 |
MethodBinding original = constructor.original(); |
4248 |
MethodBinding original = constructor.original(); |
4976 |
if(original != constructor) { |
4249 |
if(original != constructor) { |
4977 |
proposal.setOriginalSignature(getSignature(original)); |
4250 |
proposal.setOriginalSignature(getSignature(original)); |
4978 |
} |
|
|
4979 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4980 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
4981 |
proposal.setParameterPackageNames(parameterPackageNames); |
4982 |
proposal.setParameterTypeNames(parameterTypeNames); |
4983 |
//proposal.setPackageName(null); |
4984 |
//proposal.setTypeName(null); |
4985 |
proposal.setName(currentType.sourceName()); |
4986 |
proposal.setIsContructor(true); |
4987 |
proposal.setCompletion(javadocCompletion); |
4988 |
proposal.setFlags(constructor.modifiers); |
4989 |
int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition; |
4990 |
proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); |
4991 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
4992 |
proposal.setRelevance(relevance+R_INLINE_TAG); |
4993 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
4994 |
this.requestor.accept(proposal); |
4995 |
if(DEBUG) { |
4996 |
this.printDebug(proposal); |
4997 |
} |
4251 |
} |
4998 |
} |
4252 |
proposal.setDeclarationPackageName(currentType.qualifiedPackageName()); |
4999 |
} |
4253 |
proposal.setDeclarationTypeName(currentType.qualifiedSourceName()); |
5000 |
} |
4254 |
proposal.setParameterPackageNames(parameterPackageNames); |
5001 |
} |
4255 |
proposal.setParameterTypeNames(parameterTypeNames); |
5002 |
} |
4256 |
//proposal.setPackageName(null); |
5003 |
} |
4257 |
//proposal.setTypeName(null); |
5004 |
} |
4258 |
proposal.setName(currentType.sourceName()); |
5005 |
|
4259 |
proposal.setIsContructor(true); |
5006 |
private char[] getResolvedSignature(char[][] parameterTypes, char[] fullyQualifiedTypeName, int parameterCount, Scope scope) { |
4260 |
proposal.setCompletion(javadocCompletion); |
5007 |
char[][] cn = CharOperation.splitOn('.', fullyQualifiedTypeName); |
4261 |
proposal.setFlags(constructor.modifiers); |
5008 |
|
4262 |
int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition; |
5009 |
TypeReference ref; |
4263 |
proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); |
5010 |
if (cn.length == 1) { |
4264 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
5011 |
ref = new SingleTypeReference(cn[0], 0); |
4265 |
proposal.setRelevance(relevance+R_INLINE_TAG); |
5012 |
} else { |
4266 |
if(parameterNames != null) proposal.setParameterNames(parameterNames); |
5013 |
ref = new QualifiedTypeReference(cn,new long[cn.length]); |
4267 |
this.requestor.accept(proposal); |
5014 |
} |
4268 |
if(DEBUG) { |
5015 |
|
4269 |
this.printDebug(proposal); |
5016 |
TypeBinding guessedType = null; |
|
|
5017 |
INameEnvironment oldNameEnvironment = this.lookupEnvironment.nameEnvironment; |
5018 |
this.lookupEnvironment.nameEnvironment = getNoCacheNameEnvironment(); |
5019 |
try { |
5020 |
switch (scope.kind) { |
5021 |
case Scope.METHOD_SCOPE : |
5022 |
case Scope.BLOCK_SCOPE : |
5023 |
guessedType = ref.resolveType((BlockScope)scope); |
5024 |
break; |
5025 |
case Scope.CLASS_SCOPE : |
5026 |
guessedType = ref.resolveType((ClassScope)scope); |
5027 |
break; |
5028 |
} |
5029 |
} finally { |
5030 |
this.lookupEnvironment.nameEnvironment = oldNameEnvironment; |
5031 |
} |
5032 |
|
5033 |
if (guessedType != null && guessedType.isValidBinding()) { |
5034 |
if (guessedType instanceof ReferenceBinding) { |
5035 |
ReferenceBinding refBinding = (ReferenceBinding) guessedType; |
5036 |
|
5037 |
MethodBinding bestConstructor = null; |
5038 |
int[] bestMatchingLengths = null; |
5039 |
|
5040 |
MethodBinding[] methods = refBinding.methods(); |
5041 |
next : for (int i = 0; i < methods.length; i++) { |
5042 |
MethodBinding method = methods[i]; |
5043 |
|
5044 |
if (!method.isConstructor()) break next; |
5045 |
|
5046 |
TypeBinding[] parameters = method.parameters; |
5047 |
//TODO take careful of member types |
5048 |
int parametersLength = parameters == null ? 0 : parameters.length; |
5049 |
if (parameterCount != parametersLength) continue next; |
5050 |
|
5051 |
int[] matchingLengths = new int[parameterCount]; |
5052 |
for (int j = 0; j < parametersLength; j++) { |
5053 |
TypeBinding parameter = parameters[j]; |
5054 |
|
5055 |
char[] parameterTypeName; |
5056 |
if (parameter instanceof ReferenceBinding) { |
5057 |
parameterTypeName = CharOperation.concatWith(((ReferenceBinding)parameter).compoundName, '.'); |
5058 |
} else { |
5059 |
parameterTypeName = parameter.sourceName(); |
5060 |
} |
5061 |
|
5062 |
if (!CharOperation.endsWith(parameterTypeName, parameterTypes[j])) { |
5063 |
break next; |
5064 |
} |
5065 |
|
5066 |
int matchingLength = parameterTypes[j].length; |
5067 |
|
5068 |
if (bestMatchingLengths != null) { |
5069 |
if (bestMatchingLengths[j] > matchingLength) { |
5070 |
continue next; |
4270 |
} |
5071 |
} |
4271 |
} |
5072 |
} |
|
|
5073 |
|
5074 |
matchingLengths[j] = matchingLength; |
4272 |
} |
5075 |
} |
|
|
5076 |
|
5077 |
|
5078 |
bestConstructor = method; |
5079 |
bestMatchingLengths = matchingLengths; |
4273 |
} |
5080 |
} |
|
|
5081 |
|
5082 |
if (bestConstructor == null) return null; |
5083 |
return getSignature(bestConstructor); |
4274 |
} |
5084 |
} |
4275 |
} |
5085 |
} |
|
|
5086 |
|
5087 |
return null; |
5088 |
} |
5089 |
|
5090 |
private void findConstructorsOrAnonymousTypes( |
5091 |
ReferenceBinding currentType, |
5092 |
Scope scope, |
5093 |
InvocationSite invocationSite, |
5094 |
boolean isQualified, |
5095 |
int relevance) { |
5096 |
|
5097 |
if (!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) |
5098 |
&& currentType.isClass() |
5099 |
&& !currentType.isAbstract()) { |
5100 |
findConstructors( |
5101 |
currentType, |
5102 |
null, |
5103 |
scope, |
5104 |
invocationSite, |
5105 |
false, |
5106 |
false, |
5107 |
isQualified, |
5108 |
relevance); |
5109 |
} |
5110 |
|
5111 |
// This code is disabled because there is too much proposals when constructors and anonymous are proposed |
5112 |
if (!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) |
5113 |
&& !currentType.isFinal() |
5114 |
&& (currentType.isInterface() || (currentType.isClass() && currentType.isAbstract()))){ |
5115 |
findAnonymousType( |
5116 |
currentType, |
5117 |
null, |
5118 |
scope, |
5119 |
invocationSite, |
5120 |
false, |
5121 |
isQualified, |
5122 |
relevance); |
5123 |
} |
4276 |
} |
5124 |
} |
4277 |
private char[][] findEnclosingTypeNames(Scope scope){ |
5125 |
private char[][] findEnclosingTypeNames(Scope scope){ |
4278 |
char[][] excludedNames = new char[10][]; |
5126 |
char[][] excludedNames = new char[10][]; |
Lines 8230-8246
Link Here
|
8230 |
relevance += computeRelevanceForMissingElements(missingElementsHaveProblems); |
9078 |
relevance += computeRelevanceForMissingElements(missingElementsHaveProblems); |
8231 |
} |
9079 |
} |
8232 |
|
9080 |
|
|
|
9081 |
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); |
9082 |
|
8233 |
this.noProposal = false; |
9083 |
this.noProposal = false; |
8234 |
createTypeProposal( |
9084 |
if (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(memberType, invocationType, this.unitScope)) { |
8235 |
memberType, |
9085 |
createTypeProposal( |
8236 |
memberType.qualifiedSourceName(), |
9086 |
memberType, |
8237 |
IAccessRule.K_ACCESSIBLE, |
9087 |
memberType.qualifiedSourceName(), |
8238 |
completionName, |
9088 |
IAccessRule.K_ACCESSIBLE, |
8239 |
relevance, |
9089 |
completionName, |
8240 |
missingElements, |
9090 |
relevance, |
8241 |
missingElementsStarts, |
9091 |
missingElements, |
8242 |
missingElementsEnds, |
9092 |
missingElementsStarts, |
8243 |
missingElementsHaveProblems); |
9093 |
missingElementsEnds, |
|
|
9094 |
missingElementsHaveProblems); |
9095 |
} |
9096 |
|
9097 |
if (this.assistNodeIsConstructor && allowingLongComputationProposals) { |
9098 |
findConstructorsOrAnonymousTypes( |
9099 |
memberType, |
9100 |
scope, |
9101 |
FakeInvocationSite, |
9102 |
isQualified, |
9103 |
relevance); |
9104 |
} |
8244 |
} |
9105 |
} |
8245 |
} |
9106 |
} |
8246 |
private void findMemberTypesFromMissingType( |
9107 |
private void findMemberTypesFromMissingType( |
Lines 8659-8676
Link Here
|
8659 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type |
9520 |
relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for nested type |
8660 |
relevance += computeRelevanceForAnnotationTarget(localType); |
9521 |
relevance += computeRelevanceForAnnotationTarget(localType); |
8661 |
|
9522 |
|
8662 |
this.noProposal = false; |
9523 |
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); |
8663 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
9524 |
if (!this.assistNodeIsConstructor || !allowingLongComputationProposals) { |
8664 |
createTypeProposal( |
9525 |
this.noProposal = false; |
|
|
9526 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
9527 |
createTypeProposal( |
9528 |
localType, |
9529 |
localType.sourceName, |
9530 |
IAccessRule.K_ACCESSIBLE, |
9531 |
localType.sourceName, |
9532 |
relevance, |
9533 |
null, |
9534 |
null, |
9535 |
null, |
9536 |
false); |
9537 |
} |
9538 |
} |
9539 |
|
9540 |
if (this.assistNodeIsConstructor && allowingLongComputationProposals) { |
9541 |
findConstructorsOrAnonymousTypes( |
8665 |
localType, |
9542 |
localType, |
8666 |
localType.sourceName, |
9543 |
blockScope, |
8667 |
IAccessRule.K_ACCESSIBLE, |
9544 |
FakeInvocationSite, |
8668 |
localType.sourceName, |
9545 |
false, |
8669 |
relevance, |
9546 |
relevance); |
8670 |
null, |
|
|
8671 |
null, |
8672 |
null, |
8673 |
false); |
8674 |
} |
9547 |
} |
8675 |
} |
9548 |
} |
8676 |
} |
9549 |
} |
Lines 8918-8931
Link Here
|
8918 |
|
9791 |
|
8919 |
if (token == null) |
9792 |
if (token == null) |
8920 |
return; |
9793 |
return; |
8921 |
|
9794 |
|
|
|
9795 |
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); |
9796 |
|
8922 |
boolean proposeType = |
9797 |
boolean proposeType = |
8923 |
!this.requestor.isIgnored(CompletionProposal.TYPE_REF) || |
9798 |
!this.requestor.isIgnored(CompletionProposal.TYPE_REF) || |
8924 |
((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)); |
9799 |
((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)); |
8925 |
|
9800 |
|
8926 |
boolean proposeAllMemberTypes = !this.assistNodeIsConstructor; |
9801 |
boolean proposeAllMemberTypes = !this.assistNodeIsConstructor; |
|
|
9802 |
|
9803 |
boolean proposeConstructor = |
9804 |
allowingLongComputationProposals && |
9805 |
this.assistNodeIsConstructor && |
9806 |
(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) || |
9807 |
!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)); |
9808 |
|
8927 |
|
9809 |
|
8928 |
if (proposeType && scope.enclosingSourceType() != null) { |
9810 |
if ((proposeType || proposeConstructor) && scope.enclosingSourceType() != null) { |
8929 |
|
9811 |
|
8930 |
checkCancel(); |
9812 |
checkCancel(); |
8931 |
|
9813 |
|
Lines 8944-8950
Link Here
|
8944 |
|
9826 |
|
8945 |
boolean isEmptyPrefix = token.length == 0; |
9827 |
boolean isEmptyPrefix = token.length == 0; |
8946 |
|
9828 |
|
8947 |
if (proposeType && this.unitScope != null) { |
9829 |
if ((proposeType || proposeConstructor) && this.unitScope != null) { |
8948 |
|
9830 |
|
8949 |
ReferenceBinding outerInvocationType = scope.enclosingSourceType(); |
9831 |
ReferenceBinding outerInvocationType = scope.enclosingSourceType(); |
8950 |
if(outerInvocationType != null) { |
9832 |
if(outerInvocationType != null) { |
Lines 8985-8991
Link Here
|
8985 |
if (typeLength > sourceType.sourceName.length) continue next; |
9867 |
if (typeLength > sourceType.sourceName.length) continue next; |
8986 |
|
9868 |
|
8987 |
if (!CharOperation.prefixEquals(token, sourceType.sourceName, false) |
9869 |
if (!CharOperation.prefixEquals(token, sourceType.sourceName, false) |
8988 |
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue; |
9870 |
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue next; |
8989 |
|
9871 |
|
8990 |
if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) { |
9872 |
if (this.assistNodeIsAnnotation && !hasPossibleAnnotationTarget(sourceType, scope)) { |
8991 |
continue next; |
9873 |
continue next; |
Lines 8996-9003
Link Here
|
8996 |
|
9878 |
|
8997 |
if (sourceType == otherType) continue next; |
9879 |
if (sourceType == otherType) continue next; |
8998 |
} |
9880 |
} |
8999 |
|
9881 |
|
9000 |
this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this); |
9882 |
typesFound.add(sourceType); |
9001 |
|
9883 |
|
9002 |
if(this.assistNodeIsClass) { |
9884 |
if(this.assistNodeIsClass) { |
9003 |
if(!sourceType.isClass()) continue next; |
9885 |
if(!sourceType.isClass()) continue next; |
Lines 9028-9035
Link Here
|
9028 |
relevance += computeRelevanceForClass(); |
9910 |
relevance += computeRelevanceForClass(); |
9029 |
relevance += computeRelevanceForException(sourceType.sourceName); |
9911 |
relevance += computeRelevanceForException(sourceType.sourceName); |
9030 |
} |
9912 |
} |
|
|
9913 |
|
9914 |
|
9031 |
this.noProposal = false; |
9915 |
this.noProposal = false; |
9032 |
if(proposeType) { |
9916 |
if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) { |
9033 |
char[] typeName = sourceType.sourceName(); |
9917 |
char[] typeName = sourceType.sourceName(); |
9034 |
createTypeProposal( |
9918 |
createTypeProposal( |
9035 |
sourceType, |
9919 |
sourceType, |
Lines 9042-9182
Link Here
|
9042 |
null, |
9926 |
null, |
9043 |
false); |
9927 |
false); |
9044 |
} |
9928 |
} |
|
|
9929 |
|
9930 |
if (proposeConstructor) { |
9931 |
findConstructorsOrAnonymousTypes( |
9932 |
sourceType, |
9933 |
scope, |
9934 |
FakeInvocationSite, |
9935 |
false, |
9936 |
relevance); |
9937 |
} |
9045 |
} |
9938 |
} |
9046 |
} |
9939 |
} |
9047 |
|
9940 |
|
9048 |
if(proposeType) { |
9941 |
if (proposeConstructor && !isEmptyPrefix) { |
|
|
9942 |
|
9943 |
checkCancel(); |
9944 |
|
9945 |
findTypesFromImports(token, scope, proposeType, typesFound); |
9946 |
} else if(proposeType) { |
9049 |
|
9947 |
|
9050 |
checkCancel(); |
9948 |
checkCancel(); |
9051 |
|
9949 |
|
9052 |
findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound); |
9950 |
findTypesFromStaticImports(token, scope, proposeAllMemberTypes, typesFound); |
9053 |
} |
9951 |
} |
|
|
9952 |
|
9953 |
if (proposeConstructor) { |
9954 |
|
9955 |
checkCancel(); |
9956 |
|
9957 |
findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor); |
9958 |
} |
9054 |
|
9959 |
|
9055 |
if (isEmptyPrefix && !this.assistNodeIsAnnotation) { |
9960 |
if (isEmptyPrefix && !this.assistNodeIsAnnotation) { |
9056 |
if(proposeType && this.expectedTypesPtr > -1) { |
9961 |
if (!proposeConstructor) { |
9057 |
next : for (int i = 0; i <= this.expectedTypesPtr; i++) { |
9962 |
findTypesFromExpectedTypes(token, scope, typesFound, proposeType, proposeConstructor); |
9058 |
|
9963 |
} |
9059 |
checkCancel(); |
9964 |
} else { |
9060 |
|
9965 |
if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
9061 |
if(this.expectedTypes[i] instanceof ReferenceBinding) { |
9966 |
if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) { |
9062 |
ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i]; |
9967 |
if (proposeBaseTypes) { |
9063 |
|
9968 |
if (proposeVoidType) { |
9064 |
if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) { |
9969 |
findKeywords(token, BASE_TYPE_NAMES, false, false); |
9065 |
// don't propose type variable if the completion is a constructor ('new |') |
9970 |
} else { |
9066 |
continue next; |
9971 |
findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false); |
9067 |
} |
|
|
9068 |
if (this.options.checkDeprecation && |
9069 |
refBinding.isViewedAsDeprecated() && |
9070 |
!scope.isDefinedInSameUnit(refBinding)) |
9071 |
continue next; |
9072 |
|
9073 |
int accessibility = IAccessRule.K_ACCESSIBLE; |
9074 |
if(refBinding.hasRestrictedAccess()) { |
9075 |
AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding); |
9076 |
if(accessRestriction != null) { |
9077 |
switch (accessRestriction.getProblemId()) { |
9078 |
case IProblem.ForbiddenReference: |
9079 |
if (this.options.checkForbiddenReference) { |
9080 |
continue next; |
9081 |
} |
9082 |
accessibility = IAccessRule.K_NON_ACCESSIBLE; |
9083 |
break; |
9084 |
case IProblem.DiscouragedReference: |
9085 |
if (this.options.checkDiscouragedReference) { |
9086 |
continue next; |
9087 |
} |
9088 |
accessibility = IAccessRule.K_DISCOURAGED; |
9089 |
break; |
9090 |
} |
9091 |
} |
9092 |
} |
9093 |
|
9094 |
for (int j = 0; j < typesFound.size(); j++) { |
9095 |
ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j); |
9096 |
if (typeFound == refBinding) { |
9097 |
continue next; |
9098 |
} |
9099 |
} |
9100 |
|
9101 |
boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding); |
9102 |
|
9103 |
// top level types of the current unit are already proposed. |
9104 |
if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) { |
9105 |
char[] packageName = refBinding.qualifiedPackageName(); |
9106 |
char[] typeName = refBinding.sourceName(); |
9107 |
char[] completionName = typeName; |
9108 |
|
9109 |
boolean isQualified = false; |
9110 |
if (!this.insideQualifiedReference && !refBinding.isMemberType()) { |
9111 |
if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) { |
9112 |
if (packageName == null || packageName.length == 0) |
9113 |
if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR) |
9114 |
continue next; // ignore types from the default package from outside it |
9115 |
completionName = CharOperation.concat(packageName, typeName, '.'); |
9116 |
isQualified = true; |
9117 |
} |
9118 |
} |
9119 |
|
9120 |
if(this.assistNodeIsClass) { |
9121 |
if(!refBinding.isClass()) continue next; |
9122 |
} else if(this.assistNodeIsInterface) { |
9123 |
if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next; |
9124 |
} else if (this.assistNodeIsAnnotation) { |
9125 |
if(!refBinding.isAnnotationType()) continue next; |
9126 |
} |
9127 |
|
9128 |
int relevance = computeBaseRelevance(); |
9129 |
relevance += computeRelevanceForResolution(); |
9130 |
relevance += computeRelevanceForInterestingProposal(); |
9131 |
relevance += computeRelevanceForCaseMatching(token, typeName); |
9132 |
relevance += computeRelevanceForExpectingType(refBinding); |
9133 |
relevance += computeRelevanceForQualification(isQualified); |
9134 |
relevance += computeRelevanceForRestrictions(accessibility); |
9135 |
|
9136 |
if(refBinding.isClass()) { |
9137 |
relevance += computeRelevanceForClass(); |
9138 |
relevance += computeRelevanceForException(typeName); |
9139 |
} else if(refBinding.isEnum()) { |
9140 |
relevance += computeRelevanceForEnum(); |
9141 |
} else if(refBinding.isInterface()) { |
9142 |
relevance += computeRelevanceForInterface(); |
9143 |
} |
9144 |
|
9145 |
this.noProposal = false; |
9146 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
9147 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
9148 |
proposal.setDeclarationSignature(packageName); |
9149 |
proposal.setSignature(getSignature(refBinding)); |
9150 |
proposal.setPackageName(packageName); |
9151 |
proposal.setTypeName(typeName); |
9152 |
proposal.setCompletion(completionName); |
9153 |
proposal.setFlags(refBinding.modifiers); |
9154 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
9155 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
9156 |
proposal.setRelevance(relevance); |
9157 |
proposal.setAccessibility(accessibility); |
9158 |
this.requestor.accept(proposal); |
9159 |
if(DEBUG) { |
9160 |
this.printDebug(proposal); |
9161 |
} |
9162 |
} |
9163 |
} |
9972 |
} |
9164 |
} |
9973 |
} |
9165 |
} |
9974 |
} |
9166 |
} |
9975 |
} |
9167 |
} else { |
9976 |
|
9168 |
if(!isEmptyPrefix && !this.requestor.isIgnored(CompletionProposal.KEYWORD)) { |
9977 |
if (proposeConstructor) { |
9169 |
if (this.assistNodeInJavadoc == 0 || (this.assistNodeInJavadoc & CompletionOnJavadoc.BASE_TYPES) != 0) { |
9978 |
int l = typesFound.size(); |
9170 |
if (proposeBaseTypes) { |
9979 |
for (int i = 0; i < l; i++) { |
9171 |
if (proposeVoidType) { |
9980 |
ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i); |
9172 |
findKeywords(token, BASE_TYPE_NAMES, false, false); |
9981 |
char[] fullyQualifiedTypeName = |
9173 |
} else { |
9982 |
CharOperation.concat( |
9174 |
findKeywords(token, BASE_TYPE_NAMES_WITHOUT_VOID, false, false); |
9983 |
typeFound.qualifiedPackageName(), |
9175 |
} |
9984 |
typeFound.qualifiedSourceName(), |
9176 |
} |
9985 |
'.'); |
|
|
9986 |
this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS); |
9177 |
} |
9987 |
} |
9178 |
} |
9988 |
|
9179 |
if(proposeType) { |
9989 |
checkCancel(); |
|
|
9990 |
|
9991 |
this.foundConstructorsCount = 0; |
9992 |
this.nameEnvironment.findConstructorDeclarations( |
9993 |
token, |
9994 |
this.options.camelCaseMatch, |
9995 |
this, |
9996 |
this.monitor); |
9997 |
acceptConstructors(scope); |
9998 |
} else if (proposeType) { |
9180 |
int l = typesFound.size(); |
9999 |
int l = typesFound.size(); |
9181 |
for (int i = 0; i < l; i++) { |
10000 |
for (int i = 0; i < l; i++) { |
9182 |
ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i); |
10001 |
ReferenceBinding typeFound = (ReferenceBinding) typesFound.elementAt(i); |
Lines 9185-9191
Link Here
|
9185 |
typeFound.qualifiedPackageName(), |
10004 |
typeFound.qualifiedPackageName(), |
9186 |
typeFound.qualifiedSourceName(), |
10005 |
typeFound.qualifiedSourceName(), |
9187 |
'.'); |
10006 |
'.'); |
9188 |
this.knownTypes.put(fullyQualifiedTypeName, this); |
10007 |
this.knownTypes.put(fullyQualifiedTypeName, KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS); |
9189 |
} |
10008 |
} |
9190 |
int searchFor = IJavaSearchConstants.TYPE; |
10009 |
int searchFor = IJavaSearchConstants.TYPE; |
9191 |
if(this.assistNodeIsClass) { |
10010 |
if(this.assistNodeIsClass) { |
Lines 9223-9232
Link Here
|
9223 |
char[] token, |
10042 |
char[] token, |
9224 |
PackageBinding packageBinding, |
10043 |
PackageBinding packageBinding, |
9225 |
Scope scope) { |
10044 |
Scope scope) { |
|
|
10045 |
|
10046 |
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); |
9226 |
|
10047 |
|
9227 |
boolean proposeType = |
10048 |
boolean proposeType = |
9228 |
!this.requestor.isIgnored(CompletionProposal.TYPE_REF) || |
10049 |
!this.requestor.isIgnored(CompletionProposal.TYPE_REF) || |
9229 |
((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)); |
10050 |
((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)); |
|
|
10051 |
|
10052 |
boolean proposeConstructor = |
10053 |
allowingLongComputationProposals && |
10054 |
this.assistNodeIsConstructor && |
10055 |
(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF) || |
10056 |
!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)); |
9230 |
|
10057 |
|
9231 |
char[] qualifiedName = |
10058 |
char[] qualifiedName = |
9232 |
CharOperation.concatWith(packageBinding.compoundName, token, '.'); |
10059 |
CharOperation.concatWith(packageBinding.compoundName, token, '.'); |
Lines 9244-9250
Link Here
|
9244 |
|
10071 |
|
9245 |
this.qualifiedCompletionToken = qualifiedName; |
10072 |
this.qualifiedCompletionToken = qualifiedName; |
9246 |
|
10073 |
|
9247 |
if (proposeType && this.unitScope != null) { |
10074 |
if ((proposeType || proposeConstructor) && this.unitScope != null) { |
9248 |
int typeLength = qualifiedName.length; |
10075 |
int typeLength = qualifiedName.length; |
9249 |
SourceTypeBinding[] types = this.unitScope.topLevelTypes; |
10076 |
SourceTypeBinding[] types = this.unitScope.topLevelTypes; |
9250 |
|
10077 |
|
Lines 9290-9296
Link Here
|
9290 |
} |
10117 |
} |
9291 |
} |
10118 |
} |
9292 |
|
10119 |
|
9293 |
this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this); |
10120 |
this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS); |
9294 |
|
10121 |
|
9295 |
int relevance = computeBaseRelevance(); |
10122 |
int relevance = computeBaseRelevance(); |
9296 |
relevance += computeRelevanceForResolution(); |
10123 |
relevance += computeRelevanceForResolution(); |
Lines 9308-9315
Link Here
|
9308 |
relevance += computeRelevanceForClass(); |
10135 |
relevance += computeRelevanceForClass(); |
9309 |
relevance += computeRelevanceForException(sourceType.sourceName); |
10136 |
relevance += computeRelevanceForException(sourceType.sourceName); |
9310 |
} |
10137 |
} |
|
|
10138 |
|
9311 |
this.noProposal = false; |
10139 |
this.noProposal = false; |
9312 |
if(proposeType) { |
10140 |
if(proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(sourceType, null, this.unitScope))) { |
9313 |
char[] typeName = sourceType.sourceName(); |
10141 |
char[] typeName = sourceType.sourceName(); |
9314 |
createTypeProposal( |
10142 |
createTypeProposal( |
9315 |
sourceType, |
10143 |
sourceType, |
Lines 9322-9331
Link Here
|
9322 |
null, |
10150 |
null, |
9323 |
false); |
10151 |
false); |
9324 |
} |
10152 |
} |
|
|
10153 |
|
10154 |
if (proposeConstructor) { |
10155 |
findConstructorsOrAnonymousTypes( |
10156 |
sourceType, |
10157 |
scope, |
10158 |
FakeInvocationSite, |
10159 |
false, |
10160 |
relevance); |
10161 |
} |
9325 |
} |
10162 |
} |
9326 |
} |
10163 |
} |
9327 |
|
10164 |
|
9328 |
if(proposeType) { |
10165 |
if (proposeConstructor) { |
|
|
10166 |
|
10167 |
|
10168 |
checkCancel(); |
10169 |
|
10170 |
this.foundConstructorsCount = 0; |
10171 |
this.nameEnvironment.findConstructorDeclarations( |
10172 |
qualifiedName, |
10173 |
this.options.camelCaseMatch, |
10174 |
this, |
10175 |
this.monitor); |
10176 |
acceptConstructors(scope); |
10177 |
} if(proposeType) { |
9329 |
int searchFor = IJavaSearchConstants.TYPE; |
10178 |
int searchFor = IJavaSearchConstants.TYPE; |
9330 |
if(this.assistNodeIsClass) { |
10179 |
if(this.assistNodeIsClass) { |
9331 |
searchFor = IJavaSearchConstants.CLASS; |
10180 |
searchFor = IJavaSearchConstants.CLASS; |
Lines 9349-9359
Link Here
|
9349 |
this.monitor); |
10198 |
this.monitor); |
9350 |
acceptTypes(scope); |
10199 |
acceptTypes(scope); |
9351 |
} |
10200 |
} |
|
|
10201 |
|
9352 |
if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { |
10202 |
if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { |
9353 |
this.nameEnvironment.findPackages(qualifiedName, this); |
10203 |
this.nameEnvironment.findPackages(qualifiedName, this); |
9354 |
} |
10204 |
} |
9355 |
} |
10205 |
} |
|
|
10206 |
|
10207 |
private void findTypesFromExpectedTypes(char[] token, Scope scope, ObjectVector typesFound, boolean proposeType, boolean proposeConstructor) { |
10208 |
if(this.expectedTypesPtr > -1) { |
10209 |
boolean allowingLongComputationProposals = isAllowingLongComputationProposals(); |
10210 |
|
10211 |
int typeLength = token == null ? 0 : token.length; |
10212 |
|
10213 |
next : for (int i = 0; i <= this.expectedTypesPtr; i++) { |
10214 |
|
10215 |
checkCancel(); |
10216 |
|
10217 |
if(this.expectedTypes[i] instanceof ReferenceBinding) { |
10218 |
ReferenceBinding refBinding = (ReferenceBinding)this.expectedTypes[i]; |
10219 |
|
10220 |
if (typeLength > 0) { |
10221 |
if (typeLength > refBinding.sourceName.length) continue next; |
10222 |
|
10223 |
if (!CharOperation.prefixEquals(token, refBinding.sourceName, false) |
10224 |
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, refBinding.sourceName))) continue next; |
10225 |
} |
10226 |
|
10227 |
|
10228 |
if(refBinding.isTypeVariable() && this.assistNodeIsConstructor) { |
10229 |
// don't propose type variable if the completion is a constructor ('new |') |
10230 |
continue next; |
10231 |
} |
10232 |
if (this.options.checkDeprecation && |
10233 |
refBinding.isViewedAsDeprecated() && |
10234 |
!scope.isDefinedInSameUnit(refBinding)) |
10235 |
continue next; |
10236 |
|
10237 |
int accessibility = IAccessRule.K_ACCESSIBLE; |
10238 |
if(refBinding.hasRestrictedAccess()) { |
10239 |
AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(refBinding); |
10240 |
if(accessRestriction != null) { |
10241 |
switch (accessRestriction.getProblemId()) { |
10242 |
case IProblem.ForbiddenReference: |
10243 |
if (this.options.checkForbiddenReference) { |
10244 |
continue next; |
10245 |
} |
10246 |
accessibility = IAccessRule.K_NON_ACCESSIBLE; |
10247 |
break; |
10248 |
case IProblem.DiscouragedReference: |
10249 |
if (this.options.checkDiscouragedReference) { |
10250 |
continue next; |
10251 |
} |
10252 |
accessibility = IAccessRule.K_DISCOURAGED; |
10253 |
break; |
10254 |
} |
10255 |
} |
10256 |
} |
10257 |
|
10258 |
for (int j = 0; j < typesFound.size(); j++) { |
10259 |
ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j); |
10260 |
if (typeFound == refBinding) { |
10261 |
continue next; |
10262 |
} |
10263 |
} |
10264 |
|
10265 |
typesFound.add(refBinding); |
9356 |
|
10266 |
|
|
|
10267 |
boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding); |
10268 |
|
10269 |
// top level types of the current unit are already proposed. |
10270 |
if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) { |
10271 |
char[] packageName = refBinding.qualifiedPackageName(); |
10272 |
char[] typeName = refBinding.sourceName(); |
10273 |
char[] completionName = typeName; |
10274 |
|
10275 |
boolean isQualified = false; |
10276 |
if (!this.insideQualifiedReference && !refBinding.isMemberType()) { |
10277 |
if (mustQualifyType(packageName, typeName, null, refBinding.modifiers)) { |
10278 |
if (packageName == null || packageName.length == 0) |
10279 |
if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR) |
10280 |
continue next; // ignore types from the default package from outside it |
10281 |
completionName = CharOperation.concat(packageName, typeName, '.'); |
10282 |
isQualified = true; |
10283 |
} |
10284 |
} |
10285 |
|
10286 |
if(this.assistNodeIsClass) { |
10287 |
if(!refBinding.isClass()) continue next; |
10288 |
} else if(this.assistNodeIsInterface) { |
10289 |
if(!refBinding.isInterface() && !refBinding.isAnnotationType()) continue next; |
10290 |
} else if (this.assistNodeIsAnnotation) { |
10291 |
if(!refBinding.isAnnotationType()) continue next; |
10292 |
} |
10293 |
|
10294 |
int relevance = computeBaseRelevance(); |
10295 |
relevance += computeRelevanceForResolution(); |
10296 |
relevance += computeRelevanceForInterestingProposal(); |
10297 |
relevance += computeRelevanceForCaseMatching(token, typeName); |
10298 |
relevance += computeRelevanceForExpectingType(refBinding); |
10299 |
relevance += computeRelevanceForQualification(isQualified); |
10300 |
relevance += computeRelevanceForRestrictions(accessibility); |
10301 |
|
10302 |
if(refBinding.isClass()) { |
10303 |
relevance += computeRelevanceForClass(); |
10304 |
relevance += computeRelevanceForException(typeName); |
10305 |
} else if(refBinding.isEnum()) { |
10306 |
relevance += computeRelevanceForEnum(); |
10307 |
} else if(refBinding.isInterface()) { |
10308 |
relevance += computeRelevanceForInterface(); |
10309 |
} |
10310 |
|
10311 |
if (proposeType && (!this.assistNodeIsConstructor || !allowingLongComputationProposals || hasStaticMemberTypes(refBinding, scope.enclosingSourceType() ,this.unitScope))) { |
10312 |
this.noProposal = false; |
10313 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
10314 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
10315 |
proposal.setDeclarationSignature(packageName); |
10316 |
proposal.setSignature(getSignature(refBinding)); |
10317 |
proposal.setPackageName(packageName); |
10318 |
proposal.setTypeName(typeName); |
10319 |
proposal.setCompletion(completionName); |
10320 |
proposal.setFlags(refBinding.modifiers); |
10321 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
10322 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
10323 |
proposal.setRelevance(relevance); |
10324 |
proposal.setAccessibility(accessibility); |
10325 |
this.requestor.accept(proposal); |
10326 |
if(DEBUG) { |
10327 |
this.printDebug(proposal); |
10328 |
} |
10329 |
} |
10330 |
} |
10331 |
|
10332 |
if (proposeConstructor) { |
10333 |
findConstructorsOrAnonymousTypes( |
10334 |
refBinding, |
10335 |
scope, |
10336 |
FakeInvocationSite, |
10337 |
isQualified, |
10338 |
relevance); |
10339 |
} |
10340 |
} |
10341 |
} |
10342 |
} |
10343 |
} |
10344 |
} |
10345 |
|
10346 |
private void findTypesFromImports(char[] token, Scope scope, boolean proposeType, ObjectVector typesFound) { |
10347 |
ImportBinding[] importBindings = scope.compilationUnitScope().imports; |
10348 |
next : for (int i = 0; i < importBindings.length; i++) { |
10349 |
ImportBinding importBinding = importBindings[i]; |
10350 |
if(importBinding.isValidBinding()) { |
10351 |
Binding binding = importBinding.resolvedImport; |
10352 |
if(binding != null && binding.isValidBinding()) { |
10353 |
if(importBinding.onDemand) { |
10354 |
if (importBinding.isStatic()) { |
10355 |
if((binding.kind() & Binding.TYPE) != 0) { |
10356 |
this.findMemberTypes( |
10357 |
token, |
10358 |
(ReferenceBinding) binding, |
10359 |
scope, |
10360 |
scope.enclosingSourceType(), |
10361 |
true, |
10362 |
false, |
10363 |
true, |
10364 |
true, |
10365 |
false, |
10366 |
null, |
10367 |
typesFound, |
10368 |
null, |
10369 |
null, |
10370 |
null, |
10371 |
false); |
10372 |
} |
10373 |
} |
10374 |
} else { |
10375 |
if ((binding.kind() & Binding.TYPE) != 0) { |
10376 |
ReferenceBinding typeBinding = (ReferenceBinding) binding; |
10377 |
int typeLength = token.length; |
10378 |
|
10379 |
if (!typeBinding.isStatic()) continue next; |
10380 |
|
10381 |
if (typeLength > typeBinding.sourceName.length) continue next; |
10382 |
|
10383 |
if (!CharOperation.prefixEquals(token, typeBinding.sourceName, false) |
10384 |
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, typeBinding.sourceName))) continue next; |
10385 |
|
10386 |
int accessibility = IAccessRule.K_ACCESSIBLE; |
10387 |
if(typeBinding.hasRestrictedAccess()) { |
10388 |
AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(typeBinding); |
10389 |
if(accessRestriction != null) { |
10390 |
switch (accessRestriction.getProblemId()) { |
10391 |
case IProblem.ForbiddenReference: |
10392 |
if (this.options.checkForbiddenReference) { |
10393 |
continue next; |
10394 |
} |
10395 |
accessibility = IAccessRule.K_NON_ACCESSIBLE; |
10396 |
break; |
10397 |
case IProblem.DiscouragedReference: |
10398 |
if (this.options.checkDiscouragedReference) { |
10399 |
continue next; |
10400 |
} |
10401 |
accessibility = IAccessRule.K_DISCOURAGED; |
10402 |
break; |
10403 |
} |
10404 |
} |
10405 |
} |
10406 |
|
10407 |
if (typesFound.contains(typeBinding)) continue next; |
10408 |
|
10409 |
typesFound.add(typeBinding); |
10410 |
|
10411 |
if(this.assistNodeIsClass) { |
10412 |
if(!typeBinding.isClass()) continue; |
10413 |
} else if(this.assistNodeIsInterface) { |
10414 |
if(!typeBinding.isInterface() && !typeBinding.isAnnotationType()) continue; |
10415 |
} else if (this.assistNodeIsAnnotation) { |
10416 |
if(!typeBinding.isAnnotationType()) continue; |
10417 |
} |
10418 |
|
10419 |
int relevance = computeBaseRelevance(); |
10420 |
relevance += computeRelevanceForResolution(); |
10421 |
relevance += computeRelevanceForInterestingProposal(); |
10422 |
relevance += computeRelevanceForCaseMatching(token, typeBinding.sourceName); |
10423 |
relevance += computeRelevanceForExpectingType(typeBinding); |
10424 |
relevance += computeRelevanceForQualification(false); |
10425 |
relevance += computeRelevanceForRestrictions(accessibility); |
10426 |
|
10427 |
if (typeBinding.isAnnotationType()) { |
10428 |
relevance += computeRelevanceForAnnotation(); |
10429 |
relevance += computeRelevanceForAnnotationTarget(typeBinding); |
10430 |
} else if (typeBinding.isInterface()) { |
10431 |
relevance += computeRelevanceForInterface(); |
10432 |
} else if(typeBinding.isClass()){ |
10433 |
relevance += computeRelevanceForClass(); |
10434 |
relevance += computeRelevanceForException(typeBinding.sourceName); |
10435 |
} |
10436 |
|
10437 |
if (proposeType && hasStaticMemberTypes(typeBinding, scope.enclosingSourceType(), this.unitScope)) { |
10438 |
this.noProposal = false; |
10439 |
if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { |
10440 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
10441 |
proposal.setDeclarationSignature(typeBinding.qualifiedPackageName()); |
10442 |
proposal.setSignature(getSignature(typeBinding)); |
10443 |
proposal.setPackageName(typeBinding.qualifiedPackageName()); |
10444 |
proposal.setTypeName(typeBinding.qualifiedSourceName()); |
10445 |
proposal.setCompletion(typeBinding.sourceName()); |
10446 |
proposal.setFlags(typeBinding.modifiers); |
10447 |
proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
10448 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
10449 |
proposal.setRelevance(relevance); |
10450 |
this.requestor.accept(proposal); |
10451 |
if(DEBUG) { |
10452 |
this.printDebug(proposal); |
10453 |
} |
10454 |
} |
10455 |
} |
10456 |
|
10457 |
findConstructorsOrAnonymousTypes( |
10458 |
typeBinding, |
10459 |
scope, |
10460 |
FakeInvocationSite, |
10461 |
false, |
10462 |
relevance); |
10463 |
} |
10464 |
} |
10465 |
} |
10466 |
} |
10467 |
} |
10468 |
} |
10469 |
|
9357 |
private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) { |
10470 |
private void findTypesFromStaticImports(char[] token, Scope scope, boolean proposeAllMemberTypes, ObjectVector typesFound) { |
9358 |
ImportBinding[] importBindings = scope.compilationUnitScope().imports; |
10471 |
ImportBinding[] importBindings = scope.compilationUnitScope().imports; |
9359 |
for (int i = 0; i < importBindings.length; i++) { |
10472 |
for (int i = 0; i < importBindings.length; i++) { |
Lines 10206-10211
Link Here
|
10206 |
|
11319 |
|
10207 |
return this.favoriteReferenceBindings = resolvedImports; |
11320 |
return this.favoriteReferenceBindings = resolvedImports; |
10208 |
} |
11321 |
} |
|
|
11322 |
|
11323 |
private INameEnvironment getNoCacheNameEnvironment() { |
11324 |
if (this.noCacheNameEnvironment == null) { |
11325 |
JavaModelManager.getJavaModelManager().cacheZipFiles(); |
11326 |
this.noCacheNameEnvironment = new JavaSearchNameEnvironment(this.javaProject, this.owner == null ? null : JavaModelManager.getJavaModelManager().getWorkingCopies(this.owner, true/*add primary WCs*/)); |
11327 |
} |
11328 |
return this.noCacheNameEnvironment; |
11329 |
} |
10209 |
|
11330 |
|
10210 |
public AssistParser getParser() { |
11331 |
public AssistParser getParser() { |
10211 |
|
11332 |
|
Lines 10256-10261
Link Here
|
10256 |
inlineCompletion[inlineLength-1] = '}'; |
11377 |
inlineCompletion[inlineLength-1] = '}'; |
10257 |
return inlineCompletion; |
11378 |
return inlineCompletion; |
10258 |
} |
11379 |
} |
|
|
11380 |
private boolean isAllowingLongComputationProposals() { |
11381 |
return this.monitor != null; |
11382 |
} |
10259 |
private boolean isForbidden(Binding binding) { |
11383 |
private boolean isForbidden(Binding binding) { |
10260 |
for (int i = 0; i <= this.forbbidenBindingsPtr; i++) { |
11384 |
for (int i = 0; i <= this.forbbidenBindingsPtr; i++) { |
10261 |
if(this.forbbidenBindings[i] == binding) { |
11385 |
if(this.forbbidenBindings[i] == binding) { |
Lines 10469-10474
Link Here
|
10469 |
case CompletionProposal.TYPE_IMPORT : |
11593 |
case CompletionProposal.TYPE_IMPORT : |
10470 |
buffer.append("TYPE_IMPORT"); //$NON-NLS-1$ |
11594 |
buffer.append("TYPE_IMPORT"); //$NON-NLS-1$ |
10471 |
break; |
11595 |
break; |
|
|
11596 |
case CompletionProposal.CONSTRUCTOR_INVOCATION : |
11597 |
buffer.append("CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$ |
11598 |
break; |
11599 |
case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION : |
11600 |
buffer.append("ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION"); //$NON-NLS-1$ |
11601 |
break; |
10472 |
default : |
11602 |
default : |
10473 |
buffer.append("PROPOSAL"); //$NON-NLS-1$ |
11603 |
buffer.append("PROPOSAL"); //$NON-NLS-1$ |
10474 |
break; |
11604 |
break; |
Lines 10540-10545
Link Here
|
10540 |
buffer.append('\t'); |
11670 |
buffer.append('\t'); |
10541 |
} |
11671 |
} |
10542 |
} |
11672 |
} |
|
|
11673 |
|
11674 |
private void proposeConstructor(AcceptedConstructor deferredProposal, Scope scope) { |
11675 |
if (deferredProposal.proposeConstructor) { |
11676 |
proposeConstructor( |
11677 |
deferredProposal.simpleTypeName, |
11678 |
deferredProposal.parameterCount, |
11679 |
deferredProposal.signature, |
11680 |
deferredProposal.parameterTypes, |
11681 |
deferredProposal.parameterNames, |
11682 |
deferredProposal.modifiers, |
11683 |
deferredProposal.packageName, |
11684 |
deferredProposal.typeModifiers, |
11685 |
deferredProposal.accessibility, |
11686 |
deferredProposal.simpleTypeName, |
11687 |
deferredProposal.fullyQualifiedName, |
11688 |
deferredProposal.mustBeQualified, |
11689 |
scope, |
11690 |
deferredProposal.extraFlags); |
11691 |
} |
11692 |
} |
11693 |
|
11694 |
private void proposeConstructor( |
11695 |
char[] simpleTypeName, |
11696 |
int parameterCount, |
11697 |
char[] signature, |
11698 |
char[][] parameterTypes, |
11699 |
char[][] parameterNames, |
11700 |
int modifiers, |
11701 |
char[] packageName, |
11702 |
int typeModifiers, |
11703 |
int accessibility, |
11704 |
char[] typeName, |
11705 |
char[] fullyQualifiedName, |
11706 |
boolean isQualified, |
11707 |
Scope scope, |
11708 |
int extraFlags) { |
11709 |
char[] typeCompletion = fullyQualifiedName; |
11710 |
if(isQualified) { |
11711 |
if (packageName == null || packageName.length == 0) |
11712 |
if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR) |
11713 |
return; // ignore types from the default package from outside it |
11714 |
} else { |
11715 |
typeCompletion = simpleTypeName; |
11716 |
} |
11717 |
|
11718 |
int relevance = computeBaseRelevance(); |
11719 |
relevance += computeRelevanceForResolution(); |
11720 |
relevance += computeRelevanceForInterestingProposal(); |
11721 |
relevance += computeRelevanceForRestrictions(accessibility); |
11722 |
relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName); |
11723 |
relevance += computeRelevanceForExpectingType(packageName, simpleTypeName); |
11724 |
relevance += computeRelevanceForQualification(isQualified); |
11725 |
|
11726 |
boolean isInterface = false; |
11727 |
int kind = typeModifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccEnum | ClassFileConstants.AccAnnotation); |
11728 |
switch (kind) { |
11729 |
case ClassFileConstants.AccAnnotation: |
11730 |
case ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface: |
11731 |
relevance += computeRelevanceForAnnotation(); |
11732 |
relevance += computeRelevanceForInterface(); |
11733 |
isInterface = true; |
11734 |
break; |
11735 |
case ClassFileConstants.AccEnum: |
11736 |
relevance += computeRelevanceForEnum(); |
11737 |
break; |
11738 |
case ClassFileConstants.AccInterface: |
11739 |
relevance += computeRelevanceForInterface(); |
11740 |
isInterface = true; |
11741 |
break; |
11742 |
default: |
11743 |
relevance += computeRelevanceForClass(); |
11744 |
relevance += computeRelevanceForException(simpleTypeName); |
11745 |
break; |
11746 |
} |
11747 |
|
11748 |
char[] completion; |
11749 |
if (this.source != null |
11750 |
&& this.source.length > this.endPosition |
11751 |
&& this.source[this.endPosition] == '(') { |
11752 |
completion = CharOperation.NO_CHAR; |
11753 |
} else { |
11754 |
completion = new char[] { '(', ')' }; |
11755 |
} |
11756 |
|
11757 |
InternalCompletionProposal typeProposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); |
11758 |
typeProposal.nameLookup = this.nameEnvironment.nameLookup; |
11759 |
typeProposal.completionEngine = this; |
11760 |
typeProposal.setDeclarationSignature(packageName); |
11761 |
typeProposal.setSignature(createNonGenericTypeSignature(packageName, typeName)); |
11762 |
typeProposal.setPackageName(packageName); |
11763 |
typeProposal.setTypeName(typeName); |
11764 |
typeProposal.setCompletion(typeCompletion); |
11765 |
typeProposal.setFlags(typeModifiers); |
11766 |
typeProposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); |
11767 |
typeProposal.setTokenRange(this.startPosition - this.offset, this.endPosition - this.offset); |
11768 |
typeProposal.setRelevance(relevance); |
11769 |
|
11770 |
switch (parameterCount) { |
11771 |
case -1: // default constructor |
11772 |
int flags = Flags.AccPublic; |
11773 |
if (Flags.isDeprecated(typeModifiers)) { |
11774 |
flags |= Flags.AccDeprecated; |
11775 |
} |
11776 |
|
11777 |
if (isInterface || (typeModifiers & ClassFileConstants.AccAbstract) != 0) { |
11778 |
this.noProposal = false; |
11779 |
if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
11780 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11781 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11782 |
proposal.setDeclarationKey(createBindingKey(packageName, typeName)); |
11783 |
proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE); |
11784 |
proposal.setDeclarationPackageName(packageName); |
11785 |
proposal.setDeclarationTypeName(typeName); |
11786 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11787 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11788 |
proposal.setParameterNames(CharOperation.NO_CHAR_CHAR); |
11789 |
proposal.setName(simpleTypeName); |
11790 |
proposal.setRequiredProposals(new CompletionProposal[]{typeProposal}); |
11791 |
proposal.setIsContructor(true); |
11792 |
proposal.setCompletion(completion); |
11793 |
proposal.setFlags(flags); |
11794 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
11795 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11796 |
proposal.setRelevance(relevance); |
11797 |
this.requestor.accept(proposal); |
11798 |
if(DEBUG) { |
11799 |
this.printDebug(proposal); |
11800 |
} |
11801 |
} |
11802 |
} else { |
11803 |
this.noProposal = false; |
11804 |
if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
11805 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11806 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11807 |
proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE); |
11808 |
proposal.setDeclarationPackageName(packageName); |
11809 |
proposal.setDeclarationTypeName(typeName); |
11810 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11811 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11812 |
proposal.setParameterNames(CharOperation.NO_CHAR_CHAR); |
11813 |
proposal.setName(simpleTypeName); |
11814 |
proposal.setRequiredProposals(new CompletionProposal[]{typeProposal}); |
11815 |
proposal.setIsContructor(true); |
11816 |
proposal.setCompletion(completion); |
11817 |
proposal.setFlags(flags); |
11818 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
11819 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11820 |
proposal.setRelevance(relevance); |
11821 |
this.requestor.accept(proposal); |
11822 |
if(DEBUG) { |
11823 |
this.printDebug(proposal); |
11824 |
} |
11825 |
} |
11826 |
} |
11827 |
break; |
11828 |
case 0: // constructor with no parameter |
11829 |
|
11830 |
if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) { |
11831 |
this.noProposal = false; |
11832 |
if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
11833 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11834 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11835 |
proposal.setDeclarationKey(createBindingKey(packageName, typeName)); |
11836 |
proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE); |
11837 |
proposal.setDeclarationPackageName(packageName); |
11838 |
proposal.setDeclarationTypeName(typeName); |
11839 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11840 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11841 |
proposal.setParameterNames(CharOperation.NO_CHAR_CHAR); |
11842 |
proposal.setName(simpleTypeName); |
11843 |
proposal.setRequiredProposals(new CompletionProposal[]{typeProposal}); |
11844 |
proposal.setIsContructor(true); |
11845 |
proposal.setCompletion(completion); |
11846 |
proposal.setFlags(modifiers); |
11847 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
11848 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11849 |
proposal.setRelevance(relevance); |
11850 |
this.requestor.accept(proposal); |
11851 |
if(DEBUG) { |
11852 |
this.printDebug(proposal); |
11853 |
} |
11854 |
} |
11855 |
} else { |
11856 |
this.noProposal = false; |
11857 |
if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
11858 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11859 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11860 |
proposal.setSignature(DEFAULT_CONSTRUCTOR_SIGNATURE); |
11861 |
proposal.setDeclarationPackageName(packageName); |
11862 |
proposal.setDeclarationTypeName(typeName); |
11863 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11864 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11865 |
proposal.setParameterNames(CharOperation.NO_CHAR_CHAR); |
11866 |
proposal.setName(simpleTypeName); |
11867 |
proposal.setRequiredProposals(new CompletionProposal[]{typeProposal}); |
11868 |
proposal.setIsContructor(true); |
11869 |
proposal.setCompletion(completion); |
11870 |
proposal.setFlags(modifiers); |
11871 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
11872 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11873 |
proposal.setRelevance(relevance); |
11874 |
this.requestor.accept(proposal); |
11875 |
if(DEBUG) { |
11876 |
this.printDebug(proposal); |
11877 |
} |
11878 |
} |
11879 |
} |
11880 |
break; |
11881 |
default: // constructor with parameter |
11882 |
if (signature == null) { |
11883 |
// resolve type to found parameter types |
11884 |
signature = getResolvedSignature(parameterTypes, fullyQualifiedName, parameterCount, scope); |
11885 |
if (signature == null) return; |
11886 |
} else { |
11887 |
signature = CharOperation.replaceOnCopy(signature, '/', '.'); |
11888 |
} |
11889 |
|
11890 |
int parameterNamesLength = parameterNames == null ? 0 : parameterNames.length; |
11891 |
if (parameterCount != parameterNamesLength) { |
11892 |
parameterNames = null; |
11893 |
} |
11894 |
|
11895 |
if ((typeModifiers & ClassFileConstants.AccAbstract) != 0) { |
11896 |
this.noProposal = false; |
11897 |
if(!isIgnored(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
11898 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11899 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11900 |
proposal.setDeclarationKey(createBindingKey(packageName, typeName)); |
11901 |
proposal.setSignature(signature); |
11902 |
proposal.setDeclarationPackageName(packageName); |
11903 |
proposal.setDeclarationTypeName(typeName); |
11904 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11905 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11906 |
if (parameterNames != null) { |
11907 |
proposal.setParameterNames(parameterNames); |
11908 |
} else { |
11909 |
proposal.setHasNoParameterNamesFromIndex(true); |
11910 |
} |
11911 |
proposal.setName(simpleTypeName); |
11912 |
proposal.setRequiredProposals(new CompletionProposal[]{typeProposal}); |
11913 |
proposal.setIsContructor(true); |
11914 |
proposal.setCompletion(completion); |
11915 |
proposal.setFlags(modifiers); |
11916 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
11917 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11918 |
proposal.setRelevance(relevance); |
11919 |
this.requestor.accept(proposal); |
11920 |
if(DEBUG) { |
11921 |
this.printDebug(proposal); |
11922 |
} |
11923 |
} |
11924 |
} else { |
11925 |
this.noProposal = false; |
11926 |
if(!isIgnored(CompletionProposal.CONSTRUCTOR_INVOCATION, CompletionProposal.TYPE_REF)) { |
11927 |
InternalCompletionProposal proposal = createProposal(CompletionProposal.CONSTRUCTOR_INVOCATION, this.actualCompletionPosition); |
11928 |
proposal.setDeclarationSignature(createNonGenericTypeSignature(packageName, typeName)); |
11929 |
proposal.setSignature(signature); |
11930 |
proposal.setDeclarationPackageName(packageName); |
11931 |
proposal.setDeclarationTypeName(typeName); |
11932 |
proposal.setParameterPackageNames(CharOperation.NO_CHAR_CHAR); |
11933 |
proposal.setParameterTypeNames(CharOperation.NO_CHAR_CHAR); |
11934 |
if (parameterNames != null) { |
11935 |
proposal.setParameterNames(parameterNames); |
11936 |
} else { |
11937 |
proposal.setHasNoParameterNamesFromIndex(true); |
11938 |
} |
11939 |
proposal.setName(simpleTypeName); |
11940 |
proposal.setRequiredProposals(new CompletionProposal[]{typeProposal}); |
11941 |
proposal.setIsContructor(true); |
11942 |
proposal.setCompletion(completion); |
11943 |
proposal.setFlags(modifiers); |
11944 |
proposal.setReplaceRange(this.endPosition - this.offset, this.endPosition - this.offset); |
11945 |
proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); |
11946 |
proposal.setRelevance(relevance); |
11947 |
|
11948 |
this.requestor.accept(proposal); |
11949 |
if(DEBUG) { |
11950 |
this.printDebug(proposal); |
11951 |
} |
11952 |
} |
11953 |
} |
11954 |
break; |
11955 |
} |
11956 |
} |
10543 |
|
11957 |
|
10544 |
private void proposeNewMethod(char[] token, ReferenceBinding reference) { |
11958 |
private void proposeNewMethod(char[] token, ReferenceBinding reference) { |
10545 |
if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) { |
11959 |
if(!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) { |
Lines 10662-10667
Link Here
|
10662 |
super.reset(false); |
12076 |
super.reset(false); |
10663 |
this.knownPkgs = new HashtableOfObject(10); |
12077 |
this.knownPkgs = new HashtableOfObject(10); |
10664 |
this.knownTypes = new HashtableOfObject(10); |
12078 |
this.knownTypes = new HashtableOfObject(10); |
|
|
12079 |
if (this.noCacheNameEnvironment != null) { |
12080 |
this.noCacheNameEnvironment.cleanup(); |
12081 |
this.noCacheNameEnvironment = null; |
12082 |
JavaModelManager.getJavaModelManager().flushZipFiles(); |
12083 |
} |
10665 |
} |
12084 |
} |
10666 |
|
12085 |
|
10667 |
private void setSourceAndTokenRange(int start, int end) { |
12086 |
private void setSourceAndTokenRange(int start, int end) { |