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 (-15 / +8 lines)
Lines 981-996 Link Here
981
				findReferences,
981
				findReferences,
982
				isFunction,
982
				isFunction,
983
				selectorChars,
983
				selectorChars,
984
				declaringTypeQualification,
985
				declaringTypeSimpleName,
986
				declaringTypeSignature,
987
				returnTypeQualification,
988
				returnTypeSimpleName,
989
				returnTypeSignature,
990
				parameterTypeQualifications,
984
				parameterTypeQualifications,
991
				parameterTypeSimpleNames,
985
				parameterTypeSimpleNames,
992
				parameterTypeSignatures,
986
				returnTypeQualification,
993
				typeArguments,
987
				returnTypeSimpleName,
988
				declaringTypeQualification,
989
				declaringTypeSimpleName,
994
				matchRule);
990
				matchRule);
995
	}
991
	}
996
}
992
}
Lines 1475-1489 Link Here
1475
						findMethodReferences,
1471
						findMethodReferences,
1476
						isFunction,
1472
						isFunction,
1477
						selector,
1473
						selector,
1478
						declaringQualification,
1479
						declaringSimpleName,
1480
						returnQualification,
1481
						returnSimpleName,
1482
						returnSignature,
1483
						parameterQualifications,
1474
						parameterQualifications,
1484
						parameterSimpleNames,
1475
						parameterSimpleNames,
1485
						parameterSignatures,
1476
						returnQualification,
1486
						method,
1477
						returnSimpleName,
1478
						declaringQualification,
1479
						declaringSimpleName,
1487
						matchRule);
1480
						matchRule);
1488
			}
1481
			}
1489
			break;
1482
			break;
(-)src/org/eclipse/wst/jsdt/internal/codeassist/CompletionEngine.java (-95 / +158 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#acceptFunction(char[], int, char[][], char[][], char[][], char[], char[], char[], char[], int, java.lang.String)
680
	 */
681
	public void acceptFunction(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.proposeFunction(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 5875-5894 Link Here
5875
									null,
5883
									null,
5876
									null,
5884
									null,
5877
									false);
5885
									false);
5878
5879
5880
						}
5886
						}
5881
						break;
5887
						break;
5882
//					case Scope.CLASS_SCOPE :
5883
					case Scope.COMPILATION_UNIT_SCOPE :
5888
					case Scope.COMPILATION_UNIT_SCOPE :
5884
						CompilationUnitScope compilationUnitScope = (CompilationUnitScope) currentScope;
5889
						CompilationUnitScope compilationUnitScope = (CompilationUnitScope) currentScope;
5885
//						ClassScope classScope = (ClassScope) currentScope;
5886
						SourceTypeBinding enclosingType = compilationUnitScope.enclosingCompilationUnit();
5890
						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) {
5891
						if(!insideTypeAnnotation) {
5893
							if(proposeField) {
5892
							if(proposeField) {
5894
								findFields(
5893
								findFields(
Lines 5931-5940 Link Here
5931
						}
5930
						}
5932
						staticsOnly |= enclosingType.isStatic();
5931
						staticsOnly |= enclosingType.isStatic();
5933
						insideTypeAnnotation = false;
5932
						insideTypeAnnotation = false;
5934
						//				}
5935
//						break;
5936
5937
//					case Scope.COMPILATION_UNIT_SCOPE :
5938
						break done2;
5933
						break done2;
5939
				}
5934
				}
5940
				currentScope = currentScope.parent;
5935
				currentScope = currentScope.parent;
Lines 5953-5966 Link Here
5953
			}
5948
			}
5954
			
5949
			
5955
			//propose methods from environment if token length is not 0
5950
			//propose methods from environment if token length is not 0
5956
			if (proposeMethod  && token.length > 0)
5951
			if (proposeMethod  && token.length > 0) {
5957
			{
5952
				this.nameEnvironment.findFunctions(
5958
				this.nameEnvironment.findBindings(
5959
						token,
5953
						token,
5960
						Binding.METHOD,
5954
						null,
5961
						this.options.camelCaseMatch,
5962
						this);
5955
						this);
5963
				acceptBindings(token,false,false);
5964
			}
5956
			}
5965
			
5957
			
5966
			//propose fields from environment if token length is not 0
5958
			//propose fields from environment if token length is not 0
Lines 6000-6007 Link Here
6000
						if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
5992
						if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
6001
							CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition);
5993
							CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition);
6002
							proposal.setSignature(getSignature(type.resolvedType));
5994
							proposal.setSignature(getSignature(type.resolvedType));
6003
							proposal.setPackageName(type.resolvedType.qualifiedPackageName());
5995
							proposal.setReturnQualification(type.resolvedType.qualifiedPackageName());
6004
							proposal.setTypeName(type.resolvedType.qualifiedSourceName());
5996
							proposal.setReturnSimpleName(type.resolvedType.qualifiedSourceName());
6005
							proposal.setName(name);
5997
							proposal.setName(name);
6006
							proposal.setCompletion(name);
5998
							proposal.setCompletion(name);
6007
							//proposal.setFlags(Flags.AccDefault);
5999
							//proposal.setFlags(Flags.AccDefault);
Lines 6270-6277 Link Here
6270
					if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
6262
					if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) {
6271
						CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition);
6263
						CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition);
6272
						proposal.setSignature(getSignature(typeBinding));
6264
						proposal.setSignature(getSignature(typeBinding));
6273
						proposal.setPackageName(q);
6265
						proposal.setReturnQualification(q);
6274
						proposal.setTypeName(displayName);
6266
						proposal.setReturnSimpleName(displayName);
6275
						proposal.setName(name);
6267
						proposal.setName(name);
6276
						proposal.setCompletion(name);
6268
						proposal.setCompletion(name);
6277
						//proposal.setFlags(Flags.AccDefault);
6269
						//proposal.setFlags(Flags.AccDefault);
Lines 6899-6905 Link Here
6899
			proposal.setDeclarationTypeName(reference.qualifiedSourceName());
6891
			proposal.setDeclarationTypeName(reference.qualifiedSourceName());
6900
6892
6901
			//proposal.setPackageName(null);
6893
			//proposal.setPackageName(null);
6902
			proposal.setTypeName(VOID);
6894
			proposal.setReturnSimpleName(VOID);
6903
			proposal.setName(token);
6895
			proposal.setName(token);
6904
			//proposal.setParameterPackageNames(null);
6896
			//proposal.setParameterPackageNames(null);
6905
			//proposal.setParameterTypeNames(null);
6897
			//proposal.setParameterTypeNames(null);
Lines 7012-7019 Link Here
7012
			proposal.completionEngine = this;
7004
			proposal.completionEngine = this;
7013
			proposal.setDeclarationSignature(packageName);
7005
			proposal.setDeclarationSignature(packageName);
7014
			proposal.setSignature(createNonGenericTypeSignature(typeName));
7006
			proposal.setSignature(createNonGenericTypeSignature(typeName));
7015
			proposal.setPackageName(packageName);
7007
			proposal.setReturnQualification(packageName);
7016
			proposal.setTypeName(typeName);
7008
			proposal.setReturnSimpleName(typeName);
7017
			proposal.setCompletion(completionName);
7009
			proposal.setCompletion(completionName);
7018
			proposal.setFlags(modifiers);
7010
			proposal.setFlags(modifiers);
7019
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
7011
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
Lines 7033-7040 Link Here
7033
			proposal.completionEngine = this;
7025
			proposal.completionEngine = this;
7034
			proposal.setDeclarationSignature(packageName);
7026
			proposal.setDeclarationSignature(packageName);
7035
			proposal.setSignature(createNonGenericTypeSignature(typeName));
7027
			proposal.setSignature(createNonGenericTypeSignature(typeName));
7036
			proposal.setPackageName(packageName);
7028
			proposal.setReturnQualification(packageName);
7037
			proposal.setTypeName(typeName);
7029
			proposal.setReturnSimpleName(typeName);
7038
			proposal.setCompletion(javadocCompletion);
7030
			proposal.setCompletion(javadocCompletion);
7039
			proposal.setFlags(modifiers);
7031
			proposal.setFlags(modifiers);
7040
			int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
7032
			int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
Lines 7060-7067 Link Here
7060
			proposal.completionEngine = this;
7052
			proposal.completionEngine = this;
7061
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
7053
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
7062
			proposal.setSignature(getSignature(refBinding));
7054
			proposal.setSignature(getSignature(refBinding));
7063
			proposal.setPackageName(refBinding.qualifiedPackageName());
7055
			proposal.setReturnQualification(refBinding.qualifiedPackageName());
7064
			proposal.setTypeName(typeName);
7056
			proposal.setReturnSimpleName(typeName);
7065
			proposal.setCompletion(completionName);
7057
			proposal.setCompletion(completionName);
7066
			proposal.setFlags(refBinding.modifiers);
7058
			proposal.setFlags(refBinding.modifiers);
7067
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
7059
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
Lines 7080-7087 Link Here
7080
			proposal.completionEngine = this;
7072
			proposal.completionEngine = this;
7081
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
7073
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
7082
			proposal.setSignature(getSignature(refBinding));
7074
			proposal.setSignature(getSignature(refBinding));
7083
			proposal.setPackageName(refBinding.qualifiedPackageName());
7075
			proposal.setReturnQualification(refBinding.qualifiedPackageName());
7084
			proposal.setTypeName(typeName);
7076
			proposal.setReturnSimpleName(typeName);
7085
			proposal.setCompletion(javadocCompletion);
7077
			proposal.setCompletion(javadocCompletion);
7086
			proposal.setFlags(refBinding.modifiers);
7078
			proposal.setFlags(refBinding.modifiers);
7087
			int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition;
7079
			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);
7398
								CompletionProposal proposal =  createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition);
7407
								proposal.setDeclarationSignature(packageName);
7399
								proposal.setDeclarationSignature(packageName);
7408
								proposal.setSignature(getSignature(refBinding));
7400
								proposal.setSignature(getSignature(refBinding));
7409
								proposal.setPackageName(packageName);
7401
								proposal.setReturnQualification(packageName);
7410
								proposal.setTypeName(typeName);
7402
								proposal.setReturnSimpleName(typeName);
7411
								proposal.setCompletion(completionName);
7403
								proposal.setCompletion(completionName);
7412
								proposal.setFlags(refBinding.modifiers);
7404
								proposal.setFlags(refBinding.modifiers);
7413
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
7405
								proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
Lines 7511-7516 Link Here
7511
	}
7503
	}
7512
	
7504
	
7513
	/**
7505
	/**
7506
	 * <p>Creates a function proposal based on all of the given information</p>
7507
	 * 
7508
	 * @param signature
7509
	 * @param parameterCount
7510
	 * @param parameterQualifications
7511
	 * @param parameterSimpleNames
7512
	 * @param parameterNames
7513
	 * @param returnQualification
7514
	 * @param returnSimpleName
7515
	 * @param declaringQualification
7516
	 * @param declaringSimpleName
7517
	 * @param modifiers
7518
	 * @param path
7519
	 */
7520
	private void proposeFunction(char[] signature,
7521
			int parameterCount,
7522
			char[][] parameterQualifications,
7523
			char[][] parameterSimpleNames,
7524
			char[][] parameterNames,
7525
			char[] returnQualification,
7526
			char[] returnSimpleName,
7527
			char[] declaringQualification,
7528
			char[] declaringSimpleName,
7529
			int modifiers,
7530
			String path) {
7531
		
7532
		//compute completion
7533
		char[] completion;
7534
		if (this.source != null
7535
				&& this.source.length > this.endPosition
7536
				&& this.source[this.endPosition] == '(') {
7537
			
7538
			completion = signature;
7539
		} else {
7540
			completion = CharOperation.concat(signature, new char[] { '(', ')' });
7541
		}
7542
		
7543
		//compute relevance
7544
		int relevance = computeBaseRelevance();
7545
		relevance += computeRelevanceForInterestingProposal();
7546
		if (this.completionToken != null) relevance += computeRelevanceForCaseMatching(this.completionToken, signature);
7547
		relevance += computeRelevanceForExpectingType(returnQualification, returnSimpleName);
7548
		relevance += computeRelevanceForQualification(false);
7549
		relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
7550
		
7551
		this.noProposal = false;
7552
		// Standard proposal
7553
		if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) {
7554
			CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
7555
			proposal.setDeclarationSignature(QualificationHelpers.createFullyQualifiedName(declaringQualification, declaringSimpleName));
7556
			proposal.setDeclarationPackageName(declaringQualification);
7557
			proposal.setDeclarationTypeName(declaringSimpleName);
7558
			proposal.setParameterPackageNames(parameterQualifications);
7559
			proposal.setParameterTypeNames(parameterSimpleNames);
7560
			proposal.setReturnQualification(returnQualification);
7561
			proposal.setReturnSimpleName(returnSimpleName);
7562
			proposal.setName(signature);
7563
			proposal.setCompletion(completion);
7564
			proposal.setFlags(modifiers | Flags.AccPublic );
7565
			proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
7566
			proposal.setRelevance(relevance);
7567
			if(parameterNames != null) proposal.setParameterNames(parameterNames);
7568
			proposal.setIsContructor(false);
7569
			this.requestor.accept(proposal);
7570
			if(DEBUG) {
7571
				this.printDebug(proposal);
7572
			}
7573
		}
7574
	}
7575
	
7576
	/**
7514
	 * <p>Represents a constructor accepted from the index.</p>
7577
	 * <p>Represents a constructor accepted from the index.</p>
7515
	 */
7578
	 */
7516
	private static class AcceptedConstructor {
7579
	private static class AcceptedConstructor {
(-)src/org/eclipse/wst/jsdt/internal/codeassist/ISearchRequestor.java (+27 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
	 * <p>Accept a function defined with all of the given information</p>
70
	 * 
71
	 * @param signature
72
	 * @param parameterCount
73
	 * @param parameterQualifications
74
	 * @param parameterSimpleNames
75
	 * @param parameterNames
76
	 * @param returnQualification
77
	 * @param returnSimpleName
78
	 * @param declaringQualification
79
	 * @param declaringSimpleName
80
	 * @param modifiers
81
	 * @param path
82
	 */
83
	public void acceptFunction(char[] signature,
84
			int parameterCount,
85
			char[][] parameterQualifications,
86
			char[][] parameterSimpleNames,
87
			char[][] parameterNames,
88
			char[] returnQualification,
89
			char[] returnSimpleName,
90
			char[] declaringQualification,
91
			char[] declaringSimpleName,
92
			int modifiers,
93
			String path);
67
}
94
}
(-)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#acceptFunction(char[], int, char[][], char[][], char[][], char[], char[], char[], char[], int, java.lang.String)
339
			 */
340
			public void acceptFunction(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#acceptFunction(char[], int, char[][], char[][], char[][], char[], char[], char[], char[], int, java.lang.String)
309
	 */
310
	public void acceptFunction(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 / +112 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.IFunctionRequester;
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
	 * <p>Used to find all functions in the environment using the given information.</p>
640
	 * 
641
	 * <p><b>NOTE:</b> this function will currently ignore any results either from the index
642
	 * or working copies from the {@link #unitToSkip}.</p>
643
	 * 
644
	 * @param selectorPrefix prefix to the selector to search for functions matches for, or
645
	 * <code>null</code> to search for functions with any selector.  The <code>null</code>
646
	 * option is useful when searching for all functions on a given type.
647
	 * @param declaringTypeName fully qualified type name that any function results should be
648
	 * defined on, or <code>null</code> if the function results should not be defined on any type
649
	 * @param searchRequester search requester to return any search results too
650
	 */
651
	public void findFunctions(char[] selectorPrefix, String declaringTypeName, final ISearchRequestor searchRequester) {
652
		//calculate the exclude path
653
		final String excludePath;
654
		if (this.unitToSkip != null && this.unitToSkip instanceof IJavaScriptElement) {
655
			excludePath = ((IJavaScriptElement)this.unitToSkip).getPath().toString();
656
		} else {
657
			excludePath = null;
658
		}
659
		
660
		//create the requester
661
		IFunctionRequester functionRequestor = new IFunctionRequester() {
662
			public void acceptFunction(char[] signature,
663
					int parameterCount,
664
					char[][] parameterQualifications, char[][] parameterSimpleNames,
665
					char[][] parameterNames,
666
					char[] returnQualification, char[] returnSimpleName,
667
					char[] declaringQualification, char[] declaringSimpleName,
668
					int modifiers,
669
					String path) {
670
				
671
				if (excludePath == null || !excludePath.equals(path)) {
672
					searchRequester.acceptFunction(signature, parameterCount, parameterQualifications, parameterSimpleNames, parameterNames,
673
							returnQualification, returnSimpleName, declaringQualification, declaringSimpleName, modifiers, path);
674
				}
675
			}
676
		};
677
		
678
		/* if selector specified then search for any selector with the given selector as a prefix
679
		 * else search for any selector
680
		 */
681
		char[] selectorPattern;
682
		int selectorPatternMatchRule;
683
		if(selectorPrefix != null) {
684
			selectorPattern = selectorPrefix;
685
			selectorPatternMatchRule = SearchPattern.R_PREFIX_MATCH;
686
		} else {
687
			selectorPattern = new char[] {'*'};
688
			selectorPatternMatchRule = SearchPattern.R_PATTERN_MATCH;
689
		}
690
		
691
		/* if a declaring type name is specified then make it the pattern for matching
692
		 * else find methods not on a type
693
		 */
694
		String declaringType;
695
		if(declaringTypeName != null) {
696
			declaringType = declaringTypeName;
697
		} else {
698
			declaringType = null;
699
		}
700
		
701
		//do the search
702
		new BasicSearchEngine(this.workingCopies).searchAllFunctions(
703
				functionRequestor,
704
				selectorPattern,
705
				declaringType,
706
				selectorPatternMatchRule,
707
				this.searchScope,
708
				WAIT_UNTIL_READY_TO_SEARCH,
709
				new CancelableProgressMonitor());
710
	}
677
711
678
	/**
712
	/**
679
	 * <p>The progress monitor is used to be able to cancel completion operations</p>
713
	 * <p>The progress monitor is used to be able to cancel completion operations</p>
Lines 697-729 Link Here
697
			excludePath = null;
731
			excludePath = null;
698
		}
732
		}
699
733
700
		IProgressMonitor progressMonitor = new IProgressMonitor() {
734
		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
		
735
		
728
		IConstructorRequestor constructorRequestor = new IConstructorRequestor() {
736
		IConstructorRequestor constructorRequestor = new IConstructorRequestor() {
729
			/**
737
			/**
Lines 817-835 Link Here
817
			this.nameLookup.seekBindings(prefix, bindingType,null, true, type, requestor);
825
			this.nameLookup.seekBindings(prefix, bindingType,null, true, type, requestor);
818
		} else {
826
		} else {
819
			throw new UnimplementedException("shouldnt get here"); //$NON-NLS-1$
827
			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
		}
828
		}
834
	}
829
	}
835
	/**
830
	/**
Lines 877-880 Link Here
877
	{
872
	{
878
		nameLookup.setScriptFile(file);
873
		nameLookup.setScriptFile(file);
879
	}
874
	}
875
	
876
	/**
877
	 * <p>A cancelable progress monitor</p>
878
	 */
879
	private static class CancelableProgressMonitor implements IProgressMonitor {
880
		boolean isCanceled = false;
881
		public void beginTask(String name, int totalWork) {
882
			// implements interface method
883
		}
884
		public void done() {
885
			// implements interface method
886
		}
887
		public void internalWorked(double work) {
888
			// implements interface method
889
		}
890
		public boolean isCanceled() {
891
			return this.isCanceled;
892
		}
893
		public void setCanceled(boolean value) {
894
			this.isCanceled = value;
895
		}
896
		public void setTaskName(String name) {
897
			// implements interface method
898
		}
899
		public void subTask(String name) {
900
			// implements interface method
901
		}
902
		public void worked(int work) {
903
			// implements interface method
904
		}
905
	}
880
}
906
}
(-)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 (-99 / +310 lines)
Lines 29-35 Link Here
29
import org.eclipse.wst.jsdt.core.IType;
29
import org.eclipse.wst.jsdt.core.IType;
30
import org.eclipse.wst.jsdt.core.JavaScriptCore;
30
import org.eclipse.wst.jsdt.core.JavaScriptCore;
31
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
31
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
32
import org.eclipse.wst.jsdt.core.Signature;
32
import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
33
import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
34
import org.eclipse.wst.jsdt.core.ast.IArgument;
35
import org.eclipse.wst.jsdt.core.ast.IFunctionDeclaration;
33
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
36
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
34
import org.eclipse.wst.jsdt.core.infer.InferredAttribute;
37
import org.eclipse.wst.jsdt.core.infer.InferredAttribute;
35
import org.eclipse.wst.jsdt.core.infer.InferredMethod;
38
import org.eclipse.wst.jsdt.core.infer.InferredMethod;
Lines 52-57 Link Here
52
import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
55
import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
53
import org.eclipse.wst.jsdt.internal.compiler.env.AccessRestriction;
56
import org.eclipse.wst.jsdt.internal.compiler.env.AccessRestriction;
54
import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
57
import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
58
import org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit;
55
import org.eclipse.wst.jsdt.internal.compiler.impl.CompilerOptions;
59
import org.eclipse.wst.jsdt.internal.compiler.impl.CompilerOptions;
56
import org.eclipse.wst.jsdt.internal.compiler.lookup.Binding;
60
import org.eclipse.wst.jsdt.internal.compiler.lookup.Binding;
57
import org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope;
61
import org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope;
Lines 65-70 Link Here
65
import org.eclipse.wst.jsdt.internal.core.DefaultWorkingCopyOwner;
69
import org.eclipse.wst.jsdt.internal.core.DefaultWorkingCopyOwner;
66
import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
70
import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
67
import org.eclipse.wst.jsdt.internal.core.JavaProject;
71
import org.eclipse.wst.jsdt.internal.core.JavaProject;
72
import org.eclipse.wst.jsdt.internal.core.Logger;
68
import org.eclipse.wst.jsdt.internal.core.search.indexing.IIndexConstants;
73
import org.eclipse.wst.jsdt.internal.core.search.indexing.IIndexConstants;
69
import org.eclipse.wst.jsdt.internal.core.search.indexing.IndexManager;
74
import org.eclipse.wst.jsdt.internal.core.search.indexing.IndexManager;
70
import org.eclipse.wst.jsdt.internal.core.search.matching.ConstructorDeclarationPattern;
75
import org.eclipse.wst.jsdt.internal.core.search.matching.ConstructorDeclarationPattern;
Lines 81-86 Link Here
81
import org.eclipse.wst.jsdt.internal.core.search.matching.SecondaryTypeDeclarationPattern;
86
import org.eclipse.wst.jsdt.internal.core.search.matching.SecondaryTypeDeclarationPattern;
82
import org.eclipse.wst.jsdt.internal.core.search.matching.TypeDeclarationPattern;
87
import org.eclipse.wst.jsdt.internal.core.search.matching.TypeDeclarationPattern;
83
import org.eclipse.wst.jsdt.internal.core.util.Messages;
88
import org.eclipse.wst.jsdt.internal.core.util.Messages;
89
import org.eclipse.wst.jsdt.internal.core.util.QualificationHelpers;
84
import org.eclipse.wst.jsdt.internal.core.util.Util;
90
import org.eclipse.wst.jsdt.internal.core.util.Util;
85
91
86
/**
92
/**
Lines 101-106 Link Here
101
	 * compilation units.
107
	 * compilation units.
102
	 */
108
	 */
103
	private IJavaScriptUnit[] workingCopies;
109
	private IJavaScriptUnit[] workingCopies;
110
	
111
	/**
112
	 * <p>Set of all of the working copies paths</p>
113
	 */
114
	private HashSet fWorkingCopiesPaths;
104
115
105
	/*
116
	/*
106
	 * A working copy owner whose working copies will take precedent over
117
	 * A working copy owner whose working copies will take precedent over
Lines 366-374 Link Here
366
		return this.parser;
377
		return this.parser;
367
	}
378
	}
368
379
369
	/*
380
	/**
370
	 * Returns the list of working copies used by this search engine.
381
	 * @return list of working copies used by this search engine,
371
	 * Returns null if none.
382
	 * or <code>null</code> if none.
372
	 */
383
	 */
373
	private IJavaScriptUnit[] getWorkingCopies() {
384
	private IJavaScriptUnit[] getWorkingCopies() {
374
		IJavaScriptUnit[] copies;
385
		IJavaScriptUnit[] copies;
Lines 425-430 Link Here
425
		}
436
		}
426
		return result;
437
		return result;
427
	}
438
	}
439
	
440
	/**
441
	 * @return {@link HashSet} of all of the working copy paths
442
	 */
443
	private HashSet getWorkingCopiesPaths() {
444
		if(this.fWorkingCopiesPaths == null) {
445
			this.fWorkingCopiesPaths = new HashSet();
446
			
447
			IJavaScriptUnit[] workingCopies = this.getWorkingCopies();
448
			for(int i = 0; workingCopies != null && i < workingCopies.length; ++i) {
449
				this.fWorkingCopiesPaths.add(workingCopies[i].getPath().toString());
450
			}
451
		}
452
		
453
		return this.fWorkingCopiesPaths;
454
	}
428
455
429
	/*
456
	/*
430
	 * Returns the list of working copies used to do the search on the given Java element.
457
	 * Returns the list of working copies used to do the search on the given Java element.
Lines 566-572 Link Here
566
							true,false,true,
593
							true,false,true,
567
							bindingName,
594
							bindingName,
568
							null,null,null,null,
595
							null,null,null,null,
569
							null,null,null,
596
							null,null,
570
							matchRule);
597
							matchRule);
571
598
572
				}
599
				}
Lines 578-585 Link Here
578
						searchPattern = new MethodPattern(
605
						searchPattern = new MethodPattern(
579
								true,false,true,
606
								true,false,true,
580
								bindingName,
607
								bindingName,
581
								null,null,null,null,
582
								null,null,null,
583
								matchRule);
608
								matchRule);
584
609
585
					}
610
					}
Lines 610-633 Link Here
610
			final SearchPattern pattern =searchPattern;
635
			final SearchPattern pattern =searchPattern;
611
			final char typeSuffix=suffix;
636
			final char typeSuffix=suffix;
612
637
613
			// Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor
638
			// Index requester
614
			final HashSet workingCopyPaths = new HashSet();
615
			String workingCopyPath = null;
616
			IJavaScriptUnit[] copies = getWorkingCopies();
617
			final int copiesLength = copies == null ? 0 : copies.length;
618
			if (copies != null) {
619
				if (copiesLength == 1) {
620
					workingCopyPath = copies[0].getPath().toString();
621
				} else {
622
					for (int i = 0; i < copiesLength; i++) {
623
						IJavaScriptUnit workingCopy = copies[i];
624
						workingCopyPaths.add(workingCopy.getPath().toString());
625
					}
626
				}
627
			}
628
			final String singleWkcpPath = workingCopyPath;
629
630
			// Index requestor
631
			IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
639
			IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
632
				public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
640
				public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
633
					// Filter unexpected types
641
					// Filter unexpected types
Lines 691-696 Link Here
691
					progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 100));
699
					progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 100));
692
700
693
				// add type names from working copies
701
				// add type names from working copies
702
				IJavaScriptUnit[] copies = getWorkingCopies();
703
				final int copiesLength = copies == null ? 0 : copies.length;
694
				if (copies != null && doParse) {
704
				if (copies != null && doParse) {
695
					for (int i = 0; i < copiesLength; i++) {
705
					for (int i = 0; i < copiesLength; i++) {
696
						IJavaScriptUnit workingCopy = copies[i];
706
						IJavaScriptUnit workingCopy = copies[i];
Lines 705-718 Link Here
705
								IType[] allTypes = workingCopy.getAllTypes();
715
								IType[] allTypes = workingCopy.getAllTypes();
706
								for (int j = 0, allTypesLength = allTypes.length; j < allTypesLength; j++) {
716
								for (int j = 0, allTypesLength = allTypes.length; j < allTypesLength; j++) {
707
									IType type = allTypes[j];
717
									IType type = allTypes[j];
708
									IJavaScriptElement parent = type.getParent();
709
									char[][] enclosingTypeNames;
710
									if (parent instanceof IType) {
711
										char[] parentQualifiedName = ((IType)parent).getTypeQualifiedName('.').toCharArray();
712
										enclosingTypeNames = CharOperation.splitOn('.', parentQualifiedName);
713
									} else {
714
										enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
715
									}
716
									char[] simpleName = type.getElementName().toCharArray();
718
									char[] simpleName = type.getElementName().toCharArray();
717
									int kind = TypeDeclaration.CLASS_DECL;
719
									int kind = TypeDeclaration.CLASS_DECL;
718
									
720
									
Lines 726-741 Link Here
726
								IFunction[] allMethods = workingCopy.getFunctions();
728
								IFunction[] allMethods = workingCopy.getFunctions();
727
								for (int j = 0, allMethodsLength = allMethods.length; j < allMethodsLength; j++) {
729
								for (int j = 0, allMethodsLength = allMethods.length; j < allMethodsLength; j++) {
728
									IFunction method = allMethods[j];
730
									IFunction method = allMethods[j];
729
									IJavaScriptElement parent = method.getParent();
730
//									char[][] enclosingTypeNames;
731
									if (parent instanceof IType) {
732
//										char[] parentQualifiedName = ((IType)parent).getTypeQualifiedName('.').toCharArray();
733
//										enclosingTypeNames = CharOperation.splitOn('.', parentQualifiedName);
734
									} else {
735
//										enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
736
									}
737
									char[] simpleName = method.getElementName().toCharArray();
731
									char[] simpleName = method.getElementName().toCharArray();
738
//									int kind;
739
									if (match(typeSuffix, packageName, bindingName, matchRule, 0, packageDeclaration, simpleName)) {
732
									if (match(typeSuffix, packageName, bindingName, matchRule, 0, packageDeclaration, simpleName)) {
740
										nameRequestor.acceptBinding(bindingType,method.getFlags(), packageDeclaration, simpleName,   path, null);
733
										nameRequestor.acceptBinding(bindingType,method.getFlags(), packageDeclaration, simpleName,   path, null);
741
									}
734
									}
Lines 749-764 Link Here
749
								IField[] allFields = workingCopy.getFields ();
742
								IField[] allFields = workingCopy.getFields ();
750
								for (int j = 0, allFieldsLength = allFields.length; j < allFieldsLength; j++) {
743
								for (int j = 0, allFieldsLength = allFields.length; j < allFieldsLength; j++) {
751
									IField field = allFields[j];
744
									IField field = allFields[j];
752
									IJavaScriptElement parent = field.getParent();
753
									char[][] enclosingTypeNames;
754
									if (parent instanceof IType) {
755
										char[] parentQualifiedName = ((IType)parent).getTypeQualifiedName('.').toCharArray();
756
										enclosingTypeNames = CharOperation.splitOn('.', parentQualifiedName);
757
									} else {
758
										enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
759
									}
760
									char[] simpleName = field.getElementName().toCharArray();
745
									char[] simpleName = field.getElementName().toCharArray();
761
									int kind;
762
									if (match(typeSuffix, packageName, bindingName, matchRule, 0, packageDeclaration, simpleName)) {
746
									if (match(typeSuffix, packageName, bindingName, matchRule, 0, packageDeclaration, simpleName)) {
763
										nameRequestor.acceptBinding(bindingType,field.getFlags(), packageDeclaration, simpleName,   path, null);
747
										nameRequestor.acceptBinding(bindingType,field.getFlags(), packageDeclaration, simpleName,   path, null);
764
									}
748
									}
Lines 799-822 Link Here
799
										}
783
										}
800
										return true;
784
										return true;
801
									}
785
									}
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) {
786
									public boolean visit(InferredType inferredType, BlockScope scope) {
821
										if (bindingType==Binding.TYPE &&
787
										if (bindingType==Binding.TYPE &&
822
													match(typeSuffix, packageName, bindingName, matchRule, TypeDeclaration.kind(0), packageDeclaration, inferredType.getName())) {
788
													match(typeSuffix, packageName, bindingName, matchRule, TypeDeclaration.kind(0), packageDeclaration, inferredType.getName())) {
Lines 885-908 Link Here
885
		IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
851
		IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
886
		final TypeDeclarationPattern pattern = new SecondaryTypeDeclarationPattern();
852
		final TypeDeclarationPattern pattern = new SecondaryTypeDeclarationPattern();
887
853
888
		// Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor
854
		// Get working copy path(s). Store in a single string in case of only one to optimize comparison in requester
889
		final HashSet workingCopyPaths = new HashSet();
855
		final HashSet workingCopyPaths = this.getWorkingCopiesPaths();
890
		String workingCopyPath = null;
891
		IJavaScriptUnit[] copies = getWorkingCopies();
892
		final int copiesLength = copies == null ? 0 : copies.length;
893
		if (copies != null) {
894
			if (copiesLength == 1) {
895
				workingCopyPath = copies[0].getPath().toString();
896
			} else {
897
				for (int i = 0; i < copiesLength; i++) {
898
					IJavaScriptUnit workingCopy = copies[i];
899
					workingCopyPaths.add(workingCopy.getPath().toString());
900
				}
901
			}
902
		}
903
		final String singleWkcpPath = workingCopyPath;
904
856
905
		// Index requestor
857
		// Index requester
906
		IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
858
		IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){
907
			public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
859
			public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
908
				// Filter unexpected types
860
				// Filter unexpected types
Lines 913-931 Link Here
913
				if (record.enclosingTypeNames == IIndexConstants.ONE_ZERO_CHAR) {
865
				if (record.enclosingTypeNames == IIndexConstants.ONE_ZERO_CHAR) {
914
					return true; // filter out local and anonymous classes
866
					return true; // filter out local and anonymous classes
915
				}
867
				}
916
				switch (copiesLength) {
868
				
917
					case 0:
869
				if (workingCopyPaths.contains(documentPath)) {
918
						break;
870
					return true; // filter out working copies
919
					case 1:
920
						if (singleWkcpPath.equals(documentPath)) {
921
							return true; // fliter out *the* working copy
922
						}
923
						break;
924
					default:
925
						if (workingCopyPaths.contains(documentPath)) {
926
							return true; // filter out working copies
927
						}
928
						break;
929
				}
871
				}
930
872
931
				// Accept document path
873
				// Accept document path
Lines 1610-1616 Link Here
1610
						record.modifiers,
1552
						record.modifiers,
1611
						record.declaringSimpleName,
1553
						record.declaringSimpleName,
1612
						record.parameterCount,
1554
						record.parameterCount,
1613
						record.parameterTypes,
1555
						record.parameterTypeNames,
1614
						record.parameterNames,
1556
						record.parameterNames,
1615
						documentPath,
1557
						documentPath,
1616
						accessRestriction);
1558
						accessRestriction);
Lines 1637-1640 Link Here
1637
			}
1579
			}
1638
		}
1580
		}
1639
	}
1581
	}
1582
	
1583
	/**
1584
	 * <p>Searches for all methods in the index and working copies.</p>
1585
	 * 
1586
	 * @param functionRequester requester to report results to
1587
	 * @param selectorPattern selector pattern that the results need to match
1588
	 * @param declaringType type that all results must be defined on
1589
	 * @param selectorPatternMatchRule the match rule used with the given <code>selectorPattern</code>
1590
	 * @param scope of the search
1591
	 * @param waitingPolicy policy to use when waiting for the index to index
1592
	 * @param progressMonitor monitor to report status too
1593
	 * 
1594
	 * @see SearchPattern
1595
	 * 
1596
	 * @see IJob#ForceImmediate
1597
	 * @see IJob#CancelIfNotReady
1598
	 * @see IJob#WaitUntilReady
1599
	 */
1600
	public void searchAllFunctions(final IFunctionRequester functionRequester,
1601
			char[] selectorPattern, String declaringType, final int selectorPatternMatchRule,
1602
			IJavaScriptSearchScope scope,
1603
			int waitingPolicy, IProgressMonitor progressMonitor) {
1604
		
1605
		//determine the declaring type pattern characters
1606
		char[] declaringTypePatternChars = null;
1607
		if(declaringType != null && declaringType.trim().length() > 0) {
1608
			declaringTypePatternChars = declaringType.toCharArray();
1609
		}
1610
		
1611
		//pattern for searching the index and working copies
1612
		final MethodPattern searchPattern = new MethodPattern(true, false,
1613
				selectorPattern, declaringTypePatternChars, selectorPatternMatchRule);
1614
		
1615
		//requester used to accept index matches
1616
		final HashSet workingCopiesPaths = this.getWorkingCopiesPaths();
1617
		IndexQueryRequestor queryRequestor = new IndexQueryRequestor() {
1618
			/**
1619
			 * @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)
1620
			 */
1621
			public boolean acceptIndexMatch(String documentPath,
1622
					SearchPattern indexRecord, SearchParticipant participant,
1623
					AccessRuleSet access) {
1624
				
1625
				if(!workingCopiesPaths.contains(documentPath)) {
1626
					MethodPattern record = (MethodPattern)indexRecord;
1627
					functionRequester.acceptFunction(record.selector, record.parameterCount,
1628
							record.parameterQualifications, record.parameterSimpleNames, record.parameterNames,
1629
							record.returnQualification, record.returnSimpleName,
1630
							record.declaringQualification, record.declaringSimpleName,
1631
							record.modifiers,
1632
							documentPath);
1633
				}
1634
				
1635
				return true;
1636
			}
1637
		};
1638
		
1639
		// Find function matches from index
1640
		IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
1641
		try {
1642
			if (progressMonitor != null) {
1643
				progressMonitor.beginTask(Messages.engine_searching, 1000);
1644
			}
1645
			
1646
			indexManager.performConcurrentJob(
1647
				new PatternSearchJob(
1648
					searchPattern,
1649
					getDefaultSearchParticipant(), // JavaScript search only
1650
					scope,
1651
					queryRequestor),
1652
				waitingPolicy,
1653
				progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 1000));
1654
		} finally {
1655
			if (progressMonitor != null) {
1656
				progressMonitor.done();
1657
			}
1658
		}
1659
		
1660
		// find function matches from working copies
1661
		IJavaScriptUnit[] workingCopies = this.getWorkingCopies();
1662
		for (int i = 0; workingCopies != null && i < workingCopies.length; i++) {
1663
			final IJavaScriptUnit workingCopy = workingCopies[i];
1664
			
1665
			//skip this working copy if not in the scope
1666
			if(!scope.encloses(workingCopy)) {
1667
				continue;
1668
			}
1669
			
1670
			try {
1671
				/* if working copy is consistent use the working copy as is
1672
				 * else need to re-parse the working copy and visit its AST
1673
				 */
1674
				if (workingCopy.isConsistent()) {
1675
					//check each function in the working copy for a match
1676
					IFunction[] allFunctions = workingCopy.getFunctions();
1677
					for (int j = 0; j < allFunctions.length; ++j) {
1678
						IFunction function = allFunctions[j];
1679
						
1680
						//selector must not be null for it to be a match
1681
						char[] wcSelector = null;
1682
						if(function.getElementName() != null) {
1683
							wcSelector = function.getElementName().toCharArray();
1684
						}
1685
						if(wcSelector != null) {
1686
							
1687
							//create a pattern from the working copy method
1688
							char[] wcDeclaringType = null;
1689
							if(function.getDeclaringType() != null && function.getDeclaringType().getTypeQualifiedName() != null) {
1690
								wcDeclaringType = function.getDeclaringType().getTypeQualifiedName().toCharArray();
1691
							}
1692
							MethodPattern wcPattern = new MethodPattern(true, false,
1693
									wcSelector ,wcDeclaringType, selectorPatternMatchRule);
1694
							
1695
							//if working copy function matches the search pattern then accept the function
1696
							if(searchPattern.matchesDecodedKey(wcPattern)) {
1697
								//figure out parameter names and types
1698
								String[] wcParameterNames = function.getParameterNames();
1699
								char[][][] wcSeperatedParamTypes =
1700
										QualificationHelpers.seperateFullyQualifiednames(function.getParameterTypes(), wcParameterNames.length);
1701
								
1702
								//figure out the return type parts
1703
								char[] wcReturnQualification = null;
1704
								char[] wcReturnSimpleName = null;
1705
								String wcReturnTypeSig = function.getReturnType();
1706
								if(wcReturnTypeSig != null) {
1707
									char[] wcReturnType = Signature.toString(wcReturnTypeSig).toCharArray();
1708
									char[][] wcSeperatedReturnType = 
1709
											QualificationHelpers.seperateFullyQualifedName(wcReturnType);
1710
									wcReturnQualification = wcSeperatedReturnType[QualificationHelpers.QULIFIERS_INDEX];
1711
									wcReturnSimpleName = wcSeperatedReturnType[QualificationHelpers.SIMPLE_NAMES_INDEX];
1712
								}
1713
								
1714
								//get the declaring type parts
1715
								char[][] wcSeperatedDeclaringType = QualificationHelpers.seperateFullyQualifedName(wcDeclaringType);
1716
								
1717
								//accept the method
1718
								functionRequester.acceptFunction(wcSelector, wcParameterNames.length,
1719
										wcSeperatedParamTypes[QualificationHelpers.QULIFIERS_INDEX],
1720
										wcSeperatedParamTypes[QualificationHelpers.SIMPLE_NAMES_INDEX],
1721
										QualificationHelpers.stringArrayToCharArray(wcParameterNames),
1722
										wcReturnQualification, wcReturnSimpleName,
1723
										wcSeperatedDeclaringType[QualificationHelpers.QULIFIERS_INDEX],
1724
										wcSeperatedDeclaringType[QualificationHelpers.SIMPLE_NAMES_INDEX],
1725
										function.getFlags(), workingCopy.getPath().toString());
1726
							}
1727
						}
1728
					}
1729
				} else {
1730
					Parser basicParser = getParser();
1731
					ICompilationUnit unit = (ICompilationUnit) workingCopy;
1732
					CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0, this.compilerOptions.maxProblemsPerUnit);
1733
					CompilationUnitDeclaration parsedUnit = basicParser.dietParse(unit, compilationUnitResult);
1734
					if (parsedUnit != null) {
1735
						basicParser.inferTypes(parsedUnit, null);
1736
						parsedUnit.traverse( new ASTVisitor() {
1737
							/**
1738
							 * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration, org.eclipse.wst.jsdt.internal.compiler.lookup.Scope)
1739
							 */
1740
							public boolean visit(MethodDeclaration methodDeclaration, Scope scope) {
1741
								if(methodDeclaration.inferredMethod != null) {
1742
									this.visit(methodDeclaration.inferredMethod);
1743
								} else {
1744
									this.visit(methodDeclaration, methodDeclaration.getName(), null);
1745
								}
1746
								
1747
								return true;
1748
							}
1749
							
1750
							/**
1751
							 * @see org.eclipse.wst.jsdt.internal.compiler.ASTVisitor#visit(org.eclipse.wst.jsdt.core.infer.InferredMethod, org.eclipse.wst.jsdt.internal.compiler.lookup.BlockScope)
1752
							 */
1753
							public boolean visit(InferredMethod inferredMethod, BlockScope scope) {
1754
								visit(inferredMethod);
1755
								return true;
1756
							}
1757
							
1758
							/**
1759
							 * <p>Visits an {@link InferredMethod} on a working copy</p>
1760
							 * 
1761
							 * @param inferredMethod {@link InferredMethod} on the working copy to visit
1762
							 */
1763
							private void visit(InferredMethod inferredMethod) {
1764
								char[] wcDeclaringType = null;
1765
								if(inferredMethod.inType != null) {
1766
									wcDeclaringType = inferredMethod.inType.getName();
1767
								}
1768
								
1769
								this.visit(inferredMethod.getFunctionDeclaration(),
1770
										inferredMethod.name, wcDeclaringType);
1771
							}
1772
							
1773
							/**
1774
							 * <p>Visits an {@link IFunctionDeclaration} using a given selector name
1775
							 * and declaring type</p>
1776
							 * 
1777
							 * @param funcDecl function declaration to visit
1778
							 * @param wcSelector selector to use when visiting the declaration
1779
							 * @param wcDeclaringType declaring type to use when visiting the declaration
1780
							 */
1781
							private void visit(IFunctionDeclaration funcDecl,
1782
									char[] wcSelector, char[] wcDeclaringType) {
1783
1784
								//create the working copy pattern
1785
								MethodPattern wcPattern = new MethodPattern(true, false,
1786
										wcSelector,wcDeclaringType, selectorPatternMatchRule);
1787
								
1788
								//if working copy function matches the search pattern then accept the function qualification
1789
								if(searchPattern.matchesDecodedKey(wcPattern)) {
1790
									//get parameter names and types
1791
									IArgument[] args = funcDecl.getArguments();
1792
									char[][] wcParameterNames = null;
1793
									char[][] wcParameterQualifications = null;
1794
									char[][] wcParameterSimpleNames = null;
1795
									int wcParametersLength = 0;
1796
									if(args != null) {
1797
										wcParameterNames = new char[args.length][];
1798
										wcParameterQualifications = new char[args.length][];
1799
										wcParameterSimpleNames = new char[args.length][];
1800
										wcParametersLength = args.length;
1801
										
1802
										for(int i = 0; i < args.length; ++i) {
1803
											wcParameterNames[i] = args[i].getName();
1804
											if(args[i].getInferredType() != null) {
1805
												char[][] wcSeperatedParamType =
1806
													QualificationHelpers.seperateFullyQualifedName(args[i].getInferredType().getName());
1807
												wcParameterQualifications[i] = wcSeperatedParamType[QualificationHelpers.QULIFIERS_INDEX];
1808
												wcParameterSimpleNames[i] = wcSeperatedParamType[QualificationHelpers.SIMPLE_NAMES_INDEX];
1809
											}
1810
										}
1811
									}
1812
									
1813
									//get return type
1814
									char[] wcReturnQualification = null;
1815
									char[] wcReturnSimpleName = null;
1816
									if(funcDecl.getInferredType() != null) {
1817
										char[][] seperatedReturnType = QualificationHelpers.seperateFullyQualifedName(
1818
												funcDecl.getInferredType().getName());
1819
										wcReturnQualification = seperatedReturnType[QualificationHelpers.QULIFIERS_INDEX];
1820
										wcReturnSimpleName = seperatedReturnType[QualificationHelpers.SIMPLE_NAMES_INDEX];
1821
									}
1822
									
1823
									//get the declaring type parts
1824
									char[][] wcSeperatedDeclaringType = QualificationHelpers.seperateFullyQualifedName(wcDeclaringType);
1825
									
1826
									//get the modifiers
1827
									int modifiers = 0;
1828
									if(funcDecl instanceof MethodDeclaration) {
1829
										modifiers = ((MethodDeclaration) funcDecl).modifiers;
1830
									}
1831
									
1832
									//accept the method
1833
									functionRequester.acceptFunction(wcSelector, wcParametersLength,
1834
											wcParameterQualifications,
1835
											wcParameterSimpleNames,
1836
											wcParameterNames,
1837
											wcReturnQualification, wcReturnSimpleName,
1838
											wcSeperatedDeclaringType[QualificationHelpers.QULIFIERS_INDEX],
1839
											wcSeperatedDeclaringType[QualificationHelpers.SIMPLE_NAMES_INDEX],
1840
											modifiers, workingCopy.getPath().toString());
1841
								}
1842
							}
1843
						}, parsedUnit.scope);
1844
					}
1845
				}
1846
			} catch(JavaScriptModelException e) {
1847
				Logger.logException("Error while processing working copy", e);
1848
			}
1849
		}
1850
	}
1640
}
1851
}
(-)src/org/eclipse/wst/jsdt/internal/core/search/IFunctionRequester.java (+45 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
 * <p>Requester to use when requesting function matches.</p>
15
 */
16
public interface IFunctionRequester {
17
18
	/**
19
	 * <p>Accept a function defined with all of the given information.</p>
20
	 * 
21
	 * @param signature
22
	 * @param parameterCount
23
	 * @param parameterQualifications
24
	 * @param parameterSimpleNames
25
	 * @param parameterNames
26
	 * @param returnQualification
27
	 * @param returnSimpleName
28
	 * @param declaringQualification
29
	 * @param declaringSimpleName
30
	 * @param modifiers
31
	 * @param path
32
	 */
33
	public void acceptFunction(
34
				char[] signature,
35
				int parameterCount,
36
				char[][] parameterQualifications,
37
				char[][] parameterSimpleNames,
38
				char[][] parameterNames,
39
				char[] returnQualification,
40
				char[] returnSimpleName,
41
				char[] declaringQualification,
42
				char[] declaringSimpleName,
43
				int modifiers,
44
				String path);
45
}
(-)src/org/eclipse/wst/jsdt/internal/core/search/IndexQueryRequestor.java (-4 / +14 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 15-25 Link Here
15
import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
15
import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
16
16
17
/**
17
/**
18
 * TODO add spec
18
 * <p>Requester used when searching an index for matches to a pattern.</p>
19
 */
19
 */
20
public abstract class IndexQueryRequestor {
20
public abstract class IndexQueryRequestor {
21
21
22
	// answer false if requesting cancel
22
	/**
23
	public abstract boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access);
23
	 * <p>Accepts an index match when searching an index.</p>
24
	 * 
25
	 * @param documentPath
26
	 * @param indexRecord
27
	 * @param participant
28
	 * @param access
29
	 * 
30
	 * @return <code>true</code> to continue search, <code>false</code> to request cancel of search
31
	 */
32
	public abstract boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord,
33
			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/MatchLocator.java (-4 lines)
Lines 926-935 Link Here
926
	}
926
	}
927
	//	Get binding from unit scope
927
	//	Get binding from unit scope
928
	char[] typeName = PatternLocator.qualifiedPattern(methodPattern.declaringSimpleName, methodPattern.declaringQualification);
928
	char[] typeName = PatternLocator.qualifiedPattern(methodPattern.declaringSimpleName, methodPattern.declaringQualification);
929
	if (typeName == null) {
930
		if (methodPattern.declaringType == null) return null;
931
		typeName = methodPattern.declaringType.getFullyQualifiedName().toCharArray();
932
	}
933
	TypeBinding declaringTypeBinding = getType(typeName, typeName);
929
	TypeBinding declaringTypeBinding = getType(typeName, typeName);
934
	if (declaringTypeBinding != null) {
930
	if (declaringTypeBinding != null) {
935
		if (declaringTypeBinding.isArrayType()) {
931
		if (declaringTypeBinding.isArrayType()) {
(-)src/org/eclipse/wst/jsdt/internal/core/search/matching/MethodLocator.java (-30 / +3 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 79-85 Link Here
79
				this.pattern.declaringSimpleName,
78
				this.pattern.declaringSimpleName,
80
				this.pattern.declaringQualification,
79
				this.pattern.declaringQualification,
81
				locator,
80
				locator,
82
				this.pattern.declaringType,
81
				null,
83
				locator.progressMonitor).collect();
82
				locator.progressMonitor).collect();
84
	} catch (JavaScriptModelException e) {
83
	} catch (JavaScriptModelException e) {
85
		// inaccurate matches will be found
84
		// inaccurate matches will be found
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 (-336 / +626 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;
17
import org.eclipse.wst.jsdt.core.IType;
18
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
19
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
15
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
20
import org.eclipse.wst.jsdt.core.search.SearchPattern;
16
import org.eclipse.wst.jsdt.core.search.SearchPattern;
17
import org.eclipse.wst.jsdt.internal.compiler.classfmt.ClassFileConstants;
18
import org.eclipse.wst.jsdt.internal.core.Logger;
21
import org.eclipse.wst.jsdt.internal.core.index.EntryResult;
19
import org.eclipse.wst.jsdt.internal.core.index.EntryResult;
22
import org.eclipse.wst.jsdt.internal.core.index.Index;
20
import org.eclipse.wst.jsdt.internal.core.index.Index;
23
import org.eclipse.wst.jsdt.internal.core.util.Util;
21
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
22
61
/**
23
/**
62
 * Method entries are encoded as selector '/' Arity:
24
 * <p>Pattern used when adding functions to an index or searching an index for functions.</p>
63
 * e.g. 'foo/0'
64
 */
65
public static char[] createIndexKey(char[] selector, int argCount) {
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
95
	this.selector = (isCaseSensitive() || isCamelCase())  ? selector : CharOperation.toLowerCase(selector);
96
	this.declaringQualification = isCaseSensitive() ? declaringQualification : CharOperation.toLowerCase(declaringQualification);
97
	this.declaringSimpleName = isCaseSensitive() ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
98
	this.returnQualification = isCaseSensitive() ? returnQualification : CharOperation.toLowerCase(returnQualification);
99
	this.returnSimpleName = isCaseSensitive() ? returnSimpleName : CharOperation.toLowerCase(returnSimpleName);
100
	if (parameterSimpleNames != null) {
101
		this.parameterCount = parameterSimpleNames.length;
102
		this.parameterQualifications = new char[this.parameterCount][];
103
		this.parameterSimpleNames = new char[this.parameterCount][];
104
		for (int i = 0; i < this.parameterCount; i++) {
105
			this.parameterQualifications[i] = isCaseSensitive() ? parameterQualifications[i] : CharOperation.toLowerCase(parameterQualifications[i]);
106
			this.parameterSimpleNames[i] = isCaseSensitive() ? parameterSimpleNames[i] : CharOperation.toLowerCase(parameterSimpleNames[i]);
107
		}
108
	} else {
109
		this.parameterCount = -1;
110
	}
111
	this.declaringType = declaringType;
112
	((InternalSearchPattern)this).mustResolve = mustResolve();
113
}
114
/*
115
 * Instanciate a method pattern with signatures for generics search
116
 */
25
 */
117
public MethodPattern(
26
public class MethodPattern extends JavaSearchPattern  {
118
	boolean findDeclarations,
119
	boolean findReferences,
120
	boolean isFunction,
121
	char[] selector,
122
	char[] declaringQualification,
123
	char[] declaringSimpleName,
124
	char[] returnQualification,
125
	char[] returnSimpleName,
126
	String returnSignature,
127
	char[][] parameterQualifications,
128
	char[][] parameterSimpleNames,
129
	String[] parameterSignatures,
130
	IFunction method,
131
	int matchRule) {
132
133
	this(findDeclarations,
134
		findReferences,
135
		isFunction,
136
		selector,
137
		declaringQualification,
138
		declaringSimpleName,
139
		returnQualification,
140
		returnSimpleName,
141
		parameterQualifications,
142
		parameterSimpleNames,
143
		method.getDeclaringType(),
144
		matchRule);
145
27
146
	// Set flags
28
	protected static final char[][] REF_CATEGORIES = { METHOD_REF };
147
	try {
29
	protected static final char[][] REF_AND_DECL_CATEGORIES = { METHOD_REF, METHOD_DECL };
148
		this.varargs = (method.getFlags() & Flags.AccVarargs) != 0;
30
	protected static final char[][] DECL_CATEGORIES = { METHOD_DECL };
149
	} catch (JavaScriptModelException e) {
31
	protected static final char[][] FUNCTION_REF_AND_DECL_CATEGORIES = { METHOD_REF, FUNCTION_DECL, METHOD_DECL };
150
		// do nothing
32
	protected static final char[][] FUNCTION_DECL_CATEGORIES = { FUNCTION_DECL, METHOD_DECL };
151
	}
33
	
34
	/**
35
	 * <p><b>Required</b></p>
36
	 * 
37
	 * <p>Name of the function</p>
38
	 */
39
	public char[] selector;
40
	
41
	/**
42
	 * <p><b>Required</b></p>
43
	 * 
44
	 * <p>Number of specified parameters for this function.
45
	 * Must be equal to or greater then 0.</p>
46
	 */
47
	public int parameterCount;
48
	
49
	/**
50
	 * <p><b>Optional</b></p>
51
	 * 
52
	 * <p>Qualifications of the parameter types for this function.</p>
53
	 * <p>This should have the same length as {@link #parameterCount}, or
54
	 * <code>null</code> if {@link #parameterCount} is 0</p>
55
	 * 
56
	 * <p><b>Note:</b> If this field is defined then the {@link #parameterSimpleNames} must
57
	 * also be defined.</p>
58
	 * 
59
	 * @see #parameterSimpleNames
60
	 */
61
	public char[][] parameterQualifications;
62
	
63
	/**
64
	 * <p><b>Optional</b></p>
65
	 * 
66
	 * <p>Simple names of the parameter types for this function.</p>
67
	 * <p>This should have the same length as {@link #parameterCount}, or
68
	 * <code>null</code> if {@link #parameterCount} is 0</p>
69
	 * 
70
	 * <p><b>Note:</b> If this field is defined then the {@link #parameterQualifications}
71
	 * filed can be defined, but does not have to be.</p>
72
	 * 
73
	 * @see #parameterQualifications
74
	 */
75
	public char[][] parameterSimpleNames;
76
	
77
	/**
78
	 * <p><b>Required</b> if {@link #parameterCount} is greater then 0</p>
79
	 * 
80
	 * <p>Names of the defined parameters 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
	public char[][] parameterNames;
85
	
86
	/**
87
	 * <p><b>Optional</b></p>
88
	 * 
89
	 * <p>Qualification of the return type of this function.</p>
90
	 * 
91
	 * <p><b>Note:</b> If this field is defined then the {@link #returnSimpleName} must
92
	 * also be defined.</p>
93
	 */
94
	public char[] returnQualification;
152
	
95
	
153
	methodParameters = true;
96
	/**
97
	 * <p><b>Optional</b></p>
98
	 * 
99
	 * <p>Simple name of the return type of this function.</p>
100
	 * 
101
	 * <p><b>Note:</b> If this field is defined then the {@link #returnQualification}
102
	 * filed can be defined, but does not have to be.</p>
103
	 */
104
	public char[] returnSimpleName;
154
	
105
	
155
	if (declaringType!=null) {
106
	/**
156
		// Store type signature and arguments for declaring type
107
	 * <p><b>Optional</b></p>
157
		storeTypeSignaturesAndArguments(declaringType);
108
	 * 
109
	 * <p>Qualification of the declaring type containing this function.</p>
110
	 * 
111
	 * <p><b>Note:</b> If this field is defined then the {@link #declaringSimpleName} must
112
	 * also be defined.</p>
113
	 * 
114
	 * @see #declaringSimpleName
115
	 */
116
	public char[] declaringQualification;
117
	
118
	/**
119
	 * <p><b>Optional</b></p>
120
	 * 
121
	 * <p>Simple name of the declaring type containing this function.</p>
122
	 * 
123
	 * <p><b>Note:</b> If this field is defined then the {@link #declaringQualification}
124
	 * can be defined, but does not have to be.</p>
125
	 * 
126
	 * @see #declaringQualification
127
	 */
128
	public char[] declaringSimpleName;
129
	
130
	/**
131
	 * <p><b>Optional</b></p>
132
	 * 
133
	 * <p>Any modifiers for this function.</p>
134
	 * 
135
	 * @see ClassFileConstants
136
	 */
137
	public int modifiers;
138
	
139
	/**
140
	 * <p>When using this pattern to do a search <code>true</code> to
141
	 * find function declarations that match this pattern, <code>false</code> otherwise.</p>
142
	 */
143
	protected boolean findDeclarations;
144
	
145
	/**
146
	 * <p>When using this pattern to do a search <code>true</code> to
147
	 * find function references that match this pattern, <code>false</code> otherwise.</p>
148
	 */
149
	protected boolean findReferences;
150
	
151
	/**
152
	 * <p><code>true</code> if this pattern represents a function,
153
	 * <code>false</code> otherwise.</p>
154
	 * 
155
	 * <p><b>NOTE:</b> this whole concept should be removed, a function is a function is a function.</p>
156
	 */
157
	protected boolean isFunction;
158
159
	/**
160
	 * <p>Internal constructor for creating plank patterns</p>
161
	 *
162
	 * @param matchRule match rule used when comparing this pattern to search results
163
	 * @param isFunction <code>true</code> if this pattern represents a function,
164
	 * <code>false</code> otherwise
165
	 */
166
	MethodPattern(int matchRule, boolean isFunction) {
167
		super(METHOD_PATTERN, matchRule);
168
		this.isFunction=isFunction;
169
	}
170
	
171
	/**
172
	 * <p>Useful constructor when creating a pattern to search for index matches
173
	 * while doing content assist.</p>
174
	 *
175
	 * @param findDeclarations when using this pattern to do a search <code>true</code> to
176
	 * find function declarations that match this pattern, <code>false</code> otherwise.
177
	 * @param findReferences hen using this pattern to do a search <code>true</code> to
178
	 * find function references that match this pattern, <code>false</code> otherwise
179
	 * @param isFunction <code>true</code> if this pattern represents a function,
180
	 * <code>false</code> otherwise
181
	 * @param selector pattern for the name of the function
182
	 * @param selectorMatchRule match rule used when comparing this pattern to search results.
183
	 * This dictates what type of pattern is present, if any, in the specified <code>selector</code>
184
	 * 
185
	 * @see SearchPattern
186
	 */
187
	public MethodPattern(boolean findDeclarations,
188
			boolean findReferences,
189
			boolean isFunction,
190
			char[] selector,
191
			int selectorMatchRule) {
158
		
192
		
193
		this(findDeclarations, findReferences, isFunction, selector,
194
				null, null, null, null, null, null,
195
				selectorMatchRule);
159
	}
196
	}
160
	// Store type signatures and arguments for return type
197
	
161
	if (returnSignature != null) {
198
	/**
162
		returnTypeSignatures = Util.splitTypeLevelsSignature(returnSignature);
199
	 * <p>Useful constructor for finding index matches based on content assist pattern.</p>
163
		returnTypeArguments = Util.getAllTypeArguments(returnTypeSignatures);
200
	 *
201
	 * @param findDeclarations when using this pattern to do a search <code>true</code> to
202
	 * find function declarations that match this pattern, <code>false</code> otherwise.
203
	 * @param findReferences hen using this pattern to do a search <code>true</code> to
204
	 * find function references that match this pattern, <code>false</code> otherwise
205
	 * @param selector pattern for the name of the function
206
	 * @param declaringType optional declaring type that the given selector must be
207
	 * defined on to be a valid match, or <code>null</code> to specify the function is not
208
	 * defined on a type
209
	 * @param selectorMatchRule match rule used when comparing this pattern to search results.
210
	 * This dictates what type of pattern is present, if any, in the specified <code>selector</code>
211
	 */
212
	public MethodPattern(boolean findDeclarations, boolean findReferences,
213
			char[] selector, char[] declaringType,
214
			int selectorMatchRule){
215
		
216
		this(selectorMatchRule, true);
217
		
218
		this.findDeclarations = findDeclarations;
219
		this.findReferences = findReferences;
220
		this.selector = isCaseSensitive() ? selector : CharOperation.toLowerCase(selector);
221
		this.parameterCount = -1;
222
		
223
		char[][] seperatedDeclaringType = QualificationHelpers.seperateFullyQualifedName(declaringType);
224
		this.declaringQualification = isCaseSensitive() ?
225
				seperatedDeclaringType[QualificationHelpers.QULIFIERS_INDEX] : CharOperation.toLowerCase(seperatedDeclaringType[QualificationHelpers.QULIFIERS_INDEX]);
226
		this.declaringSimpleName = isCaseSensitive() ?
227
				seperatedDeclaringType[QualificationHelpers.SIMPLE_NAMES_INDEX] : CharOperation.toLowerCase(seperatedDeclaringType[QualificationHelpers.SIMPLE_NAMES_INDEX]);
164
	}
228
	}
165
229
	
166
	// Store type signatures and arguments for method parameters type
230
	/**
167
	if (parameterSignatures != null) {
231
	 * <p>Constructor to create a pattern that accepts all possible information about a function.</p>
168
		int length = parameterSignatures.length;
232
	 *
169
		if (length > 0) {
233
	 * @param findDeclarations
170
			parametersTypeSignatures = new char[length][][];
234
	 * @param findReferences
171
			parametersTypeArguments = new char[length][][][];
235
	 * @param isFunction
172
			for (int i=0; i<length; i++) {
236
	 * @param selector
173
				parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
237
	 * @param declaringQualification
174
				parametersTypeArguments[i] = Util.getAllTypeArguments(parametersTypeSignatures[i]);
238
	 * @param declaringSimpleName
239
	 * @param returnQualification
240
	 * @param returnSimpleName
241
	 * @param parameterQualifications
242
	 * @param parameterSimpleNames
243
	 * @param matchRule
244
	 */
245
	public MethodPattern(
246
		boolean findDeclarations,
247
		boolean findReferences,
248
		boolean isFunction,
249
		char[] selector,
250
		char[][] parameterQualifications,
251
		char[][] parameterSimpleNames,
252
		char[] returnQualification,
253
		char[] returnSimpleName,
254
		char[] declaringQualification,
255
		char[] declaringSimpleName,
256
		int matchRule) {
257
258
		this(matchRule,isFunction);
259
260
		this.findDeclarations = findDeclarations;
261
		this.findReferences = findReferences;
262
263
		this.selector = (isCaseSensitive() || isCamelCase())  ? selector : CharOperation.toLowerCase(selector);
264
		this.declaringQualification = isCaseSensitive() ? declaringQualification : CharOperation.toLowerCase(declaringQualification);
265
		this.declaringSimpleName = isCaseSensitive() ? declaringSimpleName : CharOperation.toLowerCase(declaringSimpleName);
266
		this.returnQualification = isCaseSensitive() ? returnQualification : CharOperation.toLowerCase(returnQualification);
267
		this.returnSimpleName = isCaseSensitive() ? returnSimpleName : CharOperation.toLowerCase(returnSimpleName);
268
		if (parameterSimpleNames != null) {
269
			this.parameterCount = parameterSimpleNames.length;
270
			this.parameterQualifications = new char[this.parameterCount][];
271
			this.parameterSimpleNames = new char[this.parameterCount][];
272
			for (int i = 0; i < this.parameterCount; i++) {
273
				this.parameterQualifications[i] = isCaseSensitive() ? parameterQualifications[i] : CharOperation.toLowerCase(parameterQualifications[i]);
274
				this.parameterSimpleNames[i] = isCaseSensitive() ? parameterSimpleNames[i] : CharOperation.toLowerCase(parameterSimpleNames[i]);
175
			}
275
			}
276
		} else {
277
			this.parameterCount = -1;
176
		}
278
		}
279
		
280
		((InternalSearchPattern)this).mustResolve = false;
177
	}
281
	}
178
282
	
179
	// Store type signatures and arguments for method
283
	/**
180
	methodArguments = extractMethodArguments(method);
284
	 * <p>Given an index key created by this class decodes that key into the
181
	if (hasMethodArguments())  ((InternalSearchPattern)this).mustResolve = true;
285
	 * various fields of this pattern.</p>
182
}
286
	 * 
183
/*
287
	 * @param key to decode into the fields of this pattern
184
 * Instanciate a method pattern with signatures for generics search
288
	 * 
185
 */
289
	 * @see #createIndexKey(char[], int)
186
public MethodPattern(
290
	 * @see #createIndexKey(char[], int, char[][], char[][], char[], char[], int)
187
	boolean findDeclarations,
291
	 * @see #createSearchIndexKey(char[], char[], char[], int)
188
	boolean findReferences,
292
	 * @see #createSearchIndexKey(char[], int, char[][], char[][], char[][], char[], char[], char[], char[], int)
189
	boolean isFunction,
293
	 */
190
	char[] selector,
294
	public void decodeIndexKey(char[] key) {
191
	char[] declaringQualification,
295
		char[][] seperated = CharOperation.splitOn(SEPARATOR, key);
192
	char[] declaringSimpleName,
296
		
193
	String declaringSignature,
297
		//get the selector
194
	char[] returnQualification,
298
		this.selector = seperated[0];
195
	char[] returnSimpleName,
299
		
196
	String returnSignature,
300
		//get the parameter count
197
	char[][] parameterQualifications,
301
		this.parameterCount = Integer.parseInt(new String(seperated[1]));
198
	char[][] parameterSimpleNames,
302
		
199
	String[] parameterSignatures,
303
		//get parameter types
200
	char[][] arguments,
304
		char[][][] parameterTypes = QualificationHelpers.seperateFullyQualifiedNames(seperated[2], this.parameterCount);
201
	int matchRule) {
305
		this.parameterQualifications = parameterTypes[QualificationHelpers.QULIFIERS_INDEX];
202
306
		this.parameterSimpleNames = parameterTypes[QualificationHelpers.SIMPLE_NAMES_INDEX];
203
	this(findDeclarations,
307
		
204
		findReferences,
308
		//get parameter names
205
		isFunction,
309
		char[][] parameterNames = CharOperation.splitOn(PARAMETER_SEPARATOR, seperated[3]);
206
		selector,
310
		if(parameterNames.length > 0) {
207
		declaringQualification,
311
			this.parameterNames = parameterNames;
208
		declaringSimpleName,
312
		} else {
209
		returnQualification,
313
			this.parameterNames = null;
210
		returnSimpleName,
314
		}
211
		parameterQualifications,
315
		
212
		parameterSimpleNames,
316
		//get the return type
213
		null,
317
		char[][] returnType = QualificationHelpers.seperateFullyQualifedName(seperated[4]);
214
		matchRule);
318
		this.returnQualification = returnType[QualificationHelpers.QULIFIERS_INDEX];
215
319
		this.returnSimpleName = returnType[QualificationHelpers.SIMPLE_NAMES_INDEX];
216
	// Store type signature and arguments for declaring type
320
		
217
	if (declaringSignature != null) {
321
		//get the declaration type
218
		typeSignatures = Util.splitTypeLevelsSignature(declaringSignature);
322
		char[][] declaringType = QualificationHelpers.seperateFullyQualifedName(seperated[5]);
219
		setTypeArguments(Util.getAllTypeArguments(typeSignatures));
323
		this.declaringQualification = declaringType[QualificationHelpers.QULIFIERS_INDEX];
324
		this.declaringSimpleName = declaringType[QualificationHelpers.SIMPLE_NAMES_INDEX];
325
		
326
		//get the modifiers
327
		this.modifiers = seperated[6][0] + seperated[6][1];
220
	}
328
	}
221
329
	
222
	// Store type signatures and arguments for return type
330
	public SearchPattern getBlankPattern() {
223
	if (returnSignature != null) {
331
		return new MethodPattern(R_EXACT_MATCH | R_CASE_SENSITIVE,isFunction);
224
		returnTypeSignatures = Util.splitTypeLevelsSignature(returnSignature);
332
	}
225
		returnTypeArguments = Util.getAllTypeArguments(returnTypeSignatures);
333
	public char[][] getIndexCategories() {
334
		if (this.findReferences)
335
			return this.findDeclarations ?
336
					(isFunction ? FUNCTION_REF_AND_DECL_CATEGORIES : REF_AND_DECL_CATEGORIES)
337
					: REF_CATEGORIES;
338
		if (this.findDeclarations)
339
			return isFunction ? FUNCTION_DECL_CATEGORIES : DECL_CATEGORIES;
340
		return CharOperation.NO_CHAR_CHAR;
226
	}
341
	}
227
342
228
	// Store type signatures and arguments for method parameters type
343
	boolean hasMethodParameters() {
229
	if (parameterSignatures != null) {
344
		return this.parameterCount > 0;
230
		int length = parameterSignatures.length;
345
	}
231
		if (length > 0) {
346
	boolean isPolymorphicSearch() {
232
			parametersTypeSignatures = new char[length][][];
347
		return this.findReferences;
233
			parametersTypeArguments = new char[length][][][];
348
	}
234
			for (int i=0; i<length; i++) {
349
	
235
				parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
350
	/**
236
				parametersTypeArguments[i] = Util.getAllTypeArguments(parametersTypeSignatures[i]);
351
	 * @see org.eclipse.wst.jsdt.core.search.SearchPattern#matchesDecodedKey(org.eclipse.wst.jsdt.core.search.SearchPattern)
352
	 */
353
	public boolean matchesDecodedKey(SearchPattern decodedPattern) {
354
		boolean matches = false;
355
		if(decodedPattern instanceof MethodPattern) {
356
			MethodPattern pattern = (MethodPattern) decodedPattern;
357
			
358
			matches = matchesName(this.selector, pattern.selector)
359
					&& (this.parameterCount == pattern.parameterCount || this.parameterCount == -1)
360
					&& matchesName(this.returnQualification, pattern.returnSimpleName)
361
					&& matchesName(this.returnSimpleName, pattern.returnSimpleName)
362
					&& matchesName(this.declaringQualification, pattern.declaringQualification)
363
					&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
364
			
365
			if(matches) {
366
				for(int i = 0; i < this.parameterCount && matches; ++i) {
367
					matches = matches
368
							&& matchesName(this.parameterQualifications[i], pattern.parameterQualifications[i])
369
							&& matchesName(this.parameterSimpleNames[i], pattern.parameterSimpleNames[i]);
370
				}
237
			}
371
			}
238
		}
372
		}
373
		
374
		return matches;
239
	}
375
	}
240
376
	
241
	// Store type signatures and arguments for method
377
	/**
242
	methodArguments = arguments;
378
	 * @see org.eclipse.wst.jsdt.internal.core.search.matching.InternalSearchPattern#queryIn(org.eclipse.wst.jsdt.internal.core.index.Index)
243
	if (hasMethodArguments())  ((InternalSearchPattern)this).mustResolve = true;
379
	 */
244
}
380
	EntryResult[] queryIn(Index index) throws IOException {
245
public void decodeIndexKey(char[] key) {
381
		char[] key = this.selector; // can be null
246
	int last = key.length - 1;
382
		int matchRule = getMatchRule();
247
	this.parameterCount = 0;
383
	
248
	this.selector = null;
384
		int matchRuleToUse = matchRule;
249
	int power = 1;
385
		switch(getMatchMode()) {
250
	for (int i=last; i>=0; i--) {
386
			case R_EXACT_MATCH :
251
		if (key[i] == SEPARATOR) {
387
				key = createSearchIndexKey(this.selector, this.parameterCount,
252
			System.arraycopy(key, 0, this.selector = new char[i], 0, i);
388
						this.parameterQualifications, this.parameterSimpleNames,
253
			break;
389
						this.parameterNames, this.returnQualification, this.returnSimpleName,
390
						this.declaringQualification, this.declaringSimpleName, this.modifiers);
391
				break;
392
			case R_PREFIX_MATCH :
393
				char[] selector = CharOperation.concat(this.selector, ONE_STAR);
394
				
395
				key = createSearchIndexKey(selector,
396
						this.declaringQualification, this.declaringSimpleName,
397
						this.modifiers);
398
				
399
				//the prefix match refers to the selector, but to do the actual match need to use a pattern
400
				matchRuleToUse = R_PATTERN_MATCH;
401
				break;
402
			case R_PATTERN_MATCH :
403
				key = createSearchIndexKey(this.selector,
404
						this.declaringQualification, this.declaringSimpleName,
405
						this.modifiers);
406
				break;
407
			case R_REGEXP_MATCH :
408
				// TODO implement regular expression match
409
				Logger.log(Logger.WARNING, "Regular expression matching is not yet implimented for MethodPattern");
410
				break;
254
		}
411
		}
255
		if (i == last) {
412
	
256
			this.parameterCount = key[i] - '0';
413
		return index.query(getIndexCategories(), key, matchRuleToUse); // match rule is irrelevant when the key is null
414
	}
415
	
416
	/**
417
	 * @see org.eclipse.wst.jsdt.internal.core.search.matching.JavaSearchPattern#print(java.lang.StringBuffer)
418
	 */
419
	protected StringBuffer print(StringBuffer output) {
420
		if (this.findDeclarations) {
421
			output.append(this.findReferences
422
				? "MethodCombinedPattern: " //$NON-NLS-1$
423
				: "MethodDeclarationPattern: "); //$NON-NLS-1$
424
		} else {
425
			output.append("MethodReferencePattern: "); //$NON-NLS-1$
426
		}
427
		if (declaringQualification != null)
428
			output.append(declaringQualification).append('.');
429
		if (declaringSimpleName != null)
430
			output.append(declaringSimpleName).append('.');
431
		else if (declaringQualification != null)
432
			output.append("*."); //$NON-NLS-1$
433
434
		if (selector != null)
435
			output.append(selector);
436
		else
437
			output.append("*"); //$NON-NLS-1$
438
		output.append('(');
439
		if (parameterSimpleNames == null) {
440
			output.append("..."); //$NON-NLS-1$
257
		} else {
441
		} else {
258
			power *= 10;
442
			for (int i = 0, max = parameterSimpleNames.length; i < max; i++) {
259
			this.parameterCount += power * (key[i] - '0');
443
				if (i > 0) output.append(", "); //$NON-NLS-1$
444
				if (parameterQualifications[i] != null) output.append(parameterQualifications[i]).append('.');
445
				if (parameterSimpleNames[i] == null) output.append('*'); else output.append(parameterSimpleNames[i]);
446
			}
260
		}
447
		}
448
		output.append(')');
449
		if (returnQualification != null)
450
			output.append(" --> ").append(returnQualification).append('.'); //$NON-NLS-1$
451
		else if (returnSimpleName != null)
452
			output.append(" --> "); //$NON-NLS-1$
453
		if (returnSimpleName != null)
454
			output.append(returnSimpleName);
455
		else if (returnQualification != null)
456
			output.append("*"); //$NON-NLS-1$
457
		return super.print(output);
261
	}
458
	}
262
}
459
	
263
public SearchPattern getBlankPattern() {
460
	/**
264
	return new MethodPattern(R_EXACT_MATCH | R_CASE_SENSITIVE,isFunction);
461
	 * <p>Create an index key from a selector and a parameter count.</p>
265
}
462
	 * 
266
public char[][] getIndexCategories() {
463
	 * <p><b>Note</b> Currently used to index function references, but the
267
	if (this.findReferences)
464
	 * validity of this use is questionable.</p>
268
		return this.findDeclarations ?
465
	 * 
269
				(isFunction ? FUNCTION_REF_AND_DECL_CATEGORIES : REF_AND_DECL_CATEGORIES)
466
	 * @param selector
270
				: REF_CATEGORIES;
467
	 * @param parameterCount
271
	if (this.findDeclarations)
468
	 * 
272
		return isFunction ? FUNCTION_DECL_CATEGORIES : DECL_CATEGORIES;
469
	 * @return a function index key created from a selector and a parameter count
273
	return CharOperation.NO_CHAR_CHAR;
470
	 */
274
}
471
	public static char[] createIndexKey(char[] selector, int parameterCount) {
275
boolean hasMethodArguments() {
472
		return createIndexKey(selector, parameterCount, null, null, null, null, 0);
276
	return methodArguments != null && methodArguments.length > 0;
277
}
278
boolean hasMethodParameters() {
279
	return methodParameters;
280
}
281
boolean isPolymorphicSearch() {
282
	return this.findReferences;
283
}
284
public boolean matchesDecodedKey(SearchPattern decodedPattern) {
285
	MethodPattern pattern = (MethodPattern) decodedPattern;
286
287
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
288
		&& matchesName(this.selector, pattern.selector);
289
}
290
/**
291
 * Returns whether a method declaration or message send must be resolved to
292
 * find out if this method pattern matches it.
293
 */
294
protected boolean mustResolve() {
295
	// declaring type
296
	// If declaring type is specified - even with simple name - always resolves
297
	if (declaringSimpleName != null || declaringQualification != null) return true;
298
299
	// return type
300
	// If return type is specified - even with simple name - always resolves
301
	if (returnSimpleName != null || returnQualification != null) return true;
302
303
	// parameter types
304
	if (parameterSimpleNames != null)
305
		for (int i = 0, max = parameterSimpleNames.length; i < max; i++)
306
			if (parameterQualifications[i] != null) return true;
307
	return false;
308
}
309
EntryResult[] queryIn(Index index) throws IOException {
310
	char[] key = this.selector; // can be null
311
	int matchRule = getMatchRule();
312
313
	switch(getMatchMode()) {
314
		case R_EXACT_MATCH :
315
			if (this.isCamelCase) break;
316
			if (this.selector != null && this.parameterCount >= 0 && !this.varargs)
317
				key = createIndexKey(this.selector, this.parameterCount);
318
			else { // do a prefix query with the selector
319
				matchRule &= ~R_EXACT_MATCH;
320
				matchRule |= R_PREFIX_MATCH;
321
			}
322
			break;
323
		case R_PREFIX_MATCH :
324
			// do a prefix query with the selector
325
			break;
326
		case R_PATTERN_MATCH :
327
			if (this.parameterCount >= 0 && !this.varargs)
328
				key = createIndexKey(this.selector == null ? ONE_STAR : this.selector, this.parameterCount);
329
			else if (this.selector != null && this.selector[this.selector.length - 1] != '*')
330
				key = CharOperation.concat(this.selector, ONE_STAR, SEPARATOR);
331
			// else do a pattern query with just the selector
332
			break;
333
		case R_REGEXP_MATCH :
334
			// TODO (frederic) implement regular expression match
335
			break;
336
	}
473
	}
337
474
	
338
	return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
475
	/**
339
}
476
	 * <p>Creates an index key based on the given function definition information.</p>
340
protected StringBuffer print(StringBuffer output) {
477
	 * 
341
	if (this.findDeclarations) {
478
	 * <p><b>Key Syntax</b>:
342
		output.append(this.findReferences
479
	 * <code>selector/parameterCount/parameterFullTypeNames/paramaterNames/returnFulLTypeName/declaringFullTypeName</code></p>
343
			? "MethodCombinedPattern: " //$NON-NLS-1$
480
	 * 
344
			: "MethodDeclarationPattern: "); //$NON-NLS-1$
481
	 * <p>
345
	} else {
482
	 * <b>Examples:</b><ul>
346
		output.append("MethodReferencePattern: "); //$NON-NLS-1$
483
	 * <li><code>myFunction/0////</code> - function with no parameters and no return type</li>
347
	}
484
	 * <li><code>myFunction/0///String/</code> - function with no parameters with a return type</li>
348
	if (declaringQualification != null)
485
	 * <li><code>myFunction/0////foo.bar.Type</code> - function on a type with no parameters and no return type</li>
349
		output.append(declaringQualification).append('.');
486
	 * <li><code>myFunction/0///String/foo.bar.Type</code> - function on a type with no parameters with a return type </li>
350
	if (declaringSimpleName != null)
487
	 * <li><code>myFunction/2//param1,param2//</code> - function with no parameter types, with parameter names with no return type</li>
351
		output.append(declaringSimpleName).append('.');
488
	 * <li><code>myFunction/2//param1,param2/String/</code> - function with no parameter types, with parameter names with a return type</li>
352
	else if (declaringQualification != null)
489
	 * <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>
353
		output.append("*."); //$NON-NLS-1$
490
	 * <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>
354
491
	 * <li><code>myFunction/2/String,Number/param1,param2//</code> - function with parameter types and names with no return type</li>
355
	if (selector != null)
492
	 * <li><code>myFunction/2/String,Number/param1,param2/String/</code> - function with parameter types and names with a return type</li>
356
		output.append(selector);
493
	 * <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>
357
	else
494
	 * <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>
358
		output.append("*"); //$NON-NLS-1$
495
	 * <li><code>myFunction/2/,Number/param1,param2//</code> - function where only one of the parameters has a type</li>
359
	output.append('(');
496
	 * <li><code>myFunction/2/,Number/param1,param2/String/</code> - function where only one of the parameters has a type with a return type</li>
360
	if (parameterSimpleNames == null) {
497
	 * <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>
361
		output.append("..."); //$NON-NLS-1$
498
	 * <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>
362
	} else {
499
	 * </ul></p>
363
		for (int i = 0, max = parameterSimpleNames.length; i < max; i++) {
500
	 * 
364
			if (i > 0) output.append(", "); //$NON-NLS-1$
501
	 * @param selector
365
			if (parameterQualifications[i] != null) output.append(parameterQualifications[i]).append('.');
502
	 * @param parameterCount
366
			if (parameterSimpleNames[i] == null) output.append('*'); else output.append(parameterSimpleNames[i]);
503
	 * @param declaringFullTypeName
504
	 * @param returnFullTypeName
505
	 * @param parameterFullTypeNames
506
	 * @param parameterNames
507
	 * @param modifiers
508
	 * 
509
	 * @see #decodeIndexKey(char[])
510
	 * 
511
	 * @return a key that can be put in an index or used to search an index for functions
512
	 */
513
	public static char[] createIndexKey(char[] selector, int parameterCount,
514
			char[][] parameterFullTypeNames,
515
			char[][] parameterNames,
516
			char[] declaringFullTypeName,
517
			char[] returnFullTypeName,
518
			int modifiers) {
519
		
520
		char[] indexKey = null;
521
		
522
		if(selector != null  && selector.length > 0) {
523
			char[] paramaterCountChars = null;
524
			char[] parameterTypesChars = CharOperation.NO_CHAR;
525
			char[] parameterNamesChars = CharOperation.NO_CHAR;
526
			
527
			
528
			//get param types
529
			if (parameterFullTypeNames != null) {
530
				parameterTypesChars = CharOperation.concatWith(parameterFullTypeNames, PARAMETER_SEPARATOR, false);
531
			}
532
			
533
			//get param names
534
			if (parameterNames != null) {
535
				parameterNamesChars = CharOperation.concatWith(parameterNames, PARAMETER_SEPARATOR);
536
			}
537
			
538
			//use pre-made char array for arg counts less then 10, else build a new one
539
			if(parameterCount >= 0) {
540
				paramaterCountChars = parameterCount < 10 ?
541
						COUNTS[parameterCount] : (SEPARATOR + String.valueOf(parameterCount)).toCharArray();
542
			} else {
543
				paramaterCountChars = CharOperation.concat(new char[] {SEPARATOR}, ONE_STAR);
544
			}
545
			
546
				
547
			//get lengths
548
			int parameterTypesLength = (parameterTypesChars == null ? 0 : parameterTypesChars.length);
549
			int parameterNamesLength = (parameterNamesChars == null ? 0 : parameterNamesChars.length);
550
			int returnTypeLength = (returnFullTypeName == null ? 0 : returnFullTypeName.length);
551
			int delaringTypeLength = declaringFullTypeName == null ? 0 : declaringFullTypeName.length;
552
			
553
			int resultLength = selector.length + paramaterCountChars.length
554
					+ 1 + parameterTypesLength
555
					+ 1 + parameterNamesLength
556
					+ 1 + returnTypeLength
557
					+ 1 + delaringTypeLength
558
					+ 3; //modifiers
559
			
560
			//create result char array
561
			indexKey = new char[resultLength];
562
			
563
			//add type name to result
564
			int pos = 0;
565
			System.arraycopy(selector, 0, indexKey, pos, selector.length);
566
			pos += selector.length;
567
			
568
			//add param count to result
569
			if (paramaterCountChars.length > 0) {
570
				System.arraycopy(paramaterCountChars, 0, indexKey, pos, paramaterCountChars.length);
571
				pos += paramaterCountChars.length;
572
			}
573
			
574
			//add param types
575
			indexKey[pos++] = SEPARATOR;
576
			if (parameterTypesLength > 0) {
577
				System.arraycopy(parameterTypesChars, 0, indexKey, pos, parameterTypesLength);
578
				pos += parameterTypesLength;
579
			}
580
			
581
			//add param names
582
			indexKey[pos++] = SEPARATOR;
583
			if (parameterNamesLength > 0) {
584
				System.arraycopy(parameterNamesChars, 0, indexKey, pos, parameterNamesLength);
585
				pos += parameterNamesLength;
586
			}
587
			
588
			//add return type
589
			indexKey[pos++] = SEPARATOR;
590
			if(returnTypeLength > 0) {
591
				System.arraycopy(returnFullTypeName, 0, indexKey, pos, returnTypeLength);
592
				pos += returnTypeLength;
593
			}
594
			
595
			//add declaring type
596
			indexKey[pos++] = SEPARATOR;
597
			if(delaringTypeLength > 0) {
598
				System.arraycopy(declaringFullTypeName, 0, indexKey, pos, delaringTypeLength);
599
				pos += delaringTypeLength;
600
			}
601
			
602
			//add modifiers
603
			indexKey[pos++] = SEPARATOR;
604
			indexKey[pos++] = (char) modifiers;
605
			indexKey[pos++] = (char) (modifiers>>16);
367
		}
606
		}
607
			
608
		return indexKey;
609
	}
610
	
611
	/**
612
	 * <p>Create an index key for search the index for any function that matches the given selector
613
	 * pattern, on the optionally defined declaring type, with the given modifiers.</p>
614
	 * 
615
	 * @param selectorPattern
616
	 * @param declarationType
617
	 * @param modifiers
618
	 * 
619
	 * @return
620
	 */
621
	private static char[] createSearchIndexKey(char[] selectorPattern,
622
			char[] declaringQualification, char[] declaringSimpleName, int modifiers) {
623
		
624
		char[] declaringFullTypeName = null;
625
		if(declaringSimpleName != null) {
626
			declaringFullTypeName = QualificationHelpers.createFullyQualifiedName(declaringQualification, declaringSimpleName);
627
		}
628
		
629
		return createIndexKey(selectorPattern, -1,
630
				ONE_STAR_CHAR,
631
				ONE_STAR_CHAR,
632
				declaringFullTypeName,
633
				ONE_STAR,
634
				modifiers);
635
	}
636
	
637
	/**
638
	 * <p>Used to create an index key to search for a specific function.</p>
639
	 * 
640
	 * @param selector
641
	 * @param parameterCount
642
	 * @param parameterQualifications
643
	 * @param parameterSimpleNames
644
	 * @param parameterNames
645
	 * @param returnQualification
646
	 * @param returnSimpleName
647
	 * @param declaringQualification
648
	 * @param declaringSimpleName
649
	 * @param modifiers
650
	 * @return
651
	 */
652
	private static char[] createSearchIndexKey(char[] selector, int parameterCount,
653
			char[][] parameterQualifications,
654
			char[][] parameterSimpleNames,
655
			char[][] parameterNames,
656
			char[] returnQualification,
657
			char[] returnSimpleName,
658
			char[] declaringQualification,
659
			char[] declaringSimpleName,
660
			int modifiers) {
661
		
662
		//create fully qualified type names
663
		char[] declaringFullTypeName = QualificationHelpers.createFullyQualifiedName(declaringQualification, declaringSimpleName);
664
		char[] returnFullTypeName = QualificationHelpers.createFullyQualifiedName(returnQualification, returnSimpleName);
665
		char[][] parameterFullTypeNames = QualificationHelpers.createFullyQualifiedNames(parameterQualifications, parameterSimpleNames);
666
		
667
		return createIndexKey(selector, parameterCount, parameterFullTypeNames,
668
				parameterNames, declaringFullTypeName, returnFullTypeName, modifiers);
368
	}
669
	}
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
}
670
}
(-)src/org/eclipse/wst/jsdt/internal/core/util/QualificationHelpers.java (+230 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.Signature;
14
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
15
import org.eclipse.wst.jsdt.internal.core.search.indexing.IIndexConstants;
16
17
/**
18
 * <p>Methods for helping with qualified type names, both to separate them into
19
 * qualifier and simple name, as well as recombining qualifier with simple name.</p>
20
 */
21
public class QualificationHelpers {
22
	
23
	/**
24
	 * <p>The index in the array containing the qualifier of a fully qualified name
25
	 * separated by a method in this class.</p>
26
	 * 
27
	 * @see #seperateFullyQualifedName(char[])
28
	 * @see #seperateFullyQualifedTypeNames(char[])
29
	 */
30
	public static final int QULIFIERS_INDEX = 0;
31
	
32
	/**
33
	 * <p>The index in the array containing the simple name of a fully qualified name
34
	 * separated by a method in this class.</p>
35
	 * 
36
	 * @see #seperateFullyQualifedName(char[])
37
	 * @see #seperateFullyQualifedTypeNames(char[])
38
	 */
39
	public static final int SIMPLE_NAMES_INDEX = 1;
40
	
41
	/**
42
	 * <p>Given a qualification and a simple name creates a fully qualified name.</p>
43
	 * 
44
	 * @param qualification the qualification, or <code>null</code> if no qualification
45
	 * @param simpleName the simple name, can not be <code>null</code>
46
	 * 
47
	 * @return fully qualified name created from the given <code>simpleName</code> and
48
	 * the optional <code>qualification</code>
49
	 */
50
	public static char[] createFullyQualifiedName(char[] qualification, char[] simpleName) {
51
		char[] fullTypeName = null;
52
		if(simpleName != null && simpleName.length > 0) {
53
			if(qualification != null && qualification.length > 0) {
54
				fullTypeName = CharOperation.concat(qualification, simpleName, IIndexConstants.DOT);
55
			} else {
56
				fullTypeName = simpleName;
57
			}
58
		}
59
		
60
		return fullTypeName;
61
	}
62
	
63
	/**
64
	 * <p>Given a list of qualifications and a list of simple names creates a single list of
65
	 * fully qualified names created by matching one qualification and one simple name from
66
	 * their respective lists in order.</p>
67
	 * 
68
	 * @param qualifications to match with the given <code>simpleNames</code>, this can be
69
	 * <code>null</code> if there are not qualifications, or an array of the same size as
70
	 * <code>simpleNames</code> where any one of the indices maybe <code>null</code> to signify
71
	 * there is no qualifier for that specific simple name.
72
	 * @param simpleNames to match with the given <code>qualifications</code>, this array
73
	 * can <b>not</b> be <code>null</code> and no indices in the array can be <code>null</code> either
74
	 * 
75
	 * @return an array of fully qualified names created from the given <code>simpleNames</code>
76
	 * and the optional <code>qualifications</code>
77
	 */
78
	public static char[][] createFullyQualifiedNames(char[][] qualifications, char[][] simpleNames) {
79
		char[][] fullTypeNames = null;
80
		
81
		if(simpleNames != null) {
82
			fullTypeNames = new char[simpleNames.length][];
83
			for(int i = 0; i < fullTypeNames.length; ++i) {
84
				if(qualifications != null && qualifications.length > i) {
85
					fullTypeNames[i] = createFullyQualifiedName(qualifications[i], simpleNames[i]);
86
				} else {
87
					fullTypeNames[i] = simpleNames[i];
88
				}
89
			}
90
		}
91
		
92
		return fullTypeNames;
93
	}
94
	
95
	/**
96
	 * <p>Separates a fully qualified name into its qualifier and its simple name</p>
97
	 * 
98
	 * @param fullyQualifiedName fully qualified type name to separate into its qualifier and simple name
99
	 * 
100
	 * @return a multidimensional array with one dimension for the qualifier and one for the simple name
101
	 * 
102
	 * @see #QULIFIERS_INDEX
103
	 * @see #SIMPLE_NAMES_INDEX
104
	 */
105
	public static char[][] seperateFullyQualifedName(char[] fullyQualifiedName) {
106
		char[][] seperatedTypeName = new char[2][];
107
		
108
		if(fullyQualifiedName != null && fullyQualifiedName.length > 0) {
109
			int lastIndexOfDot = CharOperation.lastIndexOf(IIndexConstants.DOT, fullyQualifiedName);
110
			if(lastIndexOfDot != -1) {
111
				seperatedTypeName[QULIFIERS_INDEX] = CharOperation.subarray(fullyQualifiedName, 0, lastIndexOfDot);
112
				seperatedTypeName[SIMPLE_NAMES_INDEX] = CharOperation.subarray(fullyQualifiedName, lastIndexOfDot+1, -1);
113
			} else {
114
				seperatedTypeName[QULIFIERS_INDEX] = null;
115
				seperatedTypeName[SIMPLE_NAMES_INDEX] = fullyQualifiedName;
116
			}
117
		}
118
		
119
		return seperatedTypeName;
120
	}
121
	
122
	/**
123
	 * <p>Separates an array of fully qualified names into their qualifiers and their simple names</p>
124
	 * 
125
	 * @param fullyQualifiedNames fully qualified type names to separate into their qualifiers and their simple names
126
	 * @param minLength the minimum length of the result, padding will be with <code>null</code>
127
	 * 
128
	 * @return resulting array consists of three indices.  The first is either {@link #QULIFIERS_INDEX} or
129
	 * {@link #SIMPLE_NAMES_INDEX}, the second is then a list of either the qualifiers or the simple names,
130
	 * depending on the first index, the last index is the char[] "string" qualifier or simple name.
131
	 * 
132
	 * @see #QULIFIERS_INDEX
133
	 * @see #SIMPLE_NAMES_INDEX
134
	 */
135
	public static char[][][] seperateFullyQualifiednames(String[] fullyQualifiedNames, int minLength) {
136
		return seperateFullyQualifiedNames(stringArrayToCharArray(fullyQualifiedNames), minLength);
137
	}
138
	
139
	/**
140
	 * <p>Separates a list of fully qualified names separated by {@link IIndexConstants#PARAMETER_SEPARATOR}
141
	 * into their qualifiers and their simple names</p>
142
	 * 
143
	 * @param fullyQualifiedNames a list of fully qualified type names separated by {@link IIndexConstants#PARAMETER_SEPARATOR}
144
	 * to separate into their qualifiers and their simple names
145
	 * @param minLength the minimum length of the result, padding will be with <code>null</code>
146
	 * 
147
	 * @return resulting array consists of three indices.  The first is either {@link #QULIFIERS_INDEX} or
148
	 * {@link #SIMPLE_NAMES_INDEX}, the second is then a list of either the qualifiers or the simple names,
149
	 * depending on the first index, the last index is the char[] "string" qualifier or simple name.
150
	 * 
151
	 * @see #QULIFIERS_INDEX
152
	 * @see #SIMPLE_NAMES_INDEX
153
	 */
154
	public static char[][][] seperateFullyQualifiedNames(char[] fullyQualifiedNames, int minLength) {
155
		char[][] names = CharOperation.splitOn(IIndexConstants.PARAMETER_SEPARATOR, fullyQualifiedNames);
156
		return seperateFullyQualifiedNames(names, minLength);
157
	}
158
	
159
	/**
160
	 * <p>Separates an array of fully qualified names into their qualifiers and their simple names</p>
161
	 * 
162
	 * @param fullyQualifiedNames fully qualified type names to separate into their qualifiers and their simple names
163
	 * @param minLength the minimum length of the result, padding will be with <code>null</code>
164
	 * 
165
	 * @return resulting array consists of three indices.  The first is either {@link #QULIFIERS_INDEX} or
166
	 * {@link #SIMPLE_NAMES_INDEX}, the second is then a list of either the qualifiers or the simple names,
167
	 * depending on the first index, the last index is the char[] "string" qualifier or simple name.
168
	 * 
169
	 * @see #QULIFIERS_INDEX
170
	 * @see #SIMPLE_NAMES_INDEX
171
	 */
172
	public static char[][][] seperateFullyQualifiedNames(char[][] fullyQualifiedNames, int minLength) {
173
		/* 
174
		 * First index is 0 or 1 for the list of qualifiers qualifier and then the list of simple names respectively
175
		 * Second index is a list of the qualifiers and simple names
176
		 * Third index is the actual 'string' qualifier or simple name
177
		 */
178
		char[][][] seperatedTypeNames = new char[2][][];
179
		
180
		if(fullyQualifiedNames.length > 0) {
181
			int length = minLength > fullyQualifiedNames.length ? minLength : fullyQualifiedNames.length;
182
			seperatedTypeNames[QULIFIERS_INDEX] = new char[length][];
183
			seperatedTypeNames[SIMPLE_NAMES_INDEX] = new char[length][];
184
			
185
			for(int i = 0; i < fullyQualifiedNames.length; ++i) {
186
				char[][] seperatedTypeName = seperateFullyQualifedName(fullyQualifiedNames[i]);
187
				seperatedTypeNames[QULIFIERS_INDEX][i] = seperatedTypeName[QULIFIERS_INDEX];
188
				seperatedTypeNames[SIMPLE_NAMES_INDEX][i] = seperatedTypeName[SIMPLE_NAMES_INDEX];
189
				
190
				//in case the qualifier is a signature, nothing happens if it is not
191
				if(seperatedTypeNames[QULIFIERS_INDEX][i] != null) {
192
					seperatedTypeNames[QULIFIERS_INDEX][i] = Signature.toCharArray(seperatedTypeNames[QULIFIERS_INDEX][i]);
193
				}
194
				
195
				//in case the simple name is a signature, nothing happens if it is not
196
				if(seperatedTypeNames[SIMPLE_NAMES_INDEX][i] != null) {
197
					seperatedTypeNames[SIMPLE_NAMES_INDEX][i] = Signature.toCharArray(seperatedTypeNames[SIMPLE_NAMES_INDEX][i]);
198
				}
199
			}
200
			
201
		} else if (minLength > 0) {
202
			seperatedTypeNames[QULIFIERS_INDEX] = new char[minLength][];
203
			seperatedTypeNames[SIMPLE_NAMES_INDEX] = new char[minLength][];
204
		} else {
205
			seperatedTypeNames[QULIFIERS_INDEX] = null;
206
			seperatedTypeNames[SIMPLE_NAMES_INDEX] = null;
207
		}
208
		
209
		return seperatedTypeNames;
210
	}
211
	
212
	/**
213
	 * <p>Transform a {@link String} array into a <code>char</code> array.</p>
214
	 * 
215
	 * @param array of {@link String}s to transform into an array of <code>char</code>s
216
	 * 
217
	 * @return array of {@link String}s built from the given array of <code>char</code>s
218
	 */
219
	public static char[][] stringArrayToCharArray(String[] array) {
220
		char[][] results = null;
221
		if(array != null) {
222
			results = new char[array.length][];
223
			for(int i = 0; i < array.length; ++i) {
224
				results[i] = array[i].toCharArray();
225
			}
226
		}
227
		
228
		return results;
229
	}
230
}
(-)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