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

Unified Diff: compiler/java/com/google/dart/compiler/parser/CommentPreservingParser.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: compiler/java/com/google/dart/compiler/parser/CommentPreservingParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/CommentPreservingParser.java b/compiler/java/com/google/dart/compiler/parser/CommentPreservingParser.java
index 6b0ad6ac2c84a036c65c332b175be8663bc43cb4..8754a2755cd9b05ae1bc0ec476d1c307ea101669 100644
--- a/compiler/java/com/google/dart/compiler/parser/CommentPreservingParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/CommentPreservingParser.java
@@ -12,6 +12,7 @@ import com.google.dart.compiler.ast.DartDeclaration;
import com.google.dart.compiler.ast.DartNode;
import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartUnit;
+import com.google.dart.compiler.common.SourceInfo;
import com.google.dart.compiler.metrics.CompilerMetrics;
import com.google.dart.compiler.util.DartSourceString;
@@ -167,7 +168,7 @@ public class CommentPreservingParser extends DartParser {
Collections.sort(nodes, new Comparator<DartNode>() {
@Override
public int compare(DartNode node1, DartNode node2) {
- return node1.getSourceStart() - node2.getSourceStart();
+ return node1.getSourceInfo().getOffset() - node2.getSourceInfo().getOffset();
}
});
@@ -219,11 +220,13 @@ public class CommentPreservingParser extends DartParser {
return children;
}
- private boolean isContainedBy(DartNode node, DartNode containedByNode) {
- int nodeEnd = node.getSourceStart() + node.getSourceLength();
- int containedByEnd = containedByNode.getSourceStart() + containedByNode.getSourceLength();
-
- return node.getSourceStart() >= containedByNode.getSourceStart() && nodeEnd <= containedByEnd;
+ private static boolean isContainedBy(DartNode node, DartNode containedByNode) {
+ SourceInfo nodeSource = node.getSourceInfo();
+ SourceInfo containedBySource = containedByNode.getSourceInfo();
+ int nodeEnd = nodeSource.getOffset() + nodeSource.getLength();
+ int containedByEnd = containedBySource.getOffset() + containedBySource.getLength();
+ return nodeSource.getOffset() >= containedBySource.getOffset()
+ && nodeEnd <= containedByEnd;
}
/**

Powered by Google App Engine
This is Rietveld 408576698