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

Unified Diff: compiler/java/com/google/dart/compiler/common/AbstractNode.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/common/AbstractNode.java
diff --git a/compiler/java/com/google/dart/compiler/common/AbstractNode.java b/compiler/java/com/google/dart/compiler/common/AbstractNode.java
index b423232774740c04c709da55b5964014da05c913..16d1c8b6da5f4f05b4609b817c06d93cb9ea7c14 100644
--- a/compiler/java/com/google/dart/compiler/common/AbstractNode.java
+++ b/compiler/java/com/google/dart/compiler/common/AbstractNode.java
@@ -4,79 +4,20 @@
package com.google.dart.compiler.common;
-import com.google.common.base.Preconditions;
-import com.google.dart.compiler.Source;
-
/**
* Abstract base class for nodes that carry source information.
*/
-public class AbstractNode implements SourceInfo, HasSourceInfo {
-
- // TODO(johnlenz): All this source location data is wasteful.
- // Move it into a common object, that can be shared between the ASTs
- // or something.
- protected Source source = null;
- protected int sourceLine = -1;
- protected int sourceColumn = -1;
- protected int sourceStart = -1;
- protected int sourceLength = -1;
-
- @Override
- public Source getSource() {
- return source;
- }
-
- @Override
- public int getSourceLine() {
- return sourceLine;
- }
-
- @Override
- public int getSourceColumn() {
- return sourceColumn;
- }
+public class AbstractNode implements HasSourceInfo {
- @Override
- public int getSourceStart() {
- return sourceStart;
- }
-
- @Override
- public int getSourceLength() {
- return sourceLength;
- }
+ private SourceInfo sourceInfo = SourceInfo.UNKNOWN;
@Override
public SourceInfo getSourceInfo() {
- return this;
+ return sourceInfo;
}
@Override
public void setSourceInfo(SourceInfo info) {
- source = info.getSource();
- sourceStart = info.getSourceStart();
- sourceLength = info.getSourceLength();
- sourceLine = info.getSourceLine();
- sourceColumn = info.getSourceColumn();
+ sourceInfo = info;
}
-
- @Override
- public final void setSourceLocation(
- Source source, int line, int column, int startPosition, int length) {
- Preconditions.checkArgument(startPosition != -1 && length >= 0
- || startPosition == -1 && length == 0);
- this.source = source;
- this.sourceLine = line;
- this.sourceColumn = column;
- this.sourceStart = startPosition;
- this.sourceLength = length;
- }
-
- public final void setSourceRange(int startPosition, int length) {
- Preconditions.checkArgument(startPosition != -1 && length >= 0
- || startPosition == -1 && length == 0);
- this.sourceStart = startPosition;
- this.sourceLength = length;
- }
-
}

Powered by Google App Engine
This is Rietveld 408576698