Index: pkg/analyzer/test/generated/ast_test.dart |
diff --git a/pkg/analyzer/test/generated/ast_test.dart b/pkg/analyzer/test/generated/ast_test.dart |
index 24958de3a3a80bcfb3dc1d2f797e2393fa32e4f3..fd888ccec26c3eb1346c6aa1a73fa612d5f3fc65 100644 |
--- a/pkg/analyzer/test/generated/ast_test.dart |
+++ b/pkg/analyzer/test/generated/ast_test.dart |
@@ -29,6 +29,7 @@ main() { |
runReflectiveTests(IndexExpressionTest); |
runReflectiveTests(NodeListTest); |
runReflectiveTests(NodeLocatorTest); |
+ runReflectiveTests(NodeLocator2Test); |
runReflectiveTests(SimpleIdentifierTest); |
runReflectiveTests(SimpleStringLiteralTest); |
runReflectiveTests(StringInterpolationTest); |
@@ -945,6 +946,35 @@ class NodeListTest extends EngineTestCase { |
} |
@reflectiveTest |
+class NodeLocator2Test extends ParserTestCase { |
+ void test_onlyStartOffset() { |
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit(' int vv;'); |
+ TopLevelVariableDeclaration declaration = unit.declarations[0]; |
+ VariableDeclarationList variableList = declaration.variables; |
+ Identifier typeName = variableList.type.name; |
+ expect(new NodeLocator2(0).searchWithin(unit), same(unit)); |
+ expect(new NodeLocator2(1).searchWithin(unit), same(typeName)); |
+ expect(new NodeLocator2(2).searchWithin(unit), same(typeName)); |
+ expect(new NodeLocator2(3).searchWithin(unit), same(typeName)); |
+ expect(new NodeLocator2(4).searchWithin(unit), same(variableList)); |
+ } |
+ |
+ void test_startEndOffset() { |
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit(' int vv; '); |
+ TopLevelVariableDeclaration declaration = unit.declarations[0]; |
+ VariableDeclarationList variableList = declaration.variables; |
+ Identifier typeName = variableList.type.name; |
+ SimpleIdentifier varName = variableList.variables[0].name; |
+ expect(new NodeLocator2(0, 2).searchWithin(unit), same(unit)); |
+ expect(new NodeLocator2(1, 2).searchWithin(unit), same(typeName)); |
+ expect(new NodeLocator2(1, 3).searchWithin(unit), same(typeName)); |
+ expect(new NodeLocator2(1, 4).searchWithin(unit), same(variableList)); |
+ expect(new NodeLocator2(5, 6).searchWithin(unit), same(varName)); |
+ expect(new NodeLocator2(5, 7).searchWithin(unit), same(declaration)); |
+ } |
+} |
+ |
+@reflectiveTest |
class NodeLocatorTest extends ParserTestCase { |
void test_range() { |
CompilationUnit unit = |