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

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

Issue 10828169: 'Split && condition' quick assist. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 4ecbb969fda9b96658a4cecc347f8423e18880a6..a2271beae79800316c974c8387636d3ef738782f 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
@@ -19,6 +19,8 @@ import com.google.dart.engine.scanner.Token;
import com.google.dart.tools.core.internal.model.SourceRangeImpl;
import com.google.dart.tools.core.model.SourceRange;
+import java.util.List;
+
public class SourceRangeFactory {
public static SourceRange create(DartCompilationError error) {
@@ -30,6 +32,19 @@ public class SourceRangeFactory {
}
/**
+ * @return the {@link SourceRange} which starts at the start of first "first" and ends at the end
+ * of "last" element.
+ */
+ public static SourceRange create(List<? extends HasSourceInfo> elements) {
+ if (elements.isEmpty()) {
+ return forStartLength(0, 0);
+ }
+ HasSourceInfo first = elements.get(0);
+ HasSourceInfo last = elements.get(elements.size() - 1);
+ return forStartEnd(first, last);
+ }
+
+ /**
* @return the {@link SourceRange} which start at end of "a" and ends at end of "b".
*/
public static SourceRange forEndEnd(HasSourceInfo a, HasSourceInfo b) {
@@ -72,6 +87,14 @@ public class SourceRangeFactory {
return forStartEnd(start, end);
}
+ /**
+ * @return the {@link SourceRange} which start at "start" and ends at end of "b".
+ */
+ public static SourceRange forStartEnd(int start, HasSourceInfo b) {
+ int end = b.getSourceInfo().getEnd();
+ return new SourceRangeImpl(start, end - start);
+ }
+
public static SourceRange forStartEnd(int start, int end) {
return new SourceRangeImpl(start, end - start);
}

Powered by Google App Engine
This is Rietveld 408576698