Summary: | Finding references to variables does not find all occurances | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Michael Erdmann <michael_erdmann> |
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | major | ||
Priority: | P2 | CC: | akiezun, michael_erdmann |
Version: | 2.0 | ||
Target Milestone: | 2.0 F4 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Michael Erdmann
2002-06-19 18:21:07 EDT
this breaks RenameField refactoring Thanks for the test case. It is indeed a problem with the match locator that doesn't expect a field reference that contains brackets. Fix would consist in finding the first identifier in the field reference. Proposed fix (in MatchLocator): /** * Finds the accurate positions of the sequence of tokens given by qualifiedName * in the source and reports a reference to this this qualified name * to the search requestor. */ public void reportAccurateReference( int sourceStart, int sourceEnd, char[][] qualifiedName, IJavaElement element, int accuracy) throws CoreException { if (accuracy == -1) return; // compute source positions of the qualified reference Scanner scanner = parser.scanner; scanner.setSource( this.currentMatchingOpenable.getSource()); scanner.resetTo(sourceStart, sourceEnd); int refSourceStart = -1, refSourceEnd = -1; int tokenNumber = qualifiedName.length; int token = -1; int previousValid = -1; int i = 0; int currentPosition; do { // find first token that is an identifier (parenthesized expressions include parenthesises in source range - see bug 20693 - Finding references to variables does not find all occurrences ) do { currentPosition = scanner.currentPosition; try { token = scanner.getNextToken(); } catch (InvalidInputException e) { } } while (token != ITerminalSymbols.TokenNameIdentifier && token != ITerminalSymbols.TokenNameEOF); if (token != ITerminalSymbols.TokenNameEOF) { char[] currentTokenSource = scanner.getCurrentTokenSource(); boolean equals = false; while (i < tokenNumber && !(equals = this.pattern.matchesName (qualifiedName[i++], currentTokenSource))) { } if (equals && (previousValid == -1 || previousValid == i - 2)) { previousValid = i - 1; if (refSourceStart == -1) { refSourceStart = currentPosition; } refSourceEnd = scanner.currentPosition - 1; } else { i = 0; refSourceStart = -1; previousValid = -1; } // read '.' try { token = scanner.getNextToken(); } catch (InvalidInputException e) { } } if (i == tokenNumber) { // accept reference if (refSourceStart != -1) { this.report(refSourceStart, refSourceEnd, element, accuracy); } else { this.report(sourceStart, sourceEnd, element, accuracy); } return; } } while (token != ITerminalSymbols.TokenNameEOF); } Fix is quite simple. Would candidate since it affects search based tools like refactoring. From Adam, regarding to refactoring test suites: our tests run smoothly i activated the prevously disabled tests for 20693 Finding references to variables does not find all occurances 20520 Refactor - expression detection incorrect Fix got approved, releasing into 20020621 Verified. |