|
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 7720-7724
Link Here
|
| 7720 |
|
7744 |
|
| 7721 |
return result; |
7745 |
return result; |
| 7722 |
} |
7746 |
} |
|
|
7747 |
|
| 7748 |
private char[] computeToken(FieldReference field) { |
| 7749 |
char[] currentToken = field.token; |
| 7750 |
boolean addDot = false; |
| 7751 |
if(currentToken != null && currentToken.length == 0) |
| 7752 |
addDot = true; |
| 7753 |
if(field.receiver != null) { |
| 7754 |
if(field.receiver instanceof SingleNameReference) { |
| 7755 |
currentToken = CharOperation.concat(((SingleNameReference)field.receiver).token, currentToken, '.'); |
| 7756 |
} else if(field.receiver instanceof FieldReference) { |
| 7757 |
currentToken = CharOperation.concat(computeToken((FieldReference) field.receiver), currentToken, '.'); |
| 7758 |
} |
| 7759 |
} |
| 7760 |
if(addDot) |
| 7761 |
currentToken = CharOperation.append(currentToken, '.'); |
| 7762 |
return currentToken; |
| 7763 |
} |
| 7723 |
|
7764 |
|
| 7724 |
} |
7765 |
} |