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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/SourceRangeFactory.java

Issue 10825190: Don't infer non-final field types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tests for 'const' Created 8 years, 4 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.ui/src/com/google/dart/tools/internal/corext/SourceRangeFactory.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/SourceRangeFactory.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/SourceRangeFactory.java
index aab950dc0aa731c720a956716f76f5f0075dd8fd..4ecbb969fda9b96658a4cecc347f8423e18880a6 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/SourceRangeFactory.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/SourceRangeFactory.java
@@ -15,6 +15,7 @@ package com.google.dart.tools.internal.corext;
import com.google.dart.compiler.DartCompilationError;
import com.google.dart.compiler.common.HasSourceInfo;
+import com.google.dart.engine.scanner.Token;
import com.google.dart.tools.core.internal.model.SourceRangeImpl;
import com.google.dart.tools.core.model.SourceRange;
@@ -104,6 +105,10 @@ public class SourceRangeFactory {
return forStartEnd(start, end);
}
+ public static SourceRange forToken(Token token) {
+ return forStartLength(token.getOffset(), token.getLength());
+ }
+
/**
* @return the {@link SourceRange} of "a" with offset from given "base".
*/
@@ -113,4 +118,20 @@ public class SourceRangeFactory {
return forStartLength(start, length);
}
+ /**
+ * Given {@link SourceRange} created relative to "base", return absolute {@link SourceRange}.
+ */
+ public static SourceRange withBase(HasSourceInfo base, SourceRange r) {
+ return withBase(base.getSourceInfo().getOffset(), r);
+ }
+
+ /**
+ * Given {@link SourceRange} created relative to "base", return absolute {@link SourceRange}.
+ */
+ public static SourceRange withBase(int base, SourceRange r) {
+ int start = base + r.getOffset();
+ int length = r.getLength();
+ return forStartLength(start, length);
+ }
+
}

Powered by Google App Engine
This is Rietveld 408576698