Stop using main in test code in more places, part 4

This is the last set of changes in the analysis_server package.

Change-Id: I0cffd41118ba985fc1d90cc3ae25447abb62a212
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243934
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Brian Wilkerson 2022-05-08 14:32:41 +00:00 committed by Commit Bot
parent c8e3fe3d7f
commit 748ee46cf4
13 changed files with 274 additions and 231 deletions

View file

@ -92,36 +92,33 @@ class AnalysisGetImportedElementsIntegrationTest
Future<void> test_getImportedElements_none() async {
text = r'''
main() {}
void f() {}
''';
writeFile(pathname, text);
standardAnalysisSetup();
await analysisFinished;
await checkNoElements('main() {}');
await checkNoElements('f() {}');
}
Future<void> test_getImportedElements_some() async {
var selection = r'''
main() {
text = '''
import 'dart:math';
void f() {
Random r = new Random();
String s = r.nextBool().toString();
print(s);
}
''';
text = '''
import 'dart:math';
$selection
''';
writeFile(pathname, text);
standardAnalysisSetup();
await analysisFinished;
if (disableManageImportsOnPaste) {
await checkElements(selection, []);
await checkElements('f()', []);
} else {
await checkElements(selection, [
await checkElements('f()', [
ImportedElements(
path.join('lib', 'core', 'core.dart'), '', ['String', 'print']),
ImportedElements(path.join('lib', 'math', 'math.dart'), '', ['Random'])

View file

@ -41,7 +41,7 @@ class A {
int fff;
A({this.fff});
}
main() {
void f() {
new A(^);
}
''';
@ -66,7 +66,7 @@ class A {
int fff;
A({this.fff});
}
main() {
void f() {
new A(^);
}
''');
@ -297,7 +297,7 @@ class CustomScrollView extends Widget {
addTestSource('''
import 'package:flutter/material.dart';
main() {
void f() {
foo(^);
}

View file

@ -30,7 +30,7 @@ class ClosureContributorTest extends DartCompletionContributorTest {
addTestSource(r'''
void f({void Function(int a, String b) closure}) {}
void main() {
void g() {
f(closure: ^);
}
''');
@ -54,7 +54,7 @@ ${' ' * 2}},''',
addTestSource(r'''
void f({void Function(int a, String b) closure}) {}
void main() {
void g() {
f(
closure: ^,
);
@ -80,7 +80,7 @@ ${' ' * 4}}''',
addTestSource(r'''
void f(void Function(int a, int b) closure) {}
void main() {
void g() {
f(^);
}
''');
@ -96,7 +96,7 @@ void main() {
addTestSource(r'''
void f(void Function(int a, int b) closure) {}
void main() {
void g() {
f(^,);
}
''');
@ -112,7 +112,7 @@ void main() {
addTestSource(r'''
void f({void Function(int a, {int b, int c}) closure}) {}
void main() {
void g() {
f(closure: ^);
}
''');
@ -128,7 +128,7 @@ void main() {
addTestSource(r'''
void f({void Function(int a, [int b, int c]) closure]) {}
void main() {
void g() {
f(closure: ^);
}
''');

View file

@ -45,7 +45,7 @@ library libB;
import "a.dart" as foo;
part 'test.dart';
''');
addTestSource('part of libB; main() {^}');
addTestSource('part of libB; void f() {^}');
await resolveFile('$testPackageLibPath/b.dart');

View file

@ -493,13 +493,13 @@ class KeywordContributorTest extends DartCompletionContributorTest {
}
Future<void> test_anonymous_function_async() async {
addTestSource('main() {foo(() ^ {}}}');
addTestSource('void f() {foo(() ^ {}}}');
await computeSuggestions();
assertSuggestKeywords([], pseudoKeywords: ['async', 'async*', 'sync*']);
}
Future<void> test_anonymous_function_async2() async {
addTestSource('main() {foo(() a^ {}}}');
addTestSource('void f() {foo(() a^ {}}}');
await computeSuggestions();
// Fasta adds a closing paren after the first `}`
// and reports a single function expression argument
@ -509,44 +509,44 @@ class KeywordContributorTest extends DartCompletionContributorTest {
}
Future<void> test_anonymous_function_async3() async {
addTestSource('main() {foo(() async ^ {}}}');
addTestSource('void f() {foo(() async ^ {}}}');
await computeSuggestions();
assertSuggestKeywords([]);
}
Future<void> test_anonymous_function_async4() async {
addTestSource('main() {foo(() ^ => 2}}');
addTestSource('void f() {foo(() ^ => 2}}');
await computeSuggestions();
assertSuggestKeywords([], pseudoKeywords: ['async']);
}
Future<void> test_anonymous_function_async5() async {
addTestSource('main() {foo(() ^}}');
addTestSource('void f() {foo(() ^}}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE,
pseudoKeywords: ['async', 'async*', 'sync*']);
}
Future<void> test_anonymous_function_async6() async {
addTestSource('main() {foo("bar", () as^{}}');
addTestSource('void f() {foo("bar", () as^{}}');
await computeSuggestions();
assertSuggestKeywords([], pseudoKeywords: ['async', 'async*', 'sync*']);
}
Future<void> test_anonymous_function_async7() async {
addTestSource('main() {foo("bar", () as^ => null');
addTestSource('void f() {foo("bar", () as^ => null');
await computeSuggestions();
assertSuggestKeywords([], pseudoKeywords: ['async']);
}
Future<void> test_anonymous_function_async8() async {
addTestSource('main() {foo(() ^ {})}}');
addTestSource('void f() {foo(() ^ {})}}');
await computeSuggestions();
assertSuggestKeywords([], pseudoKeywords: ['async', 'async*', 'sync*']);
}
Future<void> test_anonymous_function_async9() async {
addTestSource('main() {foo(() a^ {})}}');
addTestSource('void f() {foo(() a^ {})}}');
await computeSuggestions();
// Fasta interprets the argument as a function expression
// while analyzer adds synthetic `;`s making `a` a statement.
@ -554,37 +554,37 @@ class KeywordContributorTest extends DartCompletionContributorTest {
}
Future<void> test_argument() async {
addTestSource('main() {foo(^);}');
addTestSource('void f() {foo(^);}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_argument2() async {
addTestSource('main() {foo(n^);}');
addTestSource('void f() {foo(n^);}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_argument_literal() async {
addTestSource('main() {foo("^");}');
addTestSource('void f() {foo("^");}');
await computeSuggestions();
assertSuggestKeywords([]);
}
Future<void> test_argument_named() async {
addTestSource('main() {foo(bar: ^);}');
addTestSource('void f() {foo(bar: ^);}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_argument_named2() async {
addTestSource('main() {foo(bar: n^);}');
addTestSource('void f() {foo(bar: n^);}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_argument_named_literal() async {
addTestSource('main() {foo(bar: "^");}');
addTestSource('void f() {foo(bar: "^");}');
await computeSuggestions();
assertSuggestKeywords([]);
}
@ -602,26 +602,26 @@ class KeywordContributorTest extends DartCompletionContributorTest {
}
Future<void> test_assignment_local() async {
addTestSource('main() {var foo = ^}');
addTestSource('void f() {var foo = ^}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_assignment_local2() async {
addTestSource('main() {var foo = n^}');
addTestSource('void f() {var foo = n^}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_assignment_local2_async() async {
addTestSource('main() async {var foo = n^}');
addTestSource('void f() async {var foo = n^}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE,
pseudoKeywords: ['await']);
}
Future<void> test_assignment_local_async() async {
addTestSource('main() async {var foo = ^}');
addTestSource('void f() async {var foo = ^}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE,
pseudoKeywords: ['await']);
@ -636,7 +636,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_1a() async {
// '}' Block BlockFunctionBody FunctionExpression
addTestSource('main() {try {} ^}');
addTestSource('void f() {try {} ^}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -646,7 +646,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_1b() async {
// [ExpressionStatement 'c'] Block BlockFunctionBody FunctionExpression
addTestSource('main() {try {} c^}');
addTestSource('void f() {try {} c^}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -656,7 +656,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_1c() async {
// [EmptyStatement] Block BlockFunction FunctionExpression
addTestSource('main() {try {} ^;}');
addTestSource('void f() {try {} ^;}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -666,7 +666,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_1d() async {
// [EmptyStatement] Block BlockFunction FunctionExpression
addTestSource('main() {try {} ^ Foo foo;}');
addTestSource('void f() {try {} ^ Foo foo;}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -676,7 +676,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_2a() async {
// '}' Block BlockFunctionBody FunctionExpression
addTestSource('main() {try {} on SomeException {} ^}');
addTestSource('void f() {try {} on SomeException {} ^}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -687,7 +687,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_2b() async {
// [ExpressionStatement 'c'] Block BlockFunctionBody FunctionExpression
addTestSource('main() {try {} on SomeException {} c^}');
addTestSource('void f() {try {} on SomeException {} c^}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -698,7 +698,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_2c() async {
// [EmptyStatement] Block BlockFunction FunctionExpression
addTestSource('main() {try {} on SomeException {} ^;}');
addTestSource('void f() {try {} on SomeException {} ^;}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -709,7 +709,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_2d() async {
// [EmptyStatement] Block BlockFunction FunctionExpression
addTestSource('main() {try {} on SomeException {} ^ Foo foo;}');
addTestSource('void f() {try {} on SomeException {} ^ Foo foo;}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -720,7 +720,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_3a() async {
// '}' Block BlockFunctionBody FunctionExpression
addTestSource('main() {try {} catch (e) {} ^}');
addTestSource('void f() {try {} catch (e) {} ^}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -731,7 +731,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_3b() async {
// [ExpressionStatement 'c'] Block BlockFunctionBody FunctionExpression
addTestSource('main() {try {} catch (e) {} c^}');
addTestSource('void f() {try {} catch (e) {} c^}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -742,7 +742,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_3c() async {
// [EmptyStatement] Block BlockFunction FunctionExpression
addTestSource('main() {try {} catch (e) {} ^;}');
addTestSource('void f() {try {} catch (e) {} ^;}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -753,7 +753,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_3d() async {
// [EmptyStatement] Block BlockFunction FunctionExpression
addTestSource('main() {try {} catch (e) {} ^ Foo foo;}');
addTestSource('void f() {try {} catch (e) {} ^ Foo foo;}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -764,7 +764,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_4a1() async {
// [CatchClause] TryStatement Block
addTestSource('main() {try {} ^ on SomeException {}}');
addTestSource('void f() {try {} ^ on SomeException {}}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -773,7 +773,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_4a2() async {
// ['c' VariableDeclarationStatement] Block BlockFunctionBody
addTestSource('main() {try {} c^ on SomeException {}}');
addTestSource('void f() {try {} c^ on SomeException {}}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -784,7 +784,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_4b1() async {
// [CatchClause] TryStatement Block
addTestSource('main() {try {} ^ catch (e) {}}');
addTestSource('void f() {try {} ^ catch (e) {}}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -793,7 +793,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_4b2() async {
// ['c' ExpressionStatement] Block BlockFunctionBody
addTestSource('main() {try {} c^ catch (e) {}}');
addTestSource('void f() {try {} c^ catch (e) {}}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -804,7 +804,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_4c1() async {
// ['finally'] TryStatement Block
addTestSource('main() {try {} ^ finally {}}');
addTestSource('void f() {try {} ^ finally {}}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -813,7 +813,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_4c2() async {
// ['c' ExpressionStatement] Block BlockFunctionBody
addTestSource('main() {try {} c^ finally {}}');
addTestSource('void f() {try {} c^ finally {}}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.add(Keyword.CATCH);
@ -824,7 +824,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
Future<void> test_catch_block() async {
// '}' Block CatchClause TryStatement Block
addTestSource('main() {try {} catch (e) {^}}}');
addTestSource('void f() {try {} catch (e) {^}}}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.addAll(statementStartOutsideClass);
@ -1061,7 +1061,7 @@ class A {
}
Future<void> test_do_break_continue_outsideClass() async {
addTestSource('main() {do {^} while (true);}');
addTestSource('void f() {do {^} while (true);}');
await computeSuggestions();
assertSuggestKeywords(statementStartInLoopOutsideClass);
}
@ -1129,43 +1129,43 @@ extension E on int {
}
Future<void> test_for_break_continue_outsideClass() async {
addTestSource('main() {for (int x in myList) {^}}');
addTestSource('void f() {for (int x in myList) {^}}');
await computeSuggestions();
assertSuggestKeywords(statementStartInLoopOutsideClass);
}
Future<void> test_for_expression_in() async {
addTestSource('main() {for (int x i^)}');
addTestSource('void f() {for (int x i^)}');
await computeSuggestions();
assertSuggestKeywords([Keyword.IN]);
}
Future<void> test_for_expression_in2() async {
addTestSource('main() {for (int x in^)}');
addTestSource('void f() {for (int x in^)}');
await computeSuggestions();
assertSuggestKeywords([Keyword.IN]);
}
Future<void> test_for_expression_in_inInitializer() async {
addTestSource('main() {for (int i^)}');
addTestSource('void f() {for (int i^)}');
await computeSuggestions();
assertSuggestKeywords([]);
}
Future<void> test_for_expression_init() async {
addTestSource('main() {for (int x = i^)}');
addTestSource('void f() {for (int x = i^)}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_for_expression_init2() async {
addTestSource('main() {for (int x = in^)}');
addTestSource('void f() {for (int x = in^)}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_for_initialization_var() async {
addTestSource('main() {for (^)}');
addTestSource('void f() {for (^)}');
await computeSuggestions();
assertSuggestKeywords([Keyword.VAR]);
}
@ -1234,32 +1234,32 @@ extension E on int {
}
Future<void> test_function_async() async {
addTestSource('main()^');
addTestSource('void f()^');
await computeSuggestions();
assertSuggestKeywords([], pseudoKeywords: ['async', 'async*', 'sync*']);
}
Future<void> test_function_async2() async {
addTestSource('main()^{}');
addTestSource('void f()^{}');
await computeSuggestions();
assertSuggestKeywords([], pseudoKeywords: ['async', 'async*', 'sync*']);
}
Future<void> test_function_async3() async {
addTestSource('main()a^');
addTestSource('void f()a^');
await computeSuggestions();
assertSuggestKeywords(declarationKeywords,
pseudoKeywords: ['async', 'async*', 'sync*']);
}
Future<void> test_function_async4() async {
addTestSource('main()a^{}');
addTestSource('void f()a^{}');
await computeSuggestions();
assertSuggestKeywords([], pseudoKeywords: ['async', 'async*', 'sync*']);
}
Future<void> test_function_async5() async {
addTestSource('main()a^ Foo foo;');
addTestSource('void f()a^ Foo foo;');
await computeSuggestions();
assertSuggestKeywords(declarationKeywords,
pseudoKeywords: ['async', 'async*', 'sync*']);
@ -1371,33 +1371,33 @@ class A {
}
Future<void> test_function_body_inUnit() async {
addTestSource('main() {^}');
addTestSource('void f() {^}');
await computeSuggestions();
assertSuggestKeywords(statementStartOutsideClass);
}
Future<void> test_function_body_inUnit_afterBlock() async {
addTestSource('main() {{}^}');
addTestSource('void f() {{}^}');
await computeSuggestions();
assertSuggestKeywords(statementStartOutsideClass);
}
Future<void> test_function_body_inUnit_async() async {
addTestSource('main() async {^}');
addTestSource('void f() async {^}');
await computeSuggestions();
assertSuggestKeywords(statementStartOutsideClass,
pseudoKeywords: ['await']);
}
Future<void> test_function_body_inUnit_async_star() async {
addTestSource('main() async* {n^}');
addTestSource('void f() async* {n^}');
await computeSuggestions();
assertSuggestKeywords(statementStartOutsideClass,
pseudoKeywords: ['await', 'yield', 'yield*']);
}
Future<void> test_function_body_inUnit_async_star2() async {
addTestSource('main() async* {n^ foo}');
addTestSource('void f() async* {n^ foo}');
await computeSuggestions();
assertSuggestKeywords(statementStartOutsideClass,
pseudoKeywords: ['await', 'yield', 'yield*']);
@ -1416,27 +1416,27 @@ class A {
}
Future<void> test_function_body_inUnit_sync_star() async {
addTestSource('main() sync* {n^}');
addTestSource('void f() sync* {n^}');
await computeSuggestions();
assertSuggestKeywords(statementStartOutsideClass,
pseudoKeywords: ['await', 'yield', 'yield*']);
}
Future<void> test_function_body_inUnit_sync_star2() async {
addTestSource('main() sync* {n^ foo}');
addTestSource('void f() sync* {n^ foo}');
await computeSuggestions();
assertSuggestKeywords(statementStartOutsideClass,
pseudoKeywords: ['await', 'yield', 'yield*']);
}
Future<void> test_if_after_else() async {
addTestSource('main() { if (true) {} else ^ }');
addTestSource('void f() { if (true) {} else ^ }');
await computeSuggestions();
assertSuggestKeywords(statementStartOutsideClass);
}
Future<void> test_if_afterThen_nextCloseCurlyBrace0() async {
addTestSource('main() { if (true) {} ^ }');
addTestSource('void f() { if (true) {} ^ }');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.addAll(statementStartOutsideClass);
@ -1445,7 +1445,7 @@ class A {
}
Future<void> test_if_afterThen_nextCloseCurlyBrace1() async {
addTestSource('main() { if (true) {} e^ }');
addTestSource('void f() { if (true) {} e^ }');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.addAll(statementStartOutsideClass);
@ -1454,7 +1454,7 @@ class A {
}
Future<void> test_if_afterThen_nextStatement0() async {
addTestSource('main() { if (true) {} ^ print(0); }');
addTestSource('void f() { if (true) {} ^ print(0); }');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.addAll(statementStartOutsideClass);
@ -1463,13 +1463,13 @@ class A {
}
Future<void> test_if_condition_isKeyword() async {
addTestSource('main() { if (v i^) {} }');
addTestSource('void f() { if (v i^) {} }');
await computeSuggestions();
assertSuggestKeywords([Keyword.IS]);
}
Future<void> test_if_condition_isKeyword2() async {
addTestSource('main() { if (v i^ && false) {} }');
addTestSource('void f() { if (v i^ && false) {} }');
await computeSuggestions();
assertSuggestKeywords([Keyword.IS]);
}
@ -2012,25 +2012,25 @@ f() => <int>{1, ^, 2};
}
Future<void> test_integerLiteral_inArgumentList() async {
addTestSource('main() { print(42^); }');
addTestSource('void f() { print(42^); }');
await computeSuggestions();
assertSuggestKeywords([]);
}
Future<void> test_integerLiteral_inListLiteral() async {
addTestSource('main() { var items = [42^]; }');
addTestSource('void f() { var items = [42^]; }');
await computeSuggestions();
assertSuggestKeywords([]);
}
Future<void> test_is_expression() async {
addTestSource('main() {if (x is^)}');
addTestSource('void f() {if (x is^)}');
await computeSuggestions();
assertSuggestKeywords([Keyword.IS]);
}
Future<void> test_is_expression_partial() async {
addTestSource('main() {if (x i^)}');
addTestSource('void f() {if (x i^)}');
await computeSuggestions();
assertSuggestKeywords([Keyword.IS]);
}
@ -2243,7 +2243,7 @@ void m() {
}
Future<void> test_named_constructor_invocation() async {
addTestSource('void main() {new Future.^}');
addTestSource('void f() {new Future.^}');
await computeSuggestions();
assertSuggestKeywords([]);
}
@ -2335,67 +2335,67 @@ f() => [...^];
}
Future<void> test_switch_expression() async {
addTestSource('main() {switch(^) {}}');
addTestSource('void f() {switch(^) {}}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_switch_expression2() async {
addTestSource('main() {switch(n^) {}}');
addTestSource('void f() {switch(n^) {}}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_switch_expression3() async {
addTestSource('main() {switch(n^)}');
addTestSource('void f() {switch(n^)}');
await computeSuggestions();
assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE);
}
Future<void> test_switch_start() async {
addTestSource('main() {switch(1) {^}}');
addTestSource('void f() {switch(1) {^}}');
await computeSuggestions();
assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT]);
}
Future<void> test_switch_start2() async {
addTestSource('main() {switch(1) {^ case 1:}}');
addTestSource('void f() {switch(1) {^ case 1:}}');
await computeSuggestions();
assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT]);
}
Future<void> test_switch_start3() async {
addTestSource('main() {switch(1) {^default:}}');
addTestSource('void f() {switch(1) {^default:}}');
await computeSuggestions();
assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT]);
}
Future<void> test_switch_start4() async {
addTestSource('main() {switch(1) {^ default:}}');
addTestSource('void f() {switch(1) {^ default:}}');
await computeSuggestions();
assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT]);
}
Future<void> test_switch_start5() async {
addTestSource('main() {switch(1) {c^ default:}}');
addTestSource('void f() {switch(1) {c^ default:}}');
await computeSuggestions();
expect(replacementOffset, 19);
expect(replacementOffset, 21);
expect(replacementLength, 1);
assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT]);
}
Future<void> test_switch_start6() async {
addTestSource('main() {switch(1) {c^}}');
addTestSource('void f() {switch(1) {c^}}');
await computeSuggestions();
expect(replacementOffset, 19);
expect(replacementOffset, 21);
expect(replacementLength, 1);
assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT]);
}
Future<void> test_switch_start7() async {
addTestSource('main() {switch(1) { c^ }}');
addTestSource('void f() {switch(1) { c^ }}');
await computeSuggestions();
expect(replacementOffset, 20);
expect(replacementOffset, 22);
expect(replacementLength, 1);
assertSuggestKeywords([Keyword.CASE, Keyword.DEFAULT]);
}
@ -2419,7 +2419,7 @@ f() => [...^];
}
Future<void> test_switch_statement_outsideClass() async {
addTestSource('main() {switch(1) {case 1:^}}');
addTestSource('void f() {switch(1) {case 1:^}}');
await computeSuggestions();
assertSuggestKeywords(statementStartInSwitchOutsideClass);
}
@ -2431,7 +2431,7 @@ f() => [...^];
}
Future<void> test_while_break_continue() async {
addTestSource('main() {while (true) {^}}');
addTestSource('void f() {while (true) {^}}');
await computeSuggestions();
assertSuggestKeywords(statementStartInLoopOutsideClass);
}

View file

@ -44,7 +44,7 @@ class LabelContributorTest extends DartCompletionContributorTest {
Future<void> test_break_ignores_outer_functions_using_closure() async {
addTestSource('''
void main() {
void g() {
foo: while (true) {
var f = () {
bar: while (true) { break ^ }
@ -60,7 +60,7 @@ void main() {
Future<void> test_break_ignores_outer_functions_using_local_function() async {
addTestSource('''
void main() {
void g() {
foo: while (true) {
void f() {
bar: while (true) { break ^ }
@ -77,7 +77,7 @@ void main() {
Future<void> test_break_ignores_toplevel_variables() async {
addTestSource('''
int x;
void main() {
void f() {
while (true) {
break ^
}
@ -89,7 +89,7 @@ void main() {
Future<void> test_break_ignores_unrelated_statements() async {
addTestSource('''
void main() {
void f() {
foo: while (true) {}
while (true) { break ^ }
bar: while (true) {}
@ -105,7 +105,7 @@ void main() {
Future<void> test_break_to_enclosing_loop() async {
addTestSource('''
void main() {
void f() {
foo: while (true) {
bar: while (true) {
break ^
@ -120,7 +120,7 @@ void main() {
Future<void> test_continue_from_loop_to_switch() async {
addTestSource('''
void main() {
void f() {
switch (x) {
foo: case 1:
break;
@ -142,7 +142,7 @@ void main() {
Future<void> test_continue_from_switch_to_loop() async {
addTestSource('''
void main() {
void f() {
foo: while (true) {
switch (x) {
case 1:
@ -158,7 +158,7 @@ void main() {
Future<void>
test_continue_ignores_outer_functions_using_closure_with_loop() async {
addTestSource('''
void main() {
void f() {
foo: while (true) {
var f = () {
bar: while (true) { continue ^ }
@ -175,7 +175,7 @@ void main() {
Future<void>
test_continue_ignores_outer_functions_using_closure_with_switch() async {
addTestSource('''
void main() {
void g() {
switch (x) {
foo: case 1:
var f = () {
@ -193,7 +193,7 @@ void main() {
Future<void>
test_continue_ignores_outer_functions_using_local_function_with_loop() async {
addTestSource('''
void main() {
void g() {
foo: while (true) {
void f() {
bar: while (true) { continue ^ }
@ -210,7 +210,7 @@ void main() {
Future<void>
test_continue_ignores_outer_functions_using_local_function_with_switch() async {
addTestSource('''
void main() {
void g() {
switch (x) {
foo: case 1:
void f() {
@ -227,7 +227,7 @@ void main() {
Future<void> test_continue_ignores_unrelated_statements() async {
addTestSource('''
void main() {
void f() {
foo: while (true) {}
while (true) { continue ^ }
bar: while (true) {}
@ -243,7 +243,7 @@ void main() {
Future<void> test_continue_to_earlier_case() async {
addTestSource('''
void main() {
void f() {
switch (x) {
foo: case 1:
break;
@ -258,7 +258,7 @@ void main() {
Future<void> test_continue_to_enclosing_loop() async {
addTestSource('''
void main() {
void f() {
foo: while (true) {
bar: while (true) {
continue ^
@ -273,7 +273,7 @@ void main() {
Future<void> test_continue_to_enclosing_switch() async {
addTestSource('''
void main() {
void f() {
switch (x) {
foo: case 1:
break;
@ -296,7 +296,7 @@ void main() {
Future<void> test_continue_to_later_case() async {
addTestSource('''
void main() {
void f() {
switch (x) {
case 1:
break;
@ -311,7 +311,7 @@ void main() {
Future<void> test_continue_to_same_case() async {
addTestSource('''
void main() {
void f() {
switch (x) {
case 1:
break;

View file

@ -33,15 +33,19 @@ class LibraryMemberContributorTest extends DartCompletionContributorTest {
extension MyExt on int {}
''');
addTestSource('''
import "b.dart" as b;
main() {b.^}''');
import "b.dart" as b;
void f() {b.^}
''');
await computeSuggestions();
assertSuggest('MyExt');
}
Future<void> test_libraryPrefix() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addTestSource('import "dart:async" as bar; foo() {bar.^}');
addTestSource('''
import "dart:async" as bar;
foo() {bar.^}
''');
await computeSuggestions();
assertSuggestClass('Future');
assertNotSuggested('loadLibrary');
@ -49,14 +53,26 @@ extension MyExt on int {}
Future<void> test_libraryPrefix2() async {
// SimpleIdentifier MethodInvocation ExpressionStatement
addTestSource('import "dart:async" as bar; foo() {bar.^ print("f")}');
addTestSource('''
import "dart:async" as bar;
foo() {
bar.^
print("f");
}
''');
await computeSuggestions();
assertSuggestClass('Future');
}
Future<void> test_libraryPrefix3() async {
// SimpleIdentifier MethodInvocation ExpressionStatement
addTestSource('import "dart:async" as bar; foo() {new bar.F^ print("f")}');
addTestSource('''
import "dart:async" as bar;
foo() {
new bar.F^
print("f");
}
''');
await computeSuggestions();
assertSuggestConstructor('Future');
assertSuggestConstructor('Future.delayed');
@ -64,32 +80,44 @@ extension MyExt on int {}
Future<void> test_libraryPrefix_cascade() async {
addTestSource('''
import "dart:math" as math;
main() {math..^}''');
import "dart:math" as math;
void f() {
math..^
}
''');
await computeSuggestions();
assertNoSuggestions();
}
Future<void> test_libraryPrefix_cascade2() async {
addTestSource('''
import "dart:math" as math;
main() {math.^.}''');
import "dart:math" as math;
void f() {
math.^.
}
''');
await computeSuggestions();
assertSuggestFunction('min', 'T');
}
Future<void> test_libraryPrefix_cascade3() async {
addTestSource('''
import "dart:math" as math;
main() {math..^a}''');
import "dart:math" as math;
void f() {
math..^a
}
''');
await computeSuggestions();
assertNoSuggestions();
}
Future<void> test_libraryPrefix_cascade4() async {
addTestSource('''
import "dart:math" as math;
main() {math.^.a}''');
import "dart:math" as math;
void f() {
math.^.a
}
''');
await computeSuggestions();
assertSuggestFunction('min', 'T');
}
@ -105,9 +133,10 @@ extension MyExt on int {}
Future<void> test_libraryPrefix_deferred_inPart() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
newFile('$testPackageLibPath/a.dart', '''
library testA;
import "dart:async" deferred as bar;
part "test.dart";''');
library testA;
import "dart:async" deferred as bar;
part "test.dart";
''');
addTestSource('part of testA; foo() {bar.^}');
await resolveFile('$testPackageLibPath/a.dart');
// Assume that libraries containing has been computed for part files
@ -124,7 +153,11 @@ extension MyExt on int {}
export "a.dart";
class B { }
@deprecated class B1 { }''');
addTestSource('import "b.dart" as foo; main() {foo.^} class C { }');
addTestSource('''
import "b.dart" as foo;
void f() {foo.^}
class C { }
''');
await computeSuggestions();
assertSuggestClass('B');
assertSuggestClass('B1', isDeprecated: true);
@ -135,15 +168,17 @@ extension MyExt on int {}
Future<void> test_PrefixedIdentifier_library() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addSource('$testPackageLibPath/b.dart', '''
lib B;
var T1;
class X { }
class Y { }''');
lib B;
var T1;
class X { }
class Y { }
''');
addTestSource('''
import "b.dart" as b;
var T2;
class A { }
main() {b.^}''');
import "b.dart" as b;
var T2;
class A { }
void f() {b.^}
''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@ -167,7 +202,7 @@ export 'a.dart' show A;
''');
addTestSource(r'''
import 'b.dart' as p;
main() {
void f() {
p.^
}
''');
@ -183,7 +218,7 @@ class B {}
''');
addTestSource(r'''
import 'a.dart' as p show A;
main() {
void f() {
p.^
}
''');
@ -200,14 +235,16 @@ main() {
class X { }
class Y { }''');
newFile('$testPackageLibPath/a.dart', '''
library testA;
import "b.dart" as b;
part "test.dart";
var T2;
class A { }''');
library testA;
import "b.dart" as b;
part "test.dart";
var T2;
class A { }
''');
addTestSource('''
part of testA;
main() {b.^}''');
part of testA;
void f() {b.^}
''');
await resolveFile('$testPackageLibPath/a.dart');
// Assume that libraries containing has been computed for part files
await computeSuggestions();
@ -226,18 +263,20 @@ main() {
Future<void> test_PrefixedIdentifier_library_typesOnly() async {
// SimpleIdentifier PrefixedIdentifier NamedType
newFile('$testPackageLibPath/b.dart', '''
lib B;
var T1;
class X { }
class Y { }
typedef void TypeAliasLegacy();
typedef TypeAliasFunctionType = void Function();
typedef TypeAliasInterfaceType = List<int>;''');
lib B;
var T1;
class X { }
class Y { }
typedef void TypeAliasLegacy();
typedef TypeAliasFunctionType = void Function();
typedef TypeAliasInterfaceType = List<int>;
''');
addTestSource('''
import "b.dart" as b;
var T2;
class A { }
foo(b.^ f) {}''');
import "b.dart" as b;
var T2;
class A { }
foo(b.^ f) {}
''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@ -259,15 +298,17 @@ main() {
Future<void> test_PrefixedIdentifier_library_typesOnly2() async {
// SimpleIdentifier PrefixedIdentifier NamedType
newFile('$testPackageLibPath/b.dart', '''
lib B;
var T1;
class X { }
class Y { }''');
lib B;
var T1;
class X { }
class Y { }
''');
addTestSource('''
import "b.dart" as b;
var T2;
class A { }
foo(b.^) {}''');
import "b.dart" as b;
var T2;
class A { }
foo(b.^) {}
''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@ -284,13 +325,15 @@ main() {
Future<void> test_PrefixedIdentifier_parameter() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
newFile('$testPackageLibPath/b.dart', '''
lib B;
class _W {M y; var _z;}
class X extends _W {}
class M{}''');
lib B;
class _W {M y; var _z;}
class X extends _W {}
class M{}
''');
addTestSource('''
import "b.dart";
foo(X x) {x.^}''');
import "b.dart";
foo(X x) {x.^}
''');
await computeSuggestions();
assertNoSuggestions();
}
@ -298,11 +341,13 @@ main() {
Future<void> test_PrefixedIdentifier_prefix() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
newFile('$testPackageLibPath/a.dart', '''
class A {static int bar = 10;}
_B() {}''');
class A {static int bar = 10;}
_B() {}
''');
addTestSource('''
import "a.dart";
class X {foo(){A^.bar}}''');
import "a.dart";
class X {foo(){A^.bar}}
''');
await computeSuggestions();
assertNoSuggestions();
}

View file

@ -282,7 +282,7 @@ class C {C.bar({boo: 'hoo', int z: 0}) { } }''');
addTestSource('''
import "a.dart" as t;
import "dart:math" as math;
main() {new ^ String x = "hello";}''');
void f() {new ^ String x = "hello";}''');
await computeSuggestions();
assertSuggestLibraryPrefixes(['math', 't']);
}
@ -303,10 +303,10 @@ library testB;
import "a.dart" as t;
import "dart:math" as math;
part "test.dart";
main() {new ^ String x = "hello";}''');
void f() {new ^ String x = "hello";}''');
addTestSource('''
part of testB;
main() {new ^ String x = "hello";}''');
void f() {new ^ String x = "hello";}''');
await analyzeTestPackageFiles();
await computeSuggestions();
assertSuggestLibraryPrefixes(['math', 't']);
@ -322,10 +322,10 @@ library testB;
import "a.dart" as t;
import "dart:math" as math;
//part "$testFile"
main() {new ^ String x = "hello";}''');
void f() {new ^ String x = "hello";}''');
addTestSource('''
//part of testB;
main() {new ^ String x = "hello";}''');
void f() {new ^ String x = "hello";}''');
await computeSuggestions();
assertNoSuggestions();
}

View file

@ -43,7 +43,7 @@ class LocalLibraryContributorTest extends DartCompletionContributorTest {
addTestSource('''
part of libA;
class B { B.bar(int x); }
main() {new ^}''');
void f() {new ^}''');
await resolveFile('$testPackageLibPath/a.dart');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@ -77,7 +77,7 @@ class LocalLibraryContributorTest extends DartCompletionContributorTest {
import "b.dart";
part "a.dart";
class A { A({String boo: 'hoo'}) { } }
main() {new ^}
void f() {new ^}
var m;''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@ -129,7 +129,7 @@ void f() {^}
import "b.dart";
part "a.dart";
class Local { }
main() {
void f() {
A a;
// FAIL:
a = new ^
@ -176,7 +176,7 @@ void f() {^}
import "b.dart";
part "a.dart";
class Local { }
main() {
void f() {
A a = new ^
}
var m;''');
@ -223,7 +223,7 @@ void f() {^}
addTestSource('''
part of libA;
class B { B.bar(int x); }
main() {^}''');
void f() {^}''');
await resolveFile('$testPackageLibPath/a.dart');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@ -270,7 +270,7 @@ void f() {^}
import "b.dart";
part "a.dart";
class A { A({String boo: 'hoo'}) { } }
main() {^}
void f() {^}
var m;''');
await computeSuggestions();
expect(replacementOffset, completionOffset);

View file

@ -300,7 +300,7 @@ void f() {
addTestSource('''
import 'b.dart';
var m;
main() {new X.^}''');
void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@ -328,7 +328,7 @@ void f() {
addTestSource('''
import 'b.dart';
var m;
main() {new X.^}''');
void f() {new X.^}''');
// Assume that imported libraries are NOT resolved
//await resolveLibraryUnit(libSource);
await computeSuggestions();
@ -357,7 +357,7 @@ void f() {
addTestSource('''
import 'b.dart';
var m;
main() {new X.^}''');
void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@ -378,7 +378,7 @@ void f() {
// SimpleIdentifier PrefixedIdentifier NamedType ConstructorName
// InstanceCreationExpression
addTestSource('''
main() {new String.fr^omCharCodes([]);}''');
void f() {new String.fr^omCharCodes([]);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 2);
expect(replacementLength, 13);
@ -401,7 +401,7 @@ void f() {
int T1;
F1() { }
class X {X.c(); X._d(); z() {}}
main() {new X.^}''');
void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@ -428,7 +428,7 @@ void f() {
int T1;
F1() { }
class X {factory X.c(); factory X._d(); z() {}}
main() {new X.^}''');
void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);

View file

@ -52,7 +52,7 @@ void f() {
}
Future<void> test_enumConst() async {
addTestSource('enum E { one, two } main() {E.^}');
addTestSource('enum E { one, two } void f() {E.^}');
await computeSuggestions();
assertNotSuggested('E');
assertSuggestEnumConst('one');
@ -62,7 +62,7 @@ void f() {
}
Future<void> test_enumConst2() async {
addTestSource('enum E { one, two } main() {E.o^}');
addTestSource('enum E { one, two } void f() {E.o^}');
await computeSuggestions();
assertNotSuggested('E');
assertSuggestEnumConst('one');
@ -72,7 +72,7 @@ void f() {
}
Future<void> test_enumConst3() async {
addTestSource('enum E { one, two } main() {E.^ int g;}');
addTestSource('enum E { one, two } void f() {E.^ int g;}');
await computeSuggestions();
assertNotSuggested('E');
assertSuggestEnumConst('one');
@ -82,13 +82,13 @@ void f() {
}
Future<void> test_enumConst_cascade1() async {
addTestSource('enum E { one, two } main() {E..^}');
addTestSource('enum E { one, two } void f() {E..^}');
await computeSuggestions();
assertNoSuggestions();
}
Future<void> test_enumConst_cascade2() async {
addTestSource('enum E { one, two } main() {E.^.}');
addTestSource('enum E { one, two } void f() {E.^.}');
await computeSuggestions();
assertNotSuggested('E');
assertSuggestEnumConst('one');
@ -98,13 +98,13 @@ void f() {
}
Future<void> test_enumConst_cascade3() async {
addTestSource('enum E { one, two } main() {E..o^}');
addTestSource('enum E { one, two } void f() {E..o^}');
await computeSuggestions();
assertNoSuggestions();
}
Future<void> test_enumConst_cascade4() async {
addTestSource('enum E { one, two } main() {E.^.o}');
addTestSource('enum E { one, two } void f() {E.^.o}');
await computeSuggestions();
assertNotSuggested('E');
assertSuggestEnumConst('one');
@ -114,7 +114,7 @@ void f() {
}
Future<void> test_enumConst_deprecated() async {
addTestSource('@deprecated enum E { one, two } main() {E.^}');
addTestSource('@deprecated enum E { one, two } void f() {E.^}');
await computeSuggestions();
assertNotSuggested('E');
assertSuggestEnumConst('one', isDeprecated: true);
@ -129,7 +129,7 @@ extension E on Object {
static int i;
static String s;
}
main() {E.^}
void f() {E.^}
''');
await computeSuggestions();
assertNotSuggested('E');
@ -169,7 +169,7 @@ class A {
addTestSource('''
import 'a.dart';
main() {
void f() {
A.^;
}
''');
@ -190,7 +190,7 @@ class A {
addTestSource('''
import 'a.dart';
main() {
void f() {
A Function() v = A.^;
}
''');
@ -211,7 +211,7 @@ class A {
addTestSource('''
import 'a.dart';
main() {
void f() {
int Function() v = A.^;
}
''');
@ -222,7 +222,8 @@ main() {
}
Future<void> test_keyword() async {
addTestSource('class C { static C get instance => null; } main() {C.in^}');
addTestSource(
'class C { static C get instance => null; } void f() {C.in^}');
await computeSuggestions();
assertSuggestGetter('instance', 'C');
}
@ -239,7 +240,7 @@ class C extends B {
m1() {}
static m2() {}
}
void main() {C.^}''');
void f() {C.^}''');
await computeSuggestions();
assertNotSuggested('b1');
assertNotSuggested('f1');
@ -260,7 +261,7 @@ class C extends B {
m1() {}
static m2() {}
}
void main() {C.^ print("something");}''');
void f() {C.^ print("something");}''');
await computeSuggestions();
assertNotSuggested('b1');
assertNotSuggested('f1');
@ -281,7 +282,7 @@ class C extends B {
m1() {}
static m2() {}
}
void main() {C..^}''');
void f() {C..^}''');
await computeSuggestions();
assertNoSuggestions();
}
@ -298,7 +299,7 @@ class C extends B {
m1() {}
static m2() {}
}
void main() {C.^.}''');
void f() {C.^.}''');
await computeSuggestions();
assertNotSuggested('b1');
assertNotSuggested('f1');
@ -319,7 +320,7 @@ class C extends B {
m1() {}
static m2() {}
}
void main() {C..m^()}''');
void f() {C..m^()}''');
await computeSuggestions();
assertNoSuggestions();
}
@ -336,7 +337,7 @@ class C extends B {
m1() {}
static m2() {}
}
void main() {C.^.m()}''');
void f() {C.^.m()}''');
await computeSuggestions();
assertNotSuggested('b1');
assertNotSuggested('f1');
@ -349,7 +350,7 @@ void main() {C.^.m()}''');
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addTestSource('''
import "dart:async" as async;
void main() {async.Future..w^()}''');
void f() {async.Future..w^()}''');
await computeSuggestions();
assertNoSuggestions();
}
@ -358,7 +359,7 @@ void main() {async.Future..w^()}''');
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addTestSource('''
import "dart:async" as async;
void main() {async.Future.^.w()}''');
void f() {async.Future.^.w()}''');
await computeSuggestions();
assertSuggestMethod('wait', 'Future', 'Future<List<T>>');
}
@ -383,7 +384,7 @@ void main() {async.Future.^.w()}''');
class A extends B {
static const String scA = 'foo';
w() { }}
main() {A.^}''');
void f() {A.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);

View file

@ -1350,12 +1350,12 @@ class C {}
aaa() {}
get bbb() {}
class A {}
main() {}
void main() {}
class B {}
''');
// validate change
_assertSort(r'''
main() {}
void main() {}
get bbb() {}
aaa() {}
class A {}

View file

@ -34,7 +34,7 @@ class FlutterOutlineComputerTest extends AbstractContextTest {
var unitOutline = await _computeOutline('''
import 'package:flutter/widgets.dart';
main() {
void f() {
return new WidgetA(
value: 42,
); // WidgetA
@ -51,8 +51,8 @@ class WidgetA extends StatelessWidget {
var attribute = widget.attributes![0];
expect(attribute.name, 'value');
expect(attribute.label, '42');
_assertLocation(attribute.nameLocation!, 75, 5);
_assertLocation(attribute.valueLocation!, 82, 2);
_assertLocation(attribute.nameLocation!, 77, 5);
_assertLocation(attribute.valueLocation!, 84, 2);
}
Future<void> test_attributes_bool() async {
@ -596,7 +596,7 @@ class MyWidget extends StatelessWidget {
var unitOutline = await _computeOutline('''
import 'package:flutter/widgets.dart';
main() {
void f() {
new MyWidget($value);
}
@ -617,7 +617,7 @@ class MyWidget extends StatelessWidget {
var attribute = newMyWidget.attributes![0];
expect(attribute.name, name);
expect(attribute.nameLocation, isNull);
_assertLocation(attribute.valueLocation!, 64, value.length);
_assertLocation(attribute.valueLocation!, 66, value.length);
return attribute;
}