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

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

Issue 9651004: Make SourceInfo a class, rename its menthods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak for formatting, lazily create LainesInfo Created 8 years, 9 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
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java
index fe135242ccf86a27293f5d2e742337cad7ea3ae3..5af587e6bca06bd5819f862c8040ecdefc0e8d43 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java
@@ -246,11 +246,12 @@ public class DartElementLocator extends ASTVisitor<Void> {
public Void visitArrayAccess(DartArrayAccess node) {
super.visitArrayAccess(node);
if (foundElement == null) {
- int start = node.getSourceStart();
- int end = start + node.getSourceLength();
+ int start = node.getSourceInfo().getOffset();
+ int end = start + node.getSourceInfo().getLength();
if (start <= startOffset && endOffset <= end) {
DartExpression target = node.getTarget();
- wordRegion = new Region(target.getSourceStart() + target.getSourceLength(), end);
+ wordRegion = new Region(target.getSourceInfo().getOffset()
+ + target.getSourceInfo().getLength(), end);
Element targetElement = node.getElement();
findElementFor(targetElement);
throw new DartElementFoundException();
@@ -263,14 +264,14 @@ public class DartElementLocator extends ASTVisitor<Void> {
public Void visitBinaryExpression(DartBinaryExpression node) {
super.visitBinaryExpression(node);
if (foundElement == null) {
- int start = node.getSourceStart();
- int end = start + node.getSourceLength();
+ int start = node.getSourceInfo().getOffset();
+ int end = start + node.getSourceInfo().getLength();
if (start <= startOffset && endOffset <= end) {
DartExpression leftOperand = node.getArg1();
DartExpression rightOperand = node.getArg2();
- wordRegion = computeOperatorRegion(
- leftOperand.getSourceStart() + leftOperand.getSourceLength(),
- rightOperand.getSourceStart() - 1);
+ wordRegion = computeOperatorRegion(leftOperand.getSourceInfo().getOffset()
+ + leftOperand.getSourceInfo().getLength(),
+ rightOperand.getSourceInfo().getOffset() - 1);
Element targetElement = node.getElement();
findElementFor(targetElement);
throw new DartElementFoundException();
@@ -282,8 +283,8 @@ public class DartElementLocator extends ASTVisitor<Void> {
@Override
public Void visitIdentifier(DartIdentifier node) {
if (foundElement == null) {
- int start = node.getSourceStart();
- int length = node.getSourceLength();
+ int start = node.getSourceInfo().getOffset();
+ int length = node.getSourceInfo().getLength();
int end = start + length;
if (start <= startOffset && endOffset <= end) {
wordRegion = new Region(start, length);
@@ -378,8 +379,8 @@ public class DartElementLocator extends ASTVisitor<Void> {
DartExpression parameterName = parameter.getName();
foundElement = BindingUtils.getDartElement(compilationUnit.getLibrary(),
containingType.getElement());
- candidateRegion = new Region(parameterName.getSourceStart(),
- parameterName.getSourceLength());
+ candidateRegion = new Region(parameterName.getSourceInfo().getOffset(),
+ parameterName.getSourceInfo().getLength());
} else {
foundElement = null;
}
@@ -387,8 +388,8 @@ public class DartElementLocator extends ASTVisitor<Void> {
foundElement = BindingUtils.getDartElement(compilationUnit.getLibrary(),
method.getElement());
DartExpression parameterName = parameter.getName();
- candidateRegion = new Region(parameterName.getSourceStart(),
- parameterName.getSourceLength());
+ candidateRegion = new Region(parameterName.getSourceInfo().getOffset(),
+ parameterName.getSourceInfo().getLength());
}
} else if (variableNode instanceof DartVariable) {
DartVariable variable = (DartVariable) variableNode;
@@ -398,8 +399,8 @@ public class DartElementLocator extends ASTVisitor<Void> {
DartIdentifier variableName = variable.getName();
foundElement = BindingUtils.getDartElement(compilationUnit.getLibrary(),
containingType.getElement());
- candidateRegion = new Region(variableName.getSourceStart(),
- variableName.getSourceLength());
+ candidateRegion = new Region(variableName.getSourceInfo().getOffset(),
+ variableName.getSourceInfo().getLength());
} else {
foundElement = null;
}
@@ -434,15 +435,15 @@ public class DartElementLocator extends ASTVisitor<Void> {
@Override
public Void visitStringLiteral(DartStringLiteral node) {
if (foundElement == null) {
- int start = node.getSourceStart();
- int length = node.getSourceLength();
+ int start = node.getSourceInfo().getOffset();
+ int length = node.getSourceInfo().getLength();
int end = start + length;
if (start <= startOffset && end >= endOffset) {
wordRegion = computeInternalStringRegion(start, length);
DartNode parent = node.getParent();
if (parent instanceof DartImportDirective
&& ((DartImportDirective) parent).getLibraryUri() == node) {
- resolvedElement = (Element) ((DartImportDirective) parent).getElement();
+ resolvedElement = ((DartImportDirective) parent).getElement();
DartLibrary library = compilationUnit.getLibrary();
String libraryName = node.getValue();
if (libraryName.startsWith("dart:")) {
@@ -475,7 +476,7 @@ public class DartElementLocator extends ASTVisitor<Void> {
}
} else if (parent instanceof DartSourceDirective
&& ((DartSourceDirective) parent).getSourceUri() == node) {
- resolvedElement = (Element) ((DartSourceDirective) parent).getElement();
+ resolvedElement = ((DartSourceDirective) parent).getElement();
DartLibrary library = compilationUnit.getLibrary();
String fileName = getFileName(library, node.getValue());
CompilationUnit sourcedUnit = library.getCompilationUnit(fileName);
@@ -484,7 +485,7 @@ public class DartElementLocator extends ASTVisitor<Void> {
}
} else if (parent instanceof DartResourceDirective
&& ((DartResourceDirective) parent).getResourceUri() == node) {
- resolvedElement = (Element) ((DartResourceDirective) parent).getElement();
+ resolvedElement = ((DartResourceDirective) parent).getElement();
DartLibrary library = compilationUnit.getLibrary();
try {
DartSource unitSource = compilationUnit.getSourceRef();
@@ -515,11 +516,11 @@ public class DartElementLocator extends ASTVisitor<Void> {
public Void visitUnaryExpression(DartUnaryExpression node) {
super.visitUnaryExpression(node);
if (foundElement == null) {
- int start = node.getSourceStart();
- int end = start + node.getSourceLength();
+ int start = node.getSourceInfo().getOffset();
+ int end = start + node.getSourceInfo().getLength();
if (start <= startOffset && endOffset <= end) {
DartExpression operand = node.getArg();
- wordRegion = computeOperatorRegion(start, operand.getSourceStart() - 1);
+ wordRegion = computeOperatorRegion(start, operand.getSourceInfo().getOffset() - 1);
Element targetSymbol = node.getElement();
findElementFor(targetSymbol);
throw new DartElementFoundException();

Powered by Google App Engine
This is Rietveld 408576698