Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 352160 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/wst/jsdt/core/CompletionProposal.java (-31 / +36 lines)
Lines 13-18 Link Here
13
import org.eclipse.core.runtime.IProgressMonitor;
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
14
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
15
import org.eclipse.wst.jsdt.internal.codeassist.InternalCompletionProposal;
15
import org.eclipse.wst.jsdt.internal.codeassist.InternalCompletionProposal;
16
import org.eclipse.wst.jsdt.internal.core.util.QualificationHelpers;
16
17
17
/**
18
/**
18
 * Completion proposal.
19
 * Completion proposal.
Lines 1402-1438 Link Here
1402
//		return this.declarationPackageName;
1403
//		return this.declarationPackageName;
1403
//	}
1404
//	}
1404
//
1405
//
1405
//	/**
1406
	/**
1406
//	 * Returns the type name of the relevant
1407
	 * Returns the type name of the relevant
1407
//	 * declaration in the context without the package fragment,
1408
	 * declaration in the context without the package fragment,
1408
//	 * or <code>null</code> if none.
1409
	 * or <code>null</code> if none.
1409
//	 * <p>
1410
	 * <p>
1410
//	 * This field is available for the following kinds of
1411
	 * This field is available for the following kinds of
1411
//	 * completion proposals:
1412
	 * completion proposals:
1412
//	 * <ul>
1413
	 * <ul>
1413
//	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - the dot-based type name
1414
	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - the dot-based type name
1414
//	 * of the type that is being subclassed or implemented</li>
1415
	 * of the type that is being subclassed or implemented</li>
1415
//	 * 	<li><code>FIELD_REF</code> - the dot-based type name
1416
	 * 	<li><code>FIELD_REF</code> - the dot-based type name
1416
//	 * of the type that declares the field that is referenced
1417
	 * of the type that declares the field that is referenced
1417
//	 * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li>
1418
	 * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li>
1418
//	 * 	<li><code>FUNCTION_REF</code> - the dot-based type name
1419
	 * 	<li><code>FUNCTION_REF</code> - the dot-based type name
1419
//	 * of the type that declares the method that is referenced
1420
	 * of the type that declares the method that is referenced
1420
//	 * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li>
1421
	 * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li>
1421
//	 * 	<li><code>FUNCTION_DECLARATION</code> - the dot-based type name
1422
	 * 	<li><code>FUNCTION_DECLARATION</code> - the dot-based type name
1422
//	 * of the type that declares the method that is being
1423
	 * of the type that declares the method that is being
1423
//	 * implemented or overridden</li>
1424
	 * implemented or overridden</li>
1424
//	 * </ul>
1425
	 * </ul>
1425
//	 * For kinds of completion proposals, this method returns
1426
	 * For kinds of completion proposals, this method returns
1426
//	 * <code>null</code>. Clients must not modify the array
1427
	 * <code>null</code>. Clients must not modify the array
1427
//	 * returned.
1428
	 * returned.
1428
//	 * </p>
1429
	 * </p>
1429
//	 *
1430
	 *
1430
//	 * @return the dot-based package name, or
1431
	 * @return the dot-based package name, or
1431
//	 * <code>null</code> if none
1432
	 * <code>null</code> if none
1432
//	 * @see #getDeclarationSignature()
1433
	 * @see #getDeclarationSignature()
1433
//	 * @see #getSignature()
1434
	 * @see #getSignature()
1434
//	 *
1435
	 *
1435
//	 */
1436
	 */
1436
	public char[] getDeclarationTypeName() {
1437
	public char[] getDeclarationTypeName() {
1437
		return this.declarationTypeName;
1438
		return this.declarationTypeName;
1438
	}
1439
	}
Lines 1861-1866 Link Here
1861
	public char[][] getParameterTypeNames() {
1862
	public char[][] getParameterTypeNames() {
1862
		return this.parameterTypeNames;
1863
		return this.parameterTypeNames;
1863
	}
1864
	}
1865
	
1866
	public char[] getReturnType() {
1867
		return QualificationHelpers.createFullyQualifiedName(this.getReturnQualification(), this.getReturnSimpleName());
1868
	}
1864
1869
1865
	/**
1870
	/**
1866
	 * Returns the accessibility of the proposal.
1871
	 * Returns the accessibility of the proposal.
(-)src/org/eclipse/wst/jsdt/core/compiler/CharOperation.java (-5 / +6 lines)
Lines 1089-1108 Link Here
1089
	int size = length - 1;
1089
	int size = length - 1;
1090
	int index = length;
1090
	int index = length;
1091
	while (--index >= 0) {
1091
	while (--index >= 0) {
1092
		if (array[index].length == 0 && ignoreEmptyElements)
1092
		if ((array[index] == null || array[index].length == 0) && ignoreEmptyElements) {
1093
			size--;
1093
			size--;
1094
		else
1094
		} else {
1095
			size += array[index].length;
1095
			size += array[index] != null ? array[index].length : 0;
1096
		}
1096
	}
1097
	}
1097
	if (size <= 0)
1098
	if (size <= 0)
1098
		return CharOperation.NO_CHAR;
1099
		return CharOperation.NO_CHAR;
1099
	char[] result = new char[size];
1100
	char[] result = new char[size];
1100
	index = length;
1101
	index = length;
1101
	while (--index >= 0) {
1102
	while (--index >= 0) {
1102
		length = array[index].length;
1103
		length = array[index] != null ? array[index].length : 0;
1103
		if (length > 0 || (length == 0 && !ignoreEmptyElements)) {
1104
		if (length > 0 || (length == 0 && !ignoreEmptyElements)) {
1104
			System.arraycopy(
1105
			System.arraycopy(
1105
				array[index],
1106
				array[index] != null ? array[index] : NO_CHAR,
1106
				0,
1107
				0,
1107
				result,
1108
				result,
1108
				(size -= length),
1109
				(size -= length),
(-)src/org/eclipse/wst/jsdt/core/search/SearchPattern.java (-6 lines)
Lines 983-996 Link Here
983
				selectorChars,
983
				selectorChars,
984
				declaringTypeQualification,
984
				declaringTypeQualification,
985
				declaringTypeSimpleName,
985
				declaringTypeSimpleName,
986
				declaringTypeSignature,
987
				returnTypeQualification,
986
				returnTypeQualification,
988
				returnTypeSimpleName,
987
				returnTypeSimpleName,
989
				returnTypeSignature,
990
				parameterTypeQualifications,
988
				parameterTypeQualifications,
991
				parameterTypeSimpleNames,
989
				parameterTypeSimpleNames,
992
				parameterTypeSignatures,
993
				typeArguments,
994
				matchRule);
990
				matchRule);
995
	}
991
	}
996
}
992
}
Lines 1479-1488 Link Here
1479
						declaringSimpleName,
1475
						declaringSimpleName,
1480
						returnQualification,
1476
						returnQualification,
1481
						returnSimpleName,
1477
						returnSimpleName,
1482
						returnSignature,
1483
						parameterQualifications,
1478
						parameterQualifications,
1484
						parameterSimpleNames,
1479
						parameterSimpleNames,
1485
						parameterSignatures,
1486
						method,
1480
						method,
1487
						matchRule);
1481
						matchRule);
1488
			}
1482
			}
(-)src/org/eclipse/wst/jsdt/internal/codeassist/CompletionEngine.java (-93 / +143 lines)
Lines 161-166 Link Here
161
import org.eclipse.wst.jsdt.internal.core.SourceMethodElementInfo;
161
import org.eclipse.wst.jsdt.internal.core.SourceMethodElementInfo;
162
import org.eclipse.wst.jsdt.internal.core.SourceType;
162
import org.eclipse.wst.jsdt.internal.core.SourceType;
163
import org.eclipse.wst.jsdt.internal.core.SourceTypeElementInfo;
163
import org.eclipse.wst.jsdt.internal.core.SourceTypeElementInfo;
164
import org.eclipse.wst.jsdt.internal.core.util.QualificationHelpers;
164
import org.eclipse.wst.jsdt.internal.oaametadata.ClassData;
165
import org.eclipse.wst.jsdt.internal.oaametadata.ClassData;
165
import org.eclipse.wst.jsdt.internal.oaametadata.Method;
166
import org.eclipse.wst.jsdt.internal.oaametadata.Method;
166
167
Lines 675-680 Link Here
675
	}
676
	}
676
	
677
	
677
	/**
678
	/**
679
	 * @see org.eclipse.wst.jsdt.internal.codeassist.ISearchRequestor#acceptMethod(char[], int, char[][], char[][], char[][], char[], char[], char[], char[], int, java.lang.String)
680
	 */
681
	public void acceptMethod(char[] signature, int parameterCount,
682
			char[][] parameterQualifications, char[][] parameterSimpleNames,
683
			char[][] parameterNames, char[] returnQualification,
684
			char[] returnSimpleName, char[] declaringQualification,
685
			char[] declaringSimpleName, int modifiers, String path) {
686
		
687
		this.proposeMethod(signature, parameterCount, parameterQualifications, parameterSimpleNames, parameterNames,
688
				returnQualification, returnSimpleName, declaringQualification, declaringSimpleName, modifiers, path);
689
	}
690
	
691
	/**
678
	 * @see org.eclipse.wst.jsdt.internal.codeassist.ISearchRequestor#acceptConstructor(
692
	 * @see org.eclipse.wst.jsdt.internal.codeassist.ISearchRequestor#acceptConstructor(
679
	 * 		int, char[], int, char[][], char[][], java.lang.String, org.eclipse.wst.jsdt.internal.compiler.env.AccessRestriction)
693
	 * 		int, char[], int, char[][], char[][], java.lang.String, org.eclipse.wst.jsdt.internal.compiler.env.AccessRestriction)
680
	 */
694
	 */
Lines 756-763 Link Here
756
		if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) {
770
		if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) {
757
			CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.LOCAL_VARIABLE_REF, CompletionEngine.this.actualCompletionPosition);
771
			CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.LOCAL_VARIABLE_REF, CompletionEngine.this.actualCompletionPosition);
758
			proposal.setSignature(JAVA_LANG_OBJECT_SIGNATURE);
772
			proposal.setSignature(JAVA_LANG_OBJECT_SIGNATURE);
759
			proposal.setPackageName(JAVA_LANG_NAME);
773
			proposal.setReturnQualification(JAVA_LANG_NAME);
760
			proposal.setTypeName(OBJECT);
774
			proposal.setReturnSimpleName(OBJECT);
761
			proposal.setName(name);
775
			proposal.setName(name);
762
			proposal.setCompletion(name);
776
			proposal.setCompletion(name);
763
			proposal.setFlags(Flags.AccDefault);
777
			proposal.setFlags(Flags.AccDefault);
Lines 777-784 Link Here
777
	 * @param name the name of the binding
791
	 * @param name the name of the binding
778
	 * @param exactMatch <code>true</code> if an exact match is needed, <code>false</code> otherwise
792
	 * @param exactMatch <code>true</code> if an exact match is needed, <code>false</code> otherwise
779
	 * @param prefixRequired
793
	 * @param prefixRequired
780
	 * @param onlyConstructors <code>true</code> if only constructors should be accepted,
781
	 * <code>false</code> otherwise.  Only applies when matching on {@link Binding#METHOD}s.
782
	 */
794
	 */
783
	private void acceptBindings(char[] name,boolean exactMatch, boolean prefixRequired) {
795
	private void acceptBindings(char[] name,boolean exactMatch, boolean prefixRequired) {
784
		
796
		
Lines 866-875 Link Here
866
						proposal.setParameterTypeNames(parameterFullTypeNames);
878
						proposal.setParameterTypeNames(parameterFullTypeNames);
867
879
868
						if(method.returnType!=null) {
880
						if(method.returnType!=null) {
869
							proposal.setPackageName(method.returnType.qualifiedPackageName());
881
							proposal.setReturnQualification(method.returnType.qualifiedPackageName());
870
							proposal.setTypeName(method.returnType.qualifiedSourceName());
882
							proposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
871
						}else {
883
						}else {
872
							proposal.setTypeName(null);
884
							proposal.setReturnSimpleName(null);
873
						}
885
						}
874
886
875
887
Lines 900-907 Link Here
900
						proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
912
						proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
901
						proposal.setParameterPackageNames(parameterPackageNames);
913
						proposal.setParameterPackageNames(parameterPackageNames);
902
						proposal.setParameterTypeNames(parameterFullTypeNames);
914
						proposal.setParameterTypeNames(parameterFullTypeNames);
903
						proposal.setPackageName(method.returnType.qualifiedPackageName());
915
						proposal.setReturnQualification(method.returnType.qualifiedPackageName());
904
						proposal.setTypeName(method.returnType.qualifiedSourceName());
916
						proposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
905
						proposal.setName(bindingName);
917
						proposal.setName(bindingName);
906
						proposal.setCompletion(javadocCompletion);
918
						proposal.setCompletion(javadocCompletion);
907
						proposal.setFlags( modifiers);
919
						proposal.setFlags( modifiers);
Lines 991-998 Link Here
991
					}
1003
					}
992
					proposal.setSignature(getSignature(variableBinding.type));
1004
					proposal.setSignature(getSignature(variableBinding.type));
993
					proposal.setDeclarationTypeName(packageName);
1005
					proposal.setDeclarationTypeName(packageName);
994
					proposal.setPackageName(variableBinding.type.qualifiedPackageName());
1006
					proposal.setReturnQualification(variableBinding.type.qualifiedPackageName());
995
					proposal.setTypeName(variableBinding.type.qualifiedSourceName());
1007
					proposal.setReturnSimpleName(variableBinding.type.qualifiedSourceName());
996
					proposal.setName(variableBinding.name);
1008
					proposal.setName(variableBinding.name);
997
					proposal.setCompletion(completion);
1009
					proposal.setCompletion(completion);
998
					proposal.setFlags(variableBinding.modifiers);
1010
					proposal.setFlags(variableBinding.modifiers);
Lines 1010-1017 Link Here
1010
					CompletionProposal proposal = this.createProposal(CompletionProposal.JSDOC_FIELD_REF, this.actualCompletionPosition);
1022
					CompletionProposal proposal = this.createProposal(CompletionProposal.JSDOC_FIELD_REF, this.actualCompletionPosition);
1011
					proposal.setSignature(getSignature(variableBinding.type));
1023
					proposal.setSignature(getSignature(variableBinding.type));
1012
					proposal.setDeclarationPackageName(packageName);
1024
					proposal.setDeclarationPackageName(packageName);
1013
					proposal.setPackageName(variableBinding.type.qualifiedPackageName());
1025
					proposal.setReturnQualification(variableBinding.type.qualifiedPackageName());
1014
					proposal.setTypeName(variableBinding.type.qualifiedSourceName());
1026
					proposal.setReturnSimpleName(variableBinding.type.qualifiedSourceName());
1015
					proposal.setName(variableBinding.name);
1027
					proposal.setName(variableBinding.name);
1016
					proposal.setCompletion(javadocCompletion);
1028
					proposal.setCompletion(javadocCompletion);
1017
					proposal.setFlags(variableBinding.modifiers);
1029
					proposal.setFlags(variableBinding.modifiers);
Lines 1716-1726 Link Here
1716
			long completionPosition = access.nameSourcePosition;
1728
			long completionPosition = access.nameSourcePosition;
1717
			setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1729
			setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1718
1730
1719
1720
1721
//			this.assistNodeIsClass = true;
1722
//			this.assistNodeIsConstructor = true;
1723
1724
			// can be the start of a qualified type name
1731
			// can be the start of a qualified type name
1725
			if (qualifiedBinding == null) {
1732
			if (qualifiedBinding == null) {
1726
			
1733
			
Lines 1732-1744 Link Here
1732
			} else {
1739
			} else {
1733
				this.completionToken = access.token;
1740
				this.completionToken = access.token;
1734
				if (qualifiedBinding.problemId() == ProblemReasons.NotFound) {
1741
				if (qualifiedBinding.problemId() == ProblemReasons.NotFound) {
1735
					// complete method members with missing return type
1742
					/* complete method members with missing return type
1736
					// class X {
1743
					 * class X {
1737
					//   Missing f() {return null;}
1744
					 *   Missing f() {return null;}
1738
					//   void foo() {
1745
					 *   void foo() {
1739
					//     f().|
1746
					 *     f().|
1740
					//   }
1747
					 *   }
1741
					// }
1748
					 * }
1749
					 */
1742
					if (this.assistNodeInJavadoc == 0 &&
1750
					if (this.assistNodeInJavadoc == 0 &&
1743
							(this.requestor.isAllowingRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF) ||
1751
							(this.requestor.isAllowingRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF) ||
1744
									this.requestor.isAllowingRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF))) {
1752
									this.requestor.isAllowingRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF))) {
Lines 2572-2579 Link Here
2572
				proposal.setSignature(signature);
2580
				proposal.setSignature(signature);
2573
				//proposal.setDeclarationPackageName(null);
2581
				//proposal.setDeclarationPackageName(null);
2574
				//proposal.setDeclarationTypeName(null);
2582
				//proposal.setDeclarationTypeName(null);
2575
				proposal.setPackageName(CharOperation.concatWith(JAVA_LANG, '.'));
2583
				proposal.setReturnQualification(CharOperation.concatWith(JAVA_LANG, '.'));
2576
				proposal.setTypeName(CLASS);
2584
				proposal.setReturnSimpleName(CLASS);
2577
				proposal.setName(classField);
2585
				proposal.setName(classField);
2578
				proposal.setCompletion(classField);
2586
				proposal.setCompletion(classField);
2579
				proposal.setFlags(Flags.AccStatic | Flags.AccPublic);
2587
				proposal.setFlags(Flags.AccStatic | Flags.AccPublic);
Lines 3189-3196 Link Here
3189
				proposal.setSignature(getSignature(field.type));
3197
				proposal.setSignature(getSignature(field.type));
3190
				proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3198
				proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3191
				proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3199
				proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3192
				proposal.setPackageName(field.type.qualifiedPackageName());
3200
				proposal.setReturnQualification(field.type.qualifiedPackageName());
3193
				proposal.setTypeName(field.type.qualifiedSourceName());
3201
				proposal.setReturnSimpleName(field.type.qualifiedSourceName());
3194
				proposal.setName(field.name);
3202
				proposal.setName(field.name);
3195
				if (missingElements != null) {
3203
				if (missingElements != null) {
3196
					CompletionProposal[] subProposals = new CompletionProposal[missingElements.length];
3204
					CompletionProposal[] subProposals = new CompletionProposal[missingElements.length];
Lines 3222-3229 Link Here
3222
				proposal.setSignature(getSignature(field.type));
3230
				proposal.setSignature(getSignature(field.type));
3223
				proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3231
				proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3224
				proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3232
				proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3225
				proposal.setPackageName(field.type.qualifiedPackageName());
3233
				proposal.setReturnQualification(field.type.qualifiedPackageName());
3226
				proposal.setTypeName(field.type.qualifiedSourceName());
3234
				proposal.setReturnSimpleName(field.type.qualifiedSourceName());
3227
				proposal.setName(field.name);
3235
				proposal.setName(field.name);
3228
				proposal.setCompletion(javadocCompletion);
3236
				proposal.setCompletion(javadocCompletion);
3229
				proposal.setFlags(field.modifiers);
3237
				proposal.setFlags(field.modifiers);
Lines 3662-3669 Link Here
3662
					proposal.setSignature(getSignature(field.type));
3670
					proposal.setSignature(getSignature(field.type));
3663
					proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3671
					proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3664
					proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3672
					proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3665
					proposal.setPackageName(field.type.qualifiedPackageName());
3673
					proposal.setReturnQualification(field.type.qualifiedPackageName());
3666
					proposal.setTypeName(field.type.qualifiedSourceName());
3674
					proposal.setReturnSimpleName(field.type.qualifiedSourceName());
3667
					proposal.setName(field.name);
3675
					proposal.setName(field.name);
3668
					proposal.setCompletion(completion);
3676
					proposal.setCompletion(completion);
3669
					proposal.setFlags(field.modifiers);
3677
					proposal.setFlags(field.modifiers);
Lines 3678-3685 Link Here
3678
					char[] packageName = receiverType.qualifiedPackageName();
3686
					char[] packageName = receiverType.qualifiedPackageName();
3679
					typeImportProposal.setDeclarationSignature(packageName);
3687
					typeImportProposal.setDeclarationSignature(packageName);
3680
					typeImportProposal.setSignature(getSignature(receiverType));
3688
					typeImportProposal.setSignature(getSignature(receiverType));
3681
					typeImportProposal.setPackageName(packageName);
3689
					typeImportProposal.setReturnQualification(packageName);
3682
					typeImportProposal.setTypeName(receiverType.qualifiedSourceName());
3690
					typeImportProposal.setReturnSimpleName(receiverType.qualifiedSourceName());
3683
					typeImportProposal.setCompletion(typeImportCompletion);
3691
					typeImportProposal.setCompletion(typeImportCompletion);
3684
					typeImportProposal.setFlags(receiverType.modifiers);
3692
					typeImportProposal.setFlags(receiverType.modifiers);
3685
					typeImportProposal.setAdditionalFlags(CompletionFlags.Default);
3693
					typeImportProposal.setAdditionalFlags(CompletionFlags.Default);
Lines 3702-3709 Link Here
3702
					proposal.setSignature(getSignature(field.type));
3710
					proposal.setSignature(getSignature(field.type));
3703
					proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3711
					proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3704
					proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3712
					proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3705
					proposal.setPackageName(field.type.qualifiedPackageName());
3713
					proposal.setReturnQualification(field.type.qualifiedPackageName());
3706
					proposal.setTypeName(field.type.qualifiedSourceName());
3714
					proposal.setReturnSimpleName(field.type.qualifiedSourceName());
3707
					proposal.setName(field.name);
3715
					proposal.setName(field.name);
3708
					proposal.setCompletion(completion);
3716
					proposal.setCompletion(completion);
3709
					proposal.setFlags(field.modifiers);
3717
					proposal.setFlags(field.modifiers);
Lines 3717-3724 Link Here
3717
					fieldImportProposal.setSignature(getSignature(field.type));
3725
					fieldImportProposal.setSignature(getSignature(field.type));
3718
					fieldImportProposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3726
					fieldImportProposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3719
					fieldImportProposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3727
					fieldImportProposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3720
					fieldImportProposal.setPackageName(field.type.qualifiedPackageName());
3728
					fieldImportProposal.setReturnQualification(field.type.qualifiedPackageName());
3721
					fieldImportProposal.setTypeName(field.type.qualifiedSourceName());
3729
					fieldImportProposal.setReturnSimpleName(field.type.qualifiedSourceName());
3722
					fieldImportProposal.setName(field.name);
3730
					fieldImportProposal.setName(field.name);
3723
					fieldImportProposal.setCompletion(fieldImportCompletion);
3731
					fieldImportProposal.setCompletion(fieldImportCompletion);
3724
					fieldImportProposal.setFlags(field.modifiers);
3732
					fieldImportProposal.setFlags(field.modifiers);
Lines 4441-4448 Link Here
4441
				proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4449
				proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4442
				proposal.setParameterPackageNames(parameterPackageNames);
4450
				proposal.setParameterPackageNames(parameterPackageNames);
4443
				proposal.setParameterTypeNames(parameterTypeNames);
4451
				proposal.setParameterTypeNames(parameterTypeNames);
4444
				proposal.setPackageName(method.returnType.qualifiedPackageName());
4452
				proposal.setReturnQualification(method.returnType.qualifiedPackageName());
4445
				proposal.setTypeName(method.returnType.qualifiedSourceName());
4453
				proposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
4446
				proposal.setName(method.selector);
4454
				proposal.setName(method.selector);
4447
				proposal.setIsContructor(method.isConstructor());
4455
				proposal.setIsContructor(method.isConstructor());
4448
				
4456
				
Lines 4483-4490 Link Here
4483
				proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4491
				proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4484
				proposal.setParameterPackageNames(parameterPackageNames);
4492
				proposal.setParameterPackageNames(parameterPackageNames);
4485
				proposal.setParameterTypeNames(parameterTypeNames);
4493
				proposal.setParameterTypeNames(parameterTypeNames);
4486
				proposal.setPackageName(method.returnType.qualifiedPackageName());
4494
				proposal.setReturnQualification(method.returnType.qualifiedPackageName());
4487
				proposal.setTypeName(method.returnType.qualifiedSourceName());
4495
				proposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
4488
				proposal.setName(method.selector);
4496
				proposal.setName(method.selector);
4489
				proposal.setCompletion(javadocCompletion);
4497
				proposal.setCompletion(javadocCompletion);
4490
				proposal.setFlags(method.modifiers);
4498
				proposal.setFlags(method.modifiers);
Lines 4639-4646 Link Here
4639
							proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4647
							proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4640
							proposal.setParameterPackageNames(parameterPackageNames);
4648
							proposal.setParameterPackageNames(parameterPackageNames);
4641
							proposal.setParameterTypeNames(parameterTypeNames);
4649
							proposal.setParameterTypeNames(parameterTypeNames);
4642
							proposal.setPackageName(method.returnType.qualifiedPackageName());
4650
							proposal.setReturnQualification(method.returnType.qualifiedPackageName());
4643
							proposal.setTypeName(method.returnType.qualifiedSourceName());
4651
							proposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
4644
							proposal.setName(method.selector);
4652
							proposal.setName(method.selector);
4645
							proposal.setCompletion(completion);
4653
							proposal.setCompletion(completion);
4646
							proposal.setFlags(method.modifiers);
4654
							proposal.setFlags(method.modifiers);
Lines 4667-4674 Link Here
4667
						proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4675
						proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4668
						proposal.setParameterPackageNames(parameterPackageNames);
4676
						proposal.setParameterPackageNames(parameterPackageNames);
4669
						proposal.setParameterTypeNames(parameterTypeNames);
4677
						proposal.setParameterTypeNames(parameterTypeNames);
4670
						proposal.setPackageName(method.returnType.qualifiedPackageName());
4678
						proposal.setReturnQualification(method.returnType.qualifiedPackageName());
4671
						proposal.setTypeName(method.returnType.qualifiedSourceName());
4679
						proposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
4672
						proposal.setName(method.selector);
4680
						proposal.setName(method.selector);
4673
						proposal.setCompletion(completion);
4681
						proposal.setCompletion(completion);
4674
						proposal.setFlags(method.modifiers);
4682
						proposal.setFlags(method.modifiers);
Lines 4684-4691 Link Here
4684
						char[] packageName = receiverType.qualifiedPackageName();
4692
						char[] packageName = receiverType.qualifiedPackageName();
4685
						typeImportProposal.setDeclarationSignature(packageName);
4693
						typeImportProposal.setDeclarationSignature(packageName);
4686
						typeImportProposal.setSignature(getSignature(receiverType));
4694
						typeImportProposal.setSignature(getSignature(receiverType));
4687
						typeImportProposal.setPackageName(packageName);
4695
						typeImportProposal.setReturnQualification(packageName);
4688
						typeImportProposal.setTypeName(receiverType.qualifiedSourceName());
4696
						typeImportProposal.setReturnSimpleName(receiverType.qualifiedSourceName());
4689
						typeImportProposal.setCompletion(typeImportCompletion);
4697
						typeImportProposal.setCompletion(typeImportCompletion);
4690
						typeImportProposal.setFlags(receiverType.modifiers);
4698
						typeImportProposal.setFlags(receiverType.modifiers);
4691
						typeImportProposal.setAdditionalFlags(CompletionFlags.Default);
4699
						typeImportProposal.setAdditionalFlags(CompletionFlags.Default);
Lines 4712-4719 Link Here
4712
						proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4720
						proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4713
						proposal.setParameterPackageNames(parameterPackageNames);
4721
						proposal.setParameterPackageNames(parameterPackageNames);
4714
						proposal.setParameterTypeNames(parameterTypeNames);
4722
						proposal.setParameterTypeNames(parameterTypeNames);
4715
						proposal.setPackageName(method.returnType.qualifiedPackageName());
4723
						proposal.setReturnQualification(method.returnType.qualifiedPackageName());
4716
						proposal.setTypeName(method.returnType.qualifiedSourceName());
4724
						proposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
4717
						proposal.setName(method.selector);
4725
						proposal.setName(method.selector);
4718
						proposal.setCompletion(completion);
4726
						proposal.setCompletion(completion);
4719
						proposal.setFlags(method.modifiers);
4727
						proposal.setFlags(method.modifiers);
Lines 4733-4740 Link Here
4733
						methodImportProposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4741
						methodImportProposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4734
						methodImportProposal.setParameterPackageNames(parameterPackageNames);
4742
						methodImportProposal.setParameterPackageNames(parameterPackageNames);
4735
						methodImportProposal.setParameterTypeNames(parameterTypeNames);
4743
						methodImportProposal.setParameterTypeNames(parameterTypeNames);
4736
						methodImportProposal.setPackageName(method.returnType.qualifiedPackageName());
4744
						methodImportProposal.setReturnQualification(method.returnType.qualifiedPackageName());
4737
						methodImportProposal.setTypeName(method.returnType.qualifiedSourceName());
4745
						methodImportProposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
4738
						methodImportProposal.setName(method.selector);
4746
						methodImportProposal.setName(method.selector);
4739
						methodImportProposal.setCompletion(methodImportCompletion);
4747
						methodImportProposal.setCompletion(methodImportCompletion);
4740
						methodImportProposal.setFlags(method.modifiers);
4748
						methodImportProposal.setFlags(method.modifiers);
Lines 4769-4776 Link Here
4769
			proposal.completionEngine = this;
4777
			proposal.completionEngine = this;
4770
			proposal.setDeclarationSignature(packageName);
4778
			proposal.setDeclarationSignature(packageName);
4771
			proposal.setSignature(getSignature(typeBinding));
4779
			proposal.setSignature(getSignature(typeBinding));
4772
			proposal.setPackageName(packageName);
4780
			proposal.setReturnQualification(packageName);
4773
			proposal.setTypeName(typeName);
4781
			proposal.setReturnSimpleName(typeName);
4774
			proposal.setCompletion(fullyQualifiedName);
4782
			proposal.setCompletion(fullyQualifiedName);
4775
			proposal.setFlags(typeBinding.modifiers);
4783
			proposal.setFlags(typeBinding.modifiers);
4776
			proposal.setReplaceRange(start - this.offset, end - this.offset);
4784
			proposal.setReplaceRange(start - this.offset, end - this.offset);
Lines 4782-4788 Link Here
4782
4790
4783
			proposal = this.createProposal(CompletionProposal.PACKAGE_REF, this.actualCompletionPosition);
4791
			proposal = this.createProposal(CompletionProposal.PACKAGE_REF, this.actualCompletionPosition);
4784
			proposal.setDeclarationSignature(packageName);
4792
			proposal.setDeclarationSignature(packageName);
4785
			proposal.setPackageName(packageName);
4793
			proposal.setReturnQualification(packageName);
4786
			proposal.setCompletion(packageName);
4794
			proposal.setCompletion(packageName);
4787
			proposal.setReplaceRange(start - this.offset, end - this.offset);
4795
			proposal.setReplaceRange(start - this.offset, end - this.offset);
4788
			proposal.setRelevance(relevance);
4796
			proposal.setRelevance(relevance);
Lines 5057-5064 Link Here
5057
				proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
5065
				proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
5058
				proposal.setParameterPackageNames(parameterPackageNames);
5066
				proposal.setParameterPackageNames(parameterPackageNames);
5059
				proposal.setParameterTypeNames(parameterFullTypeNames);
5067
				proposal.setParameterTypeNames(parameterFullTypeNames);
5060
				proposal.setPackageName(method.returnType.qualifiedPackageName());
5068
				proposal.setReturnQualification(method.returnType.qualifiedPackageName());
5061
				proposal.setTypeName(method.returnType.qualifiedSourceName());
5069
				proposal.setReturnSimpleName(method.returnType.qualifiedSourceName());
5062
				proposal.setCompletion(completion.toString().toCharArray());
5070
				proposal.setCompletion(completion.toString().toCharArray());
5063
				proposal.setName(method.selector);
5071
				proposal.setName(method.selector);
5064
				proposal.setFlags(method.modifiers);
5072
				proposal.setFlags(method.modifiers);
Lines 5813-5822 Link Here
5813
									: getSignature(local.type));
5821
									: getSignature(local.type));
5814
								if(local.type == null) {
5822
								if(local.type == null) {
5815
									//proposal.setPackageName(null);
5823
									//proposal.setPackageName(null);
5816
									proposal.setTypeName(local.declaration.getTypeName().toCharArray());
5824
									proposal.setReturnSimpleName(local.declaration.getTypeName().toCharArray());
5817
								} else {
5825
								} else {
5818
									proposal.setPackageName(local.type.qualifiedPackageName());
5826
									proposal.setReturnQualification(local.type.qualifiedPackageName());
5819
									proposal.setTypeName(local.type.qualifiedSourceName());
5827
									proposal.setReturnSimpleName(local.type.qualifiedSourceName());
5820
								}
5828
								}
5821
								proposal.setName(local.name);
5829
								proposal.setName(local.name);
5822
								proposal.setCompletion(local.name);
5830
								proposal.setCompletion(local.name);
Lines 5879-5894 Link Here
5879
5887
5880
						}
5888
						}
5881
						break;
5889
						break;
5882
//					case Scope.CLASS_SCOPE :
5883
					case Scope.COMPILATION_UNIT_SCOPE :
5890
					case Scope.COMPILATION_UNIT_SCOPE :
5884
						CompilationUnitScope compilationUnitScope = (CompilationUnitScope) currentScope;
5891
						CompilationUnitScope compilationUnitScope = (CompilationUnitScope) currentScope;
5885
//						ClassScope classScope = (ClassScope) currentScope;
5886
						SourceTypeBinding enclosingType = compilationUnitScope.enclosingCompilationUnit();
5892
						SourceTypeBinding enclosingType = compilationUnitScope.enclosingCompilationUnit();
5887
						/*				if (tokenLength == 0) { // only search inside the type itself if no prefix was provided
5888
											findFields(token, enclosingType.fields(), classScope, fieldsFound, staticsOnly);
5889
											findMethods(token, enclosingType.methods(), classScope, methodsFound, staticsOnly, false);
5890
											break done;
5891
										} else { */
5892
						if(!insideTypeAnnotation) {
5893
						if(!insideTypeAnnotation) {
5893
							if(proposeField) {
5894
							if(proposeField) {
5894
								findFields(
5895
								findFields(
Lines 5931-5940 Link Here
5931
						}
5932
						}
5932
						staticsOnly |= enclosingType.isStatic();
5933
						staticsOnly |= enclosingType.isStatic();
5933
						insideTypeAnnotation = false;
5934
						insideTypeAnnotation = false;
5934
						//				}
5935
//						break;
5936
5937
//					case Scope.COMPILATION_UNIT_SCOPE :
5938
						break done2;
5935
						break done2;
5939
				}
5936
				}
5940
				currentScope = currentScope.parent;
5937
				currentScope = currentScope.parent;
Lines 5953-5966 Link Here
5953
			}
5950
			}
5954
			
5951
			
5955
			//propose methods from environment if token length is not 0
5952
			//propose methods from environment if token length is not 0
5956
			if (proposeMethod  && token.length > 0)
5953
			if (proposeMethod  && token.length > 0) {
5957
			{
5954
				this.nameEnvironment.findMethods(
5958
				this.nameEnvironment.findBindings(
5959
						token,
5955
						token,
5960
						Binding.METHOD,
5956
						null,
5961
						this.options.camelCaseMatch,
5962
						this);
5957
						this);
5963
				acceptBindings(token,false,false);
5964
			}
5958
			}
5965
			
5959
			
5966
			//propose fields from environment if token length is not 0
5960
			//propose fields from environment if token length is not 0
Lines 6000-6007 Link Here
6000
						if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
5994
						if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
6001
							CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition);
5995
							CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition);
6002
							proposal.setSignature(getSignature(type.resolvedType));
5996
							proposal.setSignature(getSignature(type.resolvedType));
6003
							proposal.setPackageName(type.resolvedType.qualifiedPackageName());
5997
							proposal.setReturnQualification(type.resolvedType.qualifiedPackageName());
6004
							proposal.setTypeName(type.resolvedType.qualifiedSourceName());
5998
							proposal.setReturnSimpleName(type.resolvedType.qualifiedSourceName());
6005
							proposal.setName(name);
5999
							proposal.setName(name);
6006
							proposal.setCompletion(name);
6000
							proposal.setCompletion(name);
6007
							//proposal.setFlags(Flags.AccDefault);
6001
							//proposal.setFlags(Flags.AccDefault);
Lines 6270-6277 Link Here
6270
					if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
6264
					if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
6271
						CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition);
6265
						CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition);
6272
						proposal.setSignature(getSignature(typeBinding));
6266
						proposal.setSignature(getSignature(typeBinding));
6273
						proposal.setPackageName(q);
6267
						proposal.setReturnQualification(q);
6274
						proposal.setTypeName(displayName);
6268
						proposal.setReturnSimpleName(displayName);
6275
						proposal.setName(name);
6269
						proposal.setName(name);
6276
						proposal.setCompletion(name);
6270
						proposal.setCompletion(name);
6277
						//proposal.setFlags(Flags.AccDefault);
6271
						//proposal.setFlags(Flags.AccDefault);
Lines 6899-6905 Link Here
6899
			proposal.setDeclarationTypeName(reference.qualifiedSourceName());
6893
			proposal.setDeclarationTypeName(reference.qualifiedSourceName());
6900
6894
6901
			//proposal.setPackageName(null);
6895
			//proposal.setPackageName(null);
6902
			proposal.setTypeName(VOID);
6896
			proposal.setReturnSimpleName(VOID);
6903
			proposal.setName(token);
6897
			proposal.setName(token);
6904
			//proposal.setParameterPackageNames(null);
6898
			//proposal.setParameterPackageNames(null);
6905
			//proposal.setParameterTypeNames(null);
6899
			//proposal.setParameterTypeNames(null);
Lines 7012-7019 Link Here
7012
			proposal.completionEngine = this;
7006
			proposal.completionEngine = this;
7013
			proposal.setDeclarationSignature(packageName);
7007
			proposal.setDeclarationSignature(packageName);
7014
			proposal.setSignature(createNonGenericTypeSignature(typeName));
7008
			proposal.setSignature(createNonGenericTypeSignature(typeName));
7015
			proposal.setPackageName(packageName);
7009
			proposal.setReturnQualification(packageName);
7016
			proposal.setTypeName(typeName);
7010
			proposal.setReturnSimpleName(typeName);
7017
			proposal.setCompletion(completionName);
7011
			proposal.setCompletion(completionName);
7018
			proposal.setFlags(modifiers);
7012
			proposal.setFlags(modifiers);
7019
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
7013
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
Lines 7033-7040 Link Here
7033
			proposal.completionEngine = this;
7027
			proposal.completionEngine = this;
7034
			proposal.setDeclarationSignature(packageName);
7028
			proposal.setDeclarationSignature(packageName);
7035
			proposal.setSignature(createNonGenericTypeSignature(typeName));
7029
			proposal.setSignature(createNonGenericTypeSignature(typeName));
7036
			proposal.setPackageName(packageName);
7030
			proposal.setReturnQualification(packageName);
7037
			proposal.setTypeName(typeName);
7031
			proposal.setReturnSimpleName(typeName);
7038
			proposal.setCompletion(javadocCompletion);
7032
			proposal.setCompletion(javadocCompletion);
7039
			proposal.setFlags(modifiers);
7033
			proposal.setFlags(modifiers);
7040
			int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
7034
			int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
Lines 7060-7067 Link Here
7060
			proposal.completionEngine = this;
7054
			proposal.completionEngine = this;
7061
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
7055
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
7062
			proposal.setSignature(getSignature(refBinding));
7056
			proposal.setSignature(getSignature(refBinding));
7063
			proposal.setPackageName(refBinding.qualifiedPackageName());
7057
			proposal.setReturnQualification(refBinding.qualifiedPackageName());
7064
			proposal.setTypeName(typeName);
7058
			proposal.setReturnSimpleName(typeName);
7065
			proposal.setCompletion(completionName);
7059
			proposal.setCompletion(completionName);
7066
			proposal.setFlags(refBinding.modifiers);
7060
			proposal.setFlags(refBinding.modifiers);
7067
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
7061
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
Lines 7080-7087 Link Here
7080
			proposal.completionEngine = this;
7074
			proposal.completionEngine = this;
7081
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
7075
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
7082
			proposal.setSignature(getSignature(refBinding));
7076
			proposal.setSignature(getSignature(refBinding));
7083
			proposal.setPackageName(refBinding.qualifiedPackageName());
7077
			proposal.setReturnQualification(refBinding.qualifiedPackageName());
7084
			proposal.setTypeName(typeName);
7078
			proposal.setReturnSimpleName(typeName);
7085
			proposal.setCompletion(javadocCompletion);
7079
			proposal.setCompletion(javadocCompletion);
7086
			proposal.setFlags(refBinding.modifiers);
7080
			proposal.setFlags(refBinding.modifiers);
7087
			int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
7081
			int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
Lines 7406-7413 Link Here
7406
								CompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
7400
								CompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
7407
								proposal.setDeclarationSignature(packageName);
7401
								proposal.setDeclarationSignature(packageName);
7408
								proposal.setSignature(getSignature(refBinding));
7402
								proposal.setSignature(getSignature(refBinding));
7409
								proposal.setPackageName(packageName);
7403
								proposal.setReturnQualification(packageName);
7410
								proposal.setTypeName(typeName);
7404
								proposal.setReturnSimpleName(typeName);
7411
								proposal.setCompletion(completionName);
7405
								proposal.setCompletion(completionName);
7412
								proposal.setFlags(refBinding.modifiers);
7406
								proposal.setFlags(refBinding.modifiers);
7413
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
7407
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
Lines 7510-7515 Link Here
7510
		return typeName;
7504
		return typeName;
7511
	}
7505
	}
7512
	
7506
	
7507
	private void proposeMethod(char[] signature,
7508
			int parameterCount,
7509
			char[][] parameterQualifications,
7510
			char[][] parameterSimpleNames,
7511
			char[][] parameterNames,
7512
			char[] returnQualification,
7513
			char[] returnSimpleName,
7514
			char[] declaringQualification,
7515
			char[] declaringSimpleName,
7516
			int modifiers,
7517
			String path) {
7518
		
7519
		//compute completion
7520
		char[] completion;
7521
		if (this.source != null
7522
				&& this.source.length > this.endPosition
7523
				&& this.source[this.endPosition] == '(') {
7524
			
7525
			completion = signature;
7526
		} else {
7527
			completion = CharOperation.concat(signature, new char[] { '(', ')' });
7528
		}
7529
		
7530
		//compute relevance
7531
		int relevance = computeBaseRelevance();
7532
		relevance += computeRelevanceForInterestingProposal();
7533
		if (this.completionToken != null) relevance += computeRelevanceForCaseMatching(this.completionToken, signature);
7534
		relevance += computeRelevanceForExpectingType(returnQualification, returnSimpleName);
7535
		relevance += computeRelevanceForQualification(false);
7536
		relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
7537
		
7538
		this.noProposal = false;
7539
		// Standard proposal
7540
		if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
7541
			CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
7542
			proposal.setDeclarationSignature(QualificationHelpers.createFullyQualifiedName(declaringQualification, declaringSimpleName));
7543
			proposal.setDeclarationPackageName(declaringQualification);
7544
			proposal.setDeclarationTypeName(declaringSimpleName);
7545
			proposal.setParameterPackageNames(parameterQualifications);
7546
			proposal.setParameterTypeNames(parameterSimpleNames);
7547
			proposal.setReturnQualification(returnQualification);
7548
			proposal.setReturnSimpleName(returnSimpleName);
7549
			proposal.setName(signature);
7550
			proposal.setCompletion(completion);
7551
			proposal.setFlags(modifiers);
7552
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
7553
			proposal.setRelevance(relevance);
7554
			if(parameterNames != null) proposal.setParameterNames(parameterNames);
7555
			proposal.setIsContructor(false);
7556
			this.requestor.accept(proposal);
7557
			if(DEBUG) {
7558
				this.printDebug(proposal);
7559
			}
7560
		}
7561
	}
7562
	
7513
	/**
7563
	/**
7514
	 * <p>Represents a constructor accepted from the index.</p>
7564
	 * <p>Represents a constructor accepted from the index.</p>
7515
	 */
7565
	 */
(-)src/org/eclipse/wst/jsdt/internal/codeassist/ISearchRequestor.java (+28 lines)
Lines 64-67 Link Here
64
			char[][] parameterNames,
64
			char[][] parameterNames,
65
			String path,
65
			String path,
66
			AccessRestriction access);
66
			AccessRestriction access);
67
	
68
	/**
69
	 * 
70
	 * TODO: IAN: doc me!
71
	 * 
72
	 * @param signature
73
	 * @param parameterCount
74
	 * @param parameterQualifications
75
	 * @param parameterSimpleNames
76
	 * @param parameterNames
77
	 * @param returnQualification
78
	 * @param returnSimpleName
79
	 * @param declaringQualification
80
	 * @param declaringSimpleName
81
	 * @param modifiers
82
	 * @param path
83
	 */
84
	public void acceptMethod(char[] signature,
85
			int parameterCount,
86
			char[][] parameterQualifications,
87
			char[][] parameterSimpleNames,
88
			char[][] parameterNames,
89
			char[] returnQualification,
90
			char[] returnSimpleName,
91
			char[] declaringQualification,
92
			char[] declaringSimpleName,
93
			int modifiers,
94
			String path);
67
}
95
}
(-)src/org/eclipse/wst/jsdt/internal/codeassist/InternalCompletionProposal.java (-10 / +10 lines)
Lines 41-48 Link Here
41
41
42
	protected char[] declarationPackageName;
42
	protected char[] declarationPackageName;
43
	protected char[] declarationTypeName;
43
	protected char[] declarationTypeName;
44
	protected char[] packageName;
44
	protected char[] returnQualification;
45
	protected char[] typeName;
45
	protected char[] returnSimpleName;
46
	protected char[][] parameterPackageNames;
46
	protected char[][] parameterPackageNames;
47
	protected char[][] parameterTypeNames;
47
	protected char[][] parameterTypeNames;
48
48
Lines 143-154 Link Here
143
		return this.declarationTypeName;
143
		return this.declarationTypeName;
144
	}
144
	}
145
145
146
	protected char[] getPackageName() {
146
	protected char[] getReturnQualification() {
147
		return this.packageName;
147
		return this.returnQualification;
148
	}
148
	}
149
149
150
	protected char[] getTypeName() {
150
	protected char[] getReturnSimpleName() {
151
		return this.typeName;
151
		return this.returnSimpleName;
152
	}
152
	}
153
153
154
	protected char[][] getParameterPackageNames() {
154
	protected char[][] getParameterPackageNames() {
Lines 168-179 Link Here
168
		this.declarationTypeName = declarationTypeName;
168
		this.declarationTypeName = declarationTypeName;
169
	}
169
	}
170
170
171
	protected void setPackageName(char[] packageName) {
171
	protected void setReturnQualification(char[] packageName) {
172
		this.packageName = packageName;
172
		this.returnQualification = packageName;
173
	}
173
	}
174
174
175
	protected void setTypeName(char[] typeName) {
175
	protected void setReturnSimpleName(char[] typeName) {
176
		this.typeName = typeName;
176
		this.returnSimpleName = typeName;
177
	}
177
	}
178
178
179
	protected void setParameterPackageNames(char[][] parameterPackageNames) {
179
	protected void setParameterPackageNames(char[][] parameterPackageNames) {
(-)src/org/eclipse/wst/jsdt/internal/codeassist/MissingTypesGuesser.java (-1 / +13 lines)
Lines 333-339 Link Here
333
				
333
				
334
				//do nothing
334
				//do nothing
335
			}
335
			}
336
336
			
337
			/**
338
			 * @see org.eclipse.wst.jsdt.internal.codeassist.ISearchRequestor#acceptMethod(char[], int, char[][], char[][], char[][], char[], char[], char[], char[], int, java.lang.String)
339
			 */
340
			public void acceptMethod(char[] signature, int parameterCount,
341
					char[][] parameterQualifications,
342
					char[][] parameterSimpleNames, char[][] parameterNames,
343
					char[] returnQualification, char[] returnSimpleName,
344
					char[] declaringQualification, char[] declaringSimpleName,
345
					int modifiers, String path) {
346
				
347
				//do nothing
348
			}
337
		};
349
		};
338
		nameEnvironment.findExactTypes(missingSimpleName, true, IJavaScriptSearchConstants.TYPE, storage);
350
		nameEnvironment.findExactTypes(missingSimpleName, true, IJavaScriptSearchConstants.TYPE, storage);
339
		if(results.size() == 0) return null;
351
		if(results.size() == 0) return null;
(-)src/org/eclipse/wst/jsdt/internal/codeassist/SelectionEngine.java (-8 / +14 lines)
Lines 303-308 Link Here
303
		
303
		
304
		// do nothing
304
		// do nothing
305
	}
305
	}
306
	
307
	/**
308
	 * @see org.eclipse.wst.jsdt.internal.codeassist.ISearchRequestor#acceptMethod(char[], int, char[][], char[][], char[][], char[], char[], char[], char[], int, java.lang.String)
309
	 */
310
	public void acceptMethod(char[] signature, int parameterCount,
311
			char[][] parameterQualifications,
312
			char[][] parameterSimpleNames, char[][] parameterNames,
313
			char[] returnQualification, char[] returnSimpleName,
314
			char[] declaringQualification, char[] declaringSimpleName,
315
			int modifiers, String path) {
316
		
317
		//do nothing
318
	}
306
319
307
	private void acceptQualifiedTypes() {
320
	private void acceptQualifiedTypes() {
308
		if(this.acceptedClasses != null){
321
		if(this.acceptedClasses != null){
Lines 1287-1301 Link Here
1287
			localParser.inferTypes(parsedUnit,this.compilerOptions);
1300
			localParser.inferTypes(parsedUnit,this.compilerOptions);
1288
			return parsedUnit;
1301
			return parsedUnit;
1289
		} catch (AbortCompilationUnit e) {
1302
		} catch (AbortCompilationUnit e) {
1290
//			// at this point, currentCompilationUnitResult may not be sourceUnit, but some other
1303
			throw e; // want to abort enclosing request to compile
1291
//			// one requested further along to resolve sourceUnit.
1292
//			if (unitResult.compilationUnit == sourceUnit) { // only report once
1293
//				requestor.acceptResult(unitResult.tagAsAccepted());
1294
//			} else {
1295
				throw e; // want to abort enclosing request to compile
1296
//			}
1297
		}
1304
		}
1298
1305
1299
	}
1306
	}
1300
1301
}
1307
}
(-)src/org/eclipse/wst/jsdt/internal/compiler/ISourceElementRequestor.java (+1 lines)
Lines 60-65 Link Here
60
		public int nameSourceEnd;
60
		public int nameSourceEnd;
61
		public char[][] parameterTypes;
61
		public char[][] parameterTypes;
62
		public char[][] parameterNames;
62
		public char[][] parameterNames;
63
		public char[] declaringType;
63
		public char[][] categories;
64
		public char[][] categories;
64
	}
65
	}
65
66
(-)src/org/eclipse/wst/jsdt/internal/compiler/SourceElementParser.java (-1 / +22 lines)
Lines 193-199 Link Here
193
				
193
				
194
				char[] selector = Util.getTypeName(leftHandSide);
194
				char[] selector = Util.getTypeName(leftHandSide);
195
				MethodDeclaration methodDecl = ((IFunctionExpression) righHandSide).getMethodDeclaration();
195
				MethodDeclaration methodDecl = ((IFunctionExpression) righHandSide).getMethodDeclaration();
196
				if(selector != null && methodDecl.isConstructor()) {
196
				if(selector != null /*&& methodDecl.isConstructor() */) {
197
					notifySourceElementRequestor(methodDecl,
197
					notifySourceElementRequestor(methodDecl,
198
							selector);
198
							selector);
199
				}
199
				}
Lines 798-803 Link Here
798
		methodInfo.parameterTypes = argumentTypes;
798
		methodInfo.parameterTypes = argumentTypes;
799
		methodInfo.parameterNames = argumentNames;
799
		methodInfo.parameterNames = argumentNames;
800
		methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
800
		methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
801
		InferredMethod inferredMeth = methodDeclaration.getInferredMethod();
802
		if(inferredMeth != null) {
803
			InferredType declaringType = inferredMeth.inType;
804
			if(declaringType != null) {
805
				methodInfo.declaringType = declaringType.getName();
806
			}
807
		}
801
		
808
		
802
		//enter either constructor or method where appropriate
809
		//enter either constructor or method where appropriate
803
		if(methodInfo.isConstructor) {
810
		if(methodInfo.isConstructor) {
Lines 916-921 Link Here
916
			methodInfo.parameterTypes = argumentTypes;
923
			methodInfo.parameterTypes = argumentTypes;
917
			methodInfo.parameterNames = argumentNames;
924
			methodInfo.parameterNames = argumentNames;
918
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
925
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
926
			InferredMethod inferredMeth = methodDeclaration.getInferredMethod();
927
			if(inferredMeth != null) {
928
				InferredType declaringType = inferredMeth.inType;
929
				if(declaringType != null) {
930
					methodInfo.declaringType = declaringType.getName();
931
				}
932
			}
919
			requestor.enterConstructor(methodInfo);
933
			requestor.enterConstructor(methodInfo);
920
		}
934
		}
921
		/* need this check because a constructor could have been made a constructor after the
935
		/* need this check because a constructor could have been made a constructor after the
Lines 970-975 Link Here
970
		methodInfo.parameterTypes = argumentTypes;
984
		methodInfo.parameterTypes = argumentTypes;
971
		methodInfo.parameterNames = argumentNames;
985
		methodInfo.parameterNames = argumentNames;
972
		methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
986
		methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
987
		InferredMethod inferredMeth = methodDeclaration.getInferredMethod();
988
		if(inferredMeth != null) {
989
			InferredType declaringType = inferredMeth.inType;
990
			if(declaringType != null) {
991
				methodInfo.declaringType = declaringType.getName();
992
			}
993
		}
973
		requestor.enterMethod(methodInfo);
994
		requestor.enterMethod(methodInfo);
974
	}
995
	}
975
996
(-)src/org/eclipse/wst/jsdt/internal/compiler/lookup/CompilationUnitScope.java (-21 / +2 lines)
Lines 632-656 Link Here
632
}
632
}
633
633
634
void connectTypeHierarchy(char[][] typeNames) {
634
void connectTypeHierarchy(char[][] typeNames) {
635
		// if(superType!=null) {
636
		// if(superType instanceof SourceTypeBinding) {
637
		// ((SourceTypeBinding)superType).classScope.buildFieldsAndMethods();
638
		// ((SourceTypeBinding)superType).classScope.connectTypeHierarchy();
639
		//
640
		// }
641
		// ReferenceBinding[] memberTypes = superType.memberTypes();
642
		// ReferenceBinding[] memberFields = superType.typeVariables();
643
		// FunctionBinding[] memberMethods = superType.availableMethods();
644
		// for(int i=0;i<memberTypes.length;i++) {
645
		// recordReference(memberTypes[i], memberTypes[i].sourceName);
646
		// }
647
		// }
648
649
		// if(superTypeName!=null) {
650
		// ReferenceBinding binding = environment.askForType(new char[][]
651
		// {superTypeName});
652
		// this.recordSuperTypeReference(binding);
653
		// }
654
		if (classScope != null)
635
		if (classScope != null)
655
			classScope.connectTypeHierarchy();
636
			classScope.connectTypeHierarchy();
656
		nextType: for (int i = 0; i < referenceContext.numberInferredTypes; i++) {
637
		nextType: for (int i = 0; i < referenceContext.numberInferredTypes; i++) {
Lines 667-675 Link Here
667
					continue nextType;
648
					continue nextType;
668
			
649
			
669
		}
650
		}
670
			if (inferredType.binding != null)
651
			if (inferredType.binding != null && inferredType.binding.classScope != null) {
671
				inferredType.binding.classScope.connectTypeHierarchy();
652
				inferredType.binding.classScope.connectTypeHierarchy();
672
653
			}
673
		}
654
		}
674
}
655
}
675
void connectTypeHierarchy() {
656
void connectTypeHierarchy() {
(-)src/org/eclipse/wst/jsdt/internal/core/SearchableEnvironment.java (-86 / +110 lines)
Lines 37-42 Link Here
37
import org.eclipse.wst.jsdt.internal.compiler.impl.ITypeRequestor;
37
import org.eclipse.wst.jsdt.internal.compiler.impl.ITypeRequestor;
38
import org.eclipse.wst.jsdt.internal.core.search.BasicSearchEngine;
38
import org.eclipse.wst.jsdt.internal.core.search.BasicSearchEngine;
39
import org.eclipse.wst.jsdt.internal.core.search.IConstructorRequestor;
39
import org.eclipse.wst.jsdt.internal.core.search.IConstructorRequestor;
40
import org.eclipse.wst.jsdt.internal.core.search.IMethodRequestor;
40
import org.eclipse.wst.jsdt.internal.core.search.IRestrictedAccessBindingRequestor;
41
import org.eclipse.wst.jsdt.internal.core.search.IRestrictedAccessBindingRequestor;
41
import org.eclipse.wst.jsdt.internal.core.search.IRestrictedAccessTypeRequestor;
42
import org.eclipse.wst.jsdt.internal.core.search.IRestrictedAccessTypeRequestor;
42
43
Lines 168-183 Link Here
168
					for (int i = 0, index = 1; i < length; i++) {
169
					for (int i = 0, index = 1; i < length; i++) {
169
						ISourceType otherType = (ISourceType) ((JavaElement) types[i])
170
						ISourceType otherType = (ISourceType) ((JavaElement) types[i])
170
								.getElementInfo();
171
								.getElementInfo();
171
						if (!otherType.equals(topLevelType) && index < length) // check
172
						//check that the index is in bounds (see Bug 62861)
172
																				// that
173
						if (!otherType.equals(topLevelType) && index < length) {
173
																				// the
174
																				// index
175
																				// is
176
																				// in
177
																				// bounds
178
																				// (see
179
																				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=62861)
180
							sourceTypes[index++] = otherType;
174
							sourceTypes[index++] = otherType;
175
						}
181
					}
176
					}
182
					return new NameEnvironmentAnswer(sourceTypes,
177
					return new NameEnvironmentAnswer(sourceTypes,
183
							answer.restriction);
178
							answer.restriction);
Lines 231-238 Link Here
231
				System.arraycopy(elements, 0, units, 0, elements.length);
226
				System.arraycopy(elements, 0, units, 0, elements.length);
232
				return new NameEnvironmentAnswer(units,answer.restriction);
227
				return new NameEnvironmentAnswer(units,answer.restriction);
233
			}
228
			}
234
				// return new NameEnvironmentAnswer((IBinaryType) ((BinaryType)
235
				// answer.type).getElementInfo(), answer.restriction);
236
		}
229
		}
237
		return null;
230
		return null;
238
	}
231
	}
Lines 586-626 Link Here
586
				}
579
				}
587
			}
580
			}
588
581
589
			IProgressMonitor progressMonitor = new IProgressMonitor() {
582
			IProgressMonitor progressMonitor = new CancelableProgressMonitor();
590
				boolean isCanceled = false;
583
			
591
592
				public void beginTask(String name, int totalWork) {
593
					// implements interface method
594
				}
595
596
				public void done() {
597
					// implements interface method
598
				}
599
600
				public void internalWorked(double work) {
601
					// implements interface method
602
				}
603
604
				public boolean isCanceled() {
605
					return isCanceled;
606
				}
607
608
				public void setCanceled(boolean value) {
609
					isCanceled = value;
610
				}
611
612
				public void setTaskName(String name) {
613
					// implements interface method
614
				}
615
616
				public void subTask(String name) {
617
					// implements interface method
618
				}
619
620
				public void worked(int work) {
621
					// implements interface method
622
				}
623
			};
624
			IRestrictedAccessBindingRequestor bindingRequestor = new IRestrictedAccessBindingRequestor() {
584
			IRestrictedAccessBindingRequestor bindingRequestor = new IRestrictedAccessBindingRequestor() {
625
				String exclude;
585
				String exclude;
626
				public boolean acceptBinding(int type,int modifiers, char[] packageName,
586
				public boolean acceptBinding(int type,int modifiers, char[] packageName,
Lines 674-679 Link Here
674
			findTypes(new String(prefix), storage, NameLookup.ACCEPT_ALL);
634
			findTypes(new String(prefix), storage, NameLookup.ACCEPT_ALL);
675
		}
635
		}
676
	}
636
	}
637
	
638
	/**
639
	 * 
640
	 * TODO: IAN: doc me!
641
	 * 
642
	 * @param selectorPrefix
643
	 * @param declaringTypeName
644
	 * @param storage
645
	 */
646
	public void findMethods(char[] selectorPrefix, String declaringTypeName, final ISearchRequestor storage) {
647
		
648
		//calculate the exclude path
649
		final String excludePath;
650
		if (this.unitToSkip != null && this.unitToSkip instanceof IJavaScriptElement) {
651
			excludePath = ((IJavaScriptElement)this.unitToSkip).getPath().toString();
652
		} else {
653
			excludePath = null;
654
		}
655
		
656
		//create the requester
657
		IMethodRequestor requestor = new IMethodRequestor() {
658
			public void acceptMethod(char[] signature,
659
					int parameterCount,
660
					char[][] parameterQualifications, char[][] parameterSimpleNames,
661
					char[][] parameterNames,
662
					char[] returnQualification, char[] returnSimpleName,
663
					char[] declaringQualification, char[] declaringSimpleName,
664
					int modifiers,
665
					String path) {
666
				
667
				if (excludePath == null || !excludePath.equals(path)) {
668
					storage.acceptMethod(signature, parameterCount, parameterQualifications, parameterSimpleNames, parameterNames,
669
							returnQualification, returnSimpleName, declaringQualification, declaringSimpleName, modifiers, path);
670
				}
671
			}
672
		};
673
		
674
		/* if selector specified then search for any selector with the given selector as a prefix
675
		 * else search for any selector
676
		 */
677
		char[] selectorPattern;
678
		int selectorPatternMatchRule;
679
		if(selectorPrefix != null) {
680
			selectorPattern = selectorPrefix;
681
			selectorPatternMatchRule = SearchPattern.R_PREFIX_MATCH;
682
		} else {
683
			selectorPattern = new char[] {'*'};
684
			selectorPatternMatchRule = SearchPattern.R_PATTERN_MATCH;
685
		}
686
		
687
		/* if a declaring type name is specified then make it the pattern for matching
688
		 * else find methods not on a type
689
		 */
690
		String declaringType;
691
		if(declaringTypeName != null) {
692
			declaringType = declaringTypeName;
693
		} else {
694
			declaringType = null;
695
		}
696
		
697
		//do the search
698
		new BasicSearchEngine(this.workingCopies).searchAllMethods(
699
				requestor,
700
				selectorPattern,
701
				declaringType,
702
				selectorPatternMatchRule,
703
				this.searchScope,
704
				WAIT_UNTIL_READY_TO_SEARCH,
705
				new CancelableProgressMonitor());
706
	}
677
707
678
	/**
708
	/**
679
	 * <p>The progress monitor is used to be able to cancel completion operations</p>
709
	 * <p>The progress monitor is used to be able to cancel completion operations</p>
Lines 697-729 Link Here
697
			excludePath = null;
727
			excludePath = null;
698
		}
728
		}
699
729
700
		IProgressMonitor progressMonitor = new IProgressMonitor() {
730
		IProgressMonitor progressMonitor = new CancelableProgressMonitor();
701
			boolean isCanceled = false;
702
			public void beginTask(String name, int totalWork) {
703
				// implements interface method
704
			}
705
			public void done() {
706
				// implements interface method
707
			}
708
			public void internalWorked(double work) {
709
				// implements interface method
710
			}
711
			public boolean isCanceled() {
712
				return this.isCanceled;
713
			}
714
			public void setCanceled(boolean value) {
715
				this.isCanceled = value;
716
			}
717
			public void setTaskName(String name) {
718
				// implements interface method
719
			}
720
			public void subTask(String name) {
721
				// implements interface method
722
			}
723
			public void worked(int work) {
724
				// implements interface method
725
			}
726
		};
727
		
731
		
728
		IConstructorRequestor constructorRequestor = new IConstructorRequestor() {
732
		IConstructorRequestor constructorRequestor = new IConstructorRequestor() {
729
			/**
733
			/**
Lines 817-835 Link Here
817
			this.nameLookup.seekBindings(prefix, bindingType,null, true, type, requestor);
821
			this.nameLookup.seekBindings(prefix, bindingType,null, true, type, requestor);
818
		} else {
822
		} else {
819
			throw new UnimplementedException("shouldnt get here"); //$NON-NLS-1$
823
			throw new UnimplementedException("shouldnt get here"); //$NON-NLS-1$
820
//			String packageName = prefix.substring(0, index);
821
//			JavaElementRequestor elementRequestor = new JavaElementRequestor();
822
//			this.nameLookup.seekPackageFragments(packageName, false,
823
//					elementRequestor);
824
//			IPackageFragment[] fragments = elementRequestor
825
//					.getPackageFragments();
826
//			if (fragments != null) {
827
//				String className = prefix.substring(index + 1);
828
//				for (int i = 0, length = fragments.length; i < length; i++)
829
//					if (fragments[i] != null)
830
//						this.nameLookup.seekTypes(className, fragments[i],
831
//								true, type, requestor);
832
//			}
833
		}
824
		}
834
	}
825
	}
835
	/**
826
	/**
Lines 877-880 Link Here
877
	{
868
	{
878
		nameLookup.setScriptFile(file);
869
		nameLookup.setScriptFile(file);
879
	}
870
	}
871
	
872
	/**
873
	 * 
874
	 * TODO: IAN: doc me!
875
	 *
876
	 */
877
	private static class CancelableProgressMonitor implements IProgressMonitor {
878
		boolean isCanceled = false;
879
		public void beginTask(String name, int totalWork) {
880
			// implements interface method
881
		}
882
		public void done() {
883
			// implements interface method
884
		}
885
		public void internalWorked(double work) {
886
			// implements interface method
887
		}
888
		public boolean isCanceled() {
889
			return this.isCanceled;
890
		}
891
		public void setCanceled(boolean value) {
892
			this.isCanceled = value;
893
		}
894
		public void setTaskName(String name) {
895
			// implements interface method
896
		}
897
		public void subTask(String name) {
898
			// implements interface method
899
		}
900
		public void worked(int work) {
901
			// implements interface method
902
		}
903
	}
880
}
904
}
(-)src/org/eclipse/wst/jsdt/internal/core/index/DiskIndex.java (-1 / +1 lines)
Lines 52-58 Link Here
52
private int bufferIndex, bufferEnd; // used when reading from the file into the streamBuffer
52
private int bufferIndex, bufferEnd; // used when reading from the file into the streamBuffer
53
private int streamEnd; // used when writing data from the streamBuffer to the file
53
private int streamEnd; // used when writing data from the streamBuffer to the file
54
54
55
public static final String SIGNATURE= "INDEX VERSION 1.122"; //$NON-NLS-1$
55
public static final String SIGNATURE= "INDEX VERSION 1.123"; //$NON-NLS-1$
56
private static final char[] SIGNATURE_CHARS = SIGNATURE.toCharArray();
56
private static final char[] SIGNATURE_CHARS = SIGNATURE.toCharArray();
57
public static boolean DEBUG = false;
57
public static boolean DEBUG = false;
58
58
(-)src/org/eclipse/wst/jsdt/internal/core/search/BasicSearchEngine.java (-32 / +68 lines)
Lines 566-572 Link Here
566
							true,false,true,
566
							true,false,true,
567
							bindingName,
567
							bindingName,
568
							null,null,null,null,
568
							null,null,null,null,
569
							null,null,null,
569
							null,null,
570
							matchRule);
570
							matchRule);
571
571
572
				}
572
				}
Lines 578-585 Link Here
578
						searchPattern = new MethodPattern(
578
						searchPattern = new MethodPattern(
579
								true,false,true,
579
								true,false,true,
580
								bindingName,
580
								bindingName,
581
								null,null,null,null,
582
								null,null,null,
583
								matchRule);
581
								matchRule);
584
582
585
					}
583
					}
Lines 612-633 Link Here
612
610
613
			// Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor
611
			// Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor
614
			final HashSet workingCopyPaths = new HashSet();
612
			final HashSet workingCopyPaths = new HashSet();
615
			String workingCopyPath = null;
616
			IJavaScriptUnit[] copies = getWorkingCopies();
613
			IJavaScriptUnit[] copies = getWorkingCopies();
617
			final int copiesLength = copies == null ? 0 : copies.length;
614
			final int copiesLength = copies == null ? 0 : copies.length;
618
			if (copies != null) {
615
			if (copies != null) {
619
				if (copiesLength == 1) {
616
				for (int i = 0; i < copiesLength; i++) {
620
					workingCopyPath = copies[0].getPath().toString();
617
					IJavaScriptUnit workingCopy = copies[i];
621
				} else {
618
					workingCopyPaths.add(workingCopy.getPath().toString());
622
					for (int i = 0; i < copiesLength; i++) {
623
						IJavaScriptUnit workingCopy = copies[i];
624
						workingCopyPaths.add(workingCopy.getPath().toString());
625
					}
626
				}
619
				}
627
			}
620
			}
628
			final String singleWkcpPath = workingCopyPath;
629
621
630
			// Index requestor
622
			// Index requester
631
			IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
623
			IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
632
				public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
624
				public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
633
					// Filter unexpected types
625
					// Filter unexpected types
Lines 799-822 Link Here
799
										}
791
										}
800
										return true;
792
										return true;
801
									}
793
									}
802
//									public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope classScope) {
803
//										if (match(typeSuffix, packageName, bindingName, matchRule, TypeDeclaration.kind(memberTypeDeclaration.modifiers), packageDeclaration, memberTypeDeclaration.name)) {
804
//											// compute encloising type names
805
//											TypeDeclaration enclosing = memberTypeDeclaration.enclosingType;
806
//											char[][] enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
807
//											while (enclosing != null) {
808
//												enclosingTypeNames = CharOperation.arrayConcat(new char[][] {enclosing.name}, enclosingTypeNames);
809
//												if ((enclosing.bits & ASTNode.IsMemberType) != 0) {
810
//													enclosing = enclosing.enclosingType;
811
//												} else {
812
//													enclosing = null;
813
//												}
814
//											}
815
//											// report
816
//											nameRequestor.acceptType(memberTypeDeclaration.modifiers, packageDeclaration, memberTypeDeclaration.name, enclosingTypeNames, path, null);
817
//										}
818
//										return true;
819
//									}
820
									public boolean visit(InferredType inferredType, BlockScope scope) {
794
									public boolean visit(InferredType inferredType, BlockScope scope) {
821
										if (bindingType==Binding.TYPE &&
795
										if (bindingType==Binding.TYPE &&
822
													match(typeSuffix, packageName, bindingName, matchRule, TypeDeclaration.kind(0), packageDeclaration, inferredType.getName())) {
796
													match(typeSuffix, packageName, bindingName, matchRule, TypeDeclaration.kind(0), packageDeclaration, inferredType.getName())) {
Lines 1610-1616 Link Here
1610
						record.modifiers,
1584
						record.modifiers,
1611
						record.declaringSimpleName,
1585
						record.declaringSimpleName,
1612
						record.parameterCount,
1586
						record.parameterCount,
1613
						record.parameterTypes,
1587
						record.parameterTypeNames,
1614
						record.parameterNames,
1588
						record.parameterNames,
1615
						documentPath,
1589
						documentPath,
1616
						accessRestriction);
1590
						accessRestriction);
Lines 1637-1640 Link Here
1637
			}
1611
			}
1638
		}
1612
		}
1639
	}
1613
	}
1614
	
1615
	/**
1616
	 * 
1617
	 * TODO: IAN: doc me!
1618
	 * 
1619
	 * @param selectorPattern
1620
	 * @param declaringType
1621
	 * @param selectorPatternMatchRule
1622
	 * @param declaringTypepatternMatchRule
1623
	 */
1624
	public void searchAllMethods(final IMethodRequestor methodRequestor,
1625
			char[] selectorPattern, String declaringType, int selectorPatternMatchRule,
1626
			IJavaScriptSearchScope scope,
1627
			int waitingPolicy, IProgressMonitor progressMonitor) {
1628
		
1629
		char[] declaringTypePatternChars = null;
1630
		if(declaringType != null && declaringType.trim().length() > 0) {
1631
			declaringTypePatternChars = declaringType.toCharArray();
1632
		}
1633
		
1634
		MethodPattern pattern = new MethodPattern(true, false,
1635
				selectorPattern, declaringTypePatternChars, selectorPatternMatchRule);
1636
		
1637
		IndexQueryRequestor queryRequestor = new IndexQueryRequestor() {
1638
			
1639
			/**
1640
			 * @see org.eclipse.wst.jsdt.internal.core.search.IndexQueryRequestor#acceptIndexMatch(java.lang.String, org.eclipse.wst.jsdt.core.search.SearchPattern, org.eclipse.wst.jsdt.core.search.SearchParticipant, org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet)
1641
			 */
1642
			public boolean acceptIndexMatch(String documentPath,
1643
					SearchPattern indexRecord, SearchParticipant participant,
1644
					AccessRuleSet access) {
1645
				
1646
				MethodPattern record = (MethodPattern)indexRecord;
1647
				methodRequestor.acceptMethod(record.selector, record.parameterCount, record.parameterQualifications, record.parameterSimpleNames,
1648
						record.parameterNames, record.returnQualification, record.returnSimpleName,
1649
						record.declaringQualification, record.declaringSimpleName, record.modifiers,
1650
						documentPath);
1651
				
1652
				return true;
1653
			}
1654
		};
1655
		
1656
		IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
1657
		try {
1658
			if (progressMonitor != null) {
1659
				progressMonitor.beginTask(Messages.engine_searching, 1000);
1660
			}
1661
			// Find constructor declarations from index
1662
			indexManager.performConcurrentJob(
1663
				new PatternSearchJob(
1664
					pattern,
1665
					getDefaultSearchParticipant(), // JavaScript search only
1666
					scope,
1667
					queryRequestor),
1668
				waitingPolicy,
1669
				progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 1000));
1670
		} finally {
1671
			if (progressMonitor != null) {
1672
				progressMonitor.done();
1673
			}
1674
		}
1675
	}
1640
}
1676
}
(-)src/org/eclipse/wst/jsdt/internal/core/search/IMethodRequestor.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.internal.core.search;
12
13
/**
14
 * TODO: IAN: doc me!
15
 *
16
 */
17
public interface IMethodRequestor {
18
19
	/**
20
	 * 
21
	 * TODO: IAN: doc me!
22
	 * 
23
	 * @param signature
24
	 * @param parameterCount
25
	 * @param parameterQualifications
26
	 * @param parameterSimpleNames
27
	 * @param parameterNames
28
	 * @param returnQualification
29
	 * @param returnSimpleName
30
	 * @param declaringQualification
31
	 * @param declaringSimpleName
32
	 * @param modifiers
33
	 * @param path
34
	 */
35
	public void acceptMethod(
36
				char[] signature,
37
				int parameterCount,
38
				char[][] parameterQualifications,
39
				char[][] parameterSimpleNames,
40
				char[][] parameterNames,
41
				char[] returnQualification,
42
				char[] returnSimpleName,
43
				char[] declaringQualification,
44
				char[] declaringSimpleName,
45
				int modifiers,
46
				String path);
47
}
(-)src/org/eclipse/wst/jsdt/internal/core/search/IndexQueryRequestor.java (-2 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 19-25 Link Here
19
 */
19
 */
20
public abstract class IndexQueryRequestor {
20
public abstract class IndexQueryRequestor {
21
21
22
	// answer false if requesting cancel
22
	/**
23
	 * 
24
	 * TODO: IAN: doc me!
25
	 * 
26
	 * @param documentPath
27
	 * @param indexRecord
28
	 * @param participant
29
	 * @param access
30
	 * 
31
	 * @return <code>true</code> to continue search, <code>false</code> to request cancel of search
32
	 */
23
	public abstract boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access);
33
	public abstract boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access);
24
34
25
}
35
}
(-)src/org/eclipse/wst/jsdt/internal/core/search/indexing/AbstractIndexer.java (-4 / +13 lines)
Lines 74-83 Link Here
74
	protected void addIndexEntry(char[] category, char[] key) {
74
	protected void addIndexEntry(char[] category, char[] key) {
75
		this.document.addIndexEntry(category, key);
75
		this.document.addIndexEntry(category, key);
76
	}
76
	}
77
	public void addMethodDeclaration(char[] methodName, char[][] parameterTypes,
77
	public void addMethodDeclaration(char[] methodName, char[][] parameterTypes, char[][] paramaterNames,
78
				char[] returnType,boolean isFunction) {
78
				char[] returnType, char[] declaringType, boolean isFunction, int modifiers) {
79
		int argCount = parameterTypes == null ? 0 : parameterTypes.length;
79
		int argCount = parameterTypes == null ? 0 : parameterTypes.length;
80
		addIndexEntry(isFunction ? FUNCTION_DECL : METHOD_DECL, MethodPattern.createIndexKey(methodName, argCount));
80
		
81
		//compute key
82
		char[] key = MethodPattern.createIndexKey(methodName, argCount,
83
				parameterTypes, paramaterNames, declaringType, returnType, modifiers);
84
		if(key != null) {
85
			addIndexEntry(isFunction ? FUNCTION_DECL : METHOD_DECL, key);
86
		}
81
87
82
		if (parameterTypes != null) {
88
		if (parameterTypes != null) {
83
			for (int i = 0; i < argCount; i++)
89
			for (int i = 0; i < argCount; i++)
Lines 87-93 Link Here
87
			addTypeReference(returnType);
93
			addTypeReference(returnType);
88
	}
94
	}
89
	public void addMethodReference(char[] methodName, int argCount) {
95
	public void addMethodReference(char[] methodName, int argCount) {
90
		addIndexEntry(METHOD_REF, MethodPattern.createIndexKey(methodName, argCount));
96
		char[] key = MethodPattern.createIndexKey(methodName, argCount);
97
		if(key != null) {
98
			addIndexEntry(METHOD_REF, key);
99
		}
91
	}
100
	}
92
	public void addNameReference(char[] name) {
101
	public void addNameReference(char[] name) {
93
		addIndexEntry(REF, name);
102
		addIndexEntry(REF, name);
(-)src/org/eclipse/wst/jsdt/internal/core/search/indexing/IIndexConstants.java (-32 / +33 lines)
Lines 14-56 Link Here
14
public interface IIndexConstants {
14
public interface IIndexConstants {
15
15
16
	/* index encoding */
16
	/* index encoding */
17
	char[] REF= "ref".toCharArray(); //$NON-NLS-1$
17
	final char[] REF= "ref".toCharArray(); //$NON-NLS-1$
18
	char[] METHOD_REF= "methodRef".toCharArray(); //$NON-NLS-1$
18
	final char[] METHOD_REF= "methodRef".toCharArray(); //$NON-NLS-1$
19
	char[] CONSTRUCTOR_REF= "constructorRef".toCharArray(); //$NON-NLS-1$
19
	final char[] CONSTRUCTOR_REF= "constructorRef".toCharArray(); //$NON-NLS-1$
20
	char[] SUPER_REF = "superRef".toCharArray(); //$NON-NLS-1$
20
	final char[] SUPER_REF = "superRef".toCharArray(); //$NON-NLS-1$
21
	char[] TYPE_DECL = "typeDecl".toCharArray(); //$NON-NLS-1$
21
	final char[] TYPE_DECL = "typeDecl".toCharArray(); //$NON-NLS-1$
22
	char[] METHOD_DECL= "methodDecl".toCharArray(); //$NON-NLS-1$
22
	final char[] METHOD_DECL= "methodDecl".toCharArray(); //$NON-NLS-1$
23
	char[] FUNCTION_DECL= "functionDecl".toCharArray(); //$NON-NLS-1$
23
	final char[] FUNCTION_DECL= "functionDecl".toCharArray(); //$NON-NLS-1$
24
	char[] CONSTRUCTOR_DECL= "constructorDecl".toCharArray(); //$NON-NLS-1$
24
	final char[] CONSTRUCTOR_DECL= "constructorDecl".toCharArray(); //$NON-NLS-1$
25
	char[] FIELD_DECL= "fieldDecl".toCharArray(); //$NON-NLS-1$
25
	final char[] FIELD_DECL= "fieldDecl".toCharArray(); //$NON-NLS-1$
26
	char[] VAR_DECL= "varDecl".toCharArray(); //$NON-NLS-1$
26
	final char[] VAR_DECL= "varDecl".toCharArray(); //$NON-NLS-1$
27
	char[] OBJECT = "Object".toCharArray(); //$NON-NLS-1$
27
	final char[] OBJECT = "Object".toCharArray(); //$NON-NLS-1$
28
	char[][] COUNTS=
28
	final char[][] COUNTS=
29
		new char[][] { new char[] {'/', '0'}, new char[] {'/', '1'}, new char[] {'/', '2'}, new char[] {'/', '3'}, new char[] {'/', '4'},
29
		new char[][] { new char[] {'/', '0'}, new char[] {'/', '1'}, new char[] {'/', '2'}, new char[] {'/', '3'}, new char[] {'/', '4'},
30
			new char[] {'/', '5'}, new char[] {'/', '6'}, new char[] {'/', '7'}, new char[] {'/', '8'}, new char[] {'/', '9'}
30
			new char[] {'/', '5'}, new char[] {'/', '6'}, new char[] {'/', '7'}, new char[] {'/', '8'}, new char[] {'/', '9'}
31
	};
31
	};
32
	char CLASS_SUFFIX = 'C';
32
	final char CLASS_SUFFIX = 'C';
33
	char TYPE_SUFFIX = 0;
33
	final char TYPE_SUFFIX = 0;
34
	char SEPARATOR= '/';
34
	final char SEPARATOR= '/';
35
	char PARAMETER_SEPARATOR= ',';
35
	final char PARAMETER_SEPARATOR= ',';
36
	char SECONDARY_SUFFIX = 'S';
36
	final char SECONDARY_SUFFIX = 'S';
37
	final char DOT = '.';
37
38
38
	char[] ONE_STAR = new char[] {'*'};
39
	final char[] ONE_STAR = new char[] {'*'};
39
	char[][] ONE_STAR_CHAR = new char[][] {ONE_STAR};
40
	final char[][] ONE_STAR_CHAR = new char[][] {ONE_STAR};
40
41
41
	// used as special marker for enclosing type name of local and anonymous classes
42
	// used as special marker for enclosing type name of local and anonymous classes
42
	char ZERO_CHAR = '0';
43
	final char ZERO_CHAR = '0';
43
	char[] ONE_ZERO = new char[] { ZERO_CHAR };
44
	final char[] ONE_ZERO = new char[] { ZERO_CHAR };
44
	char[][] ONE_ZERO_CHAR = new char[][] {ONE_ZERO};
45
	final char[][] ONE_ZERO_CHAR = new char[][] {ONE_ZERO};
45
46
46
	int PKG_REF_PATTERN = 0x0001;
47
	final int PKG_REF_PATTERN = 0x0001;
47
	int PKG_DECL_PATTERN = 0x0002;
48
	final int PKG_DECL_PATTERN = 0x0002;
48
	int TYPE_REF_PATTERN = 0x0004;
49
	final int TYPE_REF_PATTERN = 0x0004;
49
	int TYPE_DECL_PATTERN = 0x0008;
50
	final int TYPE_DECL_PATTERN = 0x0008;
50
	int SUPER_REF_PATTERN = 0x0010;
51
	final int SUPER_REF_PATTERN = 0x0010;
51
	int CONSTRUCTOR_PATTERN = 0x0020;
52
	final int CONSTRUCTOR_PATTERN = 0x0020;
52
	int FIELD_PATTERN = 0x0040;
53
	final int FIELD_PATTERN = 0x0040;
53
	int METHOD_PATTERN = 0x0080;
54
	final int METHOD_PATTERN = 0x0080;
54
	int OR_PATTERN = 0x0100;
55
	final int OR_PATTERN = 0x0100;
55
	int LOCAL_VAR_PATTERN = 0x0200;
56
	final int LOCAL_VAR_PATTERN = 0x0200;
56
}
57
}
(-)src/org/eclipse/wst/jsdt/internal/core/search/indexing/SourceIndexer.java (-4 / +2 lines)
Lines 21-28 Link Here
21
import org.eclipse.wst.jsdt.internal.compiler.util.SuffixConstants;
21
import org.eclipse.wst.jsdt.internal.compiler.util.SuffixConstants;
22
import org.eclipse.wst.jsdt.internal.core.BasicCompilationUnit;
22
import org.eclipse.wst.jsdt.internal.core.BasicCompilationUnit;
23
import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
23
import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
24
import org.eclipse.wst.jsdt.internal.core.Logger;
24
import org.eclipse.wst.jsdt.internal.core.search.JavaSearchDocument;
25
import org.eclipse.wst.jsdt.internal.core.search.JavaSearchDocument;
25
import org.eclipse.wst.jsdt.internal.core.search.processing.JobManager;
26
import org.eclipse.wst.jsdt.internal.oaametadata.LibraryAPIs;
26
import org.eclipse.wst.jsdt.internal.oaametadata.LibraryAPIs;
27
import org.eclipse.wst.jsdt.internal.oaametadata.MetadataReader;
27
import org.eclipse.wst.jsdt.internal.oaametadata.MetadataReader;
28
import org.eclipse.wst.jsdt.internal.oaametadata.MetadataSourceElementNotifier;
28
import org.eclipse.wst.jsdt.internal.oaametadata.MetadataSourceElementNotifier;
Lines 79-87 Link Here
79
		try {
79
		try {
80
			parser.parseCompilationUnit(compilationUnit, true/*full parse*/);
80
			parser.parseCompilationUnit(compilationUnit, true/*full parse*/);
81
		} catch (Exception e) {
81
		} catch (Exception e) {
82
			if (JobManager.VERBOSE) {
82
			Logger.logException("Error while indexing document", e);
83
				e.printStackTrace();
84
			}
85
		}
83
		}
86
	}
84
	}
87
	public void indexMetadata() {
85
	public void indexMetadata() {
(-)src/org/eclipse/wst/jsdt/internal/core/search/indexing/SourceIndexerRequestor.java (-1 / +3 lines)
Lines 190-196 Link Here
190
 */
190
 */
191
public void enterMethod(MethodInfo methodInfo) {
191
public void enterMethod(MethodInfo methodInfo) {
192
	boolean isFunction=this.depth==0;
192
	boolean isFunction=this.depth==0;
193
	this.indexer.addMethodDeclaration(methodInfo.name, methodInfo.parameterTypes, methodInfo.returnType,isFunction);
193
	this.indexer.addMethodDeclaration(methodInfo.name, methodInfo.parameterTypes,
194
			methodInfo.parameterNames, methodInfo.returnType, methodInfo.declaringType,
195
			isFunction, methodInfo.modifiers);
194
	this.methodDepth++;
196
	this.methodDepth++;
195
}
197
}
196
/**
198
/**
(-)src/org/eclipse/wst/jsdt/internal/core/search/matching/ConstructorDeclarationPattern.java (-45 / +10 lines)
Lines 12-25 Link Here
12
12
13
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
13
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
14
import org.eclipse.wst.jsdt.core.search.SearchPattern;
14
import org.eclipse.wst.jsdt.core.search.SearchPattern;
15
import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
16
15
17
/**
16
/**
18
 * <p>Pattern used to find and store constructor declarations.</p>
17
 * <p>Pattern used to find and store constructor declarations.</p>
19
 */
18
 */
20
public class ConstructorDeclarationPattern extends ConstructorPattern {
19
public class ConstructorDeclarationPattern extends ConstructorPattern {
20
	/** <p> Modifiers for the constructor</p> */
21
	public int modifiers;
21
	public int modifiers;
22
	public char[][] parameterTypes;
22
	
23
	/** <p>Fully qualified type names for the parameters of the constructor</p> */
24
	public char[][] parameterTypeNames;
25
	
26
	/** <p>names of the parameters</p> */
23
	public char[][] parameterNames;
27
	public char[][] parameterNames;
24
28
25
	public ConstructorDeclarationPattern(char[] declaringSimpleName, int matchRule) {
29
	public ConstructorDeclarationPattern(char[] declaringSimpleName, int matchRule) {
Lines 79-92 Link Here
79
		
83
		
80
		// initialize optional fields
84
		// initialize optional fields
81
		this.modifiers = 0;
85
		this.modifiers = 0;
82
		this.parameterTypes = null;
86
		this.parameterTypeNames = null;
83
		this.parameterNames = null;
87
		this.parameterNames = null;
84
		
88
		
85
		/* if no parameters just decode modifiers
89
		/* if no parameters just decode modifiers
86
		 * else decode parameters and modifiers
90
		 * else decode parameters and modifiers
87
		 */
91
		 */
88
		start = slash + 1;
92
		start = slash + 1;
89
		if (this.parameterCount == 0) {
93
		if (this.parameterCount <= 0 ) {
90
			slash = slash + 3;
94
			slash = slash + 3;
91
			last = slash - 1;
95
			last = slash - 1;
92
			
96
			
Lines 96-102 Link Here
96
			last = slash - 1;
100
			last = slash - 1;
97
			
101
			
98
			
102
			
99
			this.parameterTypes = CharOperation.splitOn(PARAMETER_SEPARATOR, key, start, slash);
103
			this.parameterTypeNames = CharOperation.splitOn(PARAMETER_SEPARATOR, key, start, slash);
100
			
104
			
101
			start = slash + 1;
105
			start = slash + 1;
102
			slash = CharOperation.indexOf(SEPARATOR, key, start);
106
			slash = CharOperation.indexOf(SEPARATOR, key, start);
Lines 110-117 Link Here
110
			last = slash - 1;
114
			last = slash - 1;
111
			
115
			
112
			this.modifiers = key[last-1] + (key[last]<<16);
116
			this.modifiers = key[last-1] + (key[last]<<16);
113
		} else {
114
			this.modifiers = ClassFileConstants.AccPublic;
115
		}
117
		}
116
	}
118
	}
117
	
119
	
Lines 143-153 Link Here
143
		if (parameterCount > 0) {
145
		if (parameterCount > 0) {
144
			//get param types
146
			//get param types
145
			if (parameterTypes != null && parameterTypes.length == parameterCount) {
147
			if (parameterTypes != null && parameterTypes.length == parameterCount) {
146
				char[][] parameterTypeErasures = new char[parameterCount][];
148
				parameterTypesChars = CharOperation.concatWith(parameterTypes, PARAMETER_SEPARATOR, false);
147
				for (int i = 0; i < parameterTypes.length; i++) {
148
					parameterTypeErasures[i] = getTypeErasure(parameterTypes[i]);
149
				}
150
				parameterTypesChars = CharOperation.concatWith(parameterTypeErasures, PARAMETER_SEPARATOR, false);
151
			}
149
			}
152
			
150
			
153
			//get param names
151
			//get param names
Lines 214-250 Link Here
214
		
212
		
215
		return result;
213
		return result;
216
	}
214
	}
217
	
218
	private static char[] getTypeErasure(char[] typeName) {
219
		char[] typeErasurename = new char[0];
220
		if(typeName != null) {
221
			int index;
222
			if ((index = CharOperation.indexOf('<', typeName)) == -1) return typeName;
223
			
224
			int length = typeName.length;
225
			typeErasurename = new char[length - 2];
226
			
227
			System.arraycopy(typeName, 0, typeErasurename, 0, index);
228
			
229
			int depth = 1;
230
			for (int i = index + 1; i < length; i++) {
231
				switch (typeName[i]) {
232
					case '<':
233
						depth++;
234
						break;
235
					case '>':
236
						depth--;
237
						break;
238
					default:
239
						if (depth == 0) {
240
							typeErasurename[index++] = typeName[i];
241
						}
242
						break;
243
				}
244
			}
245
			
246
			System.arraycopy(typeErasurename, 0, typeErasurename = new char[index], 0, index);
247
		}
248
		return typeErasurename;
249
	}
250
}
215
}
(-)src/org/eclipse/wst/jsdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java (-1 / +1 lines)
Lines 21-27 Link Here
21
protected SimpleSet knownMethods;
21
protected SimpleSet knownMethods;
22
22
23
public DeclarationOfReferencedMethodsPattern(IJavaScriptElement enclosingElement) {
23
public DeclarationOfReferencedMethodsPattern(IJavaScriptElement enclosingElement) {
24
	super(false, true, false,null, null, null, null, null, null, null, null, R_PATTERN_MATCH);
24
	super(false, true, false,null, R_PATTERN_MATCH);
25
25
26
	this.enclosingElement = enclosingElement;
26
	this.enclosingElement = enclosingElement;
27
	this.knownMethods = new SimpleSet();
27
	this.knownMethods = new SimpleSet();
(-)src/org/eclipse/wst/jsdt/internal/core/search/matching/MethodLocator.java (-29 / +2 lines)
Lines 24-30 Link Here
24
import org.eclipse.wst.jsdt.core.infer.InferredMethod;
24
import org.eclipse.wst.jsdt.core.infer.InferredMethod;
25
import org.eclipse.wst.jsdt.core.search.MethodDeclarationMatch;
25
import org.eclipse.wst.jsdt.core.search.MethodDeclarationMatch;
26
import org.eclipse.wst.jsdt.core.search.SearchMatch;
26
import org.eclipse.wst.jsdt.core.search.SearchMatch;
27
import org.eclipse.wst.jsdt.core.search.SearchPattern;
28
import org.eclipse.wst.jsdt.internal.compiler.ast.ASTNode;
27
import org.eclipse.wst.jsdt.internal.compiler.ast.ASTNode;
29
import org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration;
28
import org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration;
30
import org.eclipse.wst.jsdt.internal.compiler.ast.Argument;
29
import org.eclipse.wst.jsdt.internal.compiler.ast.Argument;
Lines 146-156 Link Here
146
		}
145
		}
147
	}
146
	}
148
147
149
	// Verify type arguments (do not reject if pattern has no argument as it can be an erasure match)
150
	if (this.pattern.hasMethodArguments()) {
151
		return IMPOSSIBLE_MATCH;
152
	}
153
154
	// Method declaration may match pattern
148
	// Method declaration may match pattern
155
	return nodeSet.addMatch(node, resolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
149
	return nodeSet.addMatch(node, resolve ? POSSIBLE_MATCH : ACCURATE_MATCH);
156
}
150
}
Lines 158-164 Link Here
158
	if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH;
152
	if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH;
159
153
160
	if (!matchesName(this.pattern.selector, node.selector)) return IMPOSSIBLE_MATCH;
154
	if (!matchesName(this.pattern.selector, node.selector)) return IMPOSSIBLE_MATCH;
161
	if (this.pattern.parameterSimpleNames != null && (!this.pattern.varargs || ((node.bits & ASTNode.InsideJavadoc) != 0))) {
155
	if (this.pattern.parameterSimpleNames != null && ((node.bits & ASTNode.InsideJavadoc) != 0)) {
162
		int length = this.pattern.parameterSimpleNames.length;
156
		int length = this.pattern.parameterSimpleNames.length;
163
		ASTNode[] args = node.arguments;
157
		ASTNode[] args = node.arguments;
164
		int argsLength = args == null ? 0 : args.length;
158
		int argsLength = args == null ? 0 : args.length;
Lines 295-305 Link Here
295
	}
289
	}
296
}
290
}
297
void matchReportReference(MessageSend messageSend, MatchLocator locator, MethodBinding methodBinding) throws CoreException {
291
void matchReportReference(MessageSend messageSend, MatchLocator locator, MethodBinding methodBinding) throws CoreException {
298
299
	if (this.pattern.hasMethodArguments()) { // binding has no type params, compatible erasure if pattern does
300
		match.setRule(SearchPattern.R_ERASURE_MATCH);
301
	}
302
303
	// See whether it is necessary to report or not
292
	// See whether it is necessary to report or not
304
	if (match.getRule() == 0) return; // impossible match
293
	if (match.getRule() == 0) return; // impossible match
305
	boolean report = (this.isErasureMatch && match.isErasure()) || (this.isEquivalentMatch && match.isEquivalent()) || match.isExact();
294
	boolean report = (this.isErasureMatch && match.isErasure()) || (this.isEquivalentMatch && match.isEquivalent()) || match.isExact();
Lines 311-333 Link Here
311
	match.setLength(messageSend.sourceEnd - offset + 1);
300
	match.setLength(messageSend.sourceEnd - offset + 1);
312
	locator.report(match);
301
	locator.report(match);
313
}
302
}
314
/*
315
 * Return whether method parameters are equals to pattern ones.
316
 */
317
private boolean methodParametersEqualsPattern(MethodBinding method) {
318
	TypeBinding[] methodParameters = method.parameters;
319
320
	int length = methodParameters.length;
321
	if (length != this.pattern.parameterSimpleNames.length) return false;
322
303
323
	for (int i = 0; i < length; i++) {
324
		char[] paramQualifiedName = qualifiedPattern(this.pattern.parameterSimpleNames[i], this.pattern.parameterQualifications[i]);
325
		if (!CharOperation.match(paramQualifiedName, methodParameters[i].readableName(), this.isCaseSensitive)) {
326
			return false;
327
		}
328
	}
329
	return true;
330
}
331
public SearchMatch newDeclarationMatch(ASTNode reference, IJavaScriptElement element, Binding elementBinding, int accuracy, int length, MatchLocator locator) {
304
public SearchMatch newDeclarationMatch(ASTNode reference, IJavaScriptElement element, Binding elementBinding, int accuracy, int length, MatchLocator locator) {
332
	if (elementBinding != null) {
305
	if (elementBinding != null) {
333
		MethodBinding methodBinding = (MethodBinding) elementBinding;
306
		MethodBinding methodBinding = (MethodBinding) elementBinding;
Lines 615-621 Link Here
615
						nodeSet.mustResolve = true;
588
						nodeSet.mustResolve = true;
616
						resolve = true;
589
						resolve = true;
617
					}
590
					}
618
					this.methodDeclarationsWithInvalidParam.put((AbstractMethodDeclaration)inferredMethod.getFunctionDeclaration(), null);
591
					this.methodDeclarationsWithInvalidParam.put(inferredMethod.getFunctionDeclaration(), null);
619
				} else {
592
				} else {
620
					return IMPOSSIBLE_MATCH;
593
					return IMPOSSIBLE_MATCH;
621
				}
594
				}
(-)src/org/eclipse/wst/jsdt/internal/core/search/matching/MethodPattern.java (-333 / +707 lines)
Lines 12-380 Link Here
12
12
13
import java.io.IOException;
13
import java.io.IOException;
14
14
15
import org.eclipse.wst.jsdt.core.Flags;
16
import org.eclipse.wst.jsdt.core.IFunction;
15
import org.eclipse.wst.jsdt.core.IFunction;
17
import org.eclipse.wst.jsdt.core.IType;
16
import org.eclipse.wst.jsdt.core.IType;
18
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
19
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
17
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
20
import org.eclipse.wst.jsdt.core.search.SearchPattern;
18
import org.eclipse.wst.jsdt.core.search.SearchPattern;
19
import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
20
import org.eclipse.wst.jsdt.internal.core.Logger;
21
import org.eclipse.wst.jsdt.internal.core.index.EntryResult;
21
import org.eclipse.wst.jsdt.internal.core.index.EntryResult;
22
import org.eclipse.wst.jsdt.internal.core.index.Index;
22
import org.eclipse.wst.jsdt.internal.core.index.Index;
23
import org.eclipse.wst.jsdt.internal.core.util.Util;
23
import org.eclipse.wst.jsdt.internal.core.util.QualificationHelpers;
24
25
public class MethodPattern extends JavaSearchPattern  {
26
27
protected boolean findDeclarations;
28
protected boolean findReferences;
29
30
public char[] selector;
31
32
public char[] declaringQualification;
33
public char[] declaringSimpleName;
34
35
public char[] returnQualification;
36
public char[] returnSimpleName;
37
38
public char[][] parameterQualifications;
39
public char[][] parameterSimpleNames;
40
public int parameterCount;
41
public boolean varargs = false;
42
43
protected boolean isFunction;
44
// extra reference info
45
protected IType declaringType;
46
47
// Signatures and arguments for generic search
48
char[][] returnTypeSignatures;
49
char[][][] returnTypeArguments;
50
char[][][] parametersTypeSignatures;
51
char[][][][] parametersTypeArguments;
52
boolean methodParameters = false;
53
char[][] methodArguments;
54
55
protected static char[][] REF_CATEGORIES = { METHOD_REF };
56
protected static char[][] REF_AND_DECL_CATEGORIES = { METHOD_REF, METHOD_DECL };
57
protected static char[][] DECL_CATEGORIES = { METHOD_DECL };
58
protected static char[][] FUNCTION_REF_AND_DECL_CATEGORIES = { METHOD_REF, FUNCTION_DECL, METHOD_DECL };
59
protected static char[][] FUNCTION_DECL_CATEGORIES = { FUNCTION_DECL, METHOD_DECL };
60
24
61
/**
25
/**
62
 * Method entries are encoded as selector '/' Arity:
26
 * 
63
 * e.g. 'foo/0'
27
 * TODO: IAN: doc me!
28
 *
64
 */
29
 */
65
public static char[] createIndexKey(char[] selector, int argCount) {
30
public class MethodPattern extends JavaSearchPattern  {
66
	char[] countChars = argCount < 10
67
		? COUNTS[argCount]
68
		: ("/" + String.valueOf(argCount)).toCharArray(); //$NON-NLS-1$
69
	return CharOperation.concat(selector, countChars);
70
}
71
72
MethodPattern(int matchRule, boolean isFunction) {
73
	super(METHOD_PATTERN, matchRule);
74
	this.isFunction=isFunction;
75
}
76
public MethodPattern(
77
	boolean findDeclarations,
78
	boolean findReferences,
79
	boolean isFunction,
80
	char[] selector,
81
	char[] declaringQualification,
82
	char[] declaringSimpleName,
83
	char[] returnQualification,
84
	char[] returnSimpleName,
85
	char[][] parameterQualifications,
86
	char[][] parameterSimpleNames,
87
	IType declaringType,
88
	int matchRule) {
89
90
	this(matchRule,isFunction);
91
92
	this.findDeclarations = findDeclarations;
93
	this.findReferences = findReferences;
94
31
95
	this.selector = (isCaseSensitive() || isCamelCase())  ? selector : CharOperation.toLowerCase(selector);
32
	protected static final char[][] REF_CATEGORIES = { METHOD_REF };
96
	this.declaringQualification = isCaseSensitive() ? declaringQualification : CharOperation.toLowerCase(declaringQualification);
33
	protected static final char[][] REF_AND_DECL_CATEGORIES = { METHOD_REF, METHOD_DECL };
97
	this.declaringSimpleName = isCaseSensitive() ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
34
	protected static final char[][] DECL_CATEGORIES = { METHOD_DECL };
98
	this.returnQualification = isCaseSensitive() ? returnQualification : CharOperation.toLowerCase(returnQualification);
35
	protected static final char[][] FUNCTION_REF_AND_DECL_CATEGORIES = { METHOD_REF, FUNCTION_DECL, METHOD_DECL };
99
	this.returnSimpleName = isCaseSensitive() ? returnSimpleName : CharOperation.toLowerCase(returnSimpleName);
36
	protected static final char[][] FUNCTION_DECL_CATEGORIES = { FUNCTION_DECL, METHOD_DECL };
100
	if (parameterSimpleNames != null) {
37
	
101
		this.parameterCount = parameterSimpleNames.length;
38
	/**
102
		this.parameterQualifications = new char[this.parameterCount][];
39
	 * <p><b>Required</b></p>
103
		this.parameterSimpleNames = new char[this.parameterCount][];
40
	 * 
104
		for (int i = 0; i < this.parameterCount; i++) {
41
	 * <p>Name of the function</p>
105
			this.parameterQualifications[i] = isCaseSensitive() ? parameterQualifications[i] : CharOperation.toLowerCase(parameterQualifications[i]);
42
	 */
106
			this.parameterSimpleNames[i] = isCaseSensitive() ? parameterSimpleNames[i] : CharOperation.toLowerCase(parameterSimpleNames[i]);
43
	public char[] selector;
107
		}
44
	
108
	} else {
45
	/**
109
		this.parameterCount = -1;
46
	 * <p><b>Optional</b></p>
47
	 * 
48
	 * <p>Qualification of the declaring type containing this function.</p>
49
	 * 
50
	 * <p><b>Note:</b> If this field is defined then the {@link #declaringSimpleName} must
51
	 * also be defined.</p>
52
	 * 
53
	 * @see #declaringSimpleName
54
	 */
55
	public char[] declaringQualification;
56
	
57
	/**
58
	 * <p><b>Optional</b></p>
59
	 * 
60
	 * <p>Simple name of the declaring type containing this function.</p>
61
	 * 
62
	 * <p><b>Note:</b> If this field is defined then the {@link #declaringQualification}
63
	 * can be defined, but does not have to be.</p>
64
	 * 
65
	 * @see #declaringQualification
66
	 */
67
	public char[] declaringSimpleName;
68
	
69
	/**
70
	 * <p><b>Required</b></p>
71
	 * 
72
	 * <p>Number of specified parameters for this function.
73
	 * Must be equal to or greater then 0.</p>
74
	 */
75
	public int parameterCount;
76
	
77
	/**
78
	 * <p><b>Optional</b></p>
79
	 * 
80
	 * <p>Qualifications of the parameter types for this function.</p>
81
	 * <p>This should have the same length as {@link #parameterCount}, or
82
	 * <code>null</code> if {@link #parameterCount} is 0</p>
83
	 * 
84
	 * <p><b>Note:</b> If this field is defined then the {@link #parameterSimpleNames} must
85
	 * also be defined.</p>
86
	 * 
87
	 * @see #parameterSimpleNames
88
	 */
89
	public char[][] parameterQualifications;
90
	
91
	/**
92
	 * <p><b>Optional</b></p>
93
	 * 
94
	 * <p>Simple names of the parameter types for this function.</p>
95
	 * <p>This should have the same length as {@link #parameterCount}, or
96
	 * <code>null</code> if {@link #parameterCount} is 0</p>
97
	 * 
98
	 * <p><b>Note:</b> If this field is defined then the {@link #parameterQualifications}
99
	 * filed can be defined, but does not have to be.</p>
100
	 * 
101
	 * @see #parameterQualifications
102
	 */
103
	public char[][] parameterSimpleNames;
104
	
105
	/**
106
	 * <p><b>Required</b> if {@link #parameterCount} is greater then 0</p>
107
	 * 
108
	 * <p>Names of the defined parameters for this function.</p>
109
	 * <p>This should have the same length as {@link #parameterCount}, or
110
	 * <code>null</code> if {@link #parameterCount} is 0</p>
111
	 */
112
	public char[][] parameterNames;
113
	
114
	/**
115
	 * <p><b>Optional</b></p>
116
	 * 
117
	 * <p>Qualification of the return type of this function.</p>
118
	 * 
119
	 * <p><b>Note:</b> If this field is defined then the {@link #returnSimpleName} must
120
	 * also be defined.</p>
121
	 */
122
	public char[] returnQualification;
123
	
124
	/**
125
	 * <p><b>Optional</b></p>
126
	 * 
127
	 * <p>Simple name of the return type of this function.</p>
128
	 * 
129
	 * <p><b>Note:</b> If this field is defined then the {@link #returnQualification}
130
	 * filed can be defined, but does not have to be.</p>
131
	 */
132
	public char[] returnSimpleName;
133
	
134
	/**
135
	 * <p><b>Optional</b></p>
136
	 * 
137
	 * <p>Any modifiers for this function.</p>
138
	 * 
139
	 * @see ClassFileConstants
140
	 */
141
	public int modifiers;
142
	
143
	/**
144
	 * <p><b>Optional</b></p>
145
	 * <p>{@link IType} containing this function.</p>
146
	 * 
147
	 * <p><b>NOTE:</b> any dependency on this field should be removed</p>
148
	 */
149
	protected IType declaringType;
150
	
151
	/**
152
	 * <p>When using this pattern to do a search <code>true</code> to
153
	 * find function declarations that match this pattern, <code>false</code> otherwise.</p>
154
	 */
155
	protected boolean findDeclarations;
156
	
157
	/**
158
	 * <p>When using this pattern to do a search <code>true</code> to
159
	 * find function references that match this pattern, <code>false</code> otherwise.</p>
160
	 */
161
	protected boolean findReferences;
162
	
163
	/**
164
	 * <p><code>true</code> if this pattern represents a function,
165
	 * <code>false</code> otherwise.</p>
166
	 * 
167
	 * <p><b>NOTE:</b> this whole concept should be removed, a funciton is a funciton is a function.</p>
168
	 */
169
	protected boolean isFunction;
170
171
	/**
172
	 * <p>Internal constructor for creating plank patterns</p>
173
	 *
174
	 * @param matchRule match rule used when comparing this pattern to search results
175
	 * @param isFunction <code>true</code> if this pattern represents a function,
176
	 * <code>false</code> otherwise
177
	 */
178
	MethodPattern(int matchRule, boolean isFunction) {
179
		super(METHOD_PATTERN, matchRule);
180
		this.isFunction=isFunction;
110
	}
181
	}
111
	this.declaringType = declaringType;
182
	
112
	((InternalSearchPattern)this).mustResolve = mustResolve();
183
	/**
113
}
184
	 * <p>Useful constructor when creating a pattern to search for index matches
114
/*
185
	 * while doing content assist.</p>
115
 * Instanciate a method pattern with signatures for generics search
186
	 *
116
 */
187
	 * @param findDeclarations when using this pattern to do a search <code>true</code> to
117
public MethodPattern(
188
	 * find function declarations that match this pattern, <code>false</code> otherwise.
118
	boolean findDeclarations,
189
	 * @param findReferences hen using this pattern to do a search <code>true</code> to
119
	boolean findReferences,
190
	 * find function references that match this pattern, <code>false</code> otherwise
120
	boolean isFunction,
191
	 * @param isFunction <code>true</code> if this pattern represents a function,
121
	char[] selector,
192
	 * <code>false</code> otherwise
122
	char[] declaringQualification,
193
	 * @param selector pattern for the name of the function
123
	char[] declaringSimpleName,
194
	 * @param selectorMatchRule match rule used when comparing this pattern to search results.
124
	char[] returnQualification,
195
	 * This dictates what type of pattern is present, if any, in the specified <code>selector</code>
125
	char[] returnSimpleName,
196
	 * 
126
	String returnSignature,
197
	 * @see SearchPattern
127
	char[][] parameterQualifications,
198
	 */
128
	char[][] parameterSimpleNames,
199
	public MethodPattern(boolean findDeclarations,
129
	String[] parameterSignatures,
200
			boolean findReferences,
130
	IFunction method,
201
			boolean isFunction,
131
	int matchRule) {
202
			char[] selector,
132
203
			int selectorMatchRule) {
133
	this(findDeclarations,
204
		
134
		findReferences,
205
		this(findDeclarations, findReferences, isFunction, selector,
135
		isFunction,
206
				null, null, null, null, null, null,
136
		selector,
207
				selectorMatchRule);
137
		declaringQualification,
138
		declaringSimpleName,
139
		returnQualification,
140
		returnSimpleName,
141
		parameterQualifications,
142
		parameterSimpleNames,
143
		method.getDeclaringType(),
144
		matchRule);
145
146
	// Set flags
147
	try {
148
		this.varargs = (method.getFlags() & Flags.AccVarargs) != 0;
149
	} catch (JavaScriptModelException e) {
150
		// do nothing
151
	}
208
	}
152
	
209
	
153
	methodParameters = true;
210
	/**
211
	 * <p>Useful constructor for finding index matches based on content assist pattern.</p>
212
	 *
213
	 * @param findDeclarations when using this pattern to do a search <code>true</code> to
214
	 * find function declarations that match this pattern, <code>false</code> otherwise.
215
	 * @param findReferences hen using this pattern to do a search <code>true</code> to
216
	 * find function references that match this pattern, <code>false</code> otherwise
217
	 * @param selector pattern for the name of the function
218
	 * @param declaringType optional declaring type that the given selector must be
219
	 * defined on to be a valid match, or <code>null</code> to specify the function is not
220
	 * defined on a type
221
	 * @param selectorMatchRule match rule used when comparing this pattern to search results.
222
	 * This dictates what type of pattern is present, if any, in the specified <code>selector</code>
223
	 */
224
	public MethodPattern(boolean findDeclarations, boolean findReferences,
225
			char[] selector, char[] declaringType,
226
			int selectorMatchRule){
227
		
228
		this(selectorMatchRule, true);
229
		
230
		this.findDeclarations = findDeclarations;
231
		this.findReferences = findReferences;
232
		this.selector = selector;
233
		this.parameterCount = -1;
234
		
235
		char[][] seperatedDeclaringType = QualificationHelpers.seperateFullyQualifedName(declaringType);
236
		this.declaringQualification = seperatedDeclaringType[QualificationHelpers.QULIFIERS_INDEX];
237
		this.declaringSimpleName = seperatedDeclaringType[QualificationHelpers.SIMPLE_NAMES_INDEX];
238
	}
239
	
240
	/**
241
	 * 
242
	 * TODO: IAN: doc me!
243
	 *
244
	 * @param findDeclarations
245
	 * @param findReferences
246
	 * @param isFunction
247
	 * @param selector
248
	 * @param declaringQualification
249
	 * @param declaringSimpleName
250
	 * @param returnQualification
251
	 * @param returnSimpleName
252
	 * @param parameterQualifications
253
	 * @param parameterSimpleNames
254
	 * @param declaringType
255
	 * @param matchRule
256
	 */
257
	public MethodPattern(
258
			boolean findDeclarations,
259
			boolean findReferences,
260
			boolean isFunction,
261
			char[] selector,
262
			char[] declaringQualification,
263
			char[] declaringSimpleName,
264
			char[] returnQualification,
265
			char[] returnSimpleName,
266
			char[][] parameterQualifications,
267
			char[][] parameterSimpleNames,
268
			IType declaringType,
269
			int matchRule) {
270
271
		this(matchRule,isFunction);
272
273
		this.findDeclarations = findDeclarations;
274
		this.findReferences = findReferences;
275
276
		this.selector = (isCaseSensitive() || isCamelCase())  ? selector : CharOperation.toLowerCase(selector);
277
		this.declaringQualification = isCaseSensitive() ? declaringQualification : CharOperation.toLowerCase(declaringQualification);
278
		this.declaringSimpleName = isCaseSensitive() ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
279
		this.returnQualification = isCaseSensitive() ? returnQualification : CharOperation.toLowerCase(returnQualification);
280
		this.returnSimpleName = isCaseSensitive() ? returnSimpleName : CharOperation.toLowerCase(returnSimpleName);
281
		if (parameterSimpleNames != null) {
282
			this.parameterCount = parameterSimpleNames.length;
283
			this.parameterQualifications = new char[this.parameterCount][];
284
			this.parameterSimpleNames = new char[this.parameterCount][];
285
			for (int i = 0; i < this.parameterCount; i++) {
286
				this.parameterQualifications[i] = isCaseSensitive() ? parameterQualifications[i] : CharOperation.toLowerCase(parameterQualifications[i]);
287
				this.parameterSimpleNames[i] = isCaseSensitive() ? parameterSimpleNames[i] : CharOperation.toLowerCase(parameterSimpleNames[i]);
288
			}
289
		} else {
290
			this.parameterCount = -1;
291
		}
292
		this.declaringType = declaringType;
293
		((InternalSearchPattern)this).mustResolve = false;
294
	}
154
	
295
	
155
	if (declaringType!=null) {
296
	/**
156
		// Store type signature and arguments for declaring type
297
	 * 
157
		storeTypeSignaturesAndArguments(declaringType);
298
	 * TODO: IAN: doc me!
299
	 *
300
	 * @param findDeclarations
301
	 * @param findReferences
302
	 * @param isFunction
303
	 * @param selector
304
	 * @param declaringQualification
305
	 * @param declaringSimpleName
306
	 * @param returnQualification
307
	 * @param returnSimpleName
308
	 * @param parameterQualifications
309
	 * @param parameterSimpleNames
310
	 * @param method
311
	 * @param matchRule
312
	 */
313
	public MethodPattern(
314
		boolean findDeclarations,
315
		boolean findReferences,
316
		boolean isFunction,
317
		char[] selector,
318
		char[] declaringQualification,
319
		char[] declaringSimpleName,
320
		char[] returnQualification,
321
		char[] returnSimpleName,
322
		char[][] parameterQualifications,
323
		char[][] parameterSimpleNames,
324
		IFunction method,
325
		int matchRule) {
326
327
		this(findDeclarations,
328
			findReferences,
329
			isFunction,
330
			selector,
331
			declaringQualification,
332
			declaringSimpleName,
333
			returnQualification,
334
			returnSimpleName,
335
			parameterQualifications,
336
			parameterSimpleNames,
337
			method.getDeclaringType(),
338
			matchRule);
158
		
339
		
340
		if (declaringType!=null) {
341
			// Store type signature and arguments for declaring type
342
			storeTypeSignaturesAndArguments(declaringType);
343
		}
159
	}
344
	}
160
	// Store type signatures and arguments for return type
345
	
161
	if (returnSignature != null) {
346
	/**
162
		returnTypeSignatures = Util.splitTypeLevelsSignature(returnSignature);
347
	 * 
163
		returnTypeArguments = Util.getAllTypeArguments(returnTypeSignatures);
348
	 * TODO: IAN: doc me!
349
	 *
350
	 * @param findDeclarations
351
	 * @param findReferences
352
	 * @param isFunction
353
	 * @param selector
354
	 * @param declaringQualification
355
	 * @param declaringSimpleName
356
	 * @param returnQualification
357
	 * @param returnSimpleName
358
	 * @param parameterQualifications
359
	 * @param parameterSimpleNames
360
	 * @param matchRule
361
	 */
362
	public MethodPattern(
363
		boolean findDeclarations,
364
		boolean findReferences,
365
		boolean isFunction,
366
		char[] selector,
367
		char[] declaringQualification,
368
		char[] declaringSimpleName,
369
		char[] returnQualification,
370
		char[] returnSimpleName,
371
		char[][] parameterQualifications,
372
		char[][] parameterSimpleNames,
373
		int matchRule) {
374
375
		this(findDeclarations,
376
			findReferences,
377
			isFunction,
378
			selector,
379
			declaringQualification,
380
			declaringSimpleName,
381
			returnQualification,
382
			returnSimpleName,
383
			parameterQualifications,
384
			parameterSimpleNames,
385
			(IType)null,
386
			matchRule);
164
	}
387
	}
165
388
	
166
	// Store type signatures and arguments for method parameters type
389
	/**
167
	if (parameterSignatures != null) {
390
	 * <p>Given an index key created by this class decodes that key into the
168
		int length = parameterSignatures.length;
391
	 * various fields of this pattern.</p>
169
		if (length > 0) {
392
	 * 
170
			parametersTypeSignatures = new char[length][][];
393
	 * @param key to decode into the fields of this pattern
171
			parametersTypeArguments = new char[length][][][];
394
	 * 
172
			for (int i=0; i<length; i++) {
395
	 * @see #createIndexKey(char[], int)
173
				parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
396
	 * @see #createIndexKey(char[], int, char[][], char[][], char[], char[], int)
174
				parametersTypeArguments[i] = Util.getAllTypeArguments(parametersTypeSignatures[i]);
397
	 * @see #createSearchIndexKey(char[], char[], char[], int)
175
			}
398
	 * @see #createSearchIndexKey(char[], int, char[][], char[][], char[][], char[], char[], char[], char[], int)
399
	 */
400
	public void decodeIndexKey(char[] key) {
401
		char[][] seperated = CharOperation.splitOn(SEPARATOR, key);
402
		
403
		//get the selector
404
		this.selector = seperated[0];
405
		
406
		//get the parameter count
407
		this.parameterCount = Integer.parseInt(new String(seperated[1]));
408
		
409
		//get parameter types
410
		char[][][] parameterTypes = QualificationHelpers.seperateFullyQualifedNames(seperated[2], this.parameterCount);
411
		this.parameterQualifications = parameterTypes[QualificationHelpers.QULIFIERS_INDEX];
412
		this.parameterSimpleNames = parameterTypes[QualificationHelpers.SIMPLE_NAMES_INDEX];
413
		
414
		//get parameter names
415
		char[][] parameterNames = CharOperation.splitOn(PARAMETER_SEPARATOR, seperated[3]);
416
		if(parameterNames.length > 0) {
417
			this.parameterNames = parameterNames;
418
		} else {
419
			this.parameterNames = null;
176
		}
420
		}
421
		
422
		//get the return type
423
		char[][] returnType = QualificationHelpers.seperateFullyQualifedName(seperated[4]);
424
		this.returnQualification = returnType[QualificationHelpers.QULIFIERS_INDEX];
425
		this.returnSimpleName = returnType[QualificationHelpers.SIMPLE_NAMES_INDEX];
426
		
427
		//get the declaration type
428
		char[][] declaringType = QualificationHelpers.seperateFullyQualifedName(seperated[5]);
429
		this.declaringQualification = declaringType[QualificationHelpers.QULIFIERS_INDEX];
430
		this.declaringSimpleName = declaringType[QualificationHelpers.SIMPLE_NAMES_INDEX];
431
		
432
		//get the modifiers
433
		this.modifiers = seperated[6][0] + seperated[6][1];
177
	}
434
	}
178
435
	
179
	// Store type signatures and arguments for method
436
	public SearchPattern getBlankPattern() {
180
	methodArguments = extractMethodArguments(method);
437
		return new MethodPattern(R_EXACT_MATCH | R_CASE_SENSITIVE,isFunction);
181
	if (hasMethodArguments())  ((InternalSearchPattern)this).mustResolve = true;
182
}
183
/*
184
 * Instanciate a method pattern with signatures for generics search
185
 */
186
public MethodPattern(
187
	boolean findDeclarations,
188
	boolean findReferences,
189
	boolean isFunction,
190
	char[] selector,
191
	char[] declaringQualification,
192
	char[] declaringSimpleName,
193
	String declaringSignature,
194
	char[] returnQualification,
195
	char[] returnSimpleName,
196
	String returnSignature,
197
	char[][] parameterQualifications,
198
	char[][] parameterSimpleNames,
199
	String[] parameterSignatures,
200
	char[][] arguments,
201
	int matchRule) {
202
203
	this(findDeclarations,
204
		findReferences,
205
		isFunction,
206
		selector,
207
		declaringQualification,
208
		declaringSimpleName,
209
		returnQualification,
210
		returnSimpleName,
211
		parameterQualifications,
212
		parameterSimpleNames,
213
		null,
214
		matchRule);
215
216
	// Store type signature and arguments for declaring type
217
	if (declaringSignature != null) {
218
		typeSignatures = Util.splitTypeLevelsSignature(declaringSignature);
219
		setTypeArguments(Util.getAllTypeArguments(typeSignatures));
220
	}
438
	}
221
439
	public char[][] getIndexCategories() {
222
	// Store type signatures and arguments for return type
440
		if (this.findReferences)
223
	if (returnSignature != null) {
441
			return this.findDeclarations ?
224
		returnTypeSignatures = Util.splitTypeLevelsSignature(returnSignature);
442
					(isFunction ? FUNCTION_REF_AND_DECL_CATEGORIES : REF_AND_DECL_CATEGORIES)
225
		returnTypeArguments = Util.getAllTypeArguments(returnTypeSignatures);
443
					: REF_CATEGORIES;
444
		if (this.findDeclarations)
445
			return isFunction ? FUNCTION_DECL_CATEGORIES : DECL_CATEGORIES;
446
		return CharOperation.NO_CHAR_CHAR;
226
	}
447
	}
227
448
228
	// Store type signatures and arguments for method parameters type
449
	boolean hasMethodParameters() {
229
	if (parameterSignatures != null) {
450
		return this.parameterCount > 0;
230
		int length = parameterSignatures.length;
451
	}
231
		if (length > 0) {
452
	boolean isPolymorphicSearch() {
232
			parametersTypeSignatures = new char[length][][];
453
		return this.findReferences;
233
			parametersTypeArguments = new char[length][][][];
454
	}
234
			for (int i=0; i<length; i++) {
455
	public boolean matchesDecodedKey(SearchPattern decodedPattern) {
235
				parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
456
		MethodPattern pattern = (MethodPattern) decodedPattern;
236
				parametersTypeArguments[i] = Util.getAllTypeArguments(parametersTypeSignatures[i]);
457
	
237
			}
458
		return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1)
459
			&& matchesName(this.selector, pattern.selector);
460
	}
461
	
462
	/**
463
	 * @see org.eclipse.wst.jsdt.internal.core.search.matching.InternalSearchPattern#queryIn(org.eclipse.wst.jsdt.internal.core.index.Index)
464
	 */
465
	EntryResult[] queryIn(Index index) throws IOException {
466
		char[] key = this.selector; // can be null
467
		int matchRule = getMatchRule();
468
	
469
		int matchRuleToUse = matchRule;
470
		switch(getMatchMode()) {
471
			case R_EXACT_MATCH :
472
				key = createSearchIndexKey(this.selector, this.parameterCount,
473
						this.parameterQualifications, this.parameterSimpleNames,
474
						this.parameterNames, this.returnQualification, this.returnSimpleName,
475
						this.declaringQualification, this.declaringSimpleName, this.modifiers);
476
				break;
477
			case R_PREFIX_MATCH :
478
				char[] selector = CharOperation.concat(this.selector, ONE_STAR);
479
				
480
				key = createSearchIndexKey(selector,
481
						this.declaringQualification, this.declaringSimpleName,
482
						this.modifiers);
483
				
484
				//the prefix match refers to the selector, but to do the actual match need to use a pattern
485
				matchRuleToUse = R_PATTERN_MATCH;
486
				break;
487
			case R_PATTERN_MATCH :
488
				key = createSearchIndexKey(this.selector,
489
						this.declaringQualification, this.declaringSimpleName,
490
						this.modifiers);
491
				break;
492
			case R_REGEXP_MATCH :
493
				// TODO implement regular expression match
494
				Logger.log(Logger.WARNING, "Regular expression matching is not yet implimented for MethodPattern");
495
				break;
238
		}
496
		}
497
	
498
		return index.query(getIndexCategories(), key, matchRuleToUse); // match rule is irrelevant when the key is null
239
	}
499
	}
240
500
	
241
	// Store type signatures and arguments for method
501
	/**
242
	methodArguments = arguments;
502
	 * @see org.eclipse.wst.jsdt.internal.core.search.matching.JavaSearchPattern#print(java.lang.StringBuffer)
243
	if (hasMethodArguments())  ((InternalSearchPattern)this).mustResolve = true;
503
	 */
244
}
504
	protected StringBuffer print(StringBuffer output) {
245
public void decodeIndexKey(char[] key) {
505
		if (this.findDeclarations) {
246
	int last = key.length - 1;
506
			output.append(this.findReferences
247
	this.parameterCount = 0;
507
				? "MethodCombinedPattern: " //$NON-NLS-1$
248
	this.selector = null;
508
				: "MethodDeclarationPattern: "); //$NON-NLS-1$
249
	int power = 1;
509
		} else {
250
	for (int i=last; i>=0; i--) {
510
			output.append("MethodReferencePattern: "); //$NON-NLS-1$
251
		if (key[i] == SEPARATOR) {
252
			System.arraycopy(key, 0, this.selector = new char[i], 0, i);
253
			break;
254
		}
511
		}
255
		if (i == last) {
512
		if (declaringQualification != null)
256
			this.parameterCount = key[i] - '0';
513
			output.append(declaringQualification).append('.');
514
		if (declaringSimpleName != null)
515
			output.append(declaringSimpleName).append('.');
516
		else if (declaringQualification != null)
517
			output.append("*."); //$NON-NLS-1$
518
519
		if (selector != null)
520
			output.append(selector);
521
		else
522
			output.append("*"); //$NON-NLS-1$
523
		output.append('(');
524
		if (parameterSimpleNames == null) {
525
			output.append("..."); //$NON-NLS-1$
257
		} else {
526
		} else {
258
			power *= 10;
527
			for (int i = 0, max = parameterSimpleNames.length; i < max; i++) {
259
			this.parameterCount += power * (key[i] - '0');
528
				if (i > 0) output.append(", "); //$NON-NLS-1$
529
				if (parameterQualifications[i] != null) output.append(parameterQualifications[i]).append('.');
530
				if (parameterSimpleNames[i] == null) output.append('*'); else output.append(parameterSimpleNames[i]);
531
			}
260
		}
532
		}
533
		output.append(')');
534
		if (returnQualification != null)
535
			output.append(" --> ").append(returnQualification).append('.'); //$NON-NLS-1$
536
		else if (returnSimpleName != null)
537
			output.append(" --> "); //$NON-NLS-1$
538
		if (returnSimpleName != null)
539
			output.append(returnSimpleName);
540
		else if (returnQualification != null)
541
			output.append("*"); //$NON-NLS-1$
542
		return super.print(output);
261
	}
543
	}
262
}
544
	
263
public SearchPattern getBlankPattern() {
545
	/**
264
	return new MethodPattern(R_EXACT_MATCH | R_CASE_SENSITIVE,isFunction);
546
	 * <p>Create an index key from a selector and a parameter count.</p>
265
}
547
	 * 
266
public char[][] getIndexCategories() {
548
	 * <p><b>Note</b> Currently used to index function references, but the
267
	if (this.findReferences)
549
	 * validity of this use is questionable.</p>
268
		return this.findDeclarations ?
550
	 * 
269
				(isFunction ? FUNCTION_REF_AND_DECL_CATEGORIES : REF_AND_DECL_CATEGORIES)
551
	 * @param selector
270
				: REF_CATEGORIES;
552
	 * @param parameterCount
271
	if (this.findDeclarations)
553
	 * 
272
		return isFunction ? FUNCTION_DECL_CATEGORIES : DECL_CATEGORIES;
554
	 * @return a function index key created from a selector and a parameter count
273
	return CharOperation.NO_CHAR_CHAR;
555
	 */
274
}
556
	public static char[] createIndexKey(char[] selector, int parameterCount) {
275
boolean hasMethodArguments() {
557
		return createIndexKey(selector, parameterCount, null, null, null, null, 0);
276
	return methodArguments != null && methodArguments.length > 0;
558
	}
277
}
559
	
278
boolean hasMethodParameters() {
560
	/**
279
	return methodParameters;
561
	 * 
280
}
562
	 * TODO: IAN: doc me!
281
boolean isPolymorphicSearch() {
563
	 * 
282
	return this.findReferences;
564
	 * <p><b>Key Syntax</b>:
283
}
565
	 * <code>selector/parameterCount/parameterFullTypeNames/paramaterNames/returnFulLTypeName/declaringFullTypeName</code></p>
284
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
566
	 * 
285
	MethodPattern pattern = (MethodPattern) decodedPattern;
567
	 * <p>
286
568
	 * <b>Examples:</b><ul>
287
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
569
	 * <li><code>myFunction/0////</code> - function with no parameters and no return type</li>
288
		&& matchesName(this.selector, pattern.selector);
570
	 * <li><code>myFunction/0///String/</code> - function with no parameters with a return type</li>
289
}
571
	 * <li><code>myFunction/0////foo.bar.Type</code> - function on a type with no parameters and no return type</li>
290
/**
572
	 * <li><code>myFunction/0///String/foo.bar.Type</code> - function on a type with no parameters with a return type </li>
291
 * Returns whether a method declaration or message send must be resolved to
573
	 * <li><code>myFunction/2//param1,param2//</code> - function with no parameter types, with parameter names with no return type</li>
292
 * find out if this method pattern matches it.
574
	 * <li><code>myFunction/2//param1,param2/String/</code> - function with no parameter types, with parameter names with a return type</li>
293
 */
575
	 * <li><code>myFunction/2//param1,param2//foo.bar.Type</code> - function on a type with no parameter types, with parameter  names with no return type</li>
294
protected boolean mustResolve() {
576
	 * <li><code>myFunction/2//param1,param2/String/foo.bar.Type</code> - function on a type with no parameter types, with parameter names with a return type</li>
295
	// declaring type
577
	 * <li><code>myFunction/2/String,Number/param1,param2//</code> - function with parameter types and names with no return type</li>
296
	// If declaring type is specified - even with simple name - always resolves
578
	 * <li><code>myFunction/2/String,Number/param1,param2/String/</code> - function with parameter types and names with a return type</li>
297
	if (declaringSimpleName != null || declaringQualification != null) return true;
579
	 * <li><code>myFunction/2/String,Number/param1,param2//foo.bar.Type</code> - function on a type with parameter types and names with no return type</li>
298
580
	 * <li><code>myFunction/2/String,Number/param1,param2/String/foo.bar.Type</code> - function on a type with parameter types and names with a return type</li>
299
	// return type
581
	 * <li><code>myFunction/2/,Number/param1,param2//</code> - function where only one of the parameters has a type</li>
300
	// If return type is specified - even with simple name - always resolves
582
	 * <li><code>myFunction/2/,Number/param1,param2/String/</code> - function where only one of the parameters has a type with a return type</li>
301
	if (returnSimpleName != null || returnQualification != null) return true;
583
	 * <li><code>myFunction/2/,Number/param1,param2//foo.bar.Type</code> - function on a type where only one of the parameters has a type</li>
302
584
	 * <li><code>myFunction/2/,Number/param1,param2/String/foo.bar.Type</code> - function on a type where only one of the parameters has a type with a return type</li>
303
	// parameter types
585
	 * </ul></p>
304
	if (parameterSimpleNames != null)
586
	 * 
305
		for (int i = 0, max = parameterSimpleNames.length; i < max; i++)
587
	 * @param selector
306
			if (parameterQualifications[i] != null) return true;
588
	 * @param parameterCount
307
	return false;
589
	 * @param declaringFullTypeName
308
}
590
	 * @param returnFullTypeName
309
EntryResult[] queryIn(Index index) throws IOException {
591
	 * @param parameterFullTypeNames
310
	char[] key = this.selector; // can be null
592
	 * @param parameterNames
311
	int matchRule = getMatchRule();
593
	 * @param modifiers
312
594
	 * 
313
	switch(getMatchMode()) {
595
	 * @return
314
		case R_EXACT_MATCH :
596
	 */
315
			if (this.isCamelCase) break;
597
	public static char[] createIndexKey(char[] selector, int parameterCount,
316
			if (this.selector != null && this.parameterCount >= 0 && !this.varargs)
598
			char[][] parameterFullTypeNames,
317
				key = createIndexKey(this.selector, this.parameterCount);
599
			char[][] parameterNames,
318
			else { // do a prefix query with the selector
600
			char[] declaringFullTypeName,
319
				matchRule &= ~R_EXACT_MATCH;
601
			char[] returnFullTypeName,
320
				matchRule |= R_PREFIX_MATCH;
602
			int modifiers) {
603
		
604
		char[] indexKey = null;
605
		
606
		if(selector != null  && selector.length > 0) {
607
			char[] paramaterCountChars = null;
608
			char[] parameterTypesChars = CharOperation.NO_CHAR;
609
			char[] parameterNamesChars = CharOperation.NO_CHAR;
610
			
611
			
612
			//get param types
613
			if (parameterFullTypeNames != null) {
614
				parameterTypesChars = CharOperation.concatWith(parameterFullTypeNames, PARAMETER_SEPARATOR, false);
615
			}
616
			
617
			//get param names
618
			if (parameterNames != null) {
619
				parameterNamesChars = CharOperation.concatWith(parameterNames, PARAMETER_SEPARATOR);
620
			}
621
			
622
			//use pre-made char array for arg counts less then 10, else build a new one
623
			if(parameterCount >= 0) {
624
				paramaterCountChars = parameterCount < 10 ?
625
						COUNTS[parameterCount] : (SEPARATOR + String.valueOf(parameterCount)).toCharArray();
626
			} else {
627
				paramaterCountChars = CharOperation.concat(new char[] {SEPARATOR}, ONE_STAR);
628
			}
629
			
630
				
631
			//get lengths
632
			int parameterTypesLength = (parameterTypesChars == null ? 0 : parameterTypesChars.length);
633
			int parameterNamesLength = (parameterNamesChars == null ? 0 : parameterNamesChars.length);
634
			int returnTypeLength = (returnFullTypeName == null ? 0 : returnFullTypeName.length);
635
			int delaringTypeLength = declaringFullTypeName == null ? 0 : declaringFullTypeName.length;
636
			
637
			int resultLength = selector.length + paramaterCountChars.length
638
					+ 1 + parameterTypesLength
639
					+ 1 + parameterNamesLength
640
					+ 1 + returnTypeLength
641
					+ 1 + delaringTypeLength
642
					+ 3; //modifiers
643
			
644
			//create result char array
645
			indexKey = new char[resultLength];
646
			
647
			//add type name to result
648
			int pos = 0;
649
			System.arraycopy(selector, 0, indexKey, pos, selector.length);
650
			pos += selector.length;
651
			
652
			//add param count to result
653
			if (paramaterCountChars.length > 0) {
654
				System.arraycopy(paramaterCountChars, 0, indexKey, pos, paramaterCountChars.length);
655
				pos += paramaterCountChars.length;
656
			}
657
			
658
			//add param types
659
			indexKey[pos++] = SEPARATOR;
660
			if (parameterTypesLength > 0) {
661
				System.arraycopy(parameterTypesChars, 0, indexKey, pos, parameterTypesLength);
662
				pos += parameterTypesLength;
663
			}
664
			
665
			//add param names
666
			indexKey[pos++] = SEPARATOR;
667
			if (parameterNamesLength > 0) {
668
				System.arraycopy(parameterNamesChars, 0, indexKey, pos, parameterNamesLength);
669
				pos += parameterNamesLength;
321
			}
670
			}
322
			break;
671
			
323
		case R_PREFIX_MATCH :
672
			//add return type
324
			// do a prefix query with the selector
673
			indexKey[pos++] = SEPARATOR;
325
			break;
674
			if(returnTypeLength > 0) {
326
		case R_PATTERN_MATCH :
675
				System.arraycopy(returnFullTypeName, 0, indexKey, pos, returnTypeLength);
327
			if (this.parameterCount >= 0 && !this.varargs)
676
				pos += returnTypeLength;
328
				key = createIndexKey(this.selector == null ? ONE_STAR : this.selector, this.parameterCount);
677
			}
329
			else if (this.selector != null && this.selector[this.selector.length - 1] != '*')
678
			
330
				key = CharOperation.concat(this.selector, ONE_STAR, SEPARATOR);
679
			//add declaring type
331
			// else do a pattern query with just the selector
680
			indexKey[pos++] = SEPARATOR;
332
			break;
681
			if(delaringTypeLength > 0) {
333
		case R_REGEXP_MATCH :
682
				System.arraycopy(declaringFullTypeName, 0, indexKey, pos, delaringTypeLength);
334
			// TODO (frederic) implement regular expression match
683
				pos += delaringTypeLength;
335
			break;
684
			}
685
			
686
			//add modifiers
687
			indexKey[pos++] = SEPARATOR;
688
			indexKey[pos++] = (char) modifiers;
689
			indexKey[pos++] = (char) (modifiers>>16);
690
		}
691
			
692
		return indexKey;
336
	}
693
	}
337
694
	
338
	return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
695
	/**
339
}
696
	 * <p>Create an index key for search the index for any function that matches the given selector
340
protected StringBuffer print(StringBuffer output) {
697
	 * pattern, on the optionally defined declaring type, with the given modifiers.</p>
341
	if (this.findDeclarations) {
698
	 * 
342
		output.append(this.findReferences
699
	 * @param selectorPattern
343
			? "MethodCombinedPattern: " //$NON-NLS-1$
700
	 * @param declarationType
344
			: "MethodDeclarationPattern: "); //$NON-NLS-1$
701
	 * @param modifiers
345
	} else {
702
	 * 
346
		output.append("MethodReferencePattern: "); //$NON-NLS-1$
703
	 * @return
347
	}
704
	 */
348
	if (declaringQualification != null)
705
	private static char[] createSearchIndexKey(char[] selectorPattern,
349
		output.append(declaringQualification).append('.');
706
			char[] declaringQualification, char[] declaringSimpleName, int modifiers) {
350
	if (declaringSimpleName != null)
707
		
351
		output.append(declaringSimpleName).append('.');
708
		char[] declaringFullTypeName = null;
352
	else if (declaringQualification != null)
709
		if(declaringSimpleName != null) {
353
		output.append("*."); //$NON-NLS-1$
710
			declaringFullTypeName = QualificationHelpers.createFullyQualifiedName(declaringQualification, declaringSimpleName);
354
355
	if (selector != null)
356
		output.append(selector);
357
	else
358
		output.append("*"); //$NON-NLS-1$
359
	output.append('(');
360
	if (parameterSimpleNames == null) {
361
		output.append("..."); //$NON-NLS-1$
362
	} else {
363
		for (int i = 0, max = parameterSimpleNames.length; i < max; i++) {
364
			if (i > 0) output.append(", "); //$NON-NLS-1$
365
			if (parameterQualifications[i] != null) output.append(parameterQualifications[i]).append('.');
366
			if (parameterSimpleNames[i] == null) output.append('*'); else output.append(parameterSimpleNames[i]);
367
		}
711
		}
712
		
713
		return createIndexKey(selectorPattern, -1,
714
				ONE_STAR_CHAR,
715
				ONE_STAR_CHAR,
716
				declaringFullTypeName,
717
				ONE_STAR,
718
				modifiers);
719
	}
720
	
721
	/**
722
	 * <p>Used to create an index key to search for a specific function.</p>
723
	 * 
724
	 * @param selector
725
	 * @param parameterCount
726
	 * @param parameterQualifications
727
	 * @param parameterSimpleNames
728
	 * @param parameterNames
729
	 * @param returnQualification
730
	 * @param returnSimpleName
731
	 * @param declaringQualification
732
	 * @param declaringSimpleName
733
	 * @param modifiers
734
	 * @return
735
	 */
736
	private static char[] createSearchIndexKey(char[] selector, int parameterCount,
737
			char[][] parameterQualifications,
738
			char[][] parameterSimpleNames,
739
			char[][] parameterNames,
740
			char[] returnQualification,
741
			char[] returnSimpleName,
742
			char[] declaringQualification,
743
			char[] declaringSimpleName,
744
			int modifiers) {
745
		
746
		//create fully qualified type names
747
		char[] declaringFullTypeName = QualificationHelpers.createFullyQualifiedName(declaringQualification, declaringSimpleName);
748
		char[] returnFullTypeName = QualificationHelpers.createFullyQualifiedName(returnQualification, returnSimpleName);
749
		char[][] parameterFullTypeNames = QualificationHelpers.createFullyQualifiedNames(parameterQualifications, parameterSimpleNames);
750
		
751
		return createIndexKey(selector, parameterCount, parameterFullTypeNames,
752
				parameterNames, declaringFullTypeName, returnFullTypeName, modifiers);
368
	}
753
	}
369
	output.append(')');
370
	if (returnQualification != null)
371
		output.append(" --> ").append(returnQualification).append('.'); //$NON-NLS-1$
372
	else if (returnSimpleName != null)
373
		output.append(" --> "); //$NON-NLS-1$
374
	if (returnSimpleName != null)
375
		output.append(returnSimpleName);
376
	else if (returnQualification != null)
377
		output.append("*"); //$NON-NLS-1$
378
	return super.print(output);
379
}
380
}
754
}
(-)src/org/eclipse/wst/jsdt/internal/core/util/QualificationHelpers.java (+164 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.internal.core.util;
12
13
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
14
import org.eclipse.wst.jsdt.internal.core.search.indexing.IIndexConstants;
15
16
/**
17
 * <p>Methods for helping with qualified type names, both to separate them into
18
 * qualifier and simple name, as well as recombining qualifier with simple name.</p>
19
 */
20
public class QualificationHelpers {
21
	
22
	/**
23
	 * <p>The index in the array containing the qualifier of a fully qualified name
24
	 * separated by a method in this class.</p>
25
	 * 
26
	 * @see #seperateFullyQualifedName(char[])
27
	 * @see #seperateFullyQualifedTypeNames(char[])
28
	 */
29
	public static final int QULIFIERS_INDEX = 0;
30
	
31
	/**
32
	 * <p>The index in the array containing the simple name of a fully qualified name
33
	 * separated by a method in this class.</p>
34
	 * 
35
	 * @see #seperateFullyQualifedName(char[])
36
	 * @see #seperateFullyQualifedTypeNames(char[])
37
	 */
38
	public static final int SIMPLE_NAMES_INDEX = 1;
39
	
40
	/**
41
	 * <p>Given a qualification and a simple name creates a fully qualified name.</p>
42
	 * 
43
	 * @param qualification the qualification, or <code>null</code> if no qualification
44
	 * @param simpleName the simple name, can not be <code>null</code>
45
	 * 
46
	 * @return fully qualified name created from the given <code>simpleName</code> and
47
	 * the optional <code>qualification</code>
48
	 */
49
	public static char[] createFullyQualifiedName(char[] qualification, char[] simpleName) {
50
		char[] fullTypeName = null;
51
		if(simpleName != null && simpleName.length > 0) {
52
			if(qualification != null && qualification.length > 0) {
53
				fullTypeName = CharOperation.concat(qualification, simpleName, IIndexConstants.DOT);
54
			} else {
55
				fullTypeName = simpleName;
56
			}
57
		}
58
		
59
		return fullTypeName;
60
	}
61
	
62
	/**
63
	 * <p>Given a list of qualifications and a list of simple names creates a single list of
64
	 * fully qualified names created by matching one qualification and one simple name from
65
	 * their respective lists in order.</p>
66
	 * 
67
	 * @param qualifications to match with the given <code>simpleNames</code>, this can be
68
	 * <code>null</code> if there are not qualifications, or an array of the same size as
69
	 * <code>simpleNames</code> where any one of the indices maybe <code>null</code> to signify
70
	 * there is no qualifier for that specific simple name.
71
	 * @param simpleNames to match with the given <code>qualifications</code>, this array
72
	 * can <b>not</b> be <code>null</code> and no indices in the array can be <code>null</code> either
73
	 * 
74
	 * @return an array of fully qualified names created from the given <code>simpleNames</code>
75
	 * and the optional <code>qualifications</code>
76
	 */
77
	public static char[][] createFullyQualifiedNames(char[][] qualifications, char[][] simpleNames) {
78
		char[][] fullTypeNames = null;
79
		
80
		if(simpleNames != null) {
81
			fullTypeNames = new char[simpleNames.length][];
82
			for(int i = 0; i < fullTypeNames.length; ++i) {
83
				if(qualifications != null && qualifications.length > i) {
84
					fullTypeNames[i] = createFullyQualifiedName(qualifications[i], simpleNames[i]);
85
				} else {
86
					fullTypeNames[i] = simpleNames[i];
87
				}
88
			}
89
		}
90
		
91
		return fullTypeNames;
92
	}
93
	
94
	/**
95
	 * <p>Separates a fully qualified name into its qualifier and its simple name</p>
96
	 * 
97
	 * @param fullyQualifiedName fully qualified type name to separate into its qualifier and simple name
98
	 * 
99
	 * @return a multidimensional array with one dimension for the qualifier and one for the simple name
100
	 * 
101
	 * @see #QULIFIERS_INDEX
102
	 * @see #SIMPLE_NAMES_INDEX
103
	 */
104
	public static char[][] seperateFullyQualifedName(char[] fullyQualifiedName) {
105
		char[][] seperatedTypeName = new char[2][];
106
		
107
		if(fullyQualifiedName != null && fullyQualifiedName.length > 0) {
108
			int lastIndexOfDot = CharOperation.lastIndexOf(IIndexConstants.DOT, fullyQualifiedName);
109
			if(lastIndexOfDot != -1) {
110
				seperatedTypeName[QULIFIERS_INDEX] = CharOperation.subarray(fullyQualifiedName, 0, lastIndexOfDot);
111
				seperatedTypeName[SIMPLE_NAMES_INDEX] = CharOperation.subarray(fullyQualifiedName, lastIndexOfDot+1, -1);
112
			} else {
113
				seperatedTypeName[QULIFIERS_INDEX] = null;
114
				seperatedTypeName[SIMPLE_NAMES_INDEX] = fullyQualifiedName;
115
			}
116
		}
117
		
118
		return seperatedTypeName;
119
	}
120
	
121
	/**
122
	 * <p>Separates an array of fully qualified names into their qualifiers and their simple names</p>
123
	 * 
124
	 * @param fullyQualifiedNames fully qualified type names to separate into their qualifiers and their simple names
125
	 * @param minLength the minimum length of the result, padding will be with <code>null</code>
126
	 * 
127
	 * @return resulting array consists of three indices.  The first is either {@link #QULIFIERS_INDEX} or
128
	 * {@link #SIMPLE_NAMES_INDEX}, the second is then a list of either the qualifiers or the simple names,
129
	 * depending on the first index, the last index is the char[] "string" qualifier or simple name.
130
	 * 
131
	 * @see #QULIFIERS_INDEX
132
	 * @see #SIMPLE_NAMES_INDEX
133
	 */
134
	public static char[][][] seperateFullyQualifedNames(char[] fullyQualifiedNames, int minLength) {
135
		/* 
136
		 * First index is 0 or 1 for the list of qualifiers qualifier and then the list of simple names respectively
137
		 * Second index is a list of the qualifiers and simple names
138
		 * Third index is the actual 'string' qualifier or simple name
139
		 */
140
		char[][][] seperatedTypeNames = new char[2][][];
141
		
142
		char[][] types = CharOperation.splitOn(IIndexConstants.PARAMETER_SEPARATOR, fullyQualifiedNames);
143
		if(types.length > 0) {
144
			int length = minLength > types.length ? minLength :types.length;
145
			seperatedTypeNames[QULIFIERS_INDEX] = new char[length][];
146
			seperatedTypeNames[SIMPLE_NAMES_INDEX] = new char[length][];
147
			
148
			for(int i = 0; i < types.length; ++i) {
149
				char[][] seperatedTypeName = seperateFullyQualifedName(types[i]);
150
				seperatedTypeNames[QULIFIERS_INDEX][i] = seperatedTypeName[QULIFIERS_INDEX];
151
				seperatedTypeNames[SIMPLE_NAMES_INDEX][i] = seperatedTypeName[SIMPLE_NAMES_INDEX];
152
			}
153
			
154
		} else if (minLength > 0) {
155
			seperatedTypeNames[QULIFIERS_INDEX] = new char[minLength][];
156
			seperatedTypeNames[SIMPLE_NAMES_INDEX] = new char[minLength][];
157
		} else {
158
			seperatedTypeNames[QULIFIERS_INDEX] = null;
159
			seperatedTypeNames[SIMPLE_NAMES_INDEX] = null;
160
		}
161
		
162
		return seperatedTypeNames;
163
	}
164
}
(-)src/org/eclipse/wst/jsdt/core/tests/compiler/JSDTCompilerTests.java (-76 / +3 lines)
Lines 26-31 Link Here
26
import org.eclipse.wst.jsdt.core.tests.compiler.regression.UtilTest;
26
import org.eclipse.wst.jsdt.core.tests.compiler.regression.UtilTest;
27
import org.eclipse.wst.jsdt.core.tests.compiler.util.ExclusionTests;
27
import org.eclipse.wst.jsdt.core.tests.compiler.util.ExclusionTests;
28
import org.eclipse.wst.jsdt.core.tests.interpret.BasicInterpretTest;
28
import org.eclipse.wst.jsdt.core.tests.interpret.BasicInterpretTest;
29
import org.eclipse.wst.jsdt.core.tests.search.SearchTests;
29
30
30
/**
31
/**
31
 * Run all compiler regression tests
32
 * Run all compiler regression tests
Lines 61-150 Link Here
61
	// interpret tests
62
	// interpret tests
62
	standardTests.add(BasicInterpretTest.class);
63
	standardTests.add(BasicInterpretTest.class);
63
	
64
	
64
	
65
	
66
	
67
//	standardTests.addAll(JavadocTest.allTestClasses);
68
65
69
//	standardTests.add(BasicErrorTests.class);
70
71
	//	// add all javadoc tests
72
//	for (int i=0, l=JavadocTest.ALL_CLASSES.size(); i<l; i++) {
73
//		standardTests.add(JavadocTest.ALL_CLASSES.get(i));
74
//	}
75
//
76
	TestSuite all = new TestSuite("JSDT 'Compiler' Tests");
66
	TestSuite all = new TestSuite("JSDT 'Compiler' Tests");
77
	all.addTest(ExclusionTests.suite());
67
	all.addTest(ExclusionTests.suite());
78
	
68
	
79
	
80
//	int possibleComplianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
81
//	if ((possibleComplianceLevels & AbstractCompilerTest.F_1_3) != 0) {
82
//		ArrayList tests_1_3 = (ArrayList)standardTests.clone();
83
//		tests_1_3.add(Compliance_1_3.class);
84
//		tests_1_3.add(JavadocTest_1_3.class);
85
//		// Reset forgotten subsets tests
86
//		TestCase.TESTS_PREFIX = null;
87
//		TestCase.TESTS_NAMES = null;
88
//		TestCase.TESTS_NUMBERS= null;
89
//		TestCase.TESTS_RANGE = null;
90
//		TestCase.RUN_ONLY_ID = null;
91
//		all.addTest(AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_3, tests_1_3));
92
//	}
93
//	if ((possibleComplianceLevels & AbstractCompilerTest.F_1_4) != 0) {
94
//		ArrayList tests_1_4 = (ArrayList)standardTests.clone();
95
//		tests_1_4.add(AssertionTest.class);
96
//		tests_1_4.add(Compliance_1_4.class);
97
//		tests_1_4.add(ClassFileReaderTest_1_4.class);
98
//		tests_1_4.add(JavadocTest_1_4.class);
99
//		// Reset forgotten subsets tests
100
//		TestCase.TESTS_PREFIX = null;
101
//		TestCase.TESTS_NAMES = null;
102
//		TestCase.TESTS_NUMBERS= null;
103
//		TestCase.TESTS_RANGE = null;
104
//		TestCase.RUN_ONLY_ID = null;
105
//		all.addTest(AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_4, tests_1_4));
106
//	}
107
//	if ((possibleComplianceLevels & AbstractCompilerTest.F_1_5) != 0) {
108
//		ArrayList tests_1_5 = (ArrayList)standardTests.clone();
109
//		tests_1_5.addAll(RunComparableTests.ALL_CLASSES);
110
//		tests_1_5.add(AssertionTest.class);
111
//		tests_1_5.add(ClassFileReaderTest_1_5.class);
112
//		tests_1_5.add(GenericTypeSignatureTest.class);
113
//		tests_1_5.add(InternalHexFloatTest.class);
114
//		tests_1_5.add(JavadocTest_1_5.class);
115
//		tests_1_5.add(BatchCompilerTest.class);
116
//		tests_1_5.add(ExternalizeStringLiterals15Test.class);
117
//		// Reset forgotten subsets tests
118
//		TestCase.TESTS_PREFIX = null;
119
//		TestCase.TESTS_NAMES = null;
120
//		TestCase.TESTS_NUMBERS= null;
121
//		TestCase.TESTS_RANGE = null;
122
//		TestCase.RUN_ONLY_ID = null;
123
//		all.addTest(AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_5, tests_1_5));
124
//	}
125
//	if ((possibleComplianceLevels & AbstractCompilerTest.F_1_6) != 0) {
126
//		ArrayList tests_1_6 = (ArrayList)standardTests.clone();
127
//		tests_1_6.addAll(RunComparableTests.ALL_CLASSES);
128
//		tests_1_6.add(AssertionTest.class);
129
//		tests_1_6.add(ClassFileReaderTest_1_5.class);
130
//		tests_1_6.add(GenericTypeSignatureTest.class);
131
//		tests_1_6.add(InternalHexFloatTest.class);
132
//		tests_1_6.add(JavadocTest_1_5.class);
133
//		tests_1_6.add(BatchCompilerTest.class);
134
//		tests_1_6.add(ExternalizeStringLiterals15Test.class);
135
//		tests_1_6.add(StackMapAttributeTest.class);
136
//		// Reset forgotten subsets tests
137
//		TestCase.TESTS_PREFIX = null;
138
//		TestCase.TESTS_NAMES = null;
139
//		TestCase.TESTS_NUMBERS= null;
140
//		TestCase.TESTS_RANGE = null;
141
//		TestCase.RUN_ONLY_ID = null;
142
//		all.addTest(AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_6, tests_1_6));
143
//	}
144
	for (Iterator iter = standardTests.iterator(); iter.hasNext();) {
69
	for (Iterator iter = standardTests.iterator(); iter.hasNext();) {
145
		Class test = (Class) iter.next();
70
		Class test = (Class) iter.next();
146
		all.addTestSuite(test); 
71
		all.addTestSuite(test); 
147
	}
72
	}
73
	
74
	all.addTest(SearchTests.suite());
148
	return all;
75
	return all;
149
} 
76
} 
150
}
77
}
(-)src/org/eclipse/wst/jsdt/core/tests/search/SearchTests.java (+43 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.core.tests.search;
12
13
import junit.framework.Test;
14
import junit.framework.TestSuite;
15
16
/**
17
 * <p>Test suite for all JSDT Search Tests.<p>
18
 */
19
public class SearchTests extends TestSuite {
20
	/**
21
	 * <p>Default constructor</p>
22
	 */
23
	public SearchTests() {
24
		this("JavaScript Search Tests");
25
	}
26
27
	/**
28
	 * <p>Constructor with specified test name.</p>
29
	 *
30
	 * @param testName of this test suite
31
	 */
32
	public SearchTests(String testName) {
33
		super(testName);
34
	}
35
	
36
	public static Test suite() {
37
		TestSuite all = new TestSuite("JavaScript Search Tests");
38
		
39
		all.addTestSuite(TestMethodPattern.class);
40
		
41
		return all;
42
	}
43
}
(-)src/org/eclipse/wst/jsdt/core/tests/search/TestMethodPattern.java (+426 lines)
Added Link Here
1
/**
2
 * 
3
 */
4
package org.eclipse.wst.jsdt.core.tests.search;
5
6
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
7
import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
8
import org.eclipse.wst.jsdt.internal.core.search.indexing.IIndexConstants;
9
import org.eclipse.wst.jsdt.internal.core.search.matching.MethodPattern;
10
11
import junit.framework.TestCase;
12
13
/**
14
 * <p>Tests for MethodPattern.</p>
15
 * 
16
 * @see MethodPattern
17
 */
18
public class TestMethodPattern extends TestCase {
19
	
20
	public void testCreateIndexKey_0() {
21
		runCreateIndexKeyTest("myFunction/0/////", "myFunction".toCharArray(), 0, null, null, null, null, 0);
22
	}
23
	
24
	public void testCreateIndexKey_1() {
25
		runCreateIndexKeyTest("myFunction/1/////", "myFunction".toCharArray(), 1, null, null, null, null, 0);
26
	}
27
	
28
	public void testCreateIndexKey_2() {
29
		runCreateIndexKeyTest("myFunction/0///String//",
30
				"myFunction".toCharArray(), 0, null, null, null, "String".toCharArray(), 0);
31
	}
32
	
33
	public void testCreateIndexKey_3() {
34
		runCreateIndexKeyTest("myFunction/0////foo.bar.Type/",
35
				"myFunction".toCharArray(), 0, null, null, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
36
	}
37
	
38
	public void testCreateIndexKey_4() {
39
		runCreateIndexKeyTest("myFunction/0///String/foo.bar.Type/",
40
				"myFunction".toCharArray(), 0, null, null, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
41
	}
42
	
43
	public void testCreateIndexKey_5() {
44
		runCreateIndexKeyTest("myFunction/2//param1,param2///",
45
				"myFunction".toCharArray(), 2, null, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
46
	}
47
	
48
	public void testCreateIndexKey_6() {
49
		runCreateIndexKeyTest("myFunction/2//param1,param2/String//",
50
				"myFunction".toCharArray(), 2, null, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
51
	}
52
	
53
	public void testCreateIndexKey_7() {
54
		runCreateIndexKeyTest("myFunction/2//param1,param2//foo.bar.Type/",
55
				"myFunction".toCharArray(), 2, null, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
56
	}
57
	
58
	public void testCreateIndexKey_8() {
59
		runCreateIndexKeyTest("myFunction/2//param1,param2/String/foo.bar.Type/",
60
				"myFunction".toCharArray(), 2, null, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
61
	}
62
	
63
	public void testCreateIndexKey_9() {
64
		runCreateIndexKeyTest("myFunction/2/String,Number/param1,param2///",
65
				"myFunction".toCharArray(), 2, new char[][] { "String".toCharArray(), "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
66
	}
67
	
68
	public void testCreateIndexKey_10() {
69
		runCreateIndexKeyTest("myFunction/2/String,Number/param1,param2/String//",
70
				"myFunction".toCharArray(), 2, new char[][] { "String".toCharArray(), "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
71
	}
72
	
73
	public void testCreateIndexKey_11() {
74
		runCreateIndexKeyTest("myFunction/2/String,Number/param1,param2//foo.bar.Type/",
75
				"myFunction".toCharArray(), 2, new char[][] { "String".toCharArray(), "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
76
	}
77
	
78
	public void testCreateIndexKey_12() {
79
		runCreateIndexKeyTest("myFunction/2/String,Number/param1,param2/String/foo.bar.Type/",
80
				"myFunction".toCharArray(), 2, new char[][] { "String".toCharArray(), "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
81
	}
82
	
83
	public void testCreateIndexKey_13() {
84
		runCreateIndexKeyTest("myFunction/2/,Number/param1,param2///",
85
				"myFunction".toCharArray(), 2, new char[][] { null, "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
86
	}
87
	
88
	public void testCreateIndexKey_14() {
89
		runCreateIndexKeyTest("myFunction/2/,Number/param1,param2/String//",
90
				"myFunction".toCharArray(), 2, new char[][] { null, "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
91
	}
92
	
93
	public void testCreateIndexKey_15() {
94
		runCreateIndexKeyTest("myFunction/2/,Number/param1,param2//foo.bar.Type/",
95
				"myFunction".toCharArray(), 2, new char[][] { null, "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
96
	}
97
	
98
	public void testCreateIndexKey_16() {
99
		runCreateIndexKeyTest("myFunction/2/,Number/param1,param2/String/foo.bar.Type/",
100
				"myFunction".toCharArray(), 2, new char[][] { null, "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
101
	}
102
	
103
	public void testCreateIndexKey_17() {
104
		runCreateIndexKeyTest("myFunction/2/,Number/param1,param2///",
105
				"myFunction".toCharArray(), 2, new char[][] { new char[0], "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
106
	}
107
	
108
	public void testCreateIndexKey_18() {
109
		runCreateIndexKeyTest("myFunction/2/,Number/param1,param2/String//",
110
				"myFunction".toCharArray(), 2, new char[][] { new char[0], "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
111
	}
112
	
113
	public void testCreateIndexKey_19() {
114
		runCreateIndexKeyTest("myFunction/2/,Number/param1,param2//foo.bar.Type/",
115
				"myFunction".toCharArray(), 2, new char[][] { new char[0], "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
116
	}
117
	
118
	public void testCreateIndexKey_20() {
119
		runCreateIndexKeyTest("myFunction/2/,Number/param1,param2/String/foo.bar.Type/",
120
				"myFunction".toCharArray(), 2, new char[][] { new char[0], "Number".toCharArray()}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
121
	}
122
	
123
	public void testCreateIndexKey_21() {
124
		runCreateIndexKeyTest("myFunction/2/String,/param1,param2///",
125
				"myFunction".toCharArray(), 2, new char[][] {"String".toCharArray(), null}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
126
	}
127
	
128
	public void testCreateIndexKey_22() {
129
		runCreateIndexKeyTest("myFunction/2/String,/param1,param2/String//",
130
				"myFunction".toCharArray(), 2, new char[][] {"String".toCharArray(), null}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
131
	}
132
	
133
	public void testCreateIndexKey_23() {
134
		runCreateIndexKeyTest("myFunction/2/String,/param1,param2//foo.bar.Type/",
135
				"myFunction".toCharArray(), 2, new char[][] {"String".toCharArray(), null}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
136
	}
137
	
138
	public void testCreateIndexKey_24() {
139
		runCreateIndexKeyTest("myFunction/2/String,/param1,param2/String/foo.bar.Type/",
140
				"myFunction".toCharArray(), 2, new char[][] {"String".toCharArray(), null}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
141
	}
142
	
143
	public void testCreateIndexKey_25() {
144
		runCreateIndexKeyTest("myFunction/2/String,/param1,param2///",
145
				"myFunction".toCharArray(), 2, new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, null, 0);
146
	}
147
	
148
	public void testCreateIndexKey_26() {
149
		runCreateIndexKeyTest("myFunction/2/String,/param1,param2/String//",
150
				"myFunction".toCharArray(), 2, new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, null, "String".toCharArray(), 0);
151
	}
152
	
153
	public void testCreateIndexKey_27() {
154
		runCreateIndexKeyTest("myFunction/2/String,/param1,param2//foo.bar.Type/",
155
				"myFunction".toCharArray(), 2, new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), null, ClassFileConstants.AccStatic);
156
	}
157
	
158
	public void testCreateIndexKey_28() {
159
		runCreateIndexKeyTest("myFunction/2/String,/param1,param2/String/foo.bar.Type/", "myFunction".toCharArray(), 2, new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
160
	}
161
	
162
	public void testCreateIndexKey_29() {
163
		char[] keyChars = MethodPattern.createIndexKey("".toCharArray(), 2, new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
164
		
165
		String key = null;
166
		if(keyChars != null) {
167
			key = new String(keyChars);
168
		}
169
		
170
		assertNull("If selector is empty the key should be null.\nWAS:\n" + key, key);
171
	}
172
	
173
	public void testCreateIndexKey_30() {
174
		char[] keyChars = MethodPattern.createIndexKey(null, 2, new char[][] {"String".toCharArray(), new char[0]}, new char[][] { "param1".toCharArray(), "param2".toCharArray()}, "foo.bar.Type".toCharArray(), "String".toCharArray(), ClassFileConstants.AccStatic);
175
		
176
		String key = null;
177
		if(keyChars != null) {
178
			key = new String(keyChars);
179
		}
180
		
181
		assertNull("If selector is empty the key should be null.\nWAS:\n" + key, key);
182
	}
183
	
184
	public void testDecodeIndexKey_0() {
185
		runDecodeIndexKeyTest("myFunction/0////", "myFunction", 0, null, null, null,null, null, null, null, 0);
186
	}
187
	
188
	public void testDecodeIndexKey_2() {
189
		runDecodeIndexKeyTest("myFunction/0///String/", "myFunction", 0, null, null, null,null, "String", null, null, 0);
190
	}
191
	
192
	public void testDecodeIndexKey_3() {
193
		runDecodeIndexKeyTest("myFunction/0////foo.bar.Type", "myFunction", 0, null, null, null,null, null, "foo.bar", "Type", 0);
194
	}
195
	
196
	public void testDecodeIndexKey_4() {
197
		runDecodeIndexKeyTest("myFunction/0///String/foo.bar.Type", "myFunction", 0, null, null, null,null, "String", "foo.bar", "Type", 0);
198
	}
199
	
200
	public void testDecodeIndexKey_5() {
201
		runDecodeIndexKeyTest("myFunction/2//param1,param2//", "myFunction", 2, new String[2], new String[2], new String[] {"param1", "param2"},null, null, null, null, 0);
202
	}
203
	
204
	public void testDecodeIndexKey_6() {
205
		runDecodeIndexKeyTest("myFunction/2//param1,param2/String/", "myFunction", 2, new String[2], new String[2], new String[] {"param1", "param2"},null, "String", null, null, 0);
206
	}
207
	
208
	public void testDecodeIndexKey_7() {
209
		runDecodeIndexKeyTest("myFunction/2//param1,param2//foo.bar.Type", "myFunction", 2, new String[2], new String[2], new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
210
	}
211
	
212
	public void testDecodeIndexKey_8() {
213
		runDecodeIndexKeyTest("myFunction/2//param1,param2/String/foo.bar.Type", "myFunction", 2, new String[2], new String[2], new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
214
	}
215
	
216
	public void testDecodeIndexKey_9() {
217
		runDecodeIndexKeyTest("myFunction/2/String,Number/param1,param2//", "myFunction", 2, new String[]{null, null}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, null, null, null, 0);
218
	}
219
	
220
	public void testDecodeIndexKey_10() {
221
		runDecodeIndexKeyTest("myFunction/2/String,Number/param1,param2/String/", "myFunction", 2, new String[]{null, null}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, "String", null, null, 0);
222
	}
223
	
224
	public void testDecodeIndexKey_11() {
225
		runDecodeIndexKeyTest("myFunction/2/String,Number/param1,param2//foo.bar.Type", "myFunction", 2, new String[]{null, null}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
226
	}
227
	
228
	public void testDecodeIndexKey_12() {
229
		runDecodeIndexKeyTest("myFunction/2/String,Number/param1,param2/String/foo.bar.Type", "myFunction", 2, new String[]{null, null}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
230
	}
231
	
232
	public void testDecodeIndexKey_13() {
233
		runDecodeIndexKeyTest("myFunction/2/,Number/param1,param2//", "myFunction", 2, new String[]{null, null}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, null, null, null, 0);
234
	}
235
	
236
	public void testDecodeIndexKey_14() {
237
		runDecodeIndexKeyTest("myFunction/2/,Number/param1,param2/String/", "myFunction", 2, new String[]{null, null}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, "String", null, null, 0);
238
	}
239
	
240
	public void testDecodeIndexKey_15() {
241
		runDecodeIndexKeyTest("myFunction/2/,Number/param1,param2//foo.bar.Type", "myFunction", 2, new String[]{null, null}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
242
	}
243
	
244
	public void testDecodeIndexKey_16() {
245
		runDecodeIndexKeyTest("myFunction/2/,Number/param1,param2/String/foo.bar.Type", "myFunction", 2, new String[]{null, null}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
246
	}
247
	
248
	public void testDecodeIndexKey_17() {
249
		runDecodeIndexKeyTest("myFunction/2/String,/param1,param2//", "myFunction", 2, new String[]{null, null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, null, null, null, 0);
250
	}
251
	
252
	public void testDecodeIndexKey_18() {
253
		runDecodeIndexKeyTest("myFunction/2/String,/param1,param2/String/", "myFunction", 2, new String[]{null, null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, "String", null, null, 0);
254
	}
255
	
256
	public void testDecodeIndexKey_19() {
257
		runDecodeIndexKeyTest("myFunction/2/String,/param1,param2//foo.bar.Type", "myFunction", 2, new String[]{null, null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
258
	}
259
	
260
	public void testDecodeIndexKey_20() {
261
		runDecodeIndexKeyTest("myFunction/2/String,/param1,param2/String/foo.bar.Type", "myFunction", 2, new String[]{null, null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
262
	}
263
	
264
	public void testDecodeIndexKey_21() {
265
		runDecodeIndexKeyTest("myFunction/2/bar.foo.String,neto.crazy.Number/param1,param2//", "myFunction", 2, new String[]{"bar.foo", "neto.crazy"}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, null, null, null, 0);
266
	}
267
	
268
	public void testDecodeIndexKey_22() {
269
		runDecodeIndexKeyTest("myFunction/2/bar.foo.String,neto.crazy.Number/param1,param2/String/", "myFunction", 2, new String[]{"bar.foo", "neto.crazy"}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, "String", null, null, 0);
270
	}
271
	
272
	public void testDecodeIndexKey_23() {
273
		runDecodeIndexKeyTest("myFunction/2/bar.foo.String,neto.crazy.Number/param1,param2//foo.bar.Type", "myFunction", 2, new String[]{"bar.foo", "neto.crazy"}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
274
	}
275
	
276
	public void testDecodeIndexKey_24() {
277
		runDecodeIndexKeyTest("myFunction/2/bar.foo.String,neto.crazy.Number/param1,param2/String/foo.bar.Type", "myFunction", 2, new String[]{"bar.foo", "neto.crazy"}, new String[]{"String", "Number"}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
278
	}
279
	
280
	public void testDecodeIndexKey_25() {
281
		runDecodeIndexKeyTest("myFunction/2/,neto.crazy.Number/param1,param2//", "myFunction", 2, new String[]{null, "neto.crazy"}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, null, null, null, 0);
282
	}
283
	
284
	public void testDecodeIndexKey_26() {
285
		runDecodeIndexKeyTest("myFunction/2/,neto.crazy.Number/param1,param2/String/", "myFunction", 2, new String[]{null, "neto.crazy"}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, "String", null, null, 0);
286
	}
287
	
288
	public void testDecodeIndexKey_27() {
289
		runDecodeIndexKeyTest("myFunction/2/,neto.crazy.Number/param1,param2//foo.bar.Type", "myFunction", 2, new String[]{null, "neto.crazy"}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
290
	}
291
	
292
	public void testDecodeIndexKey_28() {
293
		runDecodeIndexKeyTest("myFunction/2/,neto.crazy.Number/param1,param2/String/foo.bar.Type", "myFunction", 2, new String[]{null, "neto.crazy"}, new String[]{null, "Number"}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
294
	}
295
	
296
	public void testDecodeIndexKey_29() {
297
		runDecodeIndexKeyTest("myFunction/2/bar.foo.String,/param1,param2//", "myFunction", 2, new String[]{"bar.foo", null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, null, null, null, 0);
298
	}
299
	
300
	public void testDecodeIndexKey_30() {
301
		runDecodeIndexKeyTest("myFunction/2/bar.foo.String,/param1,param2/String/", "myFunction", 2, new String[]{"bar.foo", null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, "String", null, null, 0);
302
	}
303
	
304
	public void testDecodeIndexKey_31() {
305
		runDecodeIndexKeyTest("myFunction/2/bar.foo.String,/param1,param2//foo.bar.Type", "myFunction", 2, new String[]{"bar.foo", null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, null, "foo.bar", "Type", 0);
306
	}
307
	
308
	public void testDecodeIndexKey_32() {
309
		runDecodeIndexKeyTest("myFunction/2/bar.foo.String,/param1,param2/String/foo.bar.Type", "myFunction", 2, new String[]{"bar.foo", null}, new String[]{"String", null}, new String[] {"param1", "param2"},null, "String", "foo.bar", "Type", 0);
310
	}
311
	
312
	/**
313
	 * <p>Runs the asserts for a single create index key test.</p>
314
	 * 
315
	 * @param expected
316
	 * @param selector
317
	 * @param parameterCount
318
	 * @param parameterFullTypeNames
319
	 * @param parameterNames
320
	 * @param declaringFullTypeName
321
	 * @param returnFullTypeName
322
	 * @param modifiers
323
	 */
324
	private static void runCreateIndexKeyTest(String expected,
325
			char[] selector,
326
			int parameterCount,
327
			char[][] parameterFullTypeNames,
328
			char[][] parameterNames,
329
			char[] declaringFullTypeName,
330
			char[] returnFullTypeName,
331
			int modifiers) {
332
		
333
		char[] indexKey = MethodPattern.createIndexKey(selector, parameterCount, parameterFullTypeNames, parameterNames, declaringFullTypeName, returnFullTypeName, modifiers);
334
		
335
		String expectedWithModifiers = expected + (char) modifiers + (char) (modifiers>>16);
336
		
337
		assertNotNull("The created index key should not be null.\nEXPECTED:\n" + expectedWithModifiers, indexKey);
338
		
339
		assertTrue("The expected index key does not match the generated index key.\nWAS:\n" + new String(indexKey) + "\nEXPECTED:\n" + expected,
340
				CharOperation.equals(indexKey, expectedWithModifiers.toCharArray()));
341
	}
342
	
343
	/**
344
	 * <p>Runs a single decode index key test</p>
345
	 * 
346
	 * @param key
347
	 * @param selector
348
	 * @param parameterCount
349
	 * @param parameterQualifications
350
	 * @param parameterSimpleNames
351
	 * @param parameterNames
352
	 * @param returnQualification
353
	 * @param returnSimpleName
354
	 * @param declaringQualification
355
	 * @param declaringSimpleName
356
	 * @param modifiers
357
	 */
358
	private static void runDecodeIndexKeyTest(String key,
359
			String selector,
360
			int parameterCount,
361
			String[] parameterQualifications,
362
			String[] parameterSimpleNames,
363
			String[] parameterNames,
364
			String returnQualification,
365
			String returnSimpleName,
366
			String declaringQualification,
367
			String declaringSimpleName,
368
			int modifiers) {
369
		
370
		char[] keyWithModifiers = new char[key.length() + 3];
371
		System.arraycopy(key.toCharArray(), 0, keyWithModifiers, 0, key.length());
372
		keyWithModifiers[keyWithModifiers.length-3] = '/';
373
		keyWithModifiers[keyWithModifiers.length-2] = (char) modifiers;
374
		keyWithModifiers[keyWithModifiers.length-1] = (char) (modifiers>>16);
375
		
376
		MethodPattern pattern = new MethodPattern(false, false, false, null, 0);
377
		pattern = (MethodPattern)pattern.getBlankPattern();
378
		pattern.decodeIndexKey(keyWithModifiers);
379
		
380
		assertEquals("Expected selector does not equal decoded selector.", selector, pattern.selector);
381
		assertEquals("Expected parameter count does not equal decoded parameter count.", parameterCount, pattern.parameterCount);
382
		assertEquals("Expected parameter qualifications does not equal decoded parameter qualifications.", parameterQualifications, pattern.parameterQualifications);
383
		assertEquals("Expected parameter simple names does not equal decoded parameter simple names.", parameterSimpleNames, pattern.parameterSimpleNames);
384
		assertEquals("Expected parameter names does not equal decoded parameter names.", parameterNames, pattern.parameterNames);
385
		assertEquals("Expected return qualification does not equal decoded return wualification.", returnQualification, pattern.returnQualification);
386
		assertEquals("Expected return simple name does not equal decoded return simple name.", returnSimpleName, pattern.returnSimpleName);
387
		assertEquals("Expected declaring qualification does not equal decoded declaring qualification.", declaringQualification, pattern.declaringQualification);
388
		assertEquals("Expected declaring simple name does not equal decoded declaring simple name.", declaringSimpleName, pattern.declaringSimpleName);
389
	}
390
	
391
	private static void assertEquals(String message, String expected, char[] chars) {
392
		String actual = null;
393
		if(chars != null) {
394
			actual = new String(chars);
395
		}
396
		
397
		assertEquals(message, expected, actual);
398
	}
399
	
400
	private static void assertEquals(String message, String[] expected, char[][] actual) {
401
		
402
		String expectedColappsed = null;
403
		String actualColappsed = null;
404
		if(actual != null) {
405
			char[] actualColappsedChars = CharOperation.concatWith(actual, IIndexConstants.PARAMETER_SEPARATOR, false);
406
			if(actualColappsedChars != null) {
407
				actualColappsed = new String(actualColappsedChars);
408
			}
409
		}
410
		
411
		if(expected != null) {
412
			expectedColappsed = "";
413
			for(int i = 0; i < expected.length; ++i) {
414
				if(i > 0) {
415
					expectedColappsed += ",";
416
				}
417
				
418
				if(expected[i] != null) {
419
					expectedColappsed += expected[i];
420
				}
421
			}
422
		}
423
		
424
		assertEquals(message, expectedColappsed, actualColappsed);
425
	}
426
}
(-).settings/org.eclipse.core.resources.prefs (-1 / +2 lines)
Lines 1-4 Link Here
1
#Mon Jan 28 15:47:49 CST 2008
1
#Thu Jul 14 08:12:53 EDT 2011
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
encoding//src/org/eclipse/wst/jsdt/core/tests/model/JSDTModelTests.java=US-ASCII
3
encoding/<project>=ISO-8859-1
4
encoding/<project>=ISO-8859-1
4
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
5
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
(-)src/org/eclipse/wst/jsdt/core/tests/model/CompletionTests2.java (-2416 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.core.tests.model;
12
13
import java.io.File;
14
import java.io.FileOutputStream;
15
import java.io.IOException;
16
import java.util.HashMap;
17
import java.util.Map;
18
import java.util.StringTokenizer;
19
20
import junit.framework.ComparisonFailure;
21
import junit.framework.Test;
22
23
import org.eclipse.core.resources.IFile;
24
import org.eclipse.core.resources.IProject;
25
import org.eclipse.core.resources.IWorkspaceRunnable;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.IPath;
28
import org.eclipse.core.runtime.IProgressMonitor;
29
import org.eclipse.core.runtime.Path;
30
import org.eclipse.wst.jsdt.core.IAccessRule;
31
import org.eclipse.wst.jsdt.core.IIncludePathAttribute;
32
import org.eclipse.wst.jsdt.core.IIncludePathEntry;
33
import org.eclipse.wst.jsdt.core.IJavaScriptProject;
34
import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
35
import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer;
36
import org.eclipse.wst.jsdt.core.JavaScriptCore;
37
import org.eclipse.wst.jsdt.internal.codeassist.RelevanceConstants;
38
39
public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants {
40
	
41
	public static final String DEFUALT_JSDTSCOPE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
42
												  "<classpath>\n" + 
43
												   "       <classpathentry kind=\"src\" path=\"\"/>\n" + 
44
												   "       <classpathentry kind=\"con\" path=\"org.eclipse.wst.jsdt.launching.JRE_CONTAINER\"/>\n"+
45
												   "       <classpathentry kind=\"output\" path=\"\"/>\n"+
46
												   "</classpath>";
47
	/* 
48
		.project = DEFAULT_PROJECT_LEFT + project name + DEFAULT_PROJECT_RIGHT;
49
	*/
50
	public static final String DEFAULT_PROJECT_LEFT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
51
													  "<projectDescription>\n" + 
52
													  "     <name>";
53
		
54
		
55
	public static final String DEFAULT_PROJECT_RIGHT ="</name>\n" + 
56
													  "     <comment></comment>\n" +
57
													  "     <projects>\n" +
58
													  "     </projects>\n"+
59
													  "     <buildSpec>\n"+
60
													  "     	<buildCommand>\n"+
61
													  "            <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>\n"+
62
													  "               <arguments>\n"+
63
													  "               </arguments>\n"+
64
													  "         </buildCommand>\n"+
65
													  "     </buildSpec>\n"+
66
													  "     <natures>\n"+
67
													  "       <nature>org.eclipse.wst.jsdt.core.jsNature</nature>\n"+
68
													  "     </natures>\n" +
69
													  "</projectDescription>";
70
71
	
72
		
73
		
74
		
75
	public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer {
76
		
77
		public static class DefaultContainer implements IJsGlobalScopeContainer {
78
			char[][] libPaths;
79
			boolean[] areExported;
80
			String[] forbiddenReferences;
81
			public DefaultContainer(char[][] libPaths, boolean[] areExported, String[] forbiddenReferences) {
82
				this.libPaths = libPaths;
83
				this.areExported = areExported;
84
				this.forbiddenReferences = forbiddenReferences;
85
			}
86
			/**
87
			 * @deprecated Use {@link #getIncludepathEntries()} instead
88
			 */
89
			public IIncludePathEntry[] getClasspathEntries() {
90
				return getIncludepathEntries();
91
			}
92
			public IIncludePathEntry[] getIncludepathEntries() {
93
				int length = this.libPaths.length;
94
				IIncludePathEntry[] entries = new IIncludePathEntry[length];
95
				for (int j = 0; j < length; j++) {
96
				    IPath path = new Path(new String(this.libPaths[j]));
97
				    boolean isExported = this.areExported[j];
98
		
99
				    IAccessRule[] accessRules;
100
				    if(forbiddenReferences != null && forbiddenReferences[j]!= null && forbiddenReferences[j].length() != 0) {
101
					    StringTokenizer tokenizer = new StringTokenizer(forbiddenReferences[j], ";");
102
					    int count = tokenizer.countTokens();
103
					    accessRules = new IAccessRule[count];
104
					    String token = null;
105
					    for (int i = 0; i < count; i++) {
106
					    	token = tokenizer.nextToken();
107
							accessRules[i] = JavaScriptCore.newAccessRule(new Path(token), IAccessRule.K_NON_ACCESSIBLE);
108
						}
109
					} else {
110
						accessRules = new IAccessRule[0];
111
					}
112
				    if (path.segmentCount() == 1) {
113
				        entries[j] = JavaScriptCore.newProjectEntry(path, accessRules, true, new IIncludePathAttribute[0], isExported);
114
				    } else {
115
						entries[j] = JavaScriptCore.newLibraryEntry(path, null, null, accessRules, new IIncludePathAttribute[0], isExported);
116
				    }
117
				}
118
				return entries;
119
			}
120
			public String getDescription() {
121
				return "Test container";
122
			}
123
			public int getKind() {
124
				return IJsGlobalScopeContainer.K_APPLICATION;
125
			}
126
			public IPath getPath() {
127
				return new Path("org.eclipse.wst.jsdt.core.tests.model.TEST_CONTAINER");
128
			}
129
			/* (non-Javadoc)
130
			 * @see org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer#resolvedLibraryImport(java.lang.String)
131
			 */
132
			public String[] resolvedLibraryImport(String a) {
133
				return new String[] {a};
134
			}
135
		}
136
		
137
		Map containerValues;
138
		CoreException exception;
139
		
140
		public CompletionContainerInitializer(String projectName, String[] libPaths, boolean[] areExported) {
141
			this(projectName, libPaths, areExported, null);
142
		}
143
		public CompletionContainerInitializer(String projectName, String[] libPaths, boolean[] areExported, String[] forbiddenRefrences) {
144
			containerValues = new HashMap();
145
			
146
			int libPathsLength = libPaths.length;
147
			char[][] charLibPaths = new char[libPathsLength][];
148
			for (int i = 0; i < libPathsLength; i++) {
149
				charLibPaths[i] = libPaths[i].toCharArray();
150
			}
151
			containerValues.put(
152
				projectName, 
153
				newContainer(charLibPaths, areExported, forbiddenRefrences)
154
			);
155
		}
156
		protected DefaultContainer newContainer(final char[][] libPaths, final boolean[] areExperted, final String[] forbiddenRefrences) {
157
			return new DefaultContainer(libPaths, areExperted, forbiddenRefrences);
158
		}
159
		public boolean allowFailureContainer() {
160
			return true;
161
		}
162
		public void initialize(IPath containerPath, IJavaScriptProject project) throws CoreException {
163
			if (containerValues == null) return;
164
			try {
165
				JavaScriptCore.setJsGlobalScopeContainer(
166
					containerPath, 
167
					new IJavaScriptProject[] {project},
168
					new IJsGlobalScopeContainer[] {(IJsGlobalScopeContainer)containerValues.get(project.getElementName())}, 
169
					null);
170
			} catch (CoreException e) {
171
				this.exception = e;
172
				throw e;
173
			}
174
		}
175
	}
176
public CompletionTests2(String name) {
177
	super(name);
178
}
179
public void setUpSuite() throws Exception {
180
	super.setUpSuite();
181
	
182
	setUpJavaProject("Completion");
183
}
184
public void tearDownSuite() throws Exception {
185
	deleteProject("Completion");
186
	
187
	super.tearDownSuite();
188
}
189
190
protected static void assertResults(String expected, String actual) {
191
	try {
192
		assertEquals(expected, actual);
193
	} catch(ComparisonFailure c) {
194
		System.out.println(actual);
195
		System.out.println();
196
		throw c;
197
	}
198
}
199
static {
200
//	TESTS_NAMES = new String[] { "testBug96950" };
201
}
202
public static Test suite() {
203
	return buildModelTestSuite(CompletionTests2.class);
204
}
205
206
File createFile(File parent, String name, String content) throws IOException {
207
	File file = new File(parent, name);
208
	FileOutputStream out = new FileOutputStream(file);
209
	out.write(content.getBytes());
210
	out.close();
211
	return file;
212
}
213
File createDirectory(File parent, String name) {
214
	File dir = new File(parent, name);
215
	dir.mkdirs();
216
	return dir;
217
}
218
/**
219
 * Test for bug 29832
220
 */
221
public void testBug29832() throws Exception {
222
	try {
223
		// create variable
224
//		JavaScriptCore.setClasspathVariables(
225
//			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
226
//			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
227
//			null);
228
229
		// create P1
230
	//	IFile f = getFile("/Completion/lib.jar");
231
		IFile f = getFile("/Completion/ZZZ.js");
232
		
233
		
234
		IJavaScriptProject p = this.createJavaProject(
235
			"P1",
236
			new String[]{"/"},
237
			new String[]{});
238
		IFile libFile = this.createFile("/P1/ZZZ.js", f.getContents());
239
		this.addLibraryEntry(p, libFile.getLocation().toString(), true);
240
		
241
		// create P2
242
		this.createJavaProject(
243
			"P2",
244
			new String[]{"/"},
245
			new String[]{},
246
			new String[]{"/P1"});
247
		this.createFile(
248
			"/P2/X.js",
249
			"function testZZZClass {\n"+
250
			"  var z = new ZZZ();\n"+
251
			"  z;\n" +
252
			"}");
253
		
254
		waitUntilIndexesReady();
255
		
256
		// do completion
257
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
258
		IJavaScriptUnit cu= getCompilationUnit("P2", "", "", "X.js");
259
		
260
		String str = cu.getSource();
261
		String completeBehind = "z";
262
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
263
		cu.codeComplete(cursorLocation, requestor);
264
265
//		assertEquals(
266
//			"element:ZZZ    completion:pz.ZZZ    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED),
267
//			requestor.getResults());
268
		assertEquals(
269
					"element:ZZZ    completion:ZZZ    relevance:" +(R_DEFAULT+R_RESOLVED+R_INTERESTING+R_NON_RESTRICTED) + "\n"+
270
					"element:ZZZ_FUNCTION    completion:ZZZ_FUNCTION()    relevance:11\n" +
271
					"element:ZZZ_FUNCTION    completion:ZZZ_FUNCTION()    relevance:11\n" +
272
					"element:z    completion:z    relevance:"+ (R_DEFAULT+R_RESOLVED+R_INTERESTING+R_CASE+R_EXACT_NAME+R_UNQUALIFIED+R_NON_RESTRICTED),
273
					requestor.getResults());
274
		
275
		// delete P1
276
		p.getProject().delete(true, false, null);
277
		
278
		// create P1
279
		File dest = getWorkspaceRoot().getLocation().toFile();
280
		File pro = this.createDirectory(dest, "P1");
281
		File proSet = this.createDirectory(pro,".settings");
282
		
283
		this.createFile(proSet, ".jsdtscope", DEFUALT_JSDTSCOPE);
284
					
285
					
286
//					"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
287
//			"<classpath>\n" +
288
//			"    <classpathentry kind=\"src\" path=\"\"/>\n" +
289
//			"    <classpathentry kind=\"var\" path=\"JCL_LIB\" sourcepath=\"JCL_SRC\" rootpath=\"JCL_SRCROOT\"/>\n" +
290
//			"    <classpathentry kind=\"output\" path=\"bin\"/>\n" +
291
//			"</classpath>");
292
			
293
		this.createFile(pro, ".project", DEFAULT_PROJECT_LEFT + "org.eclipse.wst.jsdt.core" + DEFAULT_PROJECT_RIGHT);
294
//			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
295
//			"<projectDescription>\n" +
296
//			"	<name>org.eclipse.wst.jsdt.core</name>\n" +
297
//			"	<comment></comment>\n" +
298
//			"	<projects>\n" +
299
//			"	</projects>\n" +
300
//			"	<buildSpec>\n" +
301
//			"		<buildCommand>\n" +
302
//			"			<name>org.eclipse.wst.jsdt.core.javabuilder</name>\n" +
303
//			"			<arguments>\n" +
304
//			"			</arguments>\n" +
305
//			"		</buildCommand>\n" +
306
//			"	</buildSpec>\n" +
307
//			"	<natures>\n" +
308
//			"		<nature>org.eclipse.wst.jsdt.core.javanature</nature>\n" +
309
//			"	</natures>\n" +
310
//			"</projectDescription>");
311
		
312
		//File src = this.createDirectory(pro, "src");
313
		
314
		//File pz = this.createDirectory(src, "pz");
315
316
		this.createFile(pro,"ZZZ.js","function testZZZClass {\n"+
317
										"  var z = new ZZZ();\n"+
318
										"  z;\n" +
319
										"}");
320
		
321
		final IProject project = getWorkspaceRoot().getProject("P1");
322
		IWorkspaceRunnable populate = new IWorkspaceRunnable() {
323
			public void run(IProgressMonitor monitor) throws CoreException {
324
				project.create(null);
325
				project.open(null);
326
			}
327
		};
328
		getWorkspace().run(populate, null);
329
		JavaScriptCore.create(project);
330
		
331
		waitUntilIndexesReady();
332
		
333
		// do completion
334
		requestor = new CompletionTestsRequestor();
335
		cu.codeComplete(cursorLocation, requestor);
336
337
		assertEquals(
338
			"element:z    completion:z    relevance:"+ (R_DEFAULT+R_INTERESTING+R_CASE+R_EXACT_NAME+R_UNQUALIFIED+R_NON_RESTRICTED) + "\n" +		
339
			"element:z    completion:z    relevance:"+(R_DEFAULT+R_RESOLVED+R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED),
340
			requestor.getResults());
341
	} finally {
342
		this.deleteProject("P1");
343
		this.deleteProject("P2");
344
	}
345
}
346
/**
347
 * Test for bug 33560
348
 */
349
public void testBug33560() throws Exception {
350
	try {
351
		// create variable
352
//		JavaScriptCore.setClasspathVariables(
353
//			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
354
//			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
355
//			null);
356
357
		// create P1
358
		//IFile f = getFile("/Completion/lib.jar");
359
		IFile f = getFile("/Completion/ZZZ.js");
360
		IJavaScriptProject p = this.createJavaProject(
361
					"P1",
362
					new String[]{"/"},
363
					new String[]{});;
364
					 IFile libFile = this.createFile("/P1/ZZZ.js", f.getContents());
365
						this.addLibraryEntry(p, libFile.getLocation().toString(), true);
366
		
367
		// create P2
368
						this.createJavaProject(
369
									"P2",
370
									new String[]{"/"},
371
									new String[]{},
372
									new String[]{"/P1"});
373
					
374
		// create P3
375
						this.createJavaProject(
376
									"P3",
377
									new String[]{"/"},
378
									new String[]{},
379
									new String[]{"/P1"});
380
						this.createFile(
381
									"/P3/X.js",
382
									"function testZZZClass {\n"+
383
									"  var z = new ZZZ();\n"+
384
									"  z;\n" +
385
									"}");
386
		
387
		waitUntilIndexesReady();
388
		
389
		// do completion
390
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
391
		IJavaScriptUnit cu= getCompilationUnit("P3", "", "", "X.js");
392
		
393
		String str = cu.getSource();
394
		String completeBehind = "z";
395
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
396
		cu.codeComplete(cursorLocation, requestor);
397
		assertEquals(
398
		"element:ZZZ    completion:ZZZ    relevance:" +(R_DEFAULT+R_RESOLVED+R_INTERESTING+R_NON_RESTRICTED ) + "\n"+
399
		"element:ZZZ_FUNCTION    completion:ZZZ_FUNCTION()    relevance:11\n" +
400
		"element:ZZZ_FUNCTION    completion:ZZZ_FUNCTION()    relevance:11\n" +
401
		"element:z    completion:z    relevance:"+ (R_DEFAULT+R_RESOLVED+R_INTERESTING+R_CASE+R_EXACT_NAME+R_UNQUALIFIED+R_NON_RESTRICTED),
402
		requestor.getResults());
403
		
404
		
405
		// delete P1
406
		p.getProject().delete(true, false, null);
407
		
408
		// create P1
409
		File dest = getWorkspaceRoot().getLocation().toFile();
410
		File pro = this.createDirectory(dest, "P1");
411
		File proSet = this.createDirectory(pro,".settings");
412
		
413
		this.createFile(proSet, ".jsdtscope", DEFUALT_JSDTSCOPE);
414
//		this.createFile(pro, ".classpath", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
415
//			"<classpath>\n" +
416
//			"    <classpathentry kind=\"src\" path=\"src\"/>\n" +
417
//			"    <classpathentry kind=\"var\" path=\"JCL_LIB\" sourcepath=\"JCL_SRC\" rootpath=\"JCL_SRCROOT\"/>\n" +
418
//			"    <classpathentry kind=\"output\" path=\"bin\"/>\n" +
419
//			"</classpath>");
420
		this.createFile(pro, ".project", DEFAULT_PROJECT_LEFT + "org.eclipse.wst.jsdt.core" + DEFAULT_PROJECT_RIGHT);
421
//		this.createFile(pro, ".project", 
422
//			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
423
//			"<projectDescription>\n" +
424
//			"	<name>org.eclipse.wst.jsdt.core</name>\n" +
425
//			"	<comment></comment>\n" +
426
//			"	<projects>\n" +
427
//			"	</projects>\n" +
428
//			"	<buildSpec>\n" +
429
//			"		<buildCommand>\n" +
430
//			"			<name>org.eclipse.wst.jsdt.core.javabuilder</name>\n" +
431
//			"			<arguments>\n" +
432
//			"			</arguments>\n" +
433
//			"		</buildCommand>\n" +
434
//			"	</buildSpec>\n" +
435
//			"	<natures>\n" +
436
//			"		<nature>org.eclipse.wst.jsdt.core.javanature</nature>\n" +
437
//			"	</natures>\n" +
438
//			"</projectDescription>");
439
//		
440
		File src = this.createDirectory(pro, "src");
441
		
442
		File pz = this.createDirectory(src, "pz");
443
		
444
		this.createFile(pro,"ZZZ.js","function testZZZClass {\n"+
445
					"  var z = new ZZZ();\n"+
446
					"  z;\n" +
447
					"}");
448
		
449
		final IProject project = getWorkspaceRoot().getProject("P1");
450
		IWorkspaceRunnable populate = new IWorkspaceRunnable() {
451
			public void run(IProgressMonitor monitor) throws CoreException {
452
				project.create(null);
453
				project.open(null);
454
			}
455
		};
456
		getWorkspace().run(populate, null);
457
		JavaScriptCore.create(project);
458
		
459
		waitUntilIndexesReady();
460
		
461
		// do completion
462
		requestor = new CompletionTestsRequestor();
463
		cu.codeComplete(cursorLocation, requestor);
464
465
		assertEquals(
466
					"element:z    completion:z    relevance:"+ (R_DEFAULT+R_INTERESTING+R_CASE+R_EXACT_NAME+R_UNQUALIFIED+R_NON_RESTRICTED) + "\n" +
467
					"element:z    completion:z    relevance:"+(R_DEFAULT+R_RESOLVED+R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED),
468
					requestor.getResults());
469
		} finally {
470
		this.deleteProject("P1");
471
		this.deleteProject("P2");
472
		this.deleteProject("P3");
473
	}
474
}
475
/*
476
 * 
477
 * This tests a project which includes functions and methods marked as "not exported" from another project.  This is N/A for JS.
478
 */
479
480
//public void testBug79288() throws Exception {
481
//	try {
482
//		// create variable
483
////		JavaScriptCore.setClasspathVariables(
484
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
485
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
486
////			null);
487
//
488
//		// create P1
489
//		this.createJavaProject(
490
//			"P1",
491
//			new String[]{"src"},
492
//			new String[]{"JCL_LIB"},
493
//			 "bin");
494
//		
495
//		this.createFolder("/P1/src/a");
496
//		this.createFile(
497
//				"/P1/src/a/XX1.js",
498
//				"package a;\n"+
499
//				"public class XX1 {\n"+
500
//				"}");
501
//		
502
//		// create P2
503
//		this.createJavaProject(
504
//			"P2",
505
//			new String[]{"src"},
506
//			new String[]{"JCL_LIB"},
507
//			new String[]{"/P1"},
508
//			"bin");
509
//		
510
//		this.createFolder("/P2/src/b");
511
//		this.createFile(
512
//				"/P2/src/b/XX2.js",
513
//				"package b;\n"+
514
//				"public class XX2 {\n"+
515
//				"}");
516
//		
517
//		// create P3
518
//		this.createJavaProject(
519
//			"P3",
520
//			new String[]{"src"},
521
//			new String[]{"JCL_LIB"},
522
//			new String[]{"/P2"},
523
//			"bin");
524
//		
525
//		this.createFile(
526
//				"/P3/src/YY.js",
527
//				"public class YY {\n"+
528
//				"  vois foo(){\n"+
529
//				"    XX\n"+
530
//				"  }\n"+
531
//				"}");
532
//		
533
//		waitUntilIndexesReady();
534
//		
535
//		// do completion
536
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
537
//		IJavaScriptUnit cu= getCompilationUnit("P3", "src", "", "YY.js");
538
//		
539
//		String str = cu.getSource();
540
//		String completeBehind = "XX";
541
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
542
//		cu.codeComplete(cursorLocation, requestor);
543
//		
544
//		assertResults(
545
//			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
546
//			requestor.getResults());
547
//	} finally {
548
//		this.deleteProject("P1");
549
//		this.deleteProject("P2");
550
//		this.deleteProject("P3");
551
//	}
552
//}
553
554
555
556
557
//public void testBug91772() throws Exception {
558
//	try {
559
//		// create variable
560
////		JavaScriptCore.setClasspathVariables(
561
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
562
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
563
////			null);
564
//
565
//		// create P1
566
//		this.createJavaProject(
567
//			"P1",
568
//			new String[]{"src"},
569
//			new String[]{"JCL_LIB"},
570
//			 "bin");
571
//		
572
//		this.createFolder("/P1/src/a");
573
//		this.createFile(
574
//				"/P1/src/a/XX1.js",
575
//				"package a;\n"+
576
//				"public class XX1 {\n"+
577
//				"}");
578
//		
579
//		// create P2
580
//		ContainerInitializer.setInitializer(new CompletionContainerInitializer("P2", new String[] {"/P1"}, new boolean[] {true}));
581
//		String[] classLib = new String[]{"JCL_LIB"};
582
//		int classLibLength = classLib.length;
583
//		String[] lib = new String[classLibLength + 1];
584
//		System.arraycopy(classLib, 0, lib, 0, classLibLength);
585
//		lib[classLibLength] = "org.eclipse.wst.jsdt.core.tests.model.TEST_CONTAINER";
586
//		this.createJavaProject(
587
//			"P2",
588
//			new String[]{"src"},
589
//			lib,
590
//			"bin");
591
//		
592
//		this.createFolder("/P2/src/b");
593
//		this.createFile(
594
//				"/P2/src/b/XX2.js",
595
//				"package b;\n"+
596
//				"public class XX2 {\n"+
597
//				"}");
598
//		
599
//		// create P3
600
//		this.createJavaProject(
601
//			"P3",
602
//			new String[]{"src"},
603
//			new String[]{"JCL_LIB"},
604
//			new String[]{"/P2"},
605
//			"bin");
606
//		
607
//		this.createFile(
608
//				"/P3/src/YY.js",
609
//				"public class YY {\n"+
610
//				"  vois foo(){\n"+
611
//				"    XX\n"+
612
//				"  }\n"+
613
//				"}");
614
//		
615
//		waitUntilIndexesReady();
616
//		
617
//		// do completion
618
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
619
//		IJavaScriptUnit cu= getCompilationUnit("P3", "src", "", "YY.js");
620
//		
621
//		String str = cu.getSource();
622
//		String completeBehind = "XX";
623
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
624
//		cu.codeComplete(cursorLocation, requestor);
625
//		
626
//		assertResults(
627
//			"XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
628
//			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
629
//			requestor.getResults());
630
//	} finally {
631
//		this.deleteProject("P1");
632
//		this.deleteProject("P2");
633
//		this.deleteProject("P3");
634
//		
635
//		
636
//		// TODO the following code is not the correct way to remove the container
637
//		// Cleanup caches
638
//		JavaModelManager manager = JavaModelManager.getJavaModelManager();
639
//		manager.containers = new HashMap(5);
640
//		manager.variables = new HashMap(5);
641
//	}
642
//}
643
//public void testBug93891() throws Exception {
644
//	Hashtable oldOptions = JavaScriptCore.getOptions();
645
//	try {
646
//		Hashtable options = new Hashtable(oldOptions);
647
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
648
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
649
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
650
//		JavaScriptCore.setOptions(options);
651
//		
652
//		// create variable
653
////		JavaScriptCore.setClasspathVariables(
654
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
655
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
656
////			null);
657
//
658
//		// create P1
659
//		this.createJavaProject(
660
//			"P1",
661
//			new String[]{"src"},
662
//			new String[]{"JCL_LIB"},
663
//			 "bin");
664
//		
665
//		this.createFolder("/P1/src/a");
666
//		this.createFile(
667
//				"/P1/src/a/XX1.js",
668
//				"package a;\n"+
669
//				"public class XX1 {\n"+
670
//				"}");
671
//		
672
//		this.createFolder("/P1/src/b");
673
//		this.createFile(
674
//				"/P1/src/b/XX2.js",
675
//				"package b;\n"+
676
//				"public class XX2 {\n"+
677
//				"}");
678
//		
679
//		// create P2
680
//		ContainerInitializer.setInitializer(new CompletionContainerInitializer("P2", new String[] {"/P1"}, new boolean[] {true}, new String[]{"a/*"}));
681
//		String[] classLib = new String[]{"JCL_LIB"};
682
//		int classLibLength = classLib.length;
683
//		String[] lib = new String[classLibLength + 1];
684
//		System.arraycopy(classLib, 0, lib, 0, classLibLength);
685
//		lib[classLibLength] = "org.eclipse.wst.jsdt.core.tests.model.TEST_CONTAINER";
686
//		this.createJavaProject(
687
//			"P2",
688
//			new String[]{"src"},
689
//			lib,
690
//			"bin");
691
//		
692
//		this.createFolder("/P2/src/b");
693
//		this.createFile(
694
//				"/P2/src/YY.js",
695
//				"public class YY {\n"+
696
//				"  void foo() {\n"+
697
//				"    XX\n"+
698
//				"  }\n"+
699
//				"}");
700
//		
701
//		waitUntilIndexesReady();
702
//		
703
//		// do completion
704
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
705
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
706
//		
707
//		String str = cu.getSource();
708
//		String completeBehind = "XX";
709
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
710
//		cu.codeComplete(cursorLocation, requestor);
711
//		
712
//		assertResults(
713
//			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
714
//			requestor.getResults());
715
//	} finally {
716
//		this.deleteProject("P1");
717
//		this.deleteProject("P2");
718
//		
719
//		// TODO the following code is not the correct way to remove the container
720
//		// Cleanup caches
721
//		JavaModelManager manager = JavaModelManager.getJavaModelManager();
722
//		manager.containers = new HashMap(5);
723
//		manager.variables = new HashMap(5);
724
//		
725
//		JavaScriptCore.setOptions(oldOptions);
726
//	}
727
//}
728
//public void testAccessRestriction1() throws Exception {
729
//	Hashtable oldOptions = JavaScriptCore.getOptions();
730
//	try {
731
//		Hashtable options = new Hashtable(oldOptions);
732
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.IGNORE);
733
//		options.put(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, JavaScriptCore.IGNORE);
734
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED);
735
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
736
//		JavaScriptCore.setOptions(options);
737
//		
738
//		// create variable
739
////		JavaScriptCore.setClasspathVariables(
740
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
741
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
742
////			null);
743
//
744
//		// create P1
745
//		this.createJavaProject(
746
//			"P1",
747
//			new String[]{"src"},
748
//			new String[]{"JCL_LIB"},
749
//			 "bin");
750
//		
751
//		this.createFolder("/P1/src/a");
752
//		this.createFile(
753
//				"/P1/src/a/XX1.js",
754
//				"package a;\n"+
755
//				"public class XX1 {\n"+
756
//				"}");
757
//
758
//		this.createFolder("/P1/src/b");
759
//		this.createFile(
760
//				"/P1/src/b/XX2.js",
761
//				"package b;\n"+
762
//				"public class XX2 {\n"+
763
//				"}");
764
//		
765
//		// create P2
766
//		this.createJavaProject(
767
//			"P2",
768
//			new String[]{"src"},
769
//			new String[]{"JCL_LIB"},
770
//			new String[]{"/P1"},
771
//			"bin");
772
//		this.createFile(
773
//			"/P2/src/YY.js",
774
//			"public class YY {\n"+
775
//			"  void foo() {\n"+
776
//			"    XX\n"+
777
//			"  }\n"+
778
//			"}");
779
//		
780
//		waitUntilIndexesReady();
781
//		
782
//		// do completion
783
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
784
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
785
//		
786
//		String str = cu.getSource();
787
//		String completeBehind = "XX";
788
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
789
//		cu.codeComplete(cursorLocation, requestor);
790
//		
791
//		assertResults(
792
//			"XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
793
// 			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
794
//			requestor.getResults());
795
//	} finally {
796
//		this.deleteProject("P1");
797
//		this.deleteProject("P2");
798
//		JavaScriptCore.setOptions(oldOptions);
799
//	}
800
//}
801
//
802
//public void testAccessRestriction2() throws Exception {
803
//	Hashtable oldOptions = JavaScriptCore.getOptions();
804
//	try {
805
//		Hashtable options = new Hashtable(oldOptions);
806
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.IGNORE);
807
//		options.put(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, JavaScriptCore.IGNORE);
808
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED);
809
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
810
//		JavaScriptCore.setOptions(options);
811
//		
812
//		// create variable
813
////		JavaScriptCore.setClasspathVariables(
814
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
815
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
816
////			null);
817
//
818
//		// create P1
819
//		this.createJavaProject(
820
//			"P1",
821
//			new String[]{"src"},
822
//			new String[]{"JCL_LIB"},
823
//			 "bin");
824
//		
825
//		this.createFolder("/P1/src/a");
826
//		this.createFile(
827
//				"/P1/src/a/XX1.js",
828
//				"package a;\n"+
829
//				"public class XX1 {\n"+
830
//				"}");
831
//
832
//		this.createFolder("/P1/src/b");
833
//		this.createFile(
834
//				"/P1/src/b/XX2.js",
835
//				"package b;\n"+
836
//				"public class XX2 {\n"+
837
//				"}");
838
//		
839
//		// create P2
840
//		this.createJavaProject(
841
//			"P2",
842
//			new String[]{"src"},
843
//			new String[]{"JCL_LIB"},
844
//			null,
845
//			null,
846
//			new String[]{"/P1"},
847
//			new String[][]{{}},
848
//			new String[][]{{"a/*"}},
849
//			new boolean[]{false},
850
//			"bin",
851
//			null,
852
//			null,
853
//			null,
854
//			"1.4");
855
//		this.createFile(
856
//			"/P2/src/YY.js",
857
//			"public class YY {\n"+
858
//			"  void foo() {\n"+
859
//			"    XX\n"+
860
//			"  }\n"+
861
//			"}");
862
//		
863
//		waitUntilIndexesReady();
864
//		
865
//		// do completion
866
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
867
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
868
//		
869
//		String str = cu.getSource();
870
//		String completeBehind = "XX";
871
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
872
//		cu.codeComplete(cursorLocation, requestor);
873
//		
874
//		assertResults(
875
//			"XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
876
// 			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
877
//			requestor.getResults());
878
//	} finally {
879
//		this.deleteProject("P1");
880
//		this.deleteProject("P2");
881
//		JavaScriptCore.setOptions(oldOptions);
882
//	}
883
//}
884
//public void testAccessRestriction3() throws Exception {
885
//	Hashtable oldOptions = JavaScriptCore.getOptions();
886
//	try {
887
//		Hashtable options = new Hashtable(oldOptions);
888
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
889
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED);
890
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
891
//		JavaScriptCore.setOptions(options);
892
//		
893
//		// create variable
894
////		JavaScriptCore.setClasspathVariables(
895
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
896
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
897
////			null);
898
//
899
//		// create P1
900
//		this.createJavaProject(
901
//			"P1",
902
//			new String[]{"src"},
903
//			new String[]{"JCL_LIB"},
904
//			 "bin");
905
//		
906
//		this.createFolder("/P1/src/a");
907
//		this.createFile(
908
//				"/P1/src/a/XX1.js",
909
//				"package a;\n"+
910
//				"public class XX1 {\n"+
911
//				"}");
912
//
913
//		this.createFolder("/P1/src/b");
914
//		this.createFile(
915
//				"/P1/src/b/XX2.js",
916
//				"package b;\n"+
917
//				"public class XX2 {\n"+
918
//				"}");
919
//		
920
//		// create P2
921
//		this.createJavaProject(
922
//			"P2",
923
//			new String[]{"src"},
924
//			new String[]{"JCL_LIB"},
925
//			null,
926
//			null,
927
//			new String[]{"/P1"},
928
//			new String[][]{{}},
929
//			new String[][]{{"a/*"}},
930
//			new boolean[]{false},
931
//			"bin",
932
//			null,
933
//			null,
934
//			null,
935
//			"1.4");
936
//		this.createFile(
937
//			"/P2/src/YY.js",
938
//			"public class YY {\n"+
939
//			"  void foo() {\n"+
940
//			"    XX\n"+
941
//			"  }\n"+
942
//			"}");
943
//		
944
//		waitUntilIndexesReady();
945
//		
946
//		// do completion
947
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
948
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
949
//		
950
//		String str = cu.getSource();
951
//		String completeBehind = "XX";
952
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
953
//		cu.codeComplete(cursorLocation, requestor);
954
//		
955
//		assertResults(
956
//			"XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" +
957
// 			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
958
//			requestor.getResults());
959
//	} finally {
960
//		this.deleteProject("P1");
961
//		this.deleteProject("P2");
962
//		JavaScriptCore.setOptions(oldOptions);
963
//	}
964
//}
965
//public void testAccessRestriction4() throws Exception {
966
//	Hashtable oldOptions = JavaScriptCore.getOptions();
967
//	try {
968
//		Hashtable options = new Hashtable(oldOptions);
969
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.IGNORE);
970
//		options.put(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, JavaScriptCore.IGNORE);
971
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
972
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
973
//		JavaScriptCore.setOptions(options);
974
//		
975
//		// create variable
976
////		JavaScriptCore.setClasspathVariables(
977
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
978
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
979
////			null);
980
//
981
//		// create P1
982
//		this.createJavaProject(
983
//			"P1",
984
//			new String[]{"src"},
985
//			new String[]{"JCL_LIB"},
986
//			 "bin");
987
//		
988
//		this.createFolder("/P1/src/a");
989
//		this.createFile(
990
//				"/P1/src/a/XX1.js",
991
//				"package a;\n"+
992
//				"public class XX1 {\n"+
993
//				"}");
994
//
995
//		this.createFolder("/P1/src/b");
996
//		this.createFile(
997
//				"/P1/src/b/XX2.js",
998
//				"package b;\n"+
999
//				"public class XX2 {\n"+
1000
//				"}");
1001
//		
1002
//		// create P2
1003
//		this.createJavaProject(
1004
//			"P2",
1005
//			new String[]{"src"},
1006
//			new String[]{"JCL_LIB"},
1007
//			null,
1008
//			null,
1009
//			new String[]{"/P1"},
1010
//			new String[][]{{}},
1011
//			new String[][]{{"a/*"}},
1012
//			new boolean[]{false},
1013
//			"bin",
1014
//			null,
1015
//			null,
1016
//			null,
1017
//			"1.4");
1018
//		this.createFile(
1019
//			"/P2/src/YY.js",
1020
//			"public class YY {\n"+
1021
//			"  void foo() {\n"+
1022
//			"    XX\n"+
1023
//			"  }\n"+
1024
//			"}");
1025
//		
1026
//		waitUntilIndexesReady();
1027
//		
1028
//		// do completion
1029
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
1030
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
1031
//		
1032
//		String str = cu.getSource();
1033
//		String completeBehind = "XX";
1034
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1035
//		cu.codeComplete(cursorLocation, requestor);
1036
//		
1037
//		assertResults(
1038
//			"XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1039
// 			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1040
//			requestor.getResults());
1041
//	} finally {
1042
//		this.deleteProject("P1");
1043
//		this.deleteProject("P2");
1044
//		JavaScriptCore.setOptions(oldOptions);
1045
//	}
1046
//}
1047
//public void testAccessRestriction5() throws Exception {
1048
//	Hashtable oldOptions = JavaScriptCore.getOptions();
1049
//	try {
1050
//		Hashtable options = new Hashtable(oldOptions);
1051
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
1052
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
1053
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1054
//		JavaScriptCore.setOptions(options);
1055
//		
1056
//		// create variable
1057
////		JavaScriptCore.setClasspathVariables(
1058
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
1059
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
1060
////			null);
1061
//
1062
//		// create P1
1063
//		this.createJavaProject(
1064
//			"P1",
1065
//			new String[]{"src"},
1066
//			new String[]{"JCL_LIB"},
1067
//			 "bin");
1068
//		
1069
//		this.createFolder("/P1/src/a");
1070
//		this.createFile(
1071
//				"/P1/src/a/XX1.js",
1072
//				"package a;\n"+
1073
//				"public class XX1 {\n"+
1074
//				"}");
1075
//
1076
//		this.createFolder("/P1/src/b");
1077
//		this.createFile(
1078
//				"/P1/src/b/XX2.js",
1079
//				"package b;\n"+
1080
//				"public class XX2 {\n"+
1081
//				"}");
1082
//		
1083
//		// create P2
1084
//		this.createJavaProject(
1085
//			"P2",
1086
//			new String[]{"src"},
1087
//			new String[]{"JCL_LIB"},
1088
//			null,
1089
//			null,
1090
//			new String[]{"/P1"},
1091
//			new String[][]{{}},
1092
//			new String[][]{{"a/*"}},
1093
//			new boolean[]{false},
1094
//			"bin",
1095
//			null,
1096
//			null,
1097
//			null,
1098
//			"1.4");
1099
//		this.createFile(
1100
//			"/P2/src/YY.js",
1101
//			"public class YY {\n"+
1102
//			"  void foo() {\n"+
1103
//			"    XX\n"+
1104
//			"  }\n"+
1105
//			"}");
1106
//		
1107
//		waitUntilIndexesReady();
1108
//		
1109
//		// do completion
1110
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
1111
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
1112
//		
1113
//		String str = cu.getSource();
1114
//		String completeBehind = "XX";
1115
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1116
//		cu.codeComplete(cursorLocation, requestor);
1117
//		
1118
//		assertResults(
1119
//			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1120
//			requestor.getResults());
1121
//	} finally {
1122
//		this.deleteProject("P1");
1123
//		this.deleteProject("P2");
1124
//		JavaScriptCore.setOptions(oldOptions);
1125
//	}
1126
//}
1127
//public void testAccessRestriction6() throws Exception {
1128
//	Hashtable oldOptions = JavaScriptCore.getOptions();
1129
//	try {
1130
//		Hashtable options = new Hashtable(oldOptions);
1131
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
1132
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
1133
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1134
//		JavaScriptCore.setOptions(options);
1135
//		
1136
//		// create variable
1137
////		JavaScriptCore.setClasspathVariables(
1138
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
1139
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
1140
////			null);
1141
//
1142
//		// create P1
1143
//		this.createJavaProject(
1144
//			"P1",
1145
//			new String[]{"src"},
1146
//			new String[]{"JCL_LIB"},
1147
//			 "bin");
1148
//		
1149
//		this.createFolder("/P1/src/a");
1150
//		this.createFile(
1151
//				"/P1/src/a/XX1.js",
1152
//				"package a;\n"+
1153
//				"public class XX1 {\n"+
1154
//				"}");
1155
//
1156
//		this.createFolder("/P1/src/b");
1157
//		this.createFile(
1158
//				"/P1/src/b/XX2.js",
1159
//				"package b;\n"+
1160
//				"public class XX2 {\n"+
1161
//				"}");
1162
//		
1163
//		this.createFolder("/P1/src/c");
1164
//		this.createFile(
1165
//				"/P1/src/c/XX3.js",
1166
//				"package c;\n"+
1167
//				"public class XX3 {\n"+
1168
//				"}");
1169
//		
1170
//		// create P2
1171
//		this.createJavaProject(
1172
//			"P2",
1173
//			new String[]{"src"},
1174
//			new String[]{"JCL_LIB"},
1175
//			null,
1176
//			null,
1177
//			new String[]{"/P1"},
1178
//			new String[][]{{}},
1179
//			new String[][]{{"a/*"}},
1180
//			new boolean[]{true},
1181
//			"bin",
1182
//			null,
1183
//			null,
1184
//			null,
1185
//			"1.4");
1186
//		
1187
//		// create P3
1188
//		this.createJavaProject(
1189
//			"P3",
1190
//			new String[]{"src"},
1191
//			new String[]{"JCL_LIB"},
1192
//			null,
1193
//			null,
1194
//			new String[]{"/P2"},
1195
//			new String[][]{{}},
1196
//			new String[][]{{"b/*"}},
1197
//			new boolean[]{false},
1198
//			"bin",
1199
//			null,
1200
//			null,
1201
//			null,
1202
//			"1.4");
1203
//		
1204
//		this.createFile(
1205
//			"/P3/src/YY.js",
1206
//			"public class YY {\n"+
1207
//			"  void foo() {\n"+
1208
//			"    XX\n"+
1209
//			"  }\n"+
1210
//			"}");
1211
//		
1212
//		waitUntilIndexesReady();
1213
//		
1214
//		// do completion
1215
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
1216
//		IJavaScriptUnit cu= getCompilationUnit("P3", "src", "", "YY.js");
1217
//		
1218
//		String str = cu.getSource();
1219
//		String completeBehind = "XX";
1220
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1221
//		cu.codeComplete(cursorLocation, requestor);
1222
//		
1223
//		assertResults(
1224
//			"XX3[TYPE_REF]{c.XX3, c, Lc.XX3;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1225
//			requestor.getResults());
1226
//	} finally {
1227
//		this.deleteProject("P1");
1228
//		this.deleteProject("P2");
1229
//		this.deleteProject("P3");
1230
//		JavaScriptCore.setOptions(oldOptions);
1231
//	}
1232
//}
1233
//public void testAccessRestriction7() throws Exception {
1234
//	Hashtable oldOptions = JavaScriptCore.getOptions();
1235
//	try {
1236
//		Hashtable options = new Hashtable(oldOptions);
1237
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
1238
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
1239
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1240
//		JavaScriptCore.setOptions(options);
1241
//		
1242
//		// create variable
1243
////		JavaScriptCore.setClasspathVariables(
1244
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
1245
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
1246
////			null);
1247
//
1248
//		// create P1
1249
//		this.createJavaProject(
1250
//			"P1",
1251
//			new String[]{"src"},
1252
//			new String[]{"JCL_LIB"},
1253
//			 "bin");
1254
//		
1255
//		this.createFolder("/P1/src/a");
1256
//		this.createFile(
1257
//				"/P1/src/a/XX1.js",
1258
//				"package a;\n"+
1259
//				"public class XX1 {\n"+
1260
//				"}");
1261
//
1262
//		this.createFolder("/P1/src/b");
1263
//		this.createFile(
1264
//				"/P1/src/b/XX2.js",
1265
//				"package b;\n"+
1266
//				"public class XX2 {\n"+
1267
//				"}");
1268
//		
1269
//		// create P2
1270
//		this.createJavaProject(
1271
//			"P2",
1272
//			new String[]{"src"},
1273
//			new String[]{"JCL_LIB"},
1274
//			null,
1275
//			null,
1276
//			new String[]{"/P1", "/P3"},
1277
//			new String[][]{{}, {}},
1278
//			new String[][]{{"a/*"}, {}},
1279
//			new boolean[]{false, false},
1280
//			"bin",
1281
//			null,
1282
//			null,
1283
//			null,
1284
//			"1.4");
1285
//		this.createFile(
1286
//				"/P2/src/YY.js",
1287
//				"public class YY {\n"+
1288
//				"  void foo() {\n"+
1289
//				"    XX\n"+
1290
//				"  }\n"+
1291
//				"}");
1292
//		
1293
//		// create P3
1294
//		this.createJavaProject(
1295
//			"P3",
1296
//			new String[]{"src"},
1297
//			new String[]{"JCL_LIB"},
1298
//			null,
1299
//			null,
1300
//			new String[]{"/P1"},
1301
//			new String[][]{{}},
1302
//			new String[][]{{}},
1303
//			new boolean[]{true},
1304
//			"bin",
1305
//			null,
1306
//			null,
1307
//			null,
1308
//			"1.4");
1309
//		
1310
//		waitUntilIndexesReady();
1311
//		
1312
//		// do completion
1313
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
1314
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
1315
//		
1316
//		String str = cu.getSource();
1317
//		String completeBehind = "XX";
1318
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1319
//		cu.codeComplete(cursorLocation, requestor);
1320
//		
1321
//		assertResults(
1322
//			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1323
//			requestor.getResults());
1324
//	} finally {
1325
//		this.deleteProject("P1");
1326
//		this.deleteProject("P2");
1327
//		this.deleteProject("P3");
1328
//		JavaScriptCore.setOptions(oldOptions);
1329
//	}
1330
//}
1331
//public void testAccessRestriction8() throws Exception {
1332
//	Hashtable oldOptions = JavaScriptCore.getOptions();
1333
//	try {
1334
//		Hashtable options = new Hashtable(oldOptions);
1335
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
1336
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
1337
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1338
//		JavaScriptCore.setOptions(options);
1339
//		
1340
//		// create variable
1341
////		JavaScriptCore.setClasspathVariables(
1342
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
1343
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
1344
////			null);
1345
//
1346
//		// create P1
1347
//		this.createJavaProject(
1348
//			"P1",
1349
//			new String[]{"src"},
1350
//			new String[]{"JCL_LIB"},
1351
//			 "bin");
1352
//		
1353
//		this.createFolder("/P1/src/a");
1354
//		this.createFile(
1355
//				"/P1/src/a/XX1.js",
1356
//				"package a;\n"+
1357
//				"public class XX1 {\n"+
1358
//				"}");
1359
//
1360
//		this.createFolder("/P1/src/b");
1361
//		this.createFile(
1362
//				"/P1/src/b/XX2.js",
1363
//				"package b;\n"+
1364
//				"public class XX2 {\n"+
1365
//				"}");
1366
//		
1367
//		// create P2
1368
//		this.createJavaProject(
1369
//			"P2",
1370
//			new String[]{"src"},
1371
//			new String[]{"JCL_LIB"},
1372
//			null,
1373
//			null,
1374
//			new String[]{"/P3", "/P1"},
1375
//			new String[][]{{}, {}},
1376
//			new String[][]{{}, {"a/*"}},
1377
//			new boolean[]{false, false},
1378
//			"bin",
1379
//			null,
1380
//			null,
1381
//			null,
1382
//			"1.4");
1383
//		this.createFile(
1384
//				"/P2/src/YY.js",
1385
//				"public class YY {\n"+
1386
//				"  void foo() {\n"+
1387
//				"    XX\n"+
1388
//				"  }\n"+
1389
//				"}");
1390
//		
1391
//		// create P3
1392
//		this.createJavaProject(
1393
//			"P3",
1394
//			new String[]{"src"},
1395
//			new String[]{"JCL_LIB"},
1396
//			null,
1397
//			null,
1398
//			new String[]{"/P1"},
1399
//			new String[][]{{}},
1400
//			new String[][]{{}},
1401
//			new boolean[]{true},
1402
//			"bin",
1403
//			null,
1404
//			null,
1405
//			null,
1406
//			"1.4");
1407
//		
1408
//		waitUntilIndexesReady();
1409
//		
1410
//		// do completion
1411
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
1412
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
1413
//		
1414
//		String str = cu.getSource();
1415
//		String completeBehind = "XX";
1416
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1417
//		cu.codeComplete(cursorLocation, requestor);
1418
//		
1419
//		assertResults(
1420
//			"XX1[TYPE_REF]{a.XX1, a, La.XX1;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1421
//			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1422
//			requestor.getResults());
1423
//	} finally {
1424
//		this.deleteProject("P1");
1425
//		this.deleteProject("P2");
1426
//		this.deleteProject("P3");
1427
//		JavaScriptCore.setOptions(oldOptions);
1428
//	}
1429
//}
1430
//public void testAccessRestriction9() throws Exception {
1431
//	Hashtable oldOptions = JavaScriptCore.getOptions();
1432
//	try {
1433
//		Hashtable options = new Hashtable(oldOptions);
1434
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
1435
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
1436
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1437
//		JavaScriptCore.setOptions(options);
1438
//		
1439
//		// create variable
1440
////		JavaScriptCore.setClasspathVariables(
1441
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
1442
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
1443
////			null);
1444
//
1445
//		// create P1
1446
//		this.createJavaProject(
1447
//			"P1",
1448
//			new String[]{"src"},
1449
//			new String[]{"JCL_LIB"},
1450
//			 "bin");
1451
//		
1452
//		this.createFolder("/P1/src/p11");
1453
//		this.createFile(
1454
//				"/P1/src/p11/XX11.js",
1455
//				"package p11;\n"+
1456
//				"public class XX11 {\n"+
1457
//				"}");
1458
//		
1459
//		this.createFolder("/P1/src/p12");
1460
//		this.createFile(
1461
//				"/P1/src/p12/XX12.js",
1462
//				"package p12;\n"+
1463
//				"public class XX12 {\n"+
1464
//				"}");
1465
//		
1466
//		// create P2
1467
//		this.createJavaProject(
1468
//			"P2",
1469
//			new String[]{"src"},
1470
//			new String[]{"JCL_LIB"},
1471
//			null,
1472
//			null,
1473
//			new String[]{"/P1", "/P3"},
1474
//			new String[][]{{}, {}},
1475
//			new String[][]{{"p11/*"}, {"p31/*"}},
1476
//			new boolean[]{true, true},
1477
//			"bin",
1478
//			null,
1479
//			null,
1480
//			null,
1481
//			"1.4");
1482
//		
1483
//		this.createFolder("/P2/src/p21");
1484
//		this.createFile(
1485
//				"/P2/src/p21/XX21.js",
1486
//				"package p21;\n"+
1487
//				"public class XX21 {\n"+
1488
//				"}");
1489
//		
1490
//		this.createFolder("/P2/src/p22");
1491
//		this.createFile(
1492
//				"/P2/src/p22/XX22.js",
1493
//				"package p22;\n"+
1494
//				"public class XX22 {\n"+
1495
//				"}");
1496
//		
1497
//		// create P3
1498
//		this.createJavaProject(
1499
//			"P3",
1500
//			new String[]{"src"},
1501
//			new String[]{"JCL_LIB"},
1502
//			null,
1503
//			null,
1504
//			new String[]{"/P1"},
1505
//			new String[][]{{}},
1506
//			new String[][]{{"p12/*"}},
1507
//			new boolean[]{true},
1508
//			"bin",
1509
//			null,
1510
//			null,
1511
//			null,
1512
//			"1.4");
1513
//		
1514
//		this.createFolder("/P3/src/p31");
1515
//		this.createFile(
1516
//				"/P3/src/p31/XX31.js",
1517
//				"package p31;\n"+
1518
//				"public class XX31 {\n"+
1519
//				"}");
1520
//		
1521
//		this.createFolder("/P3/src/p32");
1522
//		this.createFile(
1523
//				"/P3/src/p32/XX32.js",
1524
//				"package p32;\n"+
1525
//				"public class XX32 {\n"+
1526
//				"}");
1527
//		
1528
//		// create PX
1529
//		this.createJavaProject(
1530
//				"PX",
1531
//				new String[]{"src"},
1532
//				new String[]{"JCL_LIB"},
1533
//				null,
1534
//				null,
1535
//				new String[]{"/P2"},
1536
//				null,
1537
//				null,
1538
//				new boolean[]{false},
1539
//				"bin",
1540
//				null,
1541
//				null,
1542
//				null,
1543
//				"1.4");
1544
//		
1545
//		this.createFile(
1546
//				"/PX/src/X.js",
1547
//				"public class X {\n"+
1548
//				"  void foo() {\n"+
1549
//				"    XX\n"+
1550
//				"  }\n"+
1551
//				"}");
1552
//		
1553
//		waitUntilIndexesReady();
1554
//		
1555
//		// do completion
1556
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
1557
//		IJavaScriptUnit cu= getCompilationUnit("PX", "src", "", "X.js");
1558
//		
1559
//		String str = cu.getSource();
1560
//		String completeBehind = "XX";
1561
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1562
//		cu.codeComplete(cursorLocation, requestor);
1563
//		
1564
//		assertResults(
1565
//			"XX12[TYPE_REF]{p12.XX12, p12, Lp12.XX12;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1566
//			"XX21[TYPE_REF]{p21.XX21, p21, Lp21.XX21;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1567
//			"XX22[TYPE_REF]{p22.XX22, p22, Lp22.XX22;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1568
//			"XX32[TYPE_REF]{p32.XX32, p32, Lp32.XX32;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1569
//			requestor.getResults());
1570
//	} finally {
1571
//		this.deleteProject("P1");
1572
//		this.deleteProject("P2");
1573
//		this.deleteProject("P3");
1574
//		this.deleteProject("PX");
1575
//		JavaScriptCore.setOptions(oldOptions);
1576
//	}
1577
//}
1578
//public void testAccessRestriction10() throws Exception {
1579
//	Hashtable oldOptions = JavaScriptCore.getOptions();
1580
//	try {
1581
//		Hashtable options = new Hashtable(oldOptions);
1582
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
1583
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1584
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1585
//		JavaScriptCore.setOptions(options);
1586
//		
1587
//		// create variable
1588
////		JavaScriptCore.setClasspathVariables(
1589
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
1590
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
1591
////			null);
1592
//
1593
//		// create P1
1594
//		this.createJavaProject(
1595
//			"P1",
1596
//			new String[]{"src"},
1597
//			new String[]{"JCL_LIB"},
1598
//			 "bin");
1599
//		
1600
//		this.createFolder("/P1/src/p11");
1601
//		this.createFile(
1602
//				"/P1/src/p11/XX11.js",
1603
//				"package p11;\n"+
1604
//				"public class XX11 {\n"+
1605
//				"}");
1606
//		
1607
//		this.createFolder("/P1/src/p12");
1608
//		this.createFile(
1609
//				"/P1/src/p12/XX12.js",
1610
//				"package p12;\n"+
1611
//				"public class XX12 {\n"+
1612
//				"}");
1613
//		
1614
//		// create P2
1615
//		this.createJavaProject(
1616
//			"P2",
1617
//			new String[]{"src"},
1618
//			new String[]{"JCL_LIB"},
1619
//			null,
1620
//			null,
1621
//			new String[]{"/P1", "/P3"},
1622
//			new String[][]{{}, {}},
1623
//			new String[][]{{"p11/*"}, {"p31/*"}},
1624
//			new boolean[]{true, true},
1625
//			"bin",
1626
//			null,
1627
//			null,
1628
//			null,
1629
//			"1.4");
1630
//		
1631
//		this.createFolder("/P2/src/p21");
1632
//		this.createFile(
1633
//				"/P2/src/p21/XX21.js",
1634
//				"package p21;\n"+
1635
//				"public class XX21 {\n"+
1636
//				"}");
1637
//		
1638
//		this.createFolder("/P2/src/p22");
1639
//		this.createFile(
1640
//				"/P2/src/p22/XX22.js",
1641
//				"package p22;\n"+
1642
//				"public class XX22 {\n"+
1643
//				"}");
1644
//		
1645
//		// create P3
1646
//		this.createJavaProject(
1647
//			"P3",
1648
//			new String[]{"src"},
1649
//			new String[]{"JCL_LIB"},
1650
//			null,
1651
//			null,
1652
//			new String[]{"/P1"},
1653
//			new String[][]{{}},
1654
//			new String[][]{{"p12/*"}},
1655
//			new boolean[]{true},
1656
//			"bin",
1657
//			null,
1658
//			null,
1659
//			null,
1660
//			"1.4");
1661
//		
1662
//		this.createFolder("/P3/src/p31");
1663
//		this.createFile(
1664
//				"/P3/src/p31/XX31.js",
1665
//				"package p31;\n"+
1666
//				"public class XX31 {\n"+
1667
//				"}");
1668
//		
1669
//		this.createFolder("/P3/src/p32");
1670
//		this.createFile(
1671
//				"/P3/src/p32/XX32.js",
1672
//				"package p32;\n"+
1673
//				"public class XX32 {\n"+
1674
//				"}");
1675
//		
1676
//		// create PX
1677
//		this.createJavaProject(
1678
//				"PX",
1679
//				new String[]{"src"},
1680
//				new String[]{"JCL_LIB"},
1681
//				null,
1682
//				null,
1683
//				new String[]{"/P2"},
1684
//				null,
1685
//				null,
1686
//				new boolean[]{false},
1687
//				"bin",
1688
//				null,
1689
//				null,
1690
//				null,
1691
//				"1.4");
1692
//		
1693
//		this.createFile(
1694
//				"/PX/src/X.js",
1695
//				"public class X {\n"+
1696
//				"  void foo() {\n"+
1697
//				"    XX\n"+
1698
//				"  }\n"+
1699
//				"}");
1700
//		
1701
//		waitUntilIndexesReady();
1702
//		
1703
//		// do completion
1704
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
1705
//		IJavaScriptUnit cu= getCompilationUnit("PX", "src", "", "X.js");
1706
//		
1707
//		String str = cu.getSource();
1708
//		String completeBehind = "XX";
1709
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1710
//		cu.codeComplete(cursorLocation, requestor);
1711
//		
1712
//		assertResults(
1713
//			"XX11[TYPE_REF]{p11.XX11, p11, Lp11.XX11;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" +
1714
//			"XX31[TYPE_REF]{p31.XX31, p31, Lp31.XX31;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" +
1715
//			"XX12[TYPE_REF]{p12.XX12, p12, Lp12.XX12;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1716
//			"XX21[TYPE_REF]{p21.XX21, p21, Lp21.XX21;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1717
//			"XX22[TYPE_REF]{p22.XX22, p22, Lp22.XX22;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1718
//			"XX32[TYPE_REF]{p32.XX32, p32, Lp32.XX32;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1719
//			requestor.getResults());
1720
//	} finally {
1721
//		this.deleteProject("P1");
1722
//		this.deleteProject("P2");
1723
//		this.deleteProject("P3");
1724
//		this.deleteProject("PX");
1725
//		JavaScriptCore.setOptions(oldOptions);
1726
//	}
1727
//}
1728
//public void testAccessRestriction11() throws Exception {
1729
//	Hashtable oldOptions = JavaScriptCore.getOptions();
1730
//	try {
1731
//		Hashtable options = new Hashtable(oldOptions);
1732
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
1733
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
1734
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1735
//		JavaScriptCore.setOptions(options);
1736
//		
1737
//		// create variable
1738
////		JavaScriptCore.setClasspathVariables(
1739
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
1740
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
1741
////			null);
1742
//
1743
//		// create P1
1744
//		this.createJavaProject(
1745
//			"P1",
1746
//			new String[]{"src"},
1747
//			new String[]{"JCL_LIB"},
1748
//			 "bin");
1749
//		
1750
//		this.createFolder("/P1/src/x/y/z/p11");
1751
//		this.createFile(
1752
//				"/P1/src/x/y/z/p11/XX11.js",
1753
//				"package x.y.z.p11;\n"+
1754
//				"public class XX11 {\n"+
1755
//				"}");
1756
//		
1757
//		this.createFolder("/P1/src/x/y/z/p12");
1758
//		this.createFile(
1759
//				"/P1/src/x/y/z/p12/XX12.js",
1760
//				"package x.y.z.p12;\n"+
1761
//				"public class XX12 {\n"+
1762
//				"}");
1763
//		
1764
//		// create P2
1765
//		this.createJavaProject(
1766
//			"P2",
1767
//			new String[]{"src"},
1768
//			new String[]{"JCL_LIB"},
1769
//			null,
1770
//			null,
1771
//			new String[]{"/P3", "/P1"},
1772
//			new String[][]{{}, {}},
1773
//			new String[][]{{"x/y/z/p31/*"}, {"x/y/z/p11/*"}},
1774
//			new boolean[]{true, true},
1775
//			"bin",
1776
//			null,
1777
//			null,
1778
//			null,
1779
//			"1.4");
1780
//		
1781
//		this.createFolder("/P2/src/x/y/z/p21");
1782
//		this.createFile(
1783
//				"/P2/src/x/y/z/p21/XX21.js",
1784
//				"package x.y.z.p21;\n"+
1785
//				"public class XX21 {\n"+
1786
//				"}");
1787
//		
1788
//		this.createFolder("/P2/src/x/y/z/p22");
1789
//		this.createFile(
1790
//				"/P2/src/x/y/z/p22/XX22.js",
1791
//				"package x.y.z.p22;\n"+
1792
//				"public class XX22 {\n"+
1793
//				"}");
1794
//		
1795
//		// create P3
1796
//		this.createJavaProject(
1797
//			"P3",
1798
//			new String[]{"src"},
1799
//			new String[]{"JCL_LIB"},
1800
//			null,
1801
//			null,
1802
//			new String[]{"/P1"},
1803
//			new String[][]{{}},
1804
//			new String[][]{{"x/y/z/p12/*"}},
1805
//			new boolean[]{true},
1806
//			"bin",
1807
//			null,
1808
//			null,
1809
//			null,
1810
//			"1.4");
1811
//		
1812
//		this.createFolder("/P3/src/x/y/z/p31");
1813
//		this.createFile(
1814
//				"/P3/src/x/y/z/p31/XX31.js",
1815
//				"package x.y.z.p31;\n"+
1816
//				"public class XX31 {\n"+
1817
//				"}");
1818
//		
1819
//		this.createFolder("/P3/src/x/y/z/p32");
1820
//		this.createFile(
1821
//				"/P3/src/x/y/z/p32/XX32.js",
1822
//				"package x.y.z.p32;\n"+
1823
//				"public class XX32 {\n"+
1824
//				"}");
1825
//		
1826
//		// create PX
1827
//		this.createJavaProject(
1828
//				"PX",
1829
//				new String[]{"src"},
1830
//				new String[]{"JCL_LIB"},
1831
//				null,
1832
//				null,
1833
//				new String[]{"/P2"},
1834
//				null,
1835
//				null,
1836
//				new boolean[]{false},
1837
//				"bin",
1838
//				null,
1839
//				null,
1840
//				null,
1841
//				"1.4");
1842
//		
1843
//		this.createFile(
1844
//				"/PX/src/X.js",
1845
//				"public class X {\n"+
1846
//				"  void foo() {\n"+
1847
//				"    XX\n"+
1848
//				"  }\n"+
1849
//				"}");
1850
//		
1851
//		waitUntilIndexesReady();
1852
//		
1853
//		// do completion
1854
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
1855
//		IJavaScriptUnit cu= getCompilationUnit("PX", "src", "", "X.js");
1856
//		
1857
//		String str = cu.getSource();
1858
//		String completeBehind = "XX";
1859
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1860
//		cu.codeComplete(cursorLocation, requestor);
1861
//		
1862
//		assertResults(
1863
//			"XX11[TYPE_REF]{x.y.z.p11.XX11, x.y.z.p11, Lx.y.z.p11.XX11;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1864
//			"XX21[TYPE_REF]{x.y.z.p21.XX21, x.y.z.p21, Lx.y.z.p21.XX21;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1865
//			"XX22[TYPE_REF]{x.y.z.p22.XX22, x.y.z.p22, Lx.y.z.p22.XX22;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1866
//			"XX32[TYPE_REF]{x.y.z.p32.XX32, x.y.z.p32, Lx.y.z.p32.XX32;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1867
//			requestor.getResults());
1868
//	} finally {
1869
//		this.deleteProject("P1");
1870
//		this.deleteProject("P2");
1871
//		this.deleteProject("P3");
1872
//		this.deleteProject("PX");
1873
//		JavaScriptCore.setOptions(oldOptions);
1874
//	}
1875
//}
1876
//public void testAccessRestriction12() throws Exception {
1877
//	Hashtable oldOptions = JavaScriptCore.getOptions();
1878
//	try {
1879
//		Hashtable options = new Hashtable(oldOptions);
1880
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
1881
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1882
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
1883
//		JavaScriptCore.setOptions(options);
1884
//		
1885
//		// create variable
1886
////		JavaScriptCore.setClasspathVariables(
1887
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
1888
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
1889
////			null);
1890
//
1891
//		// create P1
1892
//		this.createJavaProject(
1893
//			"P1",
1894
//			new String[]{"src"},
1895
//			new String[]{"JCL_LIB"},
1896
//			 "bin");
1897
//		
1898
//		this.createFolder("/P1/src/p11");
1899
//		this.createFile(
1900
//				"/P1/src/p11/XX11.js",
1901
//				"package p11;\n"+
1902
//				"public class XX11 {\n"+
1903
//				"}");
1904
//		
1905
//		this.createFolder("/P1/src/p12");
1906
//		this.createFile(
1907
//				"/P1/src/p12/XX12.js",
1908
//				"package p12;\n"+
1909
//				"public class XX12 {\n"+
1910
//				"}");
1911
//		
1912
//		// create P2
1913
//		this.createJavaProject(
1914
//			"P2",
1915
//			new String[]{"src"},
1916
//			new String[]{"JCL_LIB"},
1917
//			null,
1918
//			null,
1919
//			new String[]{"/P3", "/P1"},
1920
//			new String[][]{{}, {}},
1921
//			new String[][]{{"p31/*"}, {"p11/*"}},
1922
//			new boolean[]{true, true},
1923
//			"bin",
1924
//			null,
1925
//			null,
1926
//			null,
1927
//			"1.4");
1928
//		
1929
//		this.createFolder("/P2/src/p21");
1930
//		this.createFile(
1931
//				"/P2/src/p21/XX21.js",
1932
//				"package p21;\n"+
1933
//				"public class XX21 {\n"+
1934
//				"}");
1935
//		
1936
//		this.createFolder("/P2/src/p22");
1937
//		this.createFile(
1938
//				"/P2/src/p22/XX22.js",
1939
//				"package p22;\n"+
1940
//				"public class XX22 {\n"+
1941
//				"}");
1942
//		
1943
//		// create P3
1944
//		this.createJavaProject(
1945
//			"P3",
1946
//			new String[]{"src"},
1947
//			new String[]{"JCL_LIB"},
1948
//			null,
1949
//			null,
1950
//			new String[]{"/P1"},
1951
//			new String[][]{{}},
1952
//			new String[][]{{"p12/*"}},
1953
//			new boolean[]{true},
1954
//			"bin",
1955
//			null,
1956
//			null,
1957
//			null,
1958
//			"1.4");
1959
//		
1960
//		this.createFolder("/P3/src/p31");
1961
//		this.createFile(
1962
//				"/P3/src/p31/XX31.js",
1963
//				"package p31;\n"+
1964
//				"public class XX31 {\n"+
1965
//				"}");
1966
//		
1967
//		this.createFolder("/P3/src/p32");
1968
//		this.createFile(
1969
//				"/P3/src/p32/XX32.js",
1970
//				"package p32;\n"+
1971
//				"public class XX32 {\n"+
1972
//				"}");
1973
//		
1974
//		// create PX
1975
//		this.createJavaProject(
1976
//				"PX",
1977
//				new String[]{"src"},
1978
//				new String[]{"JCL_LIB"},
1979
//				null,
1980
//				null,
1981
//				new String[]{"/P2"},
1982
//				null,
1983
//				null,
1984
//				new boolean[]{false},
1985
//				"bin",
1986
//				null,
1987
//				null,
1988
//				null,
1989
//				"1.4");
1990
//		
1991
//		this.createFile(
1992
//				"/PX/src/X.js",
1993
//				"public class X {\n"+
1994
//				"  void foo() {\n"+
1995
//				"    XX\n"+
1996
//				"  }\n"+
1997
//				"}");
1998
//		
1999
//		waitUntilIndexesReady();
2000
//		
2001
//		// do completion
2002
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2003
//		IJavaScriptUnit cu= getCompilationUnit("PX", "src", "", "X.js");
2004
//		
2005
//		String str = cu.getSource();
2006
//		String completeBehind = "XX";
2007
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2008
//		cu.codeComplete(cursorLocation, requestor);
2009
//		
2010
//		assertResults(
2011
//			"XX12[TYPE_REF]{p12.XX12, p12, Lp12.XX12;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" +
2012
//			"XX31[TYPE_REF]{p31.XX31, p31, Lp31.XX31;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE) + "}\n" +
2013
//			"XX11[TYPE_REF]{p11.XX11, p11, Lp11.XX11;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
2014
//			"XX21[TYPE_REF]{p21.XX21, p21, Lp21.XX21;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
2015
//			"XX22[TYPE_REF]{p22.XX22, p22, Lp22.XX22;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
2016
//			"XX32[TYPE_REF]{p32.XX32, p32, Lp32.XX32;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
2017
//			requestor.getResults());
2018
//	} finally {
2019
//		this.deleteProject("P1");
2020
//		this.deleteProject("P2");
2021
//		this.deleteProject("P3");
2022
//		this.deleteProject("PX");
2023
//		JavaScriptCore.setOptions(oldOptions);
2024
//	}
2025
//}
2026
//public void testAccessRestriction13() throws Exception {
2027
//	Hashtable oldOptions = JavaScriptCore.getOptions();
2028
//	try {
2029
//		Hashtable options = new Hashtable(oldOptions);
2030
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.WARNING);
2031
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
2032
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.DISABLED);
2033
//		JavaScriptCore.setOptions(options);
2034
//		
2035
//		// create variable
2036
////		JavaScriptCore.setClasspathVariables(
2037
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
2038
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
2039
////			null);
2040
//
2041
//		// create P1
2042
//		this.createJavaProject(
2043
//			"P1",
2044
//			new String[]{"src"},
2045
//			new String[]{"JCL_LIB"},
2046
//			 "bin");
2047
//		
2048
//		this.createFolder("/P1/src/a");
2049
//		this.createFile(
2050
//				"/P1/src/a/XX1.js",
2051
//				"package a;\n"+
2052
//				"public class XX1 {\n"+
2053
//				"}");
2054
//
2055
//		this.createFolder("/P1/src/b");
2056
//		this.createFile(
2057
//				"/P1/src/b/XX2.js",
2058
//				"package b;\n"+
2059
//				"public class XX2 {\n"+
2060
//				"}");
2061
//		
2062
//		// create P2
2063
//		this.createJavaProject(
2064
//			"P2",
2065
//			new String[]{"src"},
2066
//			new String[]{"JCL_LIB"},
2067
//			null,
2068
//			null,
2069
//			new String[]{"/P1"},
2070
//			new String[][]{{}},
2071
//			new String[][]{{"a/*"}},
2072
//			new boolean[]{false},
2073
//			"bin",
2074
//			null,
2075
//			null,
2076
//			null,
2077
//			"1.4");
2078
//		this.createFile(
2079
//			"/P2/src/YY.js",
2080
//			"public class YY {\n"+
2081
//			"  void foo() {\n"+
2082
//			"    XX\n"+
2083
//			"  }\n"+
2084
//			"}");
2085
//		
2086
//		waitUntilIndexesReady();
2087
//		
2088
//		// do completion
2089
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2090
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
2091
//		
2092
//		String str = cu.getSource();
2093
//		String completeBehind = "XX";
2094
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2095
//		cu.codeComplete(cursorLocation, requestor);
2096
//		
2097
//		assertResults(
2098
//			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
2099
//			requestor.getResults());
2100
//	} finally {
2101
//		this.deleteProject("P1");
2102
//		this.deleteProject("P2");
2103
//		JavaScriptCore.setOptions(oldOptions);
2104
//	}
2105
//}
2106
//public void testAccessRestriction14() throws Exception {
2107
//	Hashtable oldOptions = JavaScriptCore.getOptions();
2108
//	try {
2109
//		Hashtable options = new Hashtable(oldOptions);
2110
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.WARNING);
2111
//		options.put(JavaScriptCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaScriptCore.ENABLED);
2112
//		options.put(JavaScriptCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaScriptCore.ENABLED);
2113
//		JavaScriptCore.setOptions(options);
2114
//		
2115
//		// create variable
2116
////		JavaScriptCore.setClasspathVariables(
2117
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
2118
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
2119
////			null);
2120
//
2121
//		// create P1
2122
//		this.createJavaProject(
2123
//			"P1",
2124
//			new String[]{"src"},
2125
//			new String[]{"JCL_LIB"},
2126
//			 "bin");
2127
//		
2128
//		this.createFolder("/P1/src/a");
2129
//		this.createFile(
2130
//				"/P1/src/a/XX1.js",
2131
//				"package a;\n"+
2132
//				"public class XX1 {\n"+
2133
//				"}");
2134
//
2135
//		this.createFolder("/P1/src/b");
2136
//		this.createFile(
2137
//				"/P1/src/b/XX2.js",
2138
//				"package b;\n"+
2139
//				"public class XX2 {\n"+
2140
//				"}");
2141
//		
2142
//		// create P2
2143
//		this.createJavaProject(
2144
//			"P2",
2145
//			new String[]{"src"},
2146
//			new String[]{"JCL_LIB"},
2147
//			null,
2148
//			null,
2149
//			new String[]{"/P1"},
2150
//			new String[][]{{}},
2151
//			new String[][]{{"a/*"}},
2152
//			new boolean[]{false},
2153
//			"bin",
2154
//			null,
2155
//			null,
2156
//			null,
2157
//			"1.4");
2158
//		this.createFile(
2159
//			"/P2/src/YY.js",
2160
//			"public class YY {\n"+
2161
//			"  void foo() {\n"+
2162
//			"    XX\n"+
2163
//			"  }\n"+
2164
//			"}");
2165
//		
2166
//		waitUntilIndexesReady();
2167
//		
2168
//		// do completion
2169
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2170
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
2171
//		
2172
//		String str = cu.getSource();
2173
//		String completeBehind = "XX";
2174
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2175
//		cu.codeComplete(cursorLocation, requestor);
2176
//		
2177
//		assertResults(
2178
//			"XX2[TYPE_REF]{b.XX2, b, Lb.XX2;, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
2179
//			requestor.getResults());
2180
//	} finally {
2181
//		this.deleteProject("P1");
2182
//		this.deleteProject("P2");
2183
//		JavaScriptCore.setOptions(oldOptions);
2184
//	}
2185
//}
2186
//public void testAccessRestrictionX() throws Exception {
2187
//	Hashtable oldOptions = JavaScriptCore.getOptions();
2188
//	try {
2189
//		Hashtable options = new Hashtable(oldOptions);
2190
//		options.put(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaScriptCore.ERROR);
2191
//		options.put(JavaScriptCore.CODEASSIST_RESTRICTIONS_CHECK, JavaScriptCore.DISABLED);
2192
//		JavaScriptCore.setOptions(options);
2193
//		
2194
//		// create variable
2195
//		JavaScriptCore.setClasspathVariables(
2196
//			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
2197
//			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
2198
//			null);
2199
//
2200
//		// create P1
2201
//		this.createJavaProject(
2202
//			"P1",
2203
//			new String[]{"src"},
2204
//			new String[]{"JCL_LIB"},
2205
//			 "bin");
2206
//		
2207
//		this.createFolder("/P1/src/a");
2208
//		this.createFile(
2209
//				"/P1/src/a/XX1.js",
2210
//				"package a;\n"+
2211
//				"public class XX1 {\n"+
2212
//				"  public void foo() {\n"+
2213
//				"  }\n"+
2214
//				"}");
2215
//		
2216
//		// create P2
2217
//		this.createJavaProject(
2218
//			"P2",
2219
//			new String[]{"src"},
2220
//			new String[]{"JCL_LIB"},
2221
//			null,
2222
//			null,
2223
//			new String[]{"/P1"},
2224
//			new String[][]{{}},
2225
//			new String[][]{{"a/*"}},
2226
//			new boolean[]{false},
2227
//			"bin",
2228
//			null,
2229
//			null,
2230
//			null,
2231
//			"1.4");
2232
//		this.createFile(
2233
//			"/P2/src/YY.js",
2234
//			"public class YY {\n"+
2235
//			"  void foo() {\n"+
2236
//			"    a.XX1 x;\n"+
2237
//			"    x.fo\n"+
2238
//			"  }\n"+
2239
//			"}");
2240
//		
2241
//		waitUntilIndexesReady();
2242
//		
2243
//		// do completion
2244
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2245
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "YY.js");
2246
//		
2247
//		String str = cu.getSource();
2248
//		String completeBehind = "x.fo";
2249
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2250
//		cu.codeComplete(cursorLocation, requestor);
2251
//		
2252
//		assertResults(
2253
//			"foo[FUNCTION_REF]{foo(), La.XX1;, ()V, foo, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC) + "}",
2254
//			requestor.getResults());
2255
//	} finally {
2256
//		this.deleteProject("P1");
2257
//		this.deleteProject("P2");
2258
//		JavaScriptCore.setOptions(oldOptions);
2259
//	}
2260
//}
2261
//public void testBug96950() throws Exception {
2262
//	try {
2263
//		// create variable
2264
////		JavaScriptCore.setClasspathVariables(
2265
////			new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
2266
////			new IPath[] {getExternalJCLPath(), getExternalJCLSourcePath(), getExternalJCLRootSourcePath()},
2267
////			null);
2268
//
2269
//		// create P1
2270
//		this.createJavaProject(
2271
//			"P1",
2272
//			new String[]{"src"},
2273
//			new String[]{"JCL_LIB"},
2274
//			 "bin");
2275
//		this.createFile(
2276
//				"/P1/src/Taratata.js",
2277
//				"public class Taratata {\n"+
2278
//				"}");
2279
//		
2280
//		// create P2
2281
//		this.createJavaProject(
2282
//			"P2",
2283
//			new String[]{"src"},
2284
//			new String[]{"JCL_LIB"},
2285
//			null,
2286
//			null,
2287
//			new String[]{"/P1"},
2288
//			new String[][]{{}},
2289
//			new String[][]{{"**/*"}},
2290
//			new boolean[]{false},
2291
//			"bin",
2292
//			null,
2293
//			null,
2294
//			null,
2295
//			"1.4");
2296
//		this.createFile(
2297
//				"/P2/src/BreakRules.js",
2298
//				"public class BreakRules {\n"+
2299
//				"	Tara\n"+
2300
//				"}");
2301
//		
2302
//		waitUntilIndexesReady();
2303
//		
2304
//		// do completion
2305
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2306
//		IJavaScriptUnit cu= getCompilationUnit("P2", "src", "", "BreakRules.js");
2307
//		
2308
//		String str = cu.getSource();
2309
//		String completeBehind = "Tara";
2310
//		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2311
//		cu.codeComplete(cursorLocation, requestor);
2312
//		
2313
//		assertResults(
2314
//			"Tara[POTENTIAL_METHOD_DECLARATION]{Tara, LBreakRules;, ()V, Tara, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
2315
//			requestor.getResults());
2316
//	} finally {
2317
//		this.deleteProject("P1");
2318
//		this.deleteProject("P2");
2319
//	}
2320
//}
2321
/**
2322
 * @bug 162621: [model][delta] Validation errors do not clear after replacing jar file
2323
 * @test Ensures that changing an internal jar and refreshing takes the change into account
2324
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=162621"
2325
 */
2326
//public void testChangeInternalJar() throws CoreException, IOException {
2327
//	
2328
//	
2329
//	IJavaScriptProject p = this.createJavaProject(
2330
//				"P1",
2331
//				new String[]{"/"},
2332
//				new String[]{},
2333
//				 "");
2334
//	
2335
//	
2336
//	
2337
//	
2338
//	try {
2339
//		// Create jar file with a class with 2 methods doXXX
2340
//		String[] pathAndContents = new String[] {
2341
//			"pack/Util.js",
2342
//			"package pack;\n" + 
2343
//			"public class Util {\n" + 
2344
//			"    public void doit2A(int x, int y) { }\n" + 
2345
//			"    public void doit2B(int x) { }\n" + 
2346
//			"}\n"
2347
//		};
2348
//		addLibrary(jarName, "b162621_src.zip", pathAndContents, JavaScriptCore.VERSION_1_4);
2349
//
2350
//		// Wait a little bit to be sure file system is aware of zip file creation
2351
//		try {
2352
//			Thread.sleep(1000);
2353
//		}
2354
//		catch (InterruptedException ie) {
2355
//			// skip
2356
//		}
2357
//
2358
//		// Create compilation unit in which completion occurs
2359
//		String path = "/Completion/src/test/Test.js";
2360
//		String source = "package test;\n" + 
2361
//			"import pack.*;\n" + 
2362
//			"public class Test {\n" + 
2363
//			"	public void foo() {\n" + 
2364
//			"		Util test = new Util();\n" + 
2365
//			"		test.doit2A(1, 2);\n" + 
2366
//			"	}\n" + 
2367
//			"}\n";
2368
//		createFolder("/Completion/src/test");
2369
//		createFile(path, source);
2370
//
2371
//		// first completion
2372
//		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2373
//		IJavaScriptUnit unit = getCompilationUnit(path);
2374
//		String completeBehind = "test.do";
2375
//		int cursorLocation = source.lastIndexOf(completeBehind) + completeBehind.length();
2376
//		unit.codeComplete(cursorLocation, requestor);
2377
//		assertResults(
2378
//			"doit2A[FUNCTION_REF]{doit2A, Lpack.Util;, (II)V, doit2A, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" +
2379
//			"doit2B[FUNCTION_REF]{doit2B, Lpack.Util;, (I)V, doit2B, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}",
2380
//			requestor.getResults());
2381
//
2382
//		// change class file to add a third doXXX method and refresh
2383
//		String projectLocation = this.currentProject.getProject().getLocation().toOSString();
2384
//		String jarPath = projectLocation + File.separator + jarName;
2385
//		org.eclipse.wst.jsdt.core.tests.util.Util.createJar(new String[] {
2386
//			"pack/Util.js",
2387
//			"package pack;\n" + 
2388
//			"public class Util {\n" + 
2389
//			"    public void doit2A(int x, int y) { }\n" + 
2390
//			"    public void doit2B(int x) { }\n" + 
2391
//			"    public void doit2C(int x) { }\n" + 
2392
//			"}\n"
2393
//		}, jarPath, "1.4");
2394
//		this.currentProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
2395
//
2396
//		try {
2397
//			Thread.sleep(1000);
2398
//		}
2399
//		catch (InterruptedException ie) {
2400
//			// skip
2401
//		}
2402
//
2403
//		// second completion
2404
//		requestor = new CompletionTestsRequestor2();
2405
//		unit.codeComplete(cursorLocation, requestor);
2406
//		assertResults(
2407
//			"doit2A[FUNCTION_REF]{doit2A, Lpack.Util;, (II)V, doit2A, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" +
2408
//			"doit2B[FUNCTION_REF]{doit2B, Lpack.Util;, (I)V, doit2B, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}\n" +
2409
//			"doit2C[FUNCTION_REF]{doit2C, Lpack.Util;, (I)V, doit2C, "+(R_DEFAULT + R_CASE + R_INTERESTING + R_NON_RESTRICTED + R_NON_STATIC) + "}",
2410
//			requestor.getResults());
2411
//	} finally {
2412
//		removeLibraryEntry(this.currentProject, new Path(jarName));
2413
//		deleteFile(new File(jarName));
2414
//	}
2415
//}
2416
}
(-)src/org/eclipse/wst/jsdt/core/tests/model/JSDTModelTests.java (-138 / +3 lines)
Lines 47-193 Link Here
47
		// Binding key tests
47
		// Binding key tests
48
		BindingKeyTests.class,
48
		BindingKeyTests.class,
49
49
50
//		// creation of method
50
		// Working copy tests
51
//		CreateMembersTests.class,
52
//		
53
//		// Java Naming convention tests
54
//		JavaConventionTests.class,
55
//	
56
//		// Project & Root API unit tests
57
//		JavaProjectTests.class,
58
//	
59
//		// Compilation unit tests
60
//		CompilationUnitTests.class,
61
//	
62
//		// Source attachment tests
63
//		AttachSourceTests.class,
64
//		
65
//		// Attached javadoc tests
66
//		AttachedJavadocTests.class,
67
//	
68
//		// Java search tests
69
//		RunJavaSearchTests.class,
70
//			
71
//		// Working copy tests
72
		WorkingCopyTests.class,
51
		WorkingCopyTests.class,
73
//		WorkingCopyNotInClasspathTests.class,
52
74
//		HierarchyOnWorkingCopiesTests.class,
75
//		
76
//		// test IJavaScriptModel
77
//		JavaModelTests.class,
78
//	
79
//		// tests to check the encoding
80
//		EncodingTests.class,
81
//		
82
//		// test class name with special names like names containing '$'
83
//		ClassNameTests.class,
84
//		
85
		// IBuffer tests
53
		// IBuffer tests
86
		BufferTests.class,
54
		BufferTests.class,
87
//	
55
88
//		// Name lookup tests
89
//		NameLookupTests2.class,
90
//	
91
//		// Classpath and output location tests
92
//		ClasspathTests.class,
93
//	
94
//		// Delta tests
95
//		JavaElementDeltaTests.class,
96
//		ExternalJarDeltaTests.class,
97
//	
98
//		// Java element existence tests
99
//		ExistenceTests.class,
100
//		
101
//		// Support for "open on" feature tests
102
//		ResolveTests.class,
103
//		ResolveTests_1_5.class,
104
//		SelectionJavadocModelTests.class,
105
//
106
//		// Support for completion tests
107
		RunCompletionModelTests.class,
108
//		
109
//		// Prefix and suffix tests
110
//		NamingConventionTests.class,
111
//		
112
//		// Code correction tests
113
//		CodeCorrectionTests.class,
114
//		
115
//		// Options tests
116
//		OptionTests.class,
117
//		
118
//		// Type hierarchy tests
119
//		TypeHierarchyTests.class,
120
//		TypeHierarchyNotificationTests.class,
121
//		TypeHierarchySerializationTests.class,
122
//		
123
//		// Resolve type tests
124
//		TypeResolveTests.class,
125
//	
126
//		// Reconciler tests
127
//		ReconcilerTests.class,
128
//		ReconcilerStatementsRecoveryTests.class,
129
//		
130
//		// Copy and move operation tests
131
//		CopyMoveElementsTests.class,
132
//		CopyMoveResourcesTests.class,
133
//	
134
//		// Rename tests
135
//		RenameTests.class,
136
//		
137
//		// Exclusion patterns tests
138
//		ExclusionPatternsTests.class,
139
//		
140
//		// Inclusion patterns tests
141
//		InclusionPatternsTests.class,
142
//		
143
//		// Access restrictions tests
144
//		AccessRestrictionsTests.class,
145
//		
146
//		// Signature tests
147
//		SignatureTests.class,
148
//		
149
//		// Variable initializers and container initializers tests
150
//		ClasspathInitializerTests.class,
151
//	
152
//		// Java Model Factory tests
153
//		FactoryTests.class,
154
//				
155
//		// Java Element persistence tests
156
//		MementoTests.class,
157
//		
158
//		// Java Element sorting tests
159
//		SortCompilationUnitElementsTests.class,
160
//	
161
//		// Package fragment root manipulation tests
162
//		RootManipulationsTests.class,
163
//		
164
//		// Owverflowing cache tests
165
//		OverflowingCacheTests.class,
166
//		
167
//		// Working copy owner tests
168
//		WorkingCopyOwnerTests.class,
169
//	
170
//		// Delete Java element tests
171
//		DeleteTests.class,
172
//		
173
//		// Local element tests
174
//		LocalElementTests.class,
175
//		
176
//		// Get source tests
177
//		GetSourceTests.class,
178
//			
179
//		// Create packages tests
180
//		CreatePackageTests.class,
181
//	
182
//		// Create compilation units tests
183
//		CreateCompilationUnitTests.class,
184
//		
185
//		// Create search participant tests
186
//		SearchParticipantTests.class,
187
//		
188
//		// Class file tests
189
//		ClassFileTests.class,
190
//		
191
		// Java-like extensions tests
56
		// Java-like extensions tests
192
		JavaScriptLikeExtensionsTests.class,
57
		JavaScriptLikeExtensionsTests.class,
193
		
58
		
(-)src/org/eclipse/wst/jsdt/core/tests/model/RunCompletionModelTests.java (-100 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.core.tests.model;
12
13
import java.lang.reflect.*;
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.wst.jsdt.core.tests.junit.extension.TestCase;
18
19
import junit.framework.Test;
20
import junit.framework.TestSuite;
21
22
public class RunCompletionModelTests extends junit.framework.TestCase {
23
24
	protected static final boolean ONLY_JAVADOC = "true".equals(System.getProperty("onlyJavadoc", "false"));
25
26
	public final static List COMPLETION_SUITES = new ArrayList();
27
	static {
28
		if (!ONLY_JAVADOC) {
29
			if(false) COMPLETION_SUITES.add(CompletionTests.class);
30
			COMPLETION_SUITES.add(CompletionTests2.class);
31
			if(false) COMPLETION_SUITES.add(CompletionContextTests.class);
32
			if(false) COMPLETION_SUITES.add(CompletionWithMissingTypesTests.class);
33
			if(false) COMPLETION_SUITES.add(CompletionWithMissingTypesTests2.class);
34
			if(false) COMPLETION_SUITES.add(SnippetCompletionContextTests.class);
35
		}
36
		if(false) COMPLETION_SUITES.add(JavadocTypeCompletionModelTest.class);
37
		if(false) COMPLETION_SUITES.add(JavadocFieldCompletionModelTest.class);
38
		if(false) COMPLETION_SUITES.add(JavadocMethodCompletionModelTest.class);
39
		if(false) COMPLETION_SUITES.add(JavadocPackageCompletionModelTest.class);
40
		if(false) COMPLETION_SUITES.add(JavadocTextCompletionModelTest.class);
41
		if(false) COMPLETION_SUITES.add(JavadocBugsCompletionModelTest.class);
42
		if(false) COMPLETION_SUITES.add(JavadocCompletionContextTests.class);
43
	}
44
45
	public static Class[] getTestClasses() {
46
//		int size = COMPLETION_SUITES.size();
47
//		if (!ONLY_JAVADOC) {
48
//			Class[] testClasses = new Class[size+1];
49
//			COMPLETION_SUITES.toArray(testClasses);
50
//			testClasses[size] = CompletionTests2.class;
51
//			testClasses[size+1] = CompletionWithMissingTypesTests2.class;
52
//			if(false) testClasses[size+2] = SnippetCompletionTests.class;
53
//			if(false) testClasses[size+3] = SnippetCompletionTests_1_5.class;
54
//			return testClasses;
55
//		}
56
//		Class[] testClasses = new Class[size];
57
		return  (Class[])COMPLETION_SUITES.toArray(new Class[COMPLETION_SUITES.size()]);
58
		//return testClasses;
59
	}
60
61
	public RunCompletionModelTests(String name) {
62
		super(name);
63
	}
64
65
	public static Test suite() {
66
		TestSuite ts = new TestSuite(RunCompletionModelTests.class.getName());
67
68
		// Store test classes with same "Completion"project
69
		AbstractJavaModelCompletionTests.COMPLETION_SUITES = new ArrayList(COMPLETION_SUITES);
70
71
		// Get all classes
72
		Class[] allClasses = getTestClasses();
73
74
		// Reset forgotten subsets of tests
75
		TestCase.TESTS_PREFIX = null;
76
		TestCase.TESTS_NAMES = null;
77
		TestCase.TESTS_NUMBERS = null;
78
		TestCase.TESTS_RANGE = null;
79
		TestCase.RUN_ONLY_ID = null;
80
81
		// Add all tests suite of tests
82
		for (int i = 0, length = allClasses.length; i < length; i++) {
83
			Class testClass = allClasses[i];
84
85
			// call the suite() method and add the resulting suite to the suite
86
			try {
87
				Method suiteMethod = testClass.getDeclaredMethod("suite", new Class[0]); //$NON-NLS-1$
88
				Test suite = (Test) suiteMethod.invoke(null, new Object[0]);
89
				ts.addTest(suite);
90
			} catch (IllegalAccessException e) {
91
				e.printStackTrace();
92
			} catch (InvocationTargetException e) {
93
				e.getTargetException().printStackTrace();
94
			} catch (NoSuchMethodException e) {
95
				e.printStackTrace();
96
			}
97
		}
98
		return ts;
99
	}
100
}
(-)src/org/eclipse/wst/jsdt/internal/ui/text/java/JavaMethodCompletionProposal.java (-2 / +7 lines)
Lines 196-203 Link Here
196
			parameterCount= Signature.getParameterCount(fProposal.getSignature()) % 10; // we don't care about insane methods with >9 parameters
196
			parameterCount= Signature.getParameterCount(fProposal.getSignature()) % 10; // we don't care about insane methods with >9 parameters
197
		} else {
197
		} else {
198
			char[][] params = this.fProposal.getParamaterNames();
198
			char[][] params = this.fProposal.getParamaterNames();
199
			parameterList = CharOperation.concatWith(params, ',');
199
			if(params != null) {
200
			parameterCount = params.length % 10; // we don't care about insane methods with >9 parameters
200
				parameterList = CharOperation.concatWith(params, ',');
201
				parameterCount = params.length % 10; // we don't care about insane methods with >9 parameters
202
			} else {
203
				parameterList = new char[0];
204
				parameterCount = 0;
205
			}
201
		}
206
		}
202
		
207
		
203
		StringBuffer buf= new StringBuffer(name.length + 2 + parameterList.length);
208
		StringBuffer buf= new StringBuffer(name.length + 2 + parameterList.length);
(-)src/org/eclipse/wst/jsdt/ui/text/java/CompletionProposalLabelProvider.java (-20 / +20 lines)
Lines 203-209 Link Here
203
					buffer.append(',');
203
					buffer.append(',');
204
					buffer.append(' ');
204
					buffer.append(' ');
205
				}
205
				}
206
				if (parameterTypes[i].length > 0 & !Arrays.equals(Signature.ANY, parameterTypes[i])) {
206
				if (parameterTypes[i] != null && parameterTypes[i].length > 0 &&  !Arrays.equals(Signature.ANY, parameterTypes[i])) {
207
					buffer.append(parameterTypes[i]);
207
					buffer.append(parameterTypes[i]);
208
					buffer.append(' ');
208
					buffer.append(' ');
209
				}
209
				}
Lines 249-258 Link Here
249
249
250
		// return type
250
		// return type
251
		if (!methodProposal.isConstructor()) {
251
		if (!methodProposal.isConstructor()) {
252
			// TODO remove SignatureUtil.fix83600 call when bugs are fixed
252
			char[] returnType= methodProposal.getReturnType();
253
			char[] returnType= createTypeDisplayName(Signature.getReturnType(methodProposal.getSignature()));
253
			if (returnType != null && returnType.length > 0 &&  !Arrays.equals(Signature.ANY,returnType)) {
254
			if (!Arrays.equals(Signature.ANY,returnType))
255
			{
256
				nameBuffer.append("  "); //$NON-NLS-1$
254
				nameBuffer.append("  "); //$NON-NLS-1$
257
				//@GINO: Anonymous UI Label
255
				//@GINO: Anonymous UI Label
258
				org.eclipse.wst.jsdt.internal.core.util.Util.insertTypeLabel( returnType, nameBuffer );
256
				org.eclipse.wst.jsdt.internal.core.util.Util.insertTypeLabel( returnType, nameBuffer );
Lines 260-270 Link Here
260
		}
258
		}
261
259
262
		// declaring type
260
		// declaring type
263
		nameBuffer.append(" - "); //$NON-NLS-1$
264
		String declaringType= extractDeclaringTypeFQN(methodProposal);
261
		String declaringType= extractDeclaringTypeFQN(methodProposal);
265
		
262
		if(declaringType != null) {
266
		//@GINO: Anonymous UI Label
263
			nameBuffer.append(" - "); //$NON-NLS-1$
267
		org.eclipse.wst.jsdt.internal.core.util.Util.insertTypeLabel( declaringType, nameBuffer );
264
			org.eclipse.wst.jsdt.internal.core.util.Util.insertTypeLabel( declaringType, nameBuffer );
265
		}
268
266
269
		return nameBuffer.toString();
267
		return nameBuffer.toString();
270
	}
268
	}
Lines 338-356 Link Here
338
	private String extractDeclaringTypeFQN(CompletionProposal methodProposal) {
336
	private String extractDeclaringTypeFQN(CompletionProposal methodProposal) {
339
		char[] declaringTypeSignature= methodProposal.getDeclarationSignature();
337
		char[] declaringTypeSignature= methodProposal.getDeclarationSignature();
340
		char[] compUnit = methodProposal.getDeclarationTypeName();
338
		char[] compUnit = methodProposal.getDeclarationTypeName();
341
		IJavaScriptProject project = methodProposal.getJavaProject();
339
		if(compUnit != null) {
342
		JsGlobalScopeContainerInitializer init = JSDScopeUtil.findLibraryInitializer(new Path(new String(compUnit)),project);
340
			IJavaScriptProject project = methodProposal.getJavaProject();
343
		if(init!=null) {
341
			JsGlobalScopeContainerInitializer init = JSDScopeUtil.findLibraryInitializer(new Path(new String(compUnit)),project);
344
			String description = init.getDescription(new Path(new String(compUnit)),project);
342
			if(init!=null) {
345
			if( description!=null) return  "[" +  description + "]"; //$NON-NLS-1$ //$NON-NLS-2$
343
				String description = init.getDescription(new Path(new String(compUnit)),project);
346
			
344
				if( description!=null) return  "[" +  description + "]"; //$NON-NLS-1$ //$NON-NLS-2$
345
			}
346
		}
347
		
348
		String qualifedName = null;
349
		if(declaringTypeSignature != null ) {
350
			qualifedName = SignatureUtil.stripSignatureToFQN(String.valueOf(declaringTypeSignature));
347
		}
351
		}
348
		
352
		
349
		// special methods may not have a declaring type: methods defined on arrays etc.
353
		return qualifedName;
350
		// TODO remove when bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690 gets fixed
351
		if (declaringTypeSignature == null)
352
			return "java.lang.Object"; //$NON-NLS-1$
353
		return SignatureUtil.stripSignatureToFQN(String.valueOf(declaringTypeSignature));
354
	}
354
	}
355
355
356
	/**
356
	/**
(-)src/org/eclipse/wst/jsdt/ui/tests/contentassist/ContentAssistTests.java (-32 / +119 lines)
Lines 103-131 Link Here
103
		return new ContentAssistTestsSetup(ts);
103
		return new ContentAssistTestsSetup(ts);
104
	}
104
	}
105
	
105
	
106
	public void testFindFunctions_OtherFile_BeforeOpen_ExpressionStarted_0() throws Exception {
107
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)",
108
			"funcFive(Number paramOne, String paramTwo)  String", "funcSix(paramOne, String paramTwo)  Number",
109
			"funcSeven(String paramOne, paramTwo)  Number", "funcEight(paramOne)  String", "funcNine(paramOne)  Number"}};
110
		runProposalTest("test0_1.js", 0, 1, expectedProposals);
111
	}
112
	
113
	public void testFindFunctions_OtherFile_BeforeOpen_ExpressionStarted_1() throws Exception {
114
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)",
115
			"funcFive(Number paramOne, String paramTwo)  String", "funcSix(paramOne, String paramTwo)  Number",
116
			"funcSeven(String paramOne, paramTwo)  Number", "funcEight(paramOne)  String", "funcNine(paramOne)  Number"}};
117
		runProposalTest("test0_1.js", 2, 4, expectedProposals);
118
	}
119
	
120
	public void testFindFunctions_OtherFile_BeforeOpen_ExpressionStarted_2() throws Exception {
121
		String[][] expectedProposals = new String[][] {{"funcTwo()", "funcThree(paramOne)"}};
122
		runProposalTest("test0_1.js", 4, 5, expectedProposals);
123
	}
124
	
106
	public void testFindFunctions_ThisFile_EmptyLine() throws Exception {
125
	public void testFindFunctions_ThisFile_EmptyLine() throws Exception {
107
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)"}};
126
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)"}};
108
		runProposalTest("test1.js", 16, 0, expectedProposals);
127
		runProposalTest("test0_0.js", 55, 0, expectedProposals);
109
	}
128
	}
110
	
129
	
111
	public void testFindFunctions_ThisFile_ExpressionStarted_0() throws Exception {
130
	public void testFindFunctions_ThisFile_ExpressionStarted_0() throws Exception {
112
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)"}};
131
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)",
113
		runProposalTest("test1.js", 18, 3, expectedProposals);
132
			"funcFive(Number paramOne, String paramTwo)  String", "funcSix(paramOne, String paramTwo)  Number",
133
			"funcSeven(String paramOne, paramTwo)  Number"}};
134
		runProposalTest("test0_0.js", 57, 1, expectedProposals);
114
	}
135
	}
115
	
136
	
116
	public void testFindFunctions_ThisFile_ExpressionStarted_1() throws Exception {
137
	public void testFindFunctions_ThisFile_ExpressionStarted_1() throws Exception {
138
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)",
139
			"funcFive(Number paramOne, String paramTwo)  String", "funcSix(paramOne, String paramTwo)  Number",
140
			"funcSeven(String paramOne, paramTwo)  Number"}};
141
		runProposalTest("test0_0.js", 59, 4, expectedProposals);
142
	}
143
	
144
	public void testFindFunctions_ThisFile_ExpressionStarted_2() throws Exception {
117
		String[][] expectedProposals = new String[][] {{"funcTwo()", "funcThree(paramOne)"}};
145
		String[][] expectedProposals = new String[][] {{"funcTwo()", "funcThree(paramOne)"}};
118
		runProposalTest("test1.js", 20, 5, expectedProposals);
146
		runProposalTest("test0_0.js", 61, 5, expectedProposals);
119
	}
147
	}
120
	
148
	
121
	public void testFindFunctions_OtherFile_ExpressionStarted_0() throws Exception {
149
	public void testFindFunctions_OtherFile_AftereOpen_ExpressionStarted_0() throws Exception {
122
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)"}};
150
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)",
123
		runProposalTest("test2.js", 0, 1, expectedProposals);
151
			"funcFive(Number paramOne, String paramTwo)  String", "funcSix(paramOne, String paramTwo)  Number",
152
			"funcSeven(String paramOne, paramTwo)  Number", "funcEight(paramOne)  String", "funcNine(paramOne)  Number"}};
153
		runProposalTest("test0_1.js", 0, 1, expectedProposals);
124
	}
154
	}
125
	
155
	
126
	public void testFindFunctions_OtherFile_ExpressionStarted_1() throws Exception {
156
	public void testFindFunctions_OtherFile_AfterOpen_ExpressionStarted_1() throws Exception {
157
		String[][] expectedProposals = new String[][] {{"funcOne()", "funcTwo()", "funcThree(paramOne)", "funcFour(paramOne, paramTwo)",
158
			"funcFive(Number paramOne, String paramTwo)  String", "funcSix(paramOne, String paramTwo)  Number",
159
			"funcSeven(String paramOne, paramTwo)  Number", "funcEight(paramOne)  String", "funcNine(paramOne)  Number"}};
160
		runProposalTest("test0_1.js", 2, 4, expectedProposals);
161
	}
162
	
163
	public void testFindFunctions_OtherFile_AfterOpen_ExpressionStarted_2() throws Exception {
127
		String[][] expectedProposals = new String[][] {{"funcTwo()", "funcThree(paramOne)"}};
164
		String[][] expectedProposals = new String[][] {{"funcTwo()", "funcThree(paramOne)"}};
128
		runProposalTest("test2.js", 2, 5, expectedProposals);
165
		runProposalTest("test0_1.js", 4, 5, expectedProposals);
129
	}
166
	}
130
	
167
	
131
	public void testFindAnonymousTypeField_0() throws Exception {
168
	public void testFindAnonymousTypeField_0() throws Exception {
Lines 148-226 Link Here
148
		runProposalTest("test8_1.js", 8, 13, expectedProposals);
185
		runProposalTest("test8_1.js", 8, 13, expectedProposals);
149
	}
186
	}
150
	
187
	
188
	public void testFindConstructors_OtherFile_BeforeOpen_ExpressionStarted_0() throws Exception {
189
		String[][] expectedProposals = new String[][] {{"Awesome(param1, param2)"}};
190
		runProposalTest("test2_1.js", 0, 6, expectedProposals);
191
	}
192
	
193
	public void testFindConstructors_OtherFile_BeforeOpen_ExpressionStarted_1() throws Exception {
194
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
195
		runProposalTest("test2_1.js", 2, 6, expectedProposals);
196
	}
197
	
198
	public void testFindConstructors_OtherFile_BeforeOpen_ExpressionStarted_2() throws Exception {
199
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)"}};
200
		runProposalTest("test2_1.js", 4, 9, expectedProposals);
201
	}
202
	
203
	public void testFindConstructors_OtherFile_BeforeOpen_ExpressionStarted_3() throws Exception {
204
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
205
		runProposalTest("test2_1.js", 6, 10, expectedProposals);
206
	}
207
	
208
	public void testFindConstructors_OtherFile_BeforeOpen_ExpressionStarted_4() throws Exception {
209
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
210
		runProposalTest("test2_1.js", 8, 13, expectedProposals);
211
	}
212
	
213
	public void testFindConstructors_OtherFile_BeforeOpen_ExpressionStarted_5() throws Exception {
214
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
215
		runProposalTest("test2_1.js", 10, 5, expectedProposals);
216
	}
217
	
218
	public void testFindConstructors_OtherFile_BeforeOpen_ExpressionStarted_6() throws Exception {
219
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
220
		runProposalTest("test2_1.js", 12, 9, expectedProposals);
221
	}
222
	
151
	public void testFindConstructors_ThisFile_JustNew() throws Exception {
223
	public void testFindConstructors_ThisFile_JustNew() throws Exception {
152
		String[][] expectedProposals = new String[][] {{"Awesome(param1, param2)", "bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
224
		String[][] expectedProposals = new String[][] {{"Awesome(param1, param2)", "bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
153
		runProposalTest("test3.js", 17, 4, expectedProposals);
225
		runProposalTest("test2_0.js", 17, 4, expectedProposals);
154
	}
226
	}
155
	
227
	
156
	public void testFindConstructors_ThisFile_ExpressionStarted_0() throws Exception {
228
	public void testFindConstructors_ThisFile_ExpressionStarted_0() throws Exception {
157
		String[][] expectedProposals = new String[][] {{"Awesome(param1, param2)"}};
229
		String[][] expectedProposals = new String[][] {{"Awesome(param1, param2)"}};
158
		runProposalTest("test3.js", 19, 6, expectedProposals);
230
		runProposalTest("test2_0.js", 19, 6, expectedProposals);
159
	}
231
	}
160
	
232
	
161
	public void testFindConstructors_ThisFile_ExpressionStarted_1() throws Exception {
233
	public void testFindConstructors_ThisFile_ExpressionStarted_1() throws Exception {
162
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
234
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
163
		runProposalTest("test3.js", 21, 6, expectedProposals);
235
		runProposalTest("test2_0.js", 21, 6, expectedProposals);
164
	}
236
	}
165
	
237
	
166
	public void testFindConstructors_ThisFile_ExpressionStarted_2() throws Exception {
238
	public void testFindConstructors_ThisFile_ExpressionStarted_2() throws Exception {
167
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)"}};
239
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)"}};
168
		runProposalTest("test3.js", 23, 9, expectedProposals);
240
		runProposalTest("test2_0.js", 23, 9, expectedProposals);
169
	}
241
	}
170
	
242
	
171
	public void testFindConstructors_ThisFile_ExpressionStarted_3() throws Exception {
243
	public void testFindConstructors_ThisFile_ExpressionStarted_3() throws Exception {
172
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
244
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
173
		runProposalTest("test3.js", 25, 10, expectedProposals);
245
		runProposalTest("test2_0.js", 25, 10, expectedProposals);
174
	}
246
	}
175
	
247
	
176
	public void testFindConstructors_ThisFile_ExpressionStarted_4() throws Exception {
248
	public void testFindConstructors_ThisFile_ExpressionStarted_4() throws Exception {
177
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
249
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
178
		runProposalTest("test3.js", 27, 13, expectedProposals);
250
		runProposalTest("test2_0.js", 27, 13, expectedProposals);
179
	}
251
	}
180
	
252
	
181
	public void testFindConstructors_ThisFile_ExpressionStarted_5() throws Exception {
253
	public void testFindConstructors_ThisFile_ExpressionStarted_5() throws Exception {
182
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
254
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
183
		runProposalTest("test3.js", 29, 5, expectedProposals);
255
		runProposalTest("test2_0.js", 29, 5, expectedProposals);
184
	}
256
	}
185
	
257
	
186
	public void testFindConstructors_ThisFile_ExpressionStarted_6() throws Exception {
258
	public void testFindConstructors_ThisFile_ExpressionStarted_6() throws Exception {
187
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
259
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
188
		runProposalTest("test3.js", 31, 9, expectedProposals);
260
		runProposalTest("test2_0.js", 31, 9, expectedProposals);
189
	}
261
	}
190
	
262
	
191
	public void testFindConstructors_OtherFile_ExpressionStarted_0() throws Exception {
263
	public void testFindConstructors_OtherFile_AfterOpen_ExpressionStarted_0() throws Exception {
192
		String[][] expectedProposals = new String[][] {{"Awesome(param1, param2)"}};
264
		String[][] expectedProposals = new String[][] {{"Awesome(param1, param2)"}};
193
		runProposalTest("test4.js", 0, 6, expectedProposals);
265
		runProposalTest("test2_1.js", 0, 6, expectedProposals);
194
	}
266
	}
195
	
267
	
196
	public void testFindConstructors_OtherFile_ExpressionStarted_1() throws Exception {
268
	public void testFindConstructors_OtherFile_AfterOpen_ExpressionStarted_1() throws Exception {
197
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
269
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
198
		runProposalTest("test4.js", 2, 6, expectedProposals);
270
		runProposalTest("test2_1.js", 2, 6, expectedProposals);
199
	}
271
	}
200
	
272
	
201
	public void testFindConstructors_OtherFile_ExpressionStarted_2() throws Exception {
273
	public void testFindConstructors_OtherFile_AfterOpen_ExpressionStarted_2() throws Exception {
202
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)"}};
274
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)"}};
203
		runProposalTest("test4.js", 4, 9, expectedProposals);
275
		runProposalTest("test2_1.js", 4, 9, expectedProposals);
204
	}
276
	}
205
	
277
	
206
	public void testFindConstructors_OtherFile_ExpressionStarted_3() throws Exception {
278
	public void testFindConstructors_OtherFile_AfterOpen_ExpressionStarted_3() throws Exception {
207
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
279
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
208
		runProposalTest("test4.js", 6, 10, expectedProposals);
280
		runProposalTest("test2_1.js", 6, 10, expectedProposals);
209
	}
281
	}
210
	
282
	
211
	public void testFindConstructors_OtherFile_ExpressionStarted_4() throws Exception {
283
	public void testFindConstructors_OtherFile_ExpressionStarted_4() throws Exception {
212
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
284
		String[][] expectedProposals = new String[][] {{"bar.foo.Class3(param1, param2, param3, param4)"}};
213
		runProposalTest("test4.js", 8, 13, expectedProposals);
285
		runProposalTest("test2_1.js", 8, 13, expectedProposals);
214
	}
286
	}
215
	
287
	
216
	public void testFindConstructors_OtherFile_ExpressionStarted_5() throws Exception {
288
	public void testFindConstructors_OtherFile_AfterOpen_ExpressionStarted_5() throws Exception {
217
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
289
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
218
		runProposalTest("test4.js", 10, 5, expectedProposals);
290
		runProposalTest("test2_1.js", 10, 5, expectedProposals);
219
	}
291
	}
220
	
292
	
221
	public void testFindConstructors_OtherFile_ExpressionStarted_6() throws Exception {
293
	public void testFindConstructors_OtherFile_AfterOpen_ExpressionStarted_6() throws Exception {
222
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
294
		String[][] expectedProposals = new String[][] {{"bar.Class1(a, b)", "bar.Class2(c, d, e)", "bar.foo.Class3(param1, param2, param3, param4)"}};
223
		runProposalTest("test4.js", 12, 9, expectedProposals);
295
		runProposalTest("test2_1.js", 12, 9, expectedProposals);
296
	}
297
	
298
	public void testFindConstructors_OtherFile_BeforeOpen_VarDeclaration_ExpressionStarted_0() throws Exception {
299
		String[][] expectedProposals = new String[][] {{"MyClass1(a)", "MyClass2()"}};
300
		runProposalTest("test6.js", 0, 8, expectedProposals);
224
	}
301
	}
225
	
302
	
226
	public void testFindConstructors_ThisFile_VarDeclaration_ExpressionStarted_0() throws Exception {
303
	public void testFindConstructors_ThisFile_VarDeclaration_ExpressionStarted_0() throws Exception {
Lines 228-234 Link Here
228
		runProposalTest("test5.js", 7, 8, expectedProposals);
305
		runProposalTest("test5.js", 7, 8, expectedProposals);
229
	}
306
	}
230
	
307
	
231
	public void testFindConstructors_OtherFile_VarDeclaration_ExpressionStarted_0() throws Exception {
308
	public void testFindConstructors_OtherFile_AfterOpen_VarDeclaration_ExpressionStarted_0() throws Exception {
232
		String[][] expectedProposals = new String[][] {{"MyClass1(a)", "MyClass2()"}};
309
		String[][] expectedProposals = new String[][] {{"MyClass1(a)", "MyClass2()"}};
233
		runProposalTest("test6.js", 0, 8, expectedProposals);
310
		runProposalTest("test6.js", 0, 8, expectedProposals);
234
	}
311
	}
Lines 243-258 Link Here
243
		runProposalTest("test7.js", 10, 11, expectedProposals);
320
		runProposalTest("test7.js", 10, 11, expectedProposals);
244
	}
321
	}
245
	
322
	
323
	public void testFindConstructors_OtherFile_BeforeOpen_ArrayReferenceDeclaration_ExpressionStarted_0() throws Exception {
324
		String[][] expectedProposals = new String[][] {{"test.Foo(x, y, z)"}};
325
		runProposalTest("test9_1.js", 0, 7, expectedProposals);
326
	}
327
	
246
	public void testFindConstructors_ThisFile_ArrayReferenceDeclaration_ExpressionStarted_0() throws Exception {
328
	public void testFindConstructors_ThisFile_ArrayReferenceDeclaration_ExpressionStarted_0() throws Exception {
247
		String[][] expectedProposals = new String[][] {{"test.Foo(x, y, z)"}};
329
		String[][] expectedProposals = new String[][] {{"test.Foo(x, y, z)"}};
248
		runProposalTest("test9_0.js", 7, 7, expectedProposals);
330
		runProposalTest("test9_0.js", 7, 7, expectedProposals);
249
	}
331
	}
250
	
332
	
251
	public void testFindConstructors_OtherFile_ArrayReferenceDeclaration_ExpressionStarted_0() throws Exception {
333
	public void testFindConstructors_OtherFile_AfterOpen_ArrayReferenceDeclaration_ExpressionStarted_0() throws Exception {
252
		String[][] expectedProposals = new String[][] {{"test.Foo(x, y, z)"}};
334
		String[][] expectedProposals = new String[][] {{"test.Foo(x, y, z)"}};
253
		runProposalTest("test9_1.js", 0, 7, expectedProposals);
335
		runProposalTest("test9_1.js", 0, 7, expectedProposals);
254
	}
336
	}
255
	
337
	
338
	public void testFindFunctionOnType_OtherFile_ExpressionStarted_0() throws Exception {
339
		String[][] expectedProposals = new String[][] {{"myFunc1(Number param1)", "foo"}};
340
		runProposalTest("test10_1.js", 1, 4, expectedProposals);
341
	}
342
	
256
	/**
343
	/**
257
	 * <p>Run a proposal test by opening the given file and invoking content assist for
344
	 * <p>Run a proposal test by opening the given file and invoking content assist for
258
	 * each expected proposal count at the given line number and line character
345
	 * each expected proposal count at the given line number and line character

Return to bug 352160