Lines 1817-1822
Link Here
|
1817 |
* reports a reference to this token to the search requestor. |
1817 |
* reports a reference to this token to the search requestor. |
1818 |
* A token is valid if it has an accuracy which is not -1. |
1818 |
* A token is valid if it has an accuracy which is not -1. |
1819 |
*/ |
1819 |
*/ |
|
|
1820 |
protected void reportAccurateEnumConstructorReference(SearchMatch match, FieldDeclaration field, AllocationExpression allocation) throws CoreException { |
1821 |
// Verify that field declaration is really an enum constant |
1822 |
if (allocation == null || allocation.enumConstant == null) { |
1823 |
report(match); |
1824 |
return; |
1825 |
} |
1826 |
|
1827 |
// Get scan area |
1828 |
int sourceStart = match.getOffset()+match.getLength(); |
1829 |
if (allocation.arguments != null && allocation.arguments.length > 0) { |
1830 |
sourceStart = allocation.arguments[allocation.arguments.length-1].sourceEnd+1; |
1831 |
} |
1832 |
int sourceEnd = field.declarationSourceEnd; |
1833 |
if (allocation instanceof QualifiedAllocationExpression) { |
1834 |
QualifiedAllocationExpression qualifiedAllocation = (QualifiedAllocationExpression) allocation; |
1835 |
if (qualifiedAllocation.anonymousType != null) { |
1836 |
sourceEnd = qualifiedAllocation.anonymousType.sourceStart - 1; |
1837 |
} |
1838 |
} |
1839 |
|
1840 |
// Scan to find last closing parenthesis |
1841 |
Scanner scanner = this.parser.scanner; |
1842 |
scanner.setSource(this.currentPossibleMatch.getContents()); |
1843 |
scanner.resetTo(sourceStart, sourceEnd); |
1844 |
try { |
1845 |
int token = scanner.getNextToken(); |
1846 |
while (token != TerminalTokens.TokenNameEOF) { |
1847 |
if (token == TerminalTokens.TokenNameRPAREN) { |
1848 |
sourceEnd = scanner.getCurrentTokenEndPosition(); |
1849 |
} |
1850 |
token = scanner.getNextToken(); |
1851 |
} |
1852 |
} |
1853 |
catch (InvalidInputException iie) { |
1854 |
// give up |
1855 |
} |
1856 |
|
1857 |
// Report match |
1858 |
match.setLength(sourceEnd-match.getOffset()+1); |
1859 |
report(match); |
1860 |
} |
1861 |
/** |
1862 |
* Finds the accurate positions of each valid token in the source and |
1863 |
* reports a reference to this token to the search requestor. |
1864 |
* A token is valid if it has an accuracy which is not -1. |
1865 |
*/ |
1820 |
protected void reportAccurateFieldReference(SearchMatch[] matches, QualifiedNameReference qNameRef) throws CoreException { |
1866 |
protected void reportAccurateFieldReference(SearchMatch[] matches, QualifiedNameReference qNameRef) throws CoreException { |
1821 |
if (matches == null) return; // there's nothing to accurate in this case |
1867 |
if (matches == null) return; // there's nothing to accurate in this case |
1822 |
int matchesLength = matches.length; |
1868 |
int matchesLength = matches.length; |
Lines 2158-2164
Link Here
|
2158 |
if (encloses(enclosingElement)) { |
2204 |
if (encloses(enclosingElement)) { |
2159 |
int offset = field.sourceStart; |
2205 |
int offset = field.sourceStart; |
2160 |
SearchMatch match = newDeclarationMatch(enclosingElement, field.binding, accuracy, offset, field.sourceEnd-offset+1); |
2206 |
SearchMatch match = newDeclarationMatch(enclosingElement, field.binding, accuracy, offset, field.sourceEnd-offset+1); |
2161 |
report(match); |
2207 |
if (field.initialization instanceof AllocationExpression) { |
|
|
2208 |
reportAccurateEnumConstructorReference(match, field, (AllocationExpression) field.initialization); |
2209 |
} else { |
2210 |
report(match); |
2211 |
} |
2162 |
} |
2212 |
} |
2163 |
} |
2213 |
} |
2164 |
|
2214 |
|