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 305694 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/wst/jsdt/internal/codeassist/CompletionEngine.java (-63 / +101 lines)
Lines 83-88 Link Here
83
import org.eclipse.wst.jsdt.internal.compiler.ast.ConstructorDeclaration;
83
import org.eclipse.wst.jsdt.internal.compiler.ast.ConstructorDeclaration;
84
import org.eclipse.wst.jsdt.internal.compiler.ast.Expression;
84
import org.eclipse.wst.jsdt.internal.compiler.ast.Expression;
85
import org.eclipse.wst.jsdt.internal.compiler.ast.FieldDeclaration;
85
import org.eclipse.wst.jsdt.internal.compiler.ast.FieldDeclaration;
86
import org.eclipse.wst.jsdt.internal.compiler.ast.FieldReference;
86
import org.eclipse.wst.jsdt.internal.compiler.ast.ImportReference;
87
import org.eclipse.wst.jsdt.internal.compiler.ast.ImportReference;
87
import org.eclipse.wst.jsdt.internal.compiler.ast.Initializer;
88
import org.eclipse.wst.jsdt.internal.compiler.ast.Initializer;
88
import org.eclipse.wst.jsdt.internal.compiler.ast.InstanceOfExpression;
89
import org.eclipse.wst.jsdt.internal.compiler.ast.InstanceOfExpression;
Lines 623-629 Link Here
623
				flatEnclosingTypeNames = CharOperation.concatWith(acceptedType.enclosingTypeNames, '.');
624
				flatEnclosingTypeNames = CharOperation.concatWith(acceptedType.enclosingTypeNames, '.');
624
				typeName = CharOperation.concat(flatEnclosingTypeNames, simpleTypeName, '.');
625
				typeName = CharOperation.concat(flatEnclosingTypeNames, simpleTypeName, '.');
625
			}
626
			}
626
			char[] fullyQualifiedName = CharOperation.concat(packageName, typeName, '.');
627
			
628
			char[] fullyQualifiedName = typeName;
629
			if(CharOperation.indexOf('.', typeName) < 0) {
630
				fullyQualifiedName = CharOperation.concat(packageName, typeName, '.');
631
			}
627
632
628
			if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
633
			if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
629
634
Lines 1150-1156 Link Here
1150
		relevance += computeRelevanceForQualification(isQualified);
1155
		relevance += computeRelevanceForQualification(isQualified);
1151
		relevance += computeRelevanceForClass();
1156
		relevance += computeRelevanceForClass();
1152
		relevance += computeRelevanceForException(simpleTypeName);
1157
		relevance += computeRelevanceForException(simpleTypeName);
1153
1158
		
1159
		// put proposals that have '_' at the start of their final segment down the list
1160
		char[] lastSegment = CharOperation.lastSegment(completionName, '.');
1161
		if(CharOperation.indexOf('_', lastSegment) == 0) {
1162
			relevance--;
1163
		}
1154
		this.noProposal = false;
1164
		this.noProposal = false;
1155
		if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
1165
		if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
1156
			createTypeProposal(packageName, typeName, modifiers, accessibility, completionName, relevance);
1166
			createTypeProposal(packageName, typeName, modifiers, accessibility, completionName, relevance);
Lines 1641-1707 Link Here
1641
			long completionPosition = access.nameSourcePosition;
1651
			long completionPosition = access.nameSourcePosition;
1642
			setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1652
			setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1643
1653
1644
			this.completionToken = access.token;
1645
1654
1646
			if (qualifiedBinding.problemId() == ProblemReasons.NotFound) {
1655
1647
				// complete method members with missing return type
1656
//			this.assistNodeIsClass = true;
1648
				// class X {
1657
//			this.assistNodeIsConstructor = true;
1649
				//   Missing f() {return null;}
1658
1650
				//   void foo() {
1659
			// can be the start of a qualified type name
1651
				//     f().|
1660
			if (qualifiedBinding == null) {
1652
				//   }
1661
			
1653
				// }
1662
					this.completionToken = computeToken(access);
1654
				if (this.assistNodeInJavadoc == 0 &&
1663
					setSourceRange((int) (completionPosition >>> 32) - (this.completionToken.length - access.token.length), (int) completionPosition);
1655
						(this.requestor.isAllowingRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF) ||
1664
				
1656
								this.requestor.isAllowingRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF))) {
1665
					ObjectVector typesFound = new ObjectVector();
1657
					ProblemMethodBinding problemMethodBinding = (ProblemMethodBinding) qualifiedBinding;
1666
					findTypesAndPackages(this.completionToken, scope, typesFound);
1658
					findFieldsAndMethodsFromMissingReturnType(
1659
							problemMethodBinding.selector,
1660
							problemMethodBinding.parameters,
1661
							scope,
1662
							access,
1663
							insideTypeAnnotation);
1664
				}
1665
			} else {
1667
			} else {
1666
				if (!access.isInsideAnnotation) {
1668
				this.completionToken = access.token;
1667
					if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
1669
				if (qualifiedBinding.problemId() == ProblemReasons.NotFound) {
1668
						findKeywords(this.completionToken, new char[][]{Keywords.NEW}, false, false);
1670
					// complete method members with missing return type
1671
					// class X {
1672
					//   Missing f() {return null;}
1673
					//   void foo() {
1674
					//     f().|
1675
					//   }
1676
					// }
1677
					if (this.assistNodeInJavadoc == 0 &&
1678
							(this.requestor.isAllowingRequiredProposals(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_REF) ||
1679
									this.requestor.isAllowingRequiredProposals(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_REF))) {
1680
						ProblemMethodBinding problemMethodBinding = (ProblemMethodBinding) qualifiedBinding;
1681
						findFieldsAndMethodsFromMissingReturnType(
1682
								problemMethodBinding.selector,
1683
								problemMethodBinding.parameters,
1684
								scope,
1685
								access,
1686
								insideTypeAnnotation);
1669
					}
1687
					}
1670
1688
				} else {
1671
					findFieldsAndMethods(
1689
					if (!access.isInsideAnnotation) {
1672
						this.completionToken,
1690
						if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
1673
						((TypeBinding) qualifiedBinding),
1691
							findKeywords(this.completionToken, new char[][]{Keywords.NEW}, false, false);
1674
						scope,
1692
						}
1675
						access,
1693
	
1676
						scope,
1694
						findFieldsAndMethods(
1677
						access.isStatic,
1695
							this.completionToken,
1678
						false,
1696
							((TypeBinding) qualifiedBinding),
1679
						access.receiver instanceof SuperReference,
1697
							scope,
1680
						null,
1698
							access,
1681
						null,
1699
							scope,
1682
						null,
1700
							access.isStatic,
1683
						false);
1701
							false,
1684
					if (qualifiedBinding instanceof FunctionTypeBinding) {
1702
							access.receiver instanceof SuperReference,
1685
						FunctionTypeBinding functionTypeBinding = (FunctionTypeBinding) qualifiedBinding;
1703
							null,
1686
						if (functionTypeBinding.functionBinding!=null && functionTypeBinding.functionBinding.isConstructor())
1704
							null,
1687
						{
1705
							null,
1688
							ReferenceBinding declaringClass = (ReferenceBinding)functionTypeBinding.functionBinding.returnType;
1706
							false);
1689
							findFieldsAndMethods(
1707
						if (qualifiedBinding instanceof FunctionTypeBinding) {
1690
									this.completionToken,
1708
							FunctionTypeBinding functionTypeBinding = (FunctionTypeBinding) qualifiedBinding;
1691
									declaringClass,
1709
							if (functionTypeBinding.functionBinding!=null && functionTypeBinding.functionBinding.isConstructor())
1692
									scope,
1710
							{
1693
									access,
1711
								ReferenceBinding declaringClass = (ReferenceBinding)functionTypeBinding.functionBinding.returnType;
1694
									scope,
1712
								findFieldsAndMethods(
1695
									true,
1713
										this.completionToken,
1696
									false,
1714
										declaringClass,
1697
									access.receiver instanceof SuperReference,
1715
										scope,
1698
									null,
1716
										access,
1699
									null,
1717
										scope,
1700
									null,
1718
										true,
1701
									false);
1719
										false,
1720
										access.receiver instanceof SuperReference,
1721
										null,
1722
										null,
1723
										null,
1724
										false);
1725
								
1726
							}
1702
							
1727
							
1703
						}
1728
						}
1704
						
1705
					}
1729
					}
1706
				}
1730
				}
1707
			}
1731
			}
Lines 5879-5885 Link Here
5879
//					char[] pkg = CharOperation.subarray(sourceType.sourceName, 0, index);
5903
//					char[] pkg = CharOperation.subarray(sourceType.sourceName, 0, index);
5880
					char[] simpleName = CharOperation.subarray(sourceType.sourceName, index+1, sourceType.sourceName.length);
5904
					char[] simpleName = CharOperation.subarray(sourceType.sourceName, index+1, sourceType.sourceName.length);
5881
					
5905
					
5882
					if (!CharOperation.prefixEquals(token, simpleName, false)
5906
					if (!CharOperation.prefixEquals(token, simpleName, false) && !CharOperation.prefixEquals(token, sourceType.sourceName, false)
5883
							&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, simpleName))) continue ;
5907
							&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, simpleName))) continue ;
5884
					
5908
					
5885
				} else if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
5909
				} else if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
Lines 7357-7366 Link Here
7357
	}
7381
	}
7358
7382
7359
	public static char[] createNonGenericTypeSignature(char[] qualifiedPackageName, char[] qualifiedTypeName) {
7383
	public static char[] createNonGenericTypeSignature(char[] qualifiedPackageName, char[] qualifiedTypeName) {
7360
		return Signature.createCharArrayTypeSignature(
7384
		return Signature.createCharArrayTypeSignature(CharOperation.replaceOnCopy(qualifiedTypeName, '.', '$'), true);
7361
				CharOperation.concat(
7362
						qualifiedPackageName,
7363
						CharOperation.replaceOnCopy(qualifiedTypeName, '.', '$'), '.'), true);
7364
	}
7385
	}
7365
	public static char[] createTypeSignature(char[] qualifiedPackageName, char[] qualifiedTypeName) {
7386
	public static char[] createTypeSignature(char[] qualifiedPackageName, char[] qualifiedTypeName) {
7366
		char[] name = new char[qualifiedTypeName.length];
7387
		char[] name = new char[qualifiedTypeName.length];
Lines 7720-7724 Link Here
7720
		
7741
		
7721
		return result;
7742
		return result;
7722
	}
7743
	}
7744
	
7745
	private char[] computeToken(FieldReference field) {
7746
		char[] currentToken = field.token;
7747
		boolean addDot = false;
7748
		if(currentToken != null && currentToken.length == 0)
7749
			addDot = true;
7750
		if(field.receiver != null) {
7751
			if(field.receiver instanceof SingleNameReference) {
7752
				currentToken = CharOperation.concat(((SingleNameReference)field.receiver).token, currentToken, '.');
7753
			} else if(field.receiver instanceof FieldReference) {
7754
				currentToken = CharOperation.concat(computeToken((FieldReference) field.receiver), currentToken, '.');
7755
			}
7756
		}
7757
		if(addDot)
7758
			currentToken = CharOperation.append(currentToken, '.');
7759
		return currentToken;
7760
	}
7723
7761
7724
}
7762
}
(-)src/org/eclipse/wst/jsdt/internal/codeassist/complete/CompletionOnMemberAccess.java (+5 lines)
Lines 32-37 Link Here
32
 * which should be replaced by the completion.
32
 * which should be replaced by the completion.
33
 */
33
 */
34
34
35
import org.eclipse.wst.jsdt.internal.compiler.ast.ASTNode;
35
import org.eclipse.wst.jsdt.internal.compiler.ast.Expression;
36
import org.eclipse.wst.jsdt.internal.compiler.ast.Expression;
36
import org.eclipse.wst.jsdt.internal.compiler.ast.FieldReference;
37
import org.eclipse.wst.jsdt.internal.compiler.ast.FieldReference;
37
import org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend;
38
import org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend;
Lines 100-103 Link Here
100
			throw new CompletionNodeFound(this, this.receiverType, scope);
101
			throw new CompletionNodeFound(this, this.receiverType, scope);
101
		// array types are passed along to find the length field
102
		// array types are passed along to find the length field
102
	}
103
	}
104
	
105
	public TypeBinding resolveForAllocation(BlockScope scope, ASTNode location) {
106
		throw new CompletionNodeFound(this, scope);
107
	}
103
}
108
}
(-)src/org/eclipse/wst/jsdt/internal/core/SearchableEnvironment.java (-1 / +1 lines)
Lines 434-440 Link Here
434
			}
434
			}
435
			int lastDotIndex = CharOperation.lastIndexOf('.', prefix);
435
			int lastDotIndex = CharOperation.lastIndexOf('.', prefix);
436
			char[] qualification, simpleName;
436
			char[] qualification, simpleName;
437
			if (lastDotIndex < 0) {
437
			if (lastDotIndex < 0 || true) {
438
				qualification = null;
438
				qualification = null;
439
				if (camelCaseMatch) {
439
				if (camelCaseMatch) {
440
					simpleName = prefix;
440
					simpleName = prefix;
(-)src/org/eclipse/wst/jsdt/internal/core/index/DiskIndex.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 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 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.121"; //$NON-NLS-1$
55
public static final String SIGNATURE= "INDEX VERSION 1.122"; //$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/indexing/AbstractIndexer.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 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 100-105 Link Here
100
				packageName == null ? CharOperation.NO_CHAR : packageName);
100
				packageName == null ? CharOperation.NO_CHAR : packageName);
101
101
102
		addIndexEntry(TYPE_DECL, indexKey);
102
		addIndexEntry(TYPE_DECL, indexKey);
103
		
104
		indexKey = TypeDeclarationPattern.createIndexKey(modifiers, CharOperation.concat(packageName, name, '.'), packageName, enclosingTypeNames, secondary);
105
		addIndexEntry(TYPE_DECL, indexKey);
103
	}
106
	}
104
	public void addTypeReference(char[] typeName) {
107
	public void addTypeReference(char[] typeName) {
105
		if (typeName!=null)
108
		if (typeName!=null)
(-)src/org/eclipse/wst/jsdt/internal/core/search/matching/TypeDeclarationPattern.java (-3 / +3 lines)
Lines 145-151 Link Here
145
		if (simpleName!=null &&  (index=CharOperation.lastIndexOf('.',simpleName)) >0)
145
		if (simpleName!=null &&  (index=CharOperation.lastIndexOf('.',simpleName)) >0)
146
		{
146
		{
147
			pkg=CharOperation.subarray(simpleName, 0, index);
147
			pkg=CharOperation.subarray(simpleName, 0, index);
148
			simpleName=CharOperation.subarray(simpleName, index+1, simpleName.length);
148
//			simpleName=CharOperation.subarray(simpleName, index+1, simpleName.length);
149
		}
149
		}
150
150
151
	this.pkg = isCaseSensitive() ? pkg : CharOperation.toLowerCase(pkg);
151
	this.pkg = isCaseSensitive() ? pkg : CharOperation.toLowerCase(pkg);
Lines 232-239 Link Here
232
		return false;
232
		return false;
233
233
234
	// check package - exact match only
234
	// check package - exact match only
235
	if (this.pkg != null && !CharOperation.equals(this.pkg, pattern.pkg, isCaseSensitive()))
235
	//if (this.pkg != null && !CharOperation.equals(this.pkg, pattern.pkg, isCaseSensitive()))
236
		return false;
236
		//return false;
237
237
238
	// check enclosingTypeNames - exact match only
238
	// check enclosingTypeNames - exact match only
239
	if (this.enclosingTypeNames != null) {
239
	if (this.enclosingTypeNames != null) {
(-)src/org/eclipse/wst/jsdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java (-6 / +6 lines)
Lines 39-45 Link Here
39
  */
39
  */
40
public class LazyJavaTypeCompletionProposal extends LazyJavaCompletionProposal {
40
public class LazyJavaTypeCompletionProposal extends LazyJavaCompletionProposal {
41
	/** Triggers for types. Do not modify. */
41
	/** Triggers for types. Do not modify. */
42
	protected static final char[] TYPE_TRIGGERS= new char[] { '.', '\t', '[', '(', ' ' };
42
	protected static final char[] TYPE_TRIGGERS= new char[] { '\t', '[', '(', ' ' };
43
	/** Triggers for types in javadoc. Do not modify. */
43
	/** Triggers for types in javadoc. Do not modify. */
44
	protected static final char[] JDOC_TYPE_TRIGGERS= new char[] { '#', '}', ' ', '.' };
44
	protected static final char[] JDOC_TYPE_TRIGGERS= new char[] { '#', '}', ' ', '.' };
45
45
Lines 84-93 Link Here
84
		 if (fProposal.getKind() == CompletionProposal.TYPE_REF &&  fInvocationContext.getCoreContext().isInJsdocText())
84
		 if (fProposal.getKind() == CompletionProposal.TYPE_REF &&  fInvocationContext.getCoreContext().isInJsdocText())
85
			 return getSimpleTypeName();
85
			 return getSimpleTypeName();
86
		
86
		
87
		String qualifiedTypeName= getQualifiedTypeName();
87
		String qualifiedTypeName= replacement;
88
 		if (qualifiedTypeName.indexOf('.') == -1)
88
// 		if (qualifiedTypeName.indexOf('.') == -1)
89
 			// default package - no imports needed 
89
// 			// default package - no imports needed 
90
 			return qualifiedTypeName;
90
// 			return qualifiedTypeName;
91
91
92
 		/*
92
 		/*
93
		 * If the user types in the qualification, don't force import rewriting on him - insert the
93
		 * If the user types in the qualification, don't force import rewriting on him - insert the
Lines 339-345 Link Here
339
	 */
339
	 */
340
	protected String computeSortString() {
340
	protected String computeSortString() {
341
		// try fast sort string to avoid display string creation
341
		// try fast sort string to avoid display string creation
342
		return getSimpleTypeName() + Character.MIN_VALUE + getQualifiedTypeName();
342
		return getQualifiedTypeName();
343
	}
343
	}
344
	
344
	
345
	/*
345
	/*

Return to bug 305694