Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java

Issue 10986095: Additional fixes for cascades (issue 5146) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java (revision 13022)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java (working copy)
@@ -51,13 +51,13 @@
import org.eclipse.jface.text.Region;
/**
- * Instances of the class <code>DartElementLocator</code> locate the {@link DartElement Dart
- * element(s)} associated with a source range, given the AST structure built from the source.
+ * Instances of the class <code>DartElementLocator</code> locate the {@link DartElement Dart element(s)} associated
+ * with a source range, given the AST structure built from the source.
*/
public class DartElementLocator extends ASTVisitor<Void> {
/**
- * Instances of the class <code>DartElementFoundException</code> are used to cancel visiting after
- * an element has been found.
+ * Instances of the class <code>DartElementFoundException</code> are used to cancel visiting after an element has been
+ * found.
*/
private class DartElementFoundException extends RuntimeException {
private static final long serialVersionUID = 1L;
@@ -97,8 +97,8 @@
private IRegion wordRegion;
/**
- * The region within the element's compilation unit that needs to be highlighted, or
- * <code>null</code> if there is no element.
+ * The region within the element's compilation unit that needs to be highlighted, or <code>null</code>
+ * if there is no element.
*/
private IRegion candidateRegion;
@@ -136,8 +136,8 @@
*
* @param input the compilation unit containing the element to be found
* @param offset the offset used to identify the element
- * @param includeDeclarations <code>true</code> if elements should be returned for declaration
- * sites as well as for reference sites
+ * @param includeDeclarations <code>true</code> if elements should be returned for declaration sites
+ * as well as for reference sites
*/
public DartElementLocator(CompilationUnit input, int offset, boolean includeDeclarations) {
this(input, offset, offset, includeDeclarations);
@@ -164,10 +164,11 @@
* @param input the compilation unit containing the element to be found
* @param start the start offset of the range used to identify the element
* @param end the end offset of the range used to identify the element
- * @param includeDeclarations <code>true</code> if elements should be returned for declaration
- * sites as well as for reference sites
+ * @param includeDeclarations <code>true</code> if elements should be returned for declaration sites
+ * as well as for reference sites
*/
- public DartElementLocator(CompilationUnit input, int start, int end, boolean includeDeclarations) {
+ public DartElementLocator(
+ CompilationUnit input, int start, int end, boolean includeDeclarations) {
this.compilationUnit = input;
this.startOffset = start;
this.endOffset = end;
@@ -175,8 +176,7 @@
}
/**
- * Return the region within the element's compilation unit that needs to be highlighted, or
- * <code>null
+ * Return the region within the element's compilation unit that needs to be highlighted, or <code>null
* </code> if either there is no element or if the element can be used to determine the region.
*
* @return the region within the element's compilation unit that needs to be highlighted
@@ -186,8 +186,8 @@
}
/**
- * Return the element that was found that corresponds to the given source range, or
- * <code>null</code> if there is no such element.
+ * Return the element that was found that corresponds to the given source range, or <code>null</code>
+ * if there is no such element.
*
* @return the element that was found
*/
@@ -196,7 +196,7 @@
}
/**
- * Return the resolved element that was found that corresponds to the given source range, or
+ * Return the resolved element that was found that corresponds to the given source range, or
* <code>null</code> if there is no such element.
*
* @return the element that was found
@@ -218,8 +218,8 @@
/**
* Search within the given AST node for an identifier representing a {@link DartElement Dart
- * element} in the specified source range. Return the element that was found, or <code>null</code>
- * if no element was found.
+ * element} in the specified source range. Return the element that was found, or <code>null</code> if
+ * no element was found.
*
* @param node the AST node within which to search
* @return the element that was found
@@ -230,8 +230,10 @@
} catch (DartElementFoundException exception) {
// A node with the right source position was found.
} catch (Exception exception) {
- DartCore.logInformation("Unable to locate element at offset (" + startOffset + " - "
- + endOffset + ") in " + compilationUnit.getElementName(), exception);
+ DartCore.logInformation(
+ "Unable to locate element at offset (" + startOffset + " - " + endOffset + ") in "
+ + compilationUnit.getElementName(),
+ exception);
return null;
}
return foundElement;
@@ -244,9 +246,10 @@
int start = node.getSourceInfo().getOffset();
int end = start + node.getSourceInfo().getLength();
if (start <= startOffset && endOffset <= end) {
- DartExpression target = node.getTarget();
- wordRegion = new Region(target.getSourceInfo().getOffset()
- + target.getSourceInfo().getLength(), end);
+ DartExpression target = node.getRealTarget();
+ wordRegion = new Region(
+ target.getSourceInfo().getOffset() + target.getSourceInfo().getLength(),
+ end);
Element targetElement = node.getElement();
findElementFor(targetElement);
throw new DartElementFoundException();
@@ -264,8 +267,9 @@
if (start <= startOffset && endOffset <= end) {
DartExpression leftOperand = node.getArg1();
DartExpression rightOperand = node.getArg2();
- wordRegion = computeOperatorRegion(leftOperand.getSourceInfo().getOffset()
- + leftOperand.getSourceInfo().getLength(), rightOperand.getSourceInfo().getOffset() - 1);
+ wordRegion = computeOperatorRegion(
+ leftOperand.getSourceInfo().getOffset() + leftOperand.getSourceInfo().getLength(),
+ rightOperand.getSourceInfo().getOffset() - 1);
Element targetElement = node.getElement();
findElementFor(targetElement);
throw new DartElementFoundException();
@@ -325,8 +329,9 @@
try {
DartImport[] imports = compilationUnit.getLibrary().getImports();
for (DartImport imprt : imports) {
- if (Objects.equal(imprt.getLibrary(), foundElement)
- && Objects.equal(imprt.getPrefix(), node.getName())) {
+ if (Objects.equal(imprt.getLibrary(), foundElement) && Objects.equal(
+ imprt.getPrefix(),
+ node.getName())) {
foundElement = imprt;
SourceRange range = imprt.getNameRange();
candidateRegion = new Region(range.getOffset(), range.getLength());
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/index/contributor/IndexContributor.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698