| 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);
|
| }
|
|
|