| Index: pkg/analyzer/test/generated/parser_test.dart
|
| diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
|
| index 596fb0e1cd48599a05e78fe4189777bdbfb9b334..38d3464b32a06a32fb6f287e192eb079f10a5260 100644
|
| --- a/pkg/analyzer/test/generated/parser_test.dart
|
| +++ b/pkg/analyzer/test/generated/parser_test.dart
|
| @@ -8,14 +8,10 @@ import 'package:analyzer/dart/ast/ast.dart';
|
| import 'package:analyzer/dart/ast/token.dart';
|
| import 'package:analyzer/dart/ast/visitor.dart';
|
| import 'package:analyzer/src/dart/ast/token.dart';
|
| -import 'package:analyzer/src/dart/ast/utilities.dart';
|
| import 'package:analyzer/src/dart/scanner/reader.dart';
|
| import 'package:analyzer/src/dart/scanner/scanner.dart';
|
| -import 'package:analyzer/src/generated/engine.dart';
|
| import 'package:analyzer/src/generated/error.dart';
|
| -import 'package:analyzer/src/generated/incremental_scanner.dart';
|
| import 'package:analyzer/src/generated/parser.dart';
|
| -import 'package:analyzer/src/generated/source.dart' show Source;
|
| import 'package:analyzer/src/generated/testing/ast_factory.dart';
|
| import 'package:analyzer/src/generated/testing/token_factory.dart';
|
| import 'package:analyzer/src/generated/utilities_dart.dart';
|
| @@ -29,8 +25,6 @@ main() {
|
| initializeTestEnvironment();
|
| defineReflectiveTests(ComplexParserTest);
|
| defineReflectiveTests(ErrorParserTest);
|
| - // ignore: deprecated_member_use
|
| - defineReflectiveTests(IncrementalParserTest);
|
| defineReflectiveTests(NonErrorParserTest);
|
| defineReflectiveTests(RecoveryParserTest);
|
| defineReflectiveTests(SimpleParserTest);
|
| @@ -2367,383 +2361,6 @@ void main() {
|
| }
|
| }
|
|
|
| -@deprecated
|
| -@reflectiveTest
|
| -class IncrementalParserTest extends EngineTestCase {
|
| - void fail_replace_identifier_with_functionLiteral_in_initializer_interp() {
|
| - // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs
|
| -
|
| - // Function literals are allowed inside interpolation expressions in
|
| - // initializers.
|
| - //
|
| - // 'class A { var a; A(b) : a = "${b}";'
|
| - // 'class A { var a; A(b) : a = "${() {}}";'
|
| - _assertParse(r'class A { var a; A(b) : a = "${', 'b', '() {}', '}";');
|
| - }
|
| -
|
| - void test_delete_everything() {
|
| - // "f() => a + b;"
|
| - // ""
|
| - _assertParse("", "f() => a + b;", "", "");
|
| - }
|
| -
|
| - void test_delete_identifier_beginning() {
|
| - // "f() => abs + b;"
|
| - // "f() => s + b;"
|
| - _assertParse("f() => ", "ab", "", "s + b;");
|
| - }
|
| -
|
| - void test_delete_identifier_end() {
|
| - // "f() => abs + b;"
|
| - // "f() => a + b;"
|
| - _assertParse("f() => a", "bs", "", " + b;");
|
| - }
|
| -
|
| - void test_delete_identifier_middle() {
|
| - // "f() => abs + b;"
|
| - // "f() => as + b;"
|
| - _assertParse("f() => a", "b", "", "s + b;");
|
| - }
|
| -
|
| - void test_delete_mergeTokens() {
|
| - // "f() => a + b + c;"
|
| - // "f() => ac;"
|
| - _assertParse("f() => a", " + b + ", "", "c;");
|
| - }
|
| -
|
| - void test_insert_afterIdentifier1() {
|
| - // "f() => a + b;"
|
| - // "f() => abs + b;"
|
| - _assertParse("f() => a", "", "bs", " + b;");
|
| - }
|
| -
|
| - void test_insert_afterIdentifier2() {
|
| - // "f() => a + b;"
|
| - // "f() => a + bar;"
|
| - _assertParse("f() => a + b", "", "ar", ";");
|
| - }
|
| -
|
| - void test_insert_beforeIdentifier1() {
|
| - // "f() => a + b;"
|
| - // "f() => xa + b;"
|
| - _assertParse("f() => ", "", "x", "a + b;");
|
| - }
|
| -
|
| - void test_insert_beforeIdentifier2() {
|
| - // "f() => a + b;"
|
| - // "f() => a + xb;"
|
| - _assertParse("f() => a + ", "", "x", "b;");
|
| - }
|
| -
|
| - void test_insert_convertOneFunctionToTwo() {
|
| - // "f() {}"
|
| - // "f() => 0; g() {}"
|
| - _assertParse("f()", "", " => 0; g()", " {}");
|
| - }
|
| -
|
| - void test_insert_end() {
|
| - // "class A {}"
|
| - // "class A {} class B {}"
|
| - _assertParse("class A {}", "", " class B {}", "");
|
| - }
|
| -
|
| - void test_insert_final_before_field_declaration() {
|
| - _assertParse('class C { ', '', 'final ', 'int x; }');
|
| - }
|
| -
|
| - void test_insert_function_parameter() {
|
| - _assertParse('class C { void f(', '', 'arg', ') {} }');
|
| - }
|
| -
|
| - void test_insert_identifier_inCombinator() {
|
| - _assertParse("import 'foo.dart' show x", "", ", y", ";");
|
| - }
|
| -
|
| - void test_insert_insideClassBody() {
|
| - // "class C {C(); }"
|
| - // "class C { C(); }"
|
| - _assertParse("class C {", "", " ", "C(); }");
|
| - }
|
| -
|
| - void test_insert_insideIdentifier() {
|
| - // "f() => cob;"
|
| - // "f() => cow.b;"
|
| - _assertParse("f() => co", "", "w.", "b;");
|
| - }
|
| -
|
| - void test_insert_newIdentifier1() {
|
| - // "f() => a; c;"
|
| - // "f() => a; b c;"
|
| - _assertParse("f() => a;", "", " b", " c;");
|
| - }
|
| -
|
| - void test_insert_newIdentifier2() {
|
| - // "f() => a; c;"
|
| - // "f() => a;b c;"
|
| - _assertParse("f() => a;", "", "b", " c;");
|
| - }
|
| -
|
| - void test_insert_newIdentifier3() {
|
| - // "/** A simple function. */ f() => a; c;"
|
| - // "/** A simple function. */ f() => a; b c;"
|
| - _assertParse("/** A simple function. */ f() => a;", "", " b", " c;");
|
| - }
|
| -
|
| - void test_insert_newIdentifier4() {
|
| - // "/** An [A]. */ class A {} class B { m() { return 1; } }"
|
| - // "/** An [A]. */ class A {} class B { m() { return 1 + 2; } }"
|
| - _assertParse("/** An [A]. */ class A {} class B { m() { return 1", "",
|
| - " + 2", "; } }");
|
| - }
|
| -
|
| - void test_insert_period() {
|
| - // "f() => a + b;"
|
| - // "f() => a + b.;"
|
| - _assertParse("f() => a + b", "", ".", ";");
|
| - }
|
| -
|
| - void test_insert_period_betweenIdentifiers1() {
|
| - // "f() => a b;"
|
| - // "f() => a. b;"
|
| - _assertParse("f() => a", "", ".", " b;");
|
| - }
|
| -
|
| - void test_insert_period_betweenIdentifiers2() {
|
| - // "f() => a b;"
|
| - // "f() => a .b;"
|
| - _assertParse("f() => a ", "", ".", "b;");
|
| - }
|
| -
|
| - void test_insert_period_betweenIdentifiers3() {
|
| - // "f() => a b;"
|
| - // "f() => a . b;"
|
| - _assertParse("f() => a ", "", ".", " b;");
|
| - }
|
| -
|
| - void test_insert_period_insideExistingIdentifier() {
|
| - // "f() => ab;"
|
| - // "f() => a.b;"
|
| - _assertParse("f() => a", "", ".", "b;");
|
| - }
|
| -
|
| - void test_insert_periodAndIdentifier() {
|
| - // "f() => a + b;"
|
| - // "f() => a + b.x;"
|
| - _assertParse("f() => a + b", "", ".x", ";");
|
| - }
|
| -
|
| - void test_insert_simpleToComplexExression() {
|
| - // "/** An [A]. */ class A {} class B { m() => 1; }"
|
| - // "/** An [A]. */ class A {} class B { m() => 1 + 2; }"
|
| - _assertParse(
|
| - "/** An [A]. */ class A {} class B { m() => 1", "", " + 2", "; }");
|
| - }
|
| -
|
| - void test_insert_statement_in_method_with_mismatched_braces() {
|
| - _assertParse(
|
| - '''
|
| -class C {
|
| - void f() {
|
| -''',
|
| - '',
|
| - 'g();',
|
| - '''
|
| - if (b) {
|
| -
|
| -
|
| - }
|
| -
|
| - void g() {
|
| - h((x) {});
|
| - }
|
| -}
|
| -''');
|
| - }
|
| -
|
| - void test_insert_whitespace_end() {
|
| - // "f() => a + b;"
|
| - // "f() => a + b; "
|
| - _assertParse("f() => a + b;", "", " ", "");
|
| - }
|
| -
|
| - void test_insert_whitespace_end_multiple() {
|
| - // "f() => a + b;"
|
| - // "f() => a + b; "
|
| - _assertParse("f() => a + b;", "", " ", "");
|
| - }
|
| -
|
| - void test_insert_whitespace_middle() {
|
| - // "f() => a + b;"
|
| - // "f() => a + b;"
|
| - _assertParse("f() => a", "", " ", " + b;");
|
| - }
|
| -
|
| - void test_rename_class_withConstructor() {
|
| - // "class C { C() {} }"
|
| - // "class D { C() {} }"
|
| - _assertParse('class ', 'C', 'D', ' { C() {} }');
|
| - }
|
| -
|
| - void test_replace_field_type_with_void() {
|
| - // Note: this produces an error, but we still need the parser to produce a
|
| - // consistent parse tree for it.
|
| - _assertParse('class C { ', 'int', 'void', ' x; }');
|
| - }
|
| -
|
| - void test_replace_identifier_beginning() {
|
| - // "f() => bell + b;"
|
| - // "f() => fell + b;"
|
| - _assertParse("f() => ", "b", "f", "ell + b;");
|
| - }
|
| -
|
| - void test_replace_identifier_end() {
|
| - // "f() => bell + b;"
|
| - // "f() => belt + b;"
|
| - _assertParse("f() => bel", "l", "t", " + b;");
|
| - }
|
| -
|
| - void test_replace_identifier_middle() {
|
| - // "f() => first + b;"
|
| - // "f() => frost + b;"
|
| - _assertParse("f() => f", "ir", "ro", "st + b;");
|
| - }
|
| -
|
| - void test_replace_identifier_with_functionLiteral_in_initializer() {
|
| - // Function literals aren't allowed inside initializers; incremental parsing
|
| - // needs to gather the appropriate context.
|
| - //
|
| - // "class A { var a; A(b) : a = b ? b : 0 { } }"
|
| - // "class A { var a; A(b) : a = b ? () {} : 0 { } }"
|
| - _assertParse(
|
| - "class A { var a; A(b) : a = b ? ", "b", "() {}", " : 0 { } }");
|
| - }
|
| -
|
| - void test_replace_identifier_with_functionLiteral_in_initializer_index() {
|
| - // Function literals are allowed inside index expressions in initializers.
|
| - //
|
| - // "class A { var a; A(b) : a = b[b];"
|
| - // "class A { var a; A(b) : a = b[() {}];"
|
| - _assertParse('class A { var a; A(b) : a = b[', 'b', '() {}', '];');
|
| - }
|
| -
|
| - void test_replace_identifier_with_functionLiteral_in_initializer_list() {
|
| - // Function literals are allowed inside list literals in initializers.
|
| - //
|
| - // "class A { var a; A(b) : a = [b];"
|
| - // "class A { var a; A(b) : a = [() {}];"
|
| - _assertParse('class A { var a; A(b) : a = [', 'b', '() {}', '];');
|
| - }
|
| -
|
| - void test_replace_identifier_with_functionLiteral_in_initializer_map() {
|
| - // Function literals are allowed inside map literals in initializers.
|
| - //
|
| - // "class A { var a; A(b) : a = {0: b};"
|
| - // "class A { var a; A(b) : a = {0: () {}};"
|
| - _assertParse('class A { var a; A(b) : a = {0: ', 'b', '() {}', '};');
|
| - }
|
| -
|
| - void test_replace_identifier_with_functionLiteral_in_initializer_parens() {
|
| - // Function literals are allowed inside parentheses in initializers.
|
| - //
|
| - // "class A { var a; A(b) : a = (b);"
|
| - // "class A { var a; A(b) : a = (() {});"
|
| - _assertParse('class A { var a; A(b) : a = (', 'b', '() {}', ');');
|
| - }
|
| -
|
| - void test_replace_multiple_partialFirstAndLast() {
|
| - // "f() => aa + bb;"
|
| - // "f() => ab * ab;"
|
| - _assertParse("f() => a", "a + b", "b * a", "b;");
|
| - }
|
| -
|
| - void test_replace_operator_oneForMany() {
|
| - // "f() => a + b;"
|
| - // "f() => a * c - b;"
|
| - _assertParse("f() => a ", "+", "* c -", " b;");
|
| - }
|
| -
|
| - void test_replace_operator_oneForOne() {
|
| - // "f() => a + b;"
|
| - // "f() => a * b;"
|
| - _assertParse("f() => a ", "+", "*", " b;");
|
| - }
|
| -
|
| - void test_split_combinator() {
|
| - // "import 'foo.dart' show A;"
|
| - // "import 'foo.dart' show B hide A;"
|
| - _assertParse("import 'foo.dart' show ", "", "B hide ", "A;");
|
| - }
|
| -
|
| - /**
|
| - * Given a description of the original and modified contents, perform an incremental scan of the
|
| - * two pieces of text.
|
| - *
|
| - * @param prefix the unchanged text before the edit region
|
| - * @param removed the text that was removed from the original contents
|
| - * @param added the text that was added to the modified contents
|
| - * @param suffix the unchanged text after the edit region
|
| - */
|
| - void _assertParse(
|
| - String prefix, String removed, String added, String suffix) {
|
| - //
|
| - // Compute the information needed to perform the test.
|
| - //
|
| - String originalContents = "$prefix$removed$suffix";
|
| - String modifiedContents = "$prefix$added$suffix";
|
| - int replaceStart = prefix.length;
|
| - Source source = new TestSource();
|
| - //
|
| - // Parse the original contents.
|
| - //
|
| - GatheringErrorListener originalListener = new GatheringErrorListener();
|
| - Scanner originalScanner = new Scanner(
|
| - source, new CharSequenceReader(originalContents), originalListener);
|
| - Token originalTokens = originalScanner.tokenize();
|
| - expect(originalTokens, isNotNull);
|
| - Parser originalParser = new Parser(source, originalListener);
|
| - CompilationUnit originalUnit =
|
| - originalParser.parseCompilationUnit(originalTokens);
|
| - expect(originalUnit, isNotNull);
|
| - //
|
| - // Parse the modified contents.
|
| - //
|
| - GatheringErrorListener modifiedListener = new GatheringErrorListener();
|
| - Scanner modifiedScanner = new Scanner(
|
| - source, new CharSequenceReader(modifiedContents), modifiedListener);
|
| - Token modifiedTokens = modifiedScanner.tokenize();
|
| - expect(modifiedTokens, isNotNull);
|
| - Parser modifiedParser = new Parser(source, modifiedListener);
|
| - CompilationUnit modifiedUnit =
|
| - modifiedParser.parseCompilationUnit(modifiedTokens);
|
| - expect(modifiedUnit, isNotNull);
|
| - //
|
| - // Incrementally parse the modified contents.
|
| - //
|
| - GatheringErrorListener incrementalListener = new GatheringErrorListener();
|
| - AnalysisOptionsImpl options = new AnalysisOptionsImpl();
|
| - IncrementalScanner incrementalScanner = new IncrementalScanner(source,
|
| - new CharSequenceReader(modifiedContents), incrementalListener, options);
|
| - Token incrementalTokens = incrementalScanner.rescan(
|
| - originalTokens, replaceStart, removed.length, added.length);
|
| - expect(incrementalTokens, isNotNull);
|
| - IncrementalParser incrementalParser = new IncrementalParser(
|
| - source, incrementalScanner.tokenMap, incrementalListener);
|
| - CompilationUnit incrementalUnit = incrementalParser.reparse(
|
| - originalUnit,
|
| - incrementalScanner.leftToken,
|
| - incrementalScanner.rightToken,
|
| - replaceStart,
|
| - prefix.length + removed.length);
|
| - expect(incrementalUnit, isNotNull);
|
| - //
|
| - // Validate that the results of the incremental parse are the same as the
|
| - // full parse of the modified source.
|
| - //
|
| - expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue);
|
| - // TODO(brianwilkerson) Verify that the errors are correct?
|
| - }
|
| -}
|
| -
|
| @reflectiveTest
|
| class NonErrorParserTest extends ParserTestCase {
|
| void test_constFactory_external() {
|
|
|