Make subclasses of AbstractContextTest asynchronous.
As a preliminary step before duplicating them for the new analysis driver. R=brianwilkerson@google.com BUG= Review-Url: https://codereview.chromium.org/2614033003 .
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
library testing.abstract_context;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/dart/element/visitor.dart';
|
||||
@@ -123,12 +125,12 @@ class AbstractContextTest {
|
||||
AnalysisEngine.instance.processRequiredPlugins();
|
||||
}
|
||||
|
||||
CompilationUnit resolveDartUnit(Source unitSource, Source librarySource) {
|
||||
return context.resolveCompilationUnit2(unitSource, librarySource);
|
||||
}
|
||||
|
||||
CompilationUnit resolveLibraryUnit(Source source) {
|
||||
return context.resolveCompilationUnit2(source, source);
|
||||
Future<CompilationUnit> resolveLibraryUnit(Source source) async {
|
||||
if (enableNewAnalysisDriver) {
|
||||
return (await driver.getResult(source.fullName))?.unit;
|
||||
} else {
|
||||
return context.resolveCompilationUnit2(source, source);
|
||||
}
|
||||
}
|
||||
|
||||
void setUp() {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
library test.services.src.index.abstract_single_file;
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/error/error.dart';
|
||||
@@ -98,9 +99,9 @@ class AbstractSingleUnitTest extends AbstractContextTest {
|
||||
return length;
|
||||
}
|
||||
|
||||
void resolveTestUnit(String code) {
|
||||
Future<Null> resolveTestUnit(String code) async {
|
||||
addTestSource(code);
|
||||
testUnit = resolveLibraryUnit(testSource);
|
||||
testUnit = await resolveLibraryUnit(testSource);
|
||||
if (verifyNoTestUnitErrors) {
|
||||
assertNoErrorsInSource(testSource);
|
||||
}
|
||||
|
||||
@@ -102,14 +102,14 @@ class ElementTest extends AbstractContextTest {
|
||||
return findChildElement(unit.element, name, kind);
|
||||
}
|
||||
|
||||
void test_fromElement_CLASS() {
|
||||
test_fromElement_CLASS() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
@deprecated
|
||||
abstract class _A {}
|
||||
class B<K, V> {}''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
{
|
||||
engine.ClassElement engineElement = findElementInUnit(unit, '_A');
|
||||
// create notification Element
|
||||
@@ -143,14 +143,14 @@ class B<K, V> {}''');
|
||||
}
|
||||
}
|
||||
|
||||
void test_fromElement_CONSTRUCTOR() {
|
||||
test_fromElement_CONSTRUCTOR() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
const A.myConstructor(int a, [String b]);
|
||||
}''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
engine.ConstructorElement engineElement =
|
||||
findElementInUnit(unit, 'myConstructor');
|
||||
// create notification Element
|
||||
@@ -183,14 +183,14 @@ class A {
|
||||
expect(element.flags, 0);
|
||||
}
|
||||
|
||||
void test_fromElement_ENUM() {
|
||||
test_fromElement_ENUM() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
@deprecated
|
||||
enum _E1 { one, two }
|
||||
enum E2 { three, four }''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
{
|
||||
engine.ClassElement engineElement = findElementInUnit(unit, '_E1');
|
||||
expect(engineElement.isDeprecated, isTrue);
|
||||
@@ -224,14 +224,14 @@ enum E2 { three, four }''');
|
||||
}
|
||||
}
|
||||
|
||||
void test_fromElement_ENUM_CONSTANT() {
|
||||
test_fromElement_ENUM_CONSTANT() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
@deprecated
|
||||
enum _E1 { one, two }
|
||||
enum E2 { three, four }''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
{
|
||||
engine.FieldElement engineElement = findElementInUnit(unit, 'one');
|
||||
// create notification Element
|
||||
@@ -312,14 +312,14 @@ enum E2 { three, four }''');
|
||||
}
|
||||
}
|
||||
|
||||
void test_fromElement_FIELD() {
|
||||
test_fromElement_FIELD() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
static const myField = 42;
|
||||
}''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
engine.FieldElement engineElement = findElementInUnit(unit, 'myField');
|
||||
// create notification Element
|
||||
Element element = convertElement(engineElement);
|
||||
@@ -338,13 +338,13 @@ class A {
|
||||
expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC);
|
||||
}
|
||||
|
||||
void test_fromElement_FUNCTION_TYPE_ALIAS() {
|
||||
test_fromElement_FUNCTION_TYPE_ALIAS() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
typedef int F<T>(String x);
|
||||
''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
engine.FunctionTypeAliasElement engineElement =
|
||||
findElementInUnit(unit, 'F');
|
||||
// create notification Element
|
||||
@@ -365,14 +365,14 @@ typedef int F<T>(String x);
|
||||
expect(element.flags, 0);
|
||||
}
|
||||
|
||||
void test_fromElement_GETTER() {
|
||||
test_fromElement_GETTER() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
String get myGetter => 42;
|
||||
}''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
engine.PropertyAccessorElement engineElement =
|
||||
findElementInUnit(unit, 'myGetter', engine.ElementKind.GETTER);
|
||||
// create notification Element
|
||||
@@ -392,7 +392,7 @@ class A {
|
||||
expect(element.flags, 0);
|
||||
}
|
||||
|
||||
void test_fromElement_LABEL() {
|
||||
test_fromElement_LABEL() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
@@ -402,7 +402,7 @@ myLabel:
|
||||
break myLabel;
|
||||
}
|
||||
}''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
engine.LabelElement engineElement = findElementInUnit(unit, 'myLabel');
|
||||
// create notification Element
|
||||
Element element = convertElement(engineElement);
|
||||
@@ -421,7 +421,7 @@ myLabel:
|
||||
expect(element.flags, 0);
|
||||
}
|
||||
|
||||
void test_fromElement_METHOD() {
|
||||
test_fromElement_METHOD() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
@@ -430,7 +430,7 @@ class A {
|
||||
return null;
|
||||
}
|
||||
}''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
engine.MethodElement engineElement = findElementInUnit(unit, 'myMethod');
|
||||
// create notification Element
|
||||
Element element = convertElement(engineElement);
|
||||
@@ -449,14 +449,14 @@ class A {
|
||||
expect(element.flags, Element.FLAG_STATIC);
|
||||
}
|
||||
|
||||
void test_fromElement_SETTER() {
|
||||
test_fromElement_SETTER() async {
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
set mySetter(String x) {}
|
||||
}''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
engine.CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
engine.FieldElement engineFieldElement =
|
||||
findElementInUnit(unit, 'mySetter', engine.ElementKind.FIELD);
|
||||
engine.PropertyAccessorElement engineElement = engineFieldElement.setter;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -21,8 +21,8 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class VariableNameSuggestionTest extends AbstractSingleUnitTest {
|
||||
void test_forExpression_cast() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_cast() async {
|
||||
await resolveTestUnit('''
|
||||
main() {
|
||||
var sortedNodes;
|
||||
var res = sortedNodes as String;
|
||||
@@ -34,8 +34,8 @@ main() {
|
||||
unorderedEquals(['sortedNodes', 'nodes']));
|
||||
}
|
||||
|
||||
void test_forExpression_expectedType() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_expectedType() async {
|
||||
await resolveTestUnit('''
|
||||
class TreeNode {}
|
||||
main() {
|
||||
TreeNode node = null;
|
||||
@@ -50,8 +50,8 @@ main() {
|
||||
expect(suggestions, unorderedEquals(['treeNode', 'node']));
|
||||
}
|
||||
|
||||
void test_forExpression_expectedType_double() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_expectedType_double() async {
|
||||
await resolveTestUnit('''
|
||||
main() {
|
||||
double res = 0.0;
|
||||
}
|
||||
@@ -70,8 +70,8 @@ main() {
|
||||
unorderedEquals(['f']));
|
||||
}
|
||||
|
||||
void test_forExpression_expectedType_int() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_expectedType_int() async {
|
||||
await resolveTestUnit('''
|
||||
main() {
|
||||
int res = 0;
|
||||
}
|
||||
@@ -90,8 +90,8 @@ main() {
|
||||
unorderedEquals(['k']));
|
||||
}
|
||||
|
||||
void test_forExpression_expectedType_String() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_expectedType_String() async {
|
||||
await resolveTestUnit('''
|
||||
main() {
|
||||
String res = 'abc';
|
||||
}
|
||||
@@ -105,9 +105,9 @@ main() {
|
||||
unorderedEquals(['s']));
|
||||
}
|
||||
|
||||
void test_forExpression_instanceCreation() {
|
||||
test_forExpression_instanceCreation() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
resolveTestUnit('''
|
||||
await resolveTestUnit('''
|
||||
import 'dart:math' as p;
|
||||
main(p) {
|
||||
new NoSuchClass();
|
||||
@@ -134,8 +134,8 @@ main(p) {
|
||||
// unorderedEquals(['noSuchClass', 'suchClass', 'class']));
|
||||
}
|
||||
|
||||
void test_forExpression_invocationArgument_named() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_invocationArgument_named() async {
|
||||
await resolveTestUnit('''
|
||||
foo({a, b, c}) {}
|
||||
main() {
|
||||
foo(a: 111, c: 333, b: 222);
|
||||
@@ -159,8 +159,8 @@ main() {
|
||||
}
|
||||
}
|
||||
|
||||
void test_forExpression_invocationArgument_optional() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_invocationArgument_optional() async {
|
||||
await resolveTestUnit('''
|
||||
foo(a, [b = 2, c = 3]) {}
|
||||
main() {
|
||||
foo(111, 222, 333);
|
||||
@@ -184,8 +184,8 @@ main() {
|
||||
}
|
||||
}
|
||||
|
||||
void test_forExpression_invocationArgument_positional() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_invocationArgument_positional() async {
|
||||
await resolveTestUnit('''
|
||||
foo(a, b) {}
|
||||
main() {
|
||||
foo(111, 222);
|
||||
@@ -204,8 +204,8 @@ main() {
|
||||
}
|
||||
}
|
||||
|
||||
void test_forExpression_methodInvocation() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_methodInvocation() async {
|
||||
await resolveTestUnit('''
|
||||
main(p) {
|
||||
var res = p.getSortedNodes();
|
||||
}
|
||||
@@ -216,8 +216,8 @@ main(p) {
|
||||
unorderedEquals(['sortedNodes', 'nodes']));
|
||||
}
|
||||
|
||||
void test_forExpression_methodInvocation_noPrefix() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_methodInvocation_noPrefix() async {
|
||||
await resolveTestUnit('''
|
||||
main(p) {
|
||||
var res = p.sortedNodes();
|
||||
}
|
||||
@@ -228,8 +228,8 @@ main(p) {
|
||||
unorderedEquals(['sortedNodes', 'nodes']));
|
||||
}
|
||||
|
||||
void test_forExpression_name_get() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_name_get() async {
|
||||
await resolveTestUnit('''
|
||||
main(p) {
|
||||
var res = p.get();
|
||||
}
|
||||
@@ -240,8 +240,8 @@ main(p) {
|
||||
unorderedEquals([]));
|
||||
}
|
||||
|
||||
void test_forExpression_prefixedIdentifier() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_prefixedIdentifier() async {
|
||||
await resolveTestUnit('''
|
||||
main(p) {
|
||||
var res = p.sortedNodes;
|
||||
}
|
||||
@@ -255,8 +255,8 @@ main(p) {
|
||||
unorderedEquals(['sortedNodes', 'nodes']));
|
||||
}
|
||||
|
||||
void test_forExpression_privateName() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_privateName() async {
|
||||
await resolveTestUnit('''
|
||||
main(p) {
|
||||
p._name;
|
||||
p._computeSuffix();
|
||||
@@ -277,8 +277,8 @@ main(p) {
|
||||
unorderedEquals(['computeSuffix', 'suffix']));
|
||||
}
|
||||
|
||||
void test_forExpression_propertyAccess() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_propertyAccess() async {
|
||||
await resolveTestUnit('''
|
||||
main(p) {
|
||||
var res = p.q.sortedNodes;
|
||||
}
|
||||
@@ -290,8 +290,8 @@ main(p) {
|
||||
unorderedEquals(['sortedNodes', 'nodes']));
|
||||
}
|
||||
|
||||
void test_forExpression_simpleName() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_simpleName() async {
|
||||
await resolveTestUnit('''
|
||||
main(p) {
|
||||
var sortedNodes = null;
|
||||
var res = sortedNodes;
|
||||
@@ -303,8 +303,8 @@ main(p) {
|
||||
unorderedEquals(['sortedNodes', 'nodes']));
|
||||
}
|
||||
|
||||
void test_forExpression_unqualifiedInvocation() {
|
||||
resolveTestUnit('''
|
||||
test_forExpression_unqualifiedInvocation() async {
|
||||
await resolveTestUnit('''
|
||||
getSortedNodes() => [];
|
||||
main(p) {
|
||||
var res = getSortedNodes();
|
||||
|
||||
@@ -23,22 +23,22 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class SourceRangesTest extends AbstractSingleUnitTest {
|
||||
void test_rangeElementName() {
|
||||
resolveTestUnit('class ABC {}');
|
||||
test_rangeElementName() async {
|
||||
await resolveTestUnit('class ABC {}');
|
||||
Element element = findElement('ABC');
|
||||
expect(rangeElementName(element), new SourceRange(6, 3));
|
||||
}
|
||||
|
||||
void test_rangeEndEnd_nodeNode() {
|
||||
resolveTestUnit('main() {}');
|
||||
test_rangeEndEnd_nodeNode() async {
|
||||
await resolveTestUnit('main() {}');
|
||||
FunctionDeclaration mainFunction = testUnit.declarations[0];
|
||||
SimpleIdentifier mainName = mainFunction.name;
|
||||
FunctionBody mainBody = mainFunction.functionExpression.body;
|
||||
expect(rangeEndEnd(mainName, mainBody), new SourceRange(4, 5));
|
||||
}
|
||||
|
||||
void test_rangeEndStart_nodeNode() {
|
||||
resolveTestUnit('main() {}');
|
||||
test_rangeEndStart_nodeNode() async {
|
||||
await resolveTestUnit('main() {}');
|
||||
FunctionDeclaration mainFunction = testUnit.declarations[0];
|
||||
SimpleIdentifier mainName = mainFunction.name;
|
||||
FunctionBody mainBody = mainFunction.functionExpression.body;
|
||||
@@ -51,23 +51,23 @@ class SourceRangesTest extends AbstractSingleUnitTest {
|
||||
expect(rangeError(error), new SourceRange(10, 5));
|
||||
}
|
||||
|
||||
void test_rangeNode() {
|
||||
resolveTestUnit('main() {}');
|
||||
test_rangeNode() async {
|
||||
await resolveTestUnit('main() {}');
|
||||
FunctionDeclaration mainFunction = testUnit.declarations[0];
|
||||
SimpleIdentifier mainName = mainFunction.name;
|
||||
expect(rangeNode(mainName), new SourceRange(0, 4));
|
||||
}
|
||||
|
||||
void test_rangeNodes() {
|
||||
resolveTestUnit(' main() {}');
|
||||
test_rangeNodes() async {
|
||||
await resolveTestUnit(' main() {}');
|
||||
FunctionDeclaration mainFunction = testUnit.declarations[0];
|
||||
SimpleIdentifier mainName = mainFunction.name;
|
||||
FunctionBody mainBody = mainFunction.functionExpression.body;
|
||||
expect(rangeNodes([mainName, mainBody]), new SourceRange(1, 9));
|
||||
}
|
||||
|
||||
void test_rangeNodes_empty() {
|
||||
resolveTestUnit('main() {}');
|
||||
test_rangeNodes_empty() async {
|
||||
await resolveTestUnit('main() {}');
|
||||
expect(rangeNodes([]), new SourceRange(0, 0));
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ class SourceRangesTest extends AbstractSingleUnitTest {
|
||||
expect(rangeStartEnd(10, 25), new SourceRange(10, 15));
|
||||
}
|
||||
|
||||
void test_rangeStartEnd_nodeNode() {
|
||||
resolveTestUnit(' main() {}');
|
||||
test_rangeStartEnd_nodeNode() async {
|
||||
await resolveTestUnit(' main() {}');
|
||||
FunctionDeclaration mainFunction = testUnit.declarations[0];
|
||||
SimpleIdentifier mainName = mainFunction.name;
|
||||
FunctionBody mainBody = mainFunction.functionExpression.body;
|
||||
@@ -87,8 +87,8 @@ class SourceRangesTest extends AbstractSingleUnitTest {
|
||||
expect(rangeStartLength(5, 10), new SourceRange(5, 10));
|
||||
}
|
||||
|
||||
void test_rangeStartLength_node() {
|
||||
resolveTestUnit(' main() {}');
|
||||
test_rangeStartLength_node() async {
|
||||
await resolveTestUnit(' main() {}');
|
||||
FunctionDeclaration mainFunction = testUnit.declarations[0];
|
||||
SimpleIdentifier mainName = mainFunction.name;
|
||||
expect(rangeStartLength(mainName, 10), new SourceRange(1, 10));
|
||||
@@ -98,16 +98,16 @@ class SourceRangesTest extends AbstractSingleUnitTest {
|
||||
expect(rangeStartStart(10, 25), new SourceRange(10, 15));
|
||||
}
|
||||
|
||||
void test_rangeStartStart_nodeNode() {
|
||||
resolveTestUnit('main() {}');
|
||||
test_rangeStartStart_nodeNode() async {
|
||||
await resolveTestUnit('main() {}');
|
||||
FunctionDeclaration mainFunction = testUnit.declarations[0];
|
||||
SimpleIdentifier mainName = mainFunction.name;
|
||||
FunctionBody mainBody = mainFunction.functionExpression.body;
|
||||
expect(rangeStartStart(mainName, mainBody), new SourceRange(0, 7));
|
||||
}
|
||||
|
||||
void test_rangeToken() {
|
||||
resolveTestUnit(' main() {}');
|
||||
test_rangeToken() async {
|
||||
await resolveTestUnit(' main() {}');
|
||||
FunctionDeclaration mainFunction = testUnit.declarations[0];
|
||||
SimpleIdentifier mainName = mainFunction.name;
|
||||
expect(rangeToken(mainName.beginToken), new SourceRange(1, 4));
|
||||
|
||||
@@ -26,8 +26,8 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class RefactoringLocationTest extends AbstractSingleUnitTest {
|
||||
void test_createLocation_forElement() {
|
||||
resolveTestUnit('class MyClass {}');
|
||||
test_createLocation_forElement() async {
|
||||
await resolveTestUnit('class MyClass {}');
|
||||
Element element = findElement('MyClass');
|
||||
// check
|
||||
Location location = newLocation_fromElement(element);
|
||||
@@ -38,8 +38,8 @@ class RefactoringLocationTest extends AbstractSingleUnitTest {
|
||||
expect(location.startColumn, 7);
|
||||
}
|
||||
|
||||
void test_createLocation_forMatch() {
|
||||
resolveTestUnit('class MyClass {}');
|
||||
test_createLocation_forMatch() async {
|
||||
await resolveTestUnit('class MyClass {}');
|
||||
Element element = findElement('MyClass');
|
||||
SourceRange range = rangeElementName(element);
|
||||
SearchMatch match = new SearchMatchImpl(
|
||||
@@ -57,8 +57,8 @@ class RefactoringLocationTest extends AbstractSingleUnitTest {
|
||||
expect(location.length, range.length);
|
||||
}
|
||||
|
||||
void test_createLocation_forNode() {
|
||||
resolveTestUnit('''
|
||||
test_createLocation_forNode() async {
|
||||
await resolveTestUnit('''
|
||||
main() {
|
||||
}
|
||||
''');
|
||||
@@ -70,8 +70,8 @@ main() {
|
||||
expect(location.length, node.length);
|
||||
}
|
||||
|
||||
void test_createLocation_forUnit() {
|
||||
resolveTestUnit('');
|
||||
test_createLocation_forUnit() async {
|
||||
await resolveTestUnit('');
|
||||
SourceRange range = rangeStartLength(10, 20);
|
||||
// check
|
||||
Location location = newLocation_fromUnit(testUnit, range);
|
||||
|
||||
@@ -21,8 +21,8 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class UtilTest extends AbstractSingleUnitTest {
|
||||
test_addLibraryImports_dart_hasImports_between() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_hasImports_between() async {
|
||||
await resolveTestUnit('''
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
''');
|
||||
@@ -36,8 +36,8 @@ import 'dart:math';
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_hasImports_first() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_hasImports_first() async {
|
||||
await resolveTestUnit('''
|
||||
import 'dart:collection';
|
||||
import 'dart:math';
|
||||
''');
|
||||
@@ -51,8 +51,8 @@ import 'dart:math';
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_hasImports_last() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_hasImports_last() async {
|
||||
await resolveTestUnit('''
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
''');
|
||||
@@ -66,8 +66,8 @@ import 'dart:math';
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_hasImports_multiple() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_hasImports_multiple() async {
|
||||
await resolveTestUnit('''
|
||||
import 'dart:collection';
|
||||
import 'dart:math';
|
||||
''');
|
||||
@@ -83,8 +83,8 @@ import 'dart:math';
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_hasImports_multiple_first() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_hasImports_multiple_first() async {
|
||||
await resolveTestUnit('''
|
||||
import 'dart:html';
|
||||
import 'dart:math';
|
||||
''');
|
||||
@@ -100,8 +100,8 @@ import 'dart:math';
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_hasImports_multiple_last() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_hasImports_multiple_last() async {
|
||||
await resolveTestUnit('''
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
''');
|
||||
@@ -117,8 +117,8 @@ import 'dart:math';
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_hasLibraryDirective() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_hasLibraryDirective() async {
|
||||
await resolveTestUnit('''
|
||||
library test;
|
||||
|
||||
class A {}
|
||||
@@ -137,8 +137,8 @@ class A {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_noDirectives_hasComment() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_noDirectives_hasComment() async {
|
||||
await resolveTestUnit('''
|
||||
/// Comment.
|
||||
|
||||
class A {}
|
||||
@@ -157,8 +157,8 @@ class A {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_noDirectives_hasShebang() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_noDirectives_hasShebang() async {
|
||||
await resolveTestUnit('''
|
||||
#!/bin/dart
|
||||
|
||||
class A {}
|
||||
@@ -177,8 +177,8 @@ class A {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_dart_noDirectives_noShebang() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_dart_noDirectives_noShebang() async {
|
||||
await resolveTestUnit('''
|
||||
class A {}
|
||||
''');
|
||||
Source newLibrary1 = _getDartSource('dart:math');
|
||||
@@ -193,8 +193,8 @@ class A {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_package_hasDart_hasPackages_insertAfter() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_package_hasDart_hasPackages_insertAfter() async {
|
||||
await resolveTestUnit('''
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aaa/aaa.dart';
|
||||
@@ -210,8 +210,8 @@ import 'package:bbb/bbb.dart';
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_package_hasDart_hasPackages_insertBefore() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_package_hasDart_hasPackages_insertBefore() async {
|
||||
await resolveTestUnit('''
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:bbb/bbb.dart';
|
||||
@@ -227,8 +227,8 @@ import 'package:bbb/bbb.dart';
|
||||
''');
|
||||
}
|
||||
|
||||
test_addLibraryImports_package_hasImports_between() {
|
||||
resolveTestUnit('''
|
||||
test_addLibraryImports_package_hasImports_between() async {
|
||||
await resolveTestUnit('''
|
||||
import 'package:aaa/aaa.dart';
|
||||
import 'package:ddd/ddd.dart';
|
||||
''');
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
library test.services.dependencies.import_collector;
|
||||
|
||||
import 'package:analysis_server/src/services/dependencies/reachable_source_collector.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -20,9 +19,6 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class ReachableSourceCollectorTest extends AbstractContextTest {
|
||||
CompilationUnit addLibrary(String path, String contents) =>
|
||||
resolveLibraryUnit(addSource(path, contents));
|
||||
|
||||
Map<String, List<String>> importsFor(Source source) =>
|
||||
new ReachableSourceCollector(source, context).collectSources();
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/src/services/index/index.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
@@ -79,7 +81,7 @@ class IndexTest extends AbstractSingleUnitTest {
|
||||
}
|
||||
|
||||
test_getDefinedNames_classMember() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
@@ -100,7 +102,7 @@ class B {
|
||||
}
|
||||
|
||||
test_getDefinedNames_topLevel() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {} // A
|
||||
class B = Object with A;
|
||||
typedef C();
|
||||
@@ -124,7 +126,7 @@ class NoMatchABCDE {}
|
||||
}
|
||||
|
||||
test_getDefinedNames_topLevel2() async {
|
||||
_indexTestUnit(
|
||||
await _indexTestUnit(
|
||||
'''
|
||||
class A {} // A
|
||||
class B = Object with A;
|
||||
@@ -141,11 +143,11 @@ class NoMatchABCDE {}
|
||||
}
|
||||
|
||||
test_getRelations_isExtendedBy() async {
|
||||
_indexTestUnit(r'''
|
||||
await _indexTestUnit(r'''
|
||||
class A {}
|
||||
class B extends A {} // B
|
||||
''');
|
||||
Source source2 = _indexUnit(
|
||||
Source source2 = await _indexUnit(
|
||||
'/test2.dart',
|
||||
r'''
|
||||
import 'test.dart';
|
||||
@@ -159,7 +161,7 @@ class C extends A {} // C
|
||||
}
|
||||
|
||||
test_getRelations_isReferencedBy() async {
|
||||
_indexTestUnit(r'''
|
||||
await _indexTestUnit(r'''
|
||||
main(int a, int b) {
|
||||
}
|
||||
''');
|
||||
@@ -171,7 +173,7 @@ main(int a, int b) {
|
||||
}
|
||||
|
||||
test_getUnresolvedMemberReferences_qualified_resolved() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
var test; // A
|
||||
}
|
||||
@@ -188,7 +190,7 @@ main(A a) {
|
||||
}
|
||||
|
||||
test_getUnresolvedMemberReferences_qualified_unresolved() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
var test; // A
|
||||
}
|
||||
@@ -210,7 +212,7 @@ main(p) {
|
||||
}
|
||||
|
||||
test_getUnresolvedMemberReferences_unqualified_resolved() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
var test;
|
||||
m() {
|
||||
@@ -228,7 +230,7 @@ class A {
|
||||
|
||||
test_getUnresolvedMemberReferences_unqualified_unresolved() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
m() {
|
||||
print(test);
|
||||
@@ -249,7 +251,7 @@ class A {
|
||||
}
|
||||
|
||||
test_indexDeclarations_afterIndexUnit() async {
|
||||
resolveTestUnit('''
|
||||
await resolveTestUnit('''
|
||||
var a = 0;
|
||||
var b = a + 1;
|
||||
''');
|
||||
@@ -275,13 +277,13 @@ var b = a + 1;
|
||||
}
|
||||
|
||||
test_indexDeclarations_nullUnitElement() async {
|
||||
resolveTestUnit('');
|
||||
await resolveTestUnit('');
|
||||
testUnit.element = null;
|
||||
index.indexDeclarations(testUnit);
|
||||
}
|
||||
|
||||
test_indexUnit_nullLibraryElement() async {
|
||||
resolveTestUnit('');
|
||||
await resolveTestUnit('');
|
||||
CompilationUnitElement unitElement = new _CompilationUnitElementMock();
|
||||
expect(unitElement.library, isNull);
|
||||
testUnit.element = unitElement;
|
||||
@@ -293,13 +295,13 @@ var b = a + 1;
|
||||
}
|
||||
|
||||
test_indexUnit_nullUnitElement() async {
|
||||
resolveTestUnit('');
|
||||
await resolveTestUnit('');
|
||||
testUnit.element = null;
|
||||
index.indexUnit(testUnit);
|
||||
}
|
||||
|
||||
test_removeContext() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
''');
|
||||
RegExp regExp = new RegExp(r'^A$');
|
||||
@@ -315,8 +317,8 @@ class A {}
|
||||
RegExp regExp = new RegExp(r'^[AB]$');
|
||||
Source sourceA = addSource('/a.dart', 'class A {}');
|
||||
Source sourceB = addSource('/b.dart', 'class B {}');
|
||||
CompilationUnit unitA = resolveLibraryUnit(sourceA);
|
||||
CompilationUnit unitB = resolveLibraryUnit(sourceB);
|
||||
CompilationUnit unitA = await resolveLibraryUnit(sourceA);
|
||||
CompilationUnit unitB = await resolveLibraryUnit(sourceB);
|
||||
index.indexUnit(unitA);
|
||||
index.indexUnit(unitB);
|
||||
{
|
||||
@@ -356,8 +358,8 @@ class A {}
|
||||
'${locations.join('\n')}');
|
||||
}
|
||||
|
||||
void _indexTestUnit(String code, {bool declOnly: false}) {
|
||||
resolveTestUnit(code);
|
||||
Future<Null> _indexTestUnit(String code, {bool declOnly: false}) async {
|
||||
await resolveTestUnit(code);
|
||||
if (declOnly) {
|
||||
index.indexDeclarations(testUnit);
|
||||
} else {
|
||||
@@ -365,9 +367,9 @@ class A {}
|
||||
}
|
||||
}
|
||||
|
||||
Source _indexUnit(String path, String code) {
|
||||
Future<Source> _indexUnit(String path, String code) async {
|
||||
Source source = addSource(path, code);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
index.indexUnit(unit);
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:analysis_server/src/services/index/index_unit.dart';
|
||||
@@ -55,99 +56,99 @@ class PackageIndexAssemblerTest extends AbstractSingleUnitTest {
|
||||
return imports[index].importedLibrary.definingCompilationUnit;
|
||||
}
|
||||
|
||||
void test_definedName_classMember_field() {
|
||||
_indexTestUnit('''
|
||||
test_definedName_classMember_field() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
int f;
|
||||
}''');
|
||||
_assertDefinedName('f', IndexNameKind.classMember, 'f;');
|
||||
}
|
||||
|
||||
void test_definedName_classMember_getter() {
|
||||
_indexTestUnit('''
|
||||
test_definedName_classMember_getter() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
int get g => 0;
|
||||
}''');
|
||||
_assertDefinedName('g', IndexNameKind.classMember, 'g => 0;');
|
||||
}
|
||||
|
||||
void test_definedName_classMember_method() {
|
||||
_indexTestUnit('''
|
||||
test_definedName_classMember_method() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
m() {}
|
||||
}''');
|
||||
_assertDefinedName('m', IndexNameKind.classMember, 'm() {}');
|
||||
}
|
||||
|
||||
void test_definedName_classMember_operator() {
|
||||
_indexTestUnit('''
|
||||
test_definedName_classMember_operator() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
operator +(o) {}
|
||||
}''');
|
||||
_assertDefinedName('+', IndexNameKind.classMember, '+(o) {}');
|
||||
}
|
||||
|
||||
void test_definedName_classMember_setter() {
|
||||
_indexTestUnit('''
|
||||
test_definedName_classMember_setter() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
int set s (_) {}
|
||||
}''');
|
||||
_assertDefinedName('s', IndexNameKind.classMember, 's (_) {}');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_class() {
|
||||
_indexTestUnit('class A {}');
|
||||
test_definedName_topLevel_class() async {
|
||||
await _indexTestUnit('class A {}');
|
||||
_assertDefinedName('A', IndexNameKind.topLevel, 'A {}');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_class2() {
|
||||
_indexTestUnit('class A {}', declOnly: true);
|
||||
test_definedName_topLevel_class2() async {
|
||||
await _indexTestUnit('class A {}', declOnly: true);
|
||||
_assertDefinedName('A', IndexNameKind.topLevel, 'A {}');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_classAlias() {
|
||||
_indexTestUnit('''
|
||||
test_definedName_topLevel_classAlias() async {
|
||||
await _indexTestUnit('''
|
||||
class M {}
|
||||
class C = Object with M;''');
|
||||
_assertDefinedName('C', IndexNameKind.topLevel, 'C =');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_enum() {
|
||||
_indexTestUnit('enum E {a, b, c}');
|
||||
test_definedName_topLevel_enum() async {
|
||||
await _indexTestUnit('enum E {a, b, c}');
|
||||
_assertDefinedName('E', IndexNameKind.topLevel, 'E {');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_function() {
|
||||
_indexTestUnit('foo() {}');
|
||||
test_definedName_topLevel_function() async {
|
||||
await _indexTestUnit('foo() {}');
|
||||
_assertDefinedName('foo', IndexNameKind.topLevel, 'foo() {}');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_functionTypeAlias() {
|
||||
_indexTestUnit('typedef F(int p);');
|
||||
test_definedName_topLevel_functionTypeAlias() async {
|
||||
await _indexTestUnit('typedef F(int p);');
|
||||
_assertDefinedName('F', IndexNameKind.topLevel, 'F(int p);');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_getter() {
|
||||
_indexTestUnit('''
|
||||
test_definedName_topLevel_getter() async {
|
||||
await _indexTestUnit('''
|
||||
int get g => 0;
|
||||
''');
|
||||
_assertDefinedName('g', IndexNameKind.topLevel, 'g => 0;');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_setter() {
|
||||
_indexTestUnit('''
|
||||
test_definedName_topLevel_setter() async {
|
||||
await _indexTestUnit('''
|
||||
int set s (_) {}
|
||||
''');
|
||||
_assertDefinedName('s', IndexNameKind.topLevel, 's (_) {}');
|
||||
}
|
||||
|
||||
void test_definedName_topLevel_topLevelVariable() {
|
||||
_indexTestUnit('var V = 42;');
|
||||
test_definedName_topLevel_topLevelVariable() async {
|
||||
await _indexTestUnit('var V = 42;');
|
||||
_assertDefinedName('V', IndexNameKind.topLevel, 'V = 42;');
|
||||
}
|
||||
|
||||
void test_hasAncestor_ClassDeclaration() {
|
||||
_indexTestUnit('''
|
||||
test_hasAncestor_ClassDeclaration() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
class B1 extends A {}
|
||||
class B2 implements A {}
|
||||
@@ -168,8 +169,8 @@ class M extends Object with A {}
|
||||
..isAncestorOf('M extends Object with A');
|
||||
}
|
||||
|
||||
void test_hasAncestor_ClassTypeAlias() {
|
||||
_indexTestUnit('''
|
||||
test_hasAncestor_ClassTypeAlias() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
class B extends A {}
|
||||
class C1 = Object with A;
|
||||
@@ -183,8 +184,8 @@ class C2 = Object with B;
|
||||
assertThat(classElementB)..isAncestorOf('C2 = Object with B');
|
||||
}
|
||||
|
||||
void test_isExtendedBy_ClassDeclaration() {
|
||||
_indexTestUnit('''
|
||||
test_isExtendedBy_ClassDeclaration() async {
|
||||
await _indexTestUnit('''
|
||||
class A {} // 1
|
||||
class B extends A {} // 2
|
||||
''');
|
||||
@@ -194,13 +195,13 @@ class B extends A {} // 2
|
||||
..isReferencedAt('A {} // 2', false);
|
||||
}
|
||||
|
||||
void test_isExtendedBy_ClassDeclaration_isQualified() {
|
||||
test_isExtendedBy_ClassDeclaration_isQualified() async {
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
class A {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' as p;
|
||||
class B extends p.A {} // 2
|
||||
''');
|
||||
@@ -208,8 +209,8 @@ class B extends p.A {} // 2
|
||||
assertThat(elementA).isExtendedAt('A {} // 2', true);
|
||||
}
|
||||
|
||||
void test_isExtendedBy_ClassDeclaration_Object() {
|
||||
_indexTestUnit('''
|
||||
test_isExtendedBy_ClassDeclaration_Object() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
''');
|
||||
ClassElement elementA = findElement('A');
|
||||
@@ -217,8 +218,8 @@ class A {}
|
||||
assertThat(elementObject).isExtendedAt('A {}', true, length: 0);
|
||||
}
|
||||
|
||||
void test_isExtendedBy_ClassTypeAlias() {
|
||||
_indexTestUnit('''
|
||||
test_isExtendedBy_ClassTypeAlias() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
class B {}
|
||||
class C = A with B;
|
||||
@@ -229,13 +230,13 @@ class C = A with B;
|
||||
..isReferencedAt('A with', false);
|
||||
}
|
||||
|
||||
void test_isExtendedBy_ClassTypeAlias_isQualified() {
|
||||
test_isExtendedBy_ClassTypeAlias_isQualified() async {
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
class A {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' as p;
|
||||
class B {}
|
||||
class C = p.A with B;
|
||||
@@ -246,8 +247,8 @@ class C = p.A with B;
|
||||
..isReferencedAt('A with', true);
|
||||
}
|
||||
|
||||
void test_isImplementedBy_ClassDeclaration() {
|
||||
_indexTestUnit('''
|
||||
test_isImplementedBy_ClassDeclaration() async {
|
||||
await _indexTestUnit('''
|
||||
class A {} // 1
|
||||
class B implements A {} // 2
|
||||
''');
|
||||
@@ -257,13 +258,13 @@ class B implements A {} // 2
|
||||
..isReferencedAt('A {} // 2', false);
|
||||
}
|
||||
|
||||
void test_isImplementedBy_ClassDeclaration_isQualified() {
|
||||
test_isImplementedBy_ClassDeclaration_isQualified() async {
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
class A {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' as p;
|
||||
class B implements p.A {} // 2
|
||||
''');
|
||||
@@ -273,8 +274,8 @@ class B implements p.A {} // 2
|
||||
..isReferencedAt('A {} // 2', true);
|
||||
}
|
||||
|
||||
void test_isImplementedBy_ClassTypeAlias() {
|
||||
_indexTestUnit('''
|
||||
test_isImplementedBy_ClassTypeAlias() async {
|
||||
await _indexTestUnit('''
|
||||
class A {} // 1
|
||||
class B {} // 2
|
||||
class C = Object with A implements B; // 3
|
||||
@@ -285,8 +286,8 @@ class C = Object with A implements B; // 3
|
||||
..isReferencedAt('B; // 3', false);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_FieldElement() {
|
||||
_indexTestUnit('''
|
||||
test_isInvokedBy_FieldElement() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
var field;
|
||||
main() {
|
||||
@@ -300,14 +301,14 @@ class A {
|
||||
..isInvokedAt('field(); // nq', false);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_FunctionElement() {
|
||||
test_isInvokedBy_FunctionElement() async {
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library lib;
|
||||
foo() {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart';
|
||||
import 'lib.dart' as pref;
|
||||
main() {
|
||||
@@ -320,9 +321,9 @@ main() {
|
||||
..isInvokedAt('foo(); // nq', false);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_FunctionElement_synthetic_loadLibrary() {
|
||||
test_isInvokedBy_FunctionElement_synthetic_loadLibrary() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'dart:math' deferred as math;
|
||||
main() {
|
||||
math.loadLibrary(); // 1
|
||||
@@ -335,8 +336,8 @@ main() {
|
||||
assertThat(element).isInvokedAt('loadLibrary(); // 2', true);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_MethodElement() {
|
||||
_indexTestUnit('''
|
||||
test_isInvokedBy_MethodElement() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
foo() {}
|
||||
main() {
|
||||
@@ -350,8 +351,8 @@ class A {
|
||||
..isInvokedAt('foo(); // nq', false);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_MethodElement_propagatedType() {
|
||||
_indexTestUnit('''
|
||||
test_isInvokedBy_MethodElement_propagatedType() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
foo() {}
|
||||
}
|
||||
@@ -364,8 +365,8 @@ main() {
|
||||
assertThat(element).isInvokedAt('foo();', true);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_operator_binary() {
|
||||
_indexTestUnit('''
|
||||
test_isInvokedBy_operator_binary() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
operator +(other) => this;
|
||||
}
|
||||
@@ -384,8 +385,8 @@ main(A a) {
|
||||
..isInvokedAt('++;', true, length: 2);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_operator_index() {
|
||||
_indexTestUnit('''
|
||||
test_isInvokedBy_operator_index() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
operator [](i) => null;
|
||||
operator []=(i, v) {}
|
||||
@@ -401,8 +402,8 @@ main(A a) {
|
||||
assertThat(writeElement).isInvokedAt('[1]', true, length: 1);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_operator_prefix() {
|
||||
_indexTestUnit('''
|
||||
test_isInvokedBy_operator_prefix() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A operator ~() => this;
|
||||
}
|
||||
@@ -414,8 +415,8 @@ main(A a) {
|
||||
assertThat(element).isInvokedAt('~a', true, length: 1);
|
||||
}
|
||||
|
||||
void test_isInvokedBy_PropertyAccessorElement_getter() {
|
||||
_indexTestUnit('''
|
||||
test_isInvokedBy_PropertyAccessorElement_getter() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
get ggg => null;
|
||||
main() {
|
||||
@@ -429,8 +430,8 @@ class A {
|
||||
..isInvokedAt('ggg(); // nq', false);
|
||||
}
|
||||
|
||||
void test_isMixedInBy_ClassDeclaration() {
|
||||
_indexTestUnit('''
|
||||
test_isMixedInBy_ClassDeclaration() async {
|
||||
await _indexTestUnit('''
|
||||
class A {} // 1
|
||||
class B extends Object with A {} // 2
|
||||
''');
|
||||
@@ -440,13 +441,13 @@ class B extends Object with A {} // 2
|
||||
..isReferencedAt('A {} // 2', false);
|
||||
}
|
||||
|
||||
void test_isMixedInBy_ClassDeclaration_isQualified() {
|
||||
test_isMixedInBy_ClassDeclaration_isQualified() async {
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
class A {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' as p;
|
||||
class B extends Object with p.A {} // 2
|
||||
''');
|
||||
@@ -454,8 +455,8 @@ class B extends Object with p.A {} // 2
|
||||
assertThat(elementA).isMixedInAt('A {} // 2', true);
|
||||
}
|
||||
|
||||
void test_isMixedInBy_ClassTypeAlias() {
|
||||
_indexTestUnit('''
|
||||
test_isMixedInBy_ClassTypeAlias() async {
|
||||
await _indexTestUnit('''
|
||||
class A {} // 1
|
||||
class B = Object with A; // 2
|
||||
''');
|
||||
@@ -463,8 +464,8 @@ class B = Object with A; // 2
|
||||
assertThat(elementA).isMixedInAt('A; // 2', false);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ClassElement() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ClassElement() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
static var field;
|
||||
}
|
||||
@@ -484,9 +485,9 @@ main(A p) {
|
||||
..isReferencedAt('A.field); // 3', false);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ClassElement_invocation() {
|
||||
test_isReferencedBy_ClassElement_invocation() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
main() {
|
||||
A(); // invalid code, but still a reference
|
||||
@@ -495,14 +496,14 @@ main() {
|
||||
assertThat(element).isReferencedAt('A();', false);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ClassElement_invocation_isQualified() {
|
||||
test_isReferencedBy_ClassElement_invocation_isQualified() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
class A {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' as p;
|
||||
main() {
|
||||
p.A(); // invalid code, but still a reference
|
||||
@@ -511,8 +512,8 @@ main() {
|
||||
assertThat(element).isReferencedAt('A();', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ClassTypeAlias() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ClassTypeAlias() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
class B = Object with A;
|
||||
main(B p) {
|
||||
@@ -525,35 +526,35 @@ main(B p) {
|
||||
..isReferencedAt('B v;', false);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_CompilationUnitElement_export() {
|
||||
test_isReferencedBy_CompilationUnitElement_export() async {
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library lib;
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
export 'lib.dart';
|
||||
''');
|
||||
LibraryElement element = testLibraryElement.exports[0].exportedLibrary;
|
||||
assertThat(element)..isReferencedAt("'lib.dart'", true, length: 10);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_CompilationUnitElement_import() {
|
||||
test_isReferencedBy_CompilationUnitElement_import() async {
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library lib;
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart';
|
||||
''');
|
||||
LibraryElement element = testLibraryElement.imports[0].importedLibrary;
|
||||
assertThat(element)..isReferencedAt("'lib.dart'", true, length: 10);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_CompilationUnitElement_part() {
|
||||
test_isReferencedBy_CompilationUnitElement_part() async {
|
||||
addSource('/my_unit.dart', 'part of my_lib;');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
library my_lib;
|
||||
part 'my_unit.dart';
|
||||
''');
|
||||
@@ -561,8 +562,8 @@ part 'my_unit.dart';
|
||||
assertThat(element)..isReferencedAt("'my_unit.dart';", true, length: 14);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ConstructorElement() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ConstructorElement() async {
|
||||
await _indexTestUnit('''
|
||||
class A implements B {
|
||||
A() {}
|
||||
A.foo() {}
|
||||
@@ -593,8 +594,8 @@ main() {
|
||||
..isReferencedAt('.foo(); // 5', true, length: 4);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ConstructorElement_classTypeAlias() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ConstructorElement_classTypeAlias() async {
|
||||
await _indexTestUnit('''
|
||||
class M {}
|
||||
class A implements B {
|
||||
A() {}
|
||||
@@ -620,8 +621,8 @@ main() {
|
||||
..isReferencedAt('.named(); // C2', true, length: 6);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ConstructorElement_classTypeAlias_cycle() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ConstructorElement_classTypeAlias_cycle() async {
|
||||
await _indexTestUnit('''
|
||||
class M {}
|
||||
class A = B with M;
|
||||
class B = A with M;
|
||||
@@ -633,8 +634,8 @@ main() {
|
||||
// No additional validation, but it should not fail with stack overflow.
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ConstructorElement_namedOnlyWithDot() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ConstructorElement_namedOnlyWithDot() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A.named() {}
|
||||
}
|
||||
@@ -649,8 +650,8 @@ main() {
|
||||
expect(unitIndex.usedElementOffsets, contains(offsetWithDot));
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ConstructorElement_redirection() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ConstructorElement_redirection() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A() : this.bar(); // 1
|
||||
A.foo() : this(); // 2
|
||||
@@ -664,8 +665,8 @@ class A {
|
||||
assertThat(constA_bar).isReferencedAt('.bar(); // 1', true, length: 4);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ConstructorElement_synthetic() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ConstructorElement_synthetic() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
main() {
|
||||
new A(); // 1
|
||||
@@ -677,15 +678,15 @@ main() {
|
||||
assertThat(constA)..isReferencedAt('(); // 1', true, length: 0);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_DynamicElement() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_DynamicElement() async {
|
||||
await _indexTestUnit('''
|
||||
dynamic f() {
|
||||
}''');
|
||||
expect(unitIndex.usedElementOffsets, isEmpty);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FieldElement() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_FieldElement() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
var field;
|
||||
A({this.field});
|
||||
@@ -714,8 +715,8 @@ main(A a) {
|
||||
assertThat(field)..isReferencedAt('field: 4', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FieldElement_multiple() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_FieldElement_multiple() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
var aaa;
|
||||
var bbb;
|
||||
@@ -748,9 +749,9 @@ class A {
|
||||
}
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FieldElement_ofEnum() {
|
||||
test_isReferencedBy_FieldElement_ofEnum() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
enum MyEnum {
|
||||
A, B, C
|
||||
}
|
||||
@@ -769,9 +770,9 @@ main() {
|
||||
assertThat(enumElement.getGetter('B'))..isReferencedAt('B);', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FieldElement_synthetic_hasGetter() {
|
||||
test_isReferencedBy_FieldElement_synthetic_hasGetter() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A() : f = 42;
|
||||
int get f => 0;
|
||||
@@ -781,9 +782,9 @@ class A {
|
||||
assertThat(element2.getField('f')).isWrittenAt('f = 42', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FieldElement_synthetic_hasGetterSetter() {
|
||||
test_isReferencedBy_FieldElement_synthetic_hasGetterSetter() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A() : f = 42;
|
||||
int get f => 0;
|
||||
@@ -794,9 +795,9 @@ class A {
|
||||
assertThat(element2.getField('f')).isWrittenAt('f = 42', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FieldElement_synthetic_hasSetter() {
|
||||
test_isReferencedBy_FieldElement_synthetic_hasSetter() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A() : f = 42;
|
||||
set f(_) {}
|
||||
@@ -806,8 +807,8 @@ class A {
|
||||
assertThat(element2.getField('f')).isWrittenAt('f = 42', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FunctionElement() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_FunctionElement() async {
|
||||
await _indexTestUnit('''
|
||||
foo() {}
|
||||
main() {
|
||||
print(foo);
|
||||
@@ -820,13 +821,13 @@ main() {
|
||||
..isInvokedAt('foo());', false);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FunctionElement_with_LibraryElement() {
|
||||
test_isReferencedBy_FunctionElement_with_LibraryElement() async {
|
||||
addSource(
|
||||
'/foo.dart',
|
||||
r'''
|
||||
bar() {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import "foo.dart";
|
||||
main() {
|
||||
bar();
|
||||
@@ -840,8 +841,8 @@ main() {
|
||||
}
|
||||
}
|
||||
|
||||
void test_isReferencedBy_FunctionTypeAliasElement() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_FunctionTypeAliasElement() async {
|
||||
await _indexTestUnit('''
|
||||
typedef A();
|
||||
main(A p) {
|
||||
}
|
||||
@@ -857,8 +858,8 @@ main(A p) {
|
||||
* This caused duplicate indexing.
|
||||
* Here we test that the problem is fixed one way or another.
|
||||
*/
|
||||
void test_isReferencedBy_identifierInComment() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_identifierInComment() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
/// [A] text
|
||||
var myVariable = null;
|
||||
@@ -867,8 +868,8 @@ var myVariable = null;
|
||||
assertThat(element)..isReferencedAt('A] text', false);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_MethodElement() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_MethodElement() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
method() {}
|
||||
main() {
|
||||
@@ -882,8 +883,8 @@ class A {
|
||||
..isReferencedAt('method); // nq', false);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_ParameterElement() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_ParameterElement() async {
|
||||
await _indexTestUnit('''
|
||||
foo({var p}) {}
|
||||
main() {
|
||||
foo(p: 1);
|
||||
@@ -893,14 +894,14 @@ main() {
|
||||
assertThat(element)..isReferencedAt('p: 1', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_TopLevelVariableElement() {
|
||||
test_isReferencedBy_TopLevelVariableElement() async {
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library lib;
|
||||
var V;
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' show V; // imp
|
||||
import 'lib.dart' as pref;
|
||||
main() {
|
||||
@@ -919,7 +920,7 @@ main() {
|
||||
..isReferencedAt('V = 5; // nq', false);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_TopLevelVariableElement_synthetic_hasGetterSetter() {
|
||||
test_isReferencedBy_TopLevelVariableElement_synthetic_hasGetterSetter() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
@@ -927,29 +928,29 @@ main() {
|
||||
int get V => 0;
|
||||
void set V(_) {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' show V;
|
||||
''');
|
||||
TopLevelVariableElement element = importedUnit().topLevelVariables[0];
|
||||
assertThat(element).isReferencedAt('V;', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_TopLevelVariableElement_synthetic_hasSetter() {
|
||||
test_isReferencedBy_TopLevelVariableElement_synthetic_hasSetter() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
addSource(
|
||||
'/lib.dart',
|
||||
'''
|
||||
void set V(_) {}
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' show V;
|
||||
''');
|
||||
TopLevelVariableElement element = importedUnit().topLevelVariables[0];
|
||||
assertThat(element).isReferencedAt('V;', true);
|
||||
}
|
||||
|
||||
void test_isReferencedBy_typeInVariableList() {
|
||||
_indexTestUnit('''
|
||||
test_isReferencedBy_typeInVariableList() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
A myVariable = null;
|
||||
''');
|
||||
@@ -957,8 +958,8 @@ A myVariable = null;
|
||||
assertThat(element).isReferencedAt('A myVariable', false);
|
||||
}
|
||||
|
||||
void test_isWrittenBy_FieldElement() {
|
||||
_indexTestUnit('''
|
||||
test_isWrittenBy_FieldElement() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
int field;
|
||||
A.foo({this.field});
|
||||
@@ -971,9 +972,9 @@ class A {
|
||||
..isWrittenAt('field = 5', true);
|
||||
}
|
||||
|
||||
void test_usedName_inLibraryIdentifier() {
|
||||
test_usedName_inLibraryIdentifier() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
library aaa.bbb.ccc;
|
||||
class C {
|
||||
var bbb;
|
||||
@@ -987,9 +988,9 @@ main(p) {
|
||||
..isUsedQ('bbb = 1;', IndexRelationKind.IS_WRITTEN_BY);
|
||||
}
|
||||
|
||||
void test_usedName_qualified_resolved() {
|
||||
test_usedName_qualified_resolved() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class C {
|
||||
var x;
|
||||
}
|
||||
@@ -1007,9 +1008,9 @@ main(C c) {
|
||||
..isNotUsedQ('x();', IndexRelationKind.IS_INVOKED_BY);
|
||||
}
|
||||
|
||||
void test_usedName_qualified_unresolved() {
|
||||
test_usedName_qualified_unresolved() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
main(p) {
|
||||
p.x;
|
||||
p.x = 1;
|
||||
@@ -1024,9 +1025,9 @@ main(p) {
|
||||
..isUsedQ('x();', IndexRelationKind.IS_INVOKED_BY);
|
||||
}
|
||||
|
||||
void test_usedName_unqualified_resolved() {
|
||||
test_usedName_unqualified_resolved() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class C {
|
||||
var x;
|
||||
m() {
|
||||
@@ -1044,9 +1045,9 @@ class C {
|
||||
..isNotUsedQ('x();', IndexRelationKind.IS_INVOKED_BY);
|
||||
}
|
||||
|
||||
void test_usedName_unqualified_unresolved() {
|
||||
test_usedName_unqualified_unresolved() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
main() {
|
||||
x;
|
||||
x = 1;
|
||||
@@ -1217,8 +1218,8 @@ main() {
|
||||
return _getStringId(str);
|
||||
}
|
||||
|
||||
void _indexTestUnit(String code, {bool declOnly: false}) {
|
||||
resolveTestUnit(code);
|
||||
Future<Null> _indexTestUnit(String code, {bool declOnly: false}) async {
|
||||
await resolveTestUnit(code);
|
||||
PackageIndexAssembler assembler = new PackageIndexAssembler();
|
||||
if (declOnly) {
|
||||
assembler.indexDeclarations(testUnit);
|
||||
|
||||
@@ -160,14 +160,14 @@ abstract class RefactoringTest extends AbstractSingleUnitTest {
|
||||
.resolveCompilationUnit(element.source, element.library);
|
||||
}
|
||||
|
||||
void indexTestUnit(String code) {
|
||||
resolveTestUnit(code);
|
||||
Future<Null> indexTestUnit(String code) async {
|
||||
await resolveTestUnit(code);
|
||||
index.indexUnit(testUnit);
|
||||
}
|
||||
|
||||
void indexUnit(String file, String code) {
|
||||
Future<Null> indexUnit(String file, String code) async {
|
||||
Source source = addSource(file, code);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
index.indexUnit(unit);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ main() {
|
||||
class ConvertGetterToMethodTest extends RefactoringTest {
|
||||
ConvertGetterToMethodRefactoring refactoring;
|
||||
|
||||
test_change_function() {
|
||||
indexTestUnit('''
|
||||
test_change_function() async {
|
||||
await indexTestUnit('''
|
||||
int get test => 42;
|
||||
main() {
|
||||
var a = test;
|
||||
@@ -43,8 +43,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_change_method() {
|
||||
indexTestUnit('''
|
||||
test_change_method() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
int get test => 1;
|
||||
}
|
||||
@@ -88,15 +88,15 @@ main(A a, B b, C c, D d) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_change_multipleFiles() {
|
||||
indexUnit(
|
||||
test_change_multipleFiles() async {
|
||||
await indexUnit(
|
||||
'/other.dart',
|
||||
r'''
|
||||
class A {
|
||||
int get test => 1;
|
||||
}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
import 'other.dart';
|
||||
class B extends A {
|
||||
int get test => 2;
|
||||
@@ -120,8 +120,8 @@ main(A a, B b) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_checkInitialConditions_syntheticGetter() {
|
||||
indexTestUnit('''
|
||||
test_checkInitialConditions_syntheticGetter() async {
|
||||
await indexTestUnit('''
|
||||
int test = 42;
|
||||
main() {
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ main() {
|
||||
class ConvertMethodToGetterTest extends RefactoringTest {
|
||||
ConvertMethodToGetterRefactoring refactoring;
|
||||
|
||||
test_change_function() {
|
||||
indexTestUnit('''
|
||||
test_change_function() async {
|
||||
await indexTestUnit('''
|
||||
int test() => 42;
|
||||
main() {
|
||||
var a = test();
|
||||
@@ -44,8 +44,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_change_method() {
|
||||
indexTestUnit('''
|
||||
test_change_method() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
int test() => 1;
|
||||
}
|
||||
@@ -89,15 +89,15 @@ main(A a, B b, C c, D d) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_change_multipleFiles() {
|
||||
indexUnit(
|
||||
test_change_multipleFiles() async {
|
||||
await indexUnit(
|
||||
'/other.dart',
|
||||
r'''
|
||||
class A {
|
||||
int test() => 1;
|
||||
}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
import 'other.dart';
|
||||
class B extends A {
|
||||
int test() => 2;
|
||||
@@ -121,8 +121,8 @@ main(A a, B b) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_checkInitialConditions_alreadyGetter() {
|
||||
indexTestUnit('''
|
||||
test_checkInitialConditions_alreadyGetter() async {
|
||||
await indexTestUnit('''
|
||||
int get test => 42;
|
||||
main() {
|
||||
var a = test;
|
||||
@@ -136,8 +136,8 @@ main() {
|
||||
'Only class methods or top-level functions can be converted to getters.');
|
||||
}
|
||||
|
||||
test_checkInitialConditions_hasParameters() {
|
||||
indexTestUnit('''
|
||||
test_checkInitialConditions_hasParameters() async {
|
||||
await indexTestUnit('''
|
||||
int test(x) => x * 2;
|
||||
main() {
|
||||
var v = test(1);
|
||||
@@ -149,8 +149,8 @@ main() {
|
||||
'Only methods without parameters can be converted to getters.');
|
||||
}
|
||||
|
||||
test_checkInitialConditions_localFunction() {
|
||||
indexTestUnit('''
|
||||
test_checkInitialConditions_localFunction() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
test() {}
|
||||
var v = test();
|
||||
@@ -162,8 +162,8 @@ main() {
|
||||
'Only top-level functions can be converted to getters.');
|
||||
}
|
||||
|
||||
test_checkInitialConditions_notFunctionOrMethod() {
|
||||
indexTestUnit('''
|
||||
test_checkInitialConditions_notFunctionOrMethod() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A.test();
|
||||
}
|
||||
@@ -174,8 +174,8 @@ class A {
|
||||
'Only class methods or top-level functions can be converted to getters.');
|
||||
}
|
||||
|
||||
test_checkInitialConditions_returnTypeVoid() {
|
||||
indexTestUnit('''
|
||||
test_checkInitialConditions_returnTypeVoid() async {
|
||||
await indexTestUnit('''
|
||||
void test() {}
|
||||
''');
|
||||
_createRefactoring('test');
|
||||
|
||||
@@ -27,7 +27,7 @@ class ExtractLocalTest extends RefactoringTest {
|
||||
ExtractLocalRefactoringImpl refactoring;
|
||||
|
||||
test_checkFinalConditions_sameVariable_after() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2;
|
||||
var res;
|
||||
@@ -41,7 +41,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_sameVariable_before() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var res;
|
||||
int a = 1 + 2;
|
||||
@@ -55,7 +55,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_assignmentLeftHandSize() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var v = 0;
|
||||
v = 1;
|
||||
@@ -69,7 +69,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_namePartOfDeclaration_function() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
}
|
||||
''');
|
||||
@@ -81,7 +81,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_namePartOfDeclaration_variable() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int vvv = 0;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_noExpression() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
// abc
|
||||
}
|
||||
@@ -105,7 +105,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_notPartOfFunction() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
int a = 1 + 2;
|
||||
''');
|
||||
_createRefactoringForString('1 + 2');
|
||||
@@ -117,7 +117,7 @@ int a = 1 + 2;
|
||||
}
|
||||
|
||||
test_checkInitialConditions_stringSelection_leadingQuote() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var vvv = 'abc';
|
||||
}
|
||||
@@ -133,7 +133,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_stringSelection_trailingQuote() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var vvv = 'abc';
|
||||
}
|
||||
@@ -149,7 +149,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_voidExpression() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
print(42);
|
||||
}
|
||||
@@ -161,8 +161,8 @@ main() {
|
||||
expectedMessage: 'Cannot extract the void expression.');
|
||||
}
|
||||
|
||||
test_checkName() {
|
||||
indexTestUnit('''
|
||||
test_checkName() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkName_conflict_withInvokedFunction() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2;
|
||||
res();
|
||||
@@ -202,7 +202,7 @@ void res() {}
|
||||
}
|
||||
|
||||
test_checkName_conflict_withOtherLocal() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var res;
|
||||
int a = 1 + 2;
|
||||
@@ -217,7 +217,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkName_conflict_withTypeName() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2;
|
||||
Res b = null;
|
||||
@@ -233,8 +233,8 @@ class Res {}
|
||||
expectedMessage: "The name 'Res' is already used in the scope.");
|
||||
}
|
||||
|
||||
test_completeStatementExpression() {
|
||||
indexTestUnit('''
|
||||
test_completeStatementExpression() async {
|
||||
await indexTestUnit('''
|
||||
main(p) {
|
||||
p.toString();
|
||||
}
|
||||
@@ -248,8 +248,8 @@ main(p) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_const_argument_inConstInstanceCreation() {
|
||||
indexTestUnit('''
|
||||
test_const_argument_inConstInstanceCreation() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
const A(int a, int b);
|
||||
}
|
||||
@@ -270,8 +270,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_const_inList() {
|
||||
indexTestUnit('''
|
||||
test_const_inList() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
const [1, 2];
|
||||
}
|
||||
@@ -286,8 +286,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_const_inList_inBinaryExpression() {
|
||||
indexTestUnit('''
|
||||
test_const_inList_inBinaryExpression() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
const [1 + 2, 3];
|
||||
}
|
||||
@@ -302,8 +302,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_const_inList_inConditionalExpression() {
|
||||
indexTestUnit('''
|
||||
test_const_inList_inConditionalExpression() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
const [true ? 1 : 2, 3];
|
||||
}
|
||||
@@ -318,8 +318,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_const_inList_inParenthesis() {
|
||||
indexTestUnit('''
|
||||
test_const_inList_inParenthesis() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
const [(1), 2];
|
||||
}
|
||||
@@ -334,8 +334,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_const_inList_inPrefixExpression() {
|
||||
indexTestUnit('''
|
||||
test_const_inList_inPrefixExpression() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
const [!true, 2];
|
||||
}
|
||||
@@ -350,8 +350,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_const_inMap_key() {
|
||||
indexTestUnit('''
|
||||
test_const_inMap_key() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
const {1: 2};
|
||||
}
|
||||
@@ -366,8 +366,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_const_inMap_value() {
|
||||
indexTestUnit('''
|
||||
test_const_inMap_value() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
const {1: 2};
|
||||
}
|
||||
@@ -383,7 +383,7 @@ main() {
|
||||
}
|
||||
|
||||
test_coveringExpressions() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int aaa = 1;
|
||||
int bbb = 2;
|
||||
@@ -399,7 +399,7 @@ main() {
|
||||
}
|
||||
|
||||
test_coveringExpressions_inArgumentList() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
foo(111 + 222);
|
||||
}
|
||||
@@ -413,7 +413,7 @@ int foo(int x) => x;
|
||||
}
|
||||
|
||||
test_coveringExpressions_inInvocationOfVoidFunction() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
foo(111 + 222);
|
||||
}
|
||||
@@ -427,7 +427,7 @@ void foo(int x) {}
|
||||
}
|
||||
|
||||
test_coveringExpressions_namedExpression_value() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
foo(ppp: 42);
|
||||
}
|
||||
@@ -441,7 +441,7 @@ int foo({int ppp: 0}) => ppp + 1;
|
||||
}
|
||||
|
||||
test_coveringExpressions_skip_assignment() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int v;
|
||||
foo(v = 111 + 222);
|
||||
@@ -456,7 +456,7 @@ int foo(x) => 42;
|
||||
}
|
||||
|
||||
test_coveringExpressions_skip_constructorName() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class AAA {
|
||||
AAA.name() {}
|
||||
}
|
||||
@@ -472,7 +472,7 @@ main() {
|
||||
}
|
||||
|
||||
test_coveringExpressions_skip_constructorName_name() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A.name() {}
|
||||
}
|
||||
@@ -488,7 +488,7 @@ main() {
|
||||
}
|
||||
|
||||
test_coveringExpressions_skip_constructorName_type() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {}
|
||||
main() {
|
||||
int v = new A();
|
||||
@@ -502,7 +502,7 @@ main() {
|
||||
}
|
||||
|
||||
test_coveringExpressions_skip_constructorName_typeArgument() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A<T> {}
|
||||
main() {
|
||||
int v = new A<String>();
|
||||
@@ -516,7 +516,7 @@ main() {
|
||||
}
|
||||
|
||||
test_coveringExpressions_skip_namedExpression() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
foo(ppp: 42);
|
||||
}
|
||||
@@ -529,8 +529,8 @@ int foo({int ppp: 0}) => ppp + 1;
|
||||
expect(subExpressions, ['foo(ppp: 42)']);
|
||||
}
|
||||
|
||||
test_fragmentExpression() {
|
||||
indexTestUnit('''
|
||||
test_fragmentExpression() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2 + 3 + 4;
|
||||
}
|
||||
@@ -545,8 +545,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fragmentExpression_leadingNotWhitespace() {
|
||||
indexTestUnit('''
|
||||
test_fragmentExpression_leadingNotWhitespace() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2 + 3 + 4;
|
||||
}
|
||||
@@ -561,8 +561,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fragmentExpression_leadingPartialSelection() {
|
||||
indexTestUnit('''
|
||||
test_fragmentExpression_leadingPartialSelection() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 111 + 2 + 3 + 4;
|
||||
}
|
||||
@@ -577,8 +577,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fragmentExpression_leadingWhitespace() {
|
||||
indexTestUnit('''
|
||||
test_fragmentExpression_leadingWhitespace() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2 + 3 + 4;
|
||||
}
|
||||
@@ -593,8 +593,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fragmentExpression_notAssociativeOperator() {
|
||||
indexTestUnit('''
|
||||
test_fragmentExpression_notAssociativeOperator() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 - 2 - 3 - 4;
|
||||
}
|
||||
@@ -609,8 +609,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fragmentExpression_trailingNotWhitespace() {
|
||||
indexTestUnit('''
|
||||
test_fragmentExpression_trailingNotWhitespace() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2 + 3 + 4;
|
||||
}
|
||||
@@ -625,8 +625,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fragmentExpression_trailingPartialSelection() {
|
||||
indexTestUnit('''
|
||||
test_fragmentExpression_trailingPartialSelection() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2 + 333 + 4;
|
||||
}
|
||||
@@ -641,8 +641,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fragmentExpression_trailingWhitespace() {
|
||||
indexTestUnit('''
|
||||
test_fragmentExpression_trailingWhitespace() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2 + 3 + 4;
|
||||
}
|
||||
@@ -658,7 +658,7 @@ main() {
|
||||
}
|
||||
|
||||
test_guessNames_fragmentExpression() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var a = 111 + 222 + 333 + 444;
|
||||
}
|
||||
@@ -670,7 +670,7 @@ main() {
|
||||
}
|
||||
|
||||
test_guessNames_singleExpression() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class TreeItem {}
|
||||
TreeItem getSelectedItem() => null;
|
||||
process(my) {}
|
||||
@@ -686,7 +686,7 @@ main() {
|
||||
}
|
||||
|
||||
test_guessNames_stringPart() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var s = 'Hello Bob... welcome to Dart!';
|
||||
}
|
||||
@@ -698,7 +698,7 @@ main() {
|
||||
}
|
||||
|
||||
test_occurrences_differentVariable() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
{
|
||||
int v = 1;
|
||||
@@ -731,8 +731,8 @@ main() {
|
||||
length: 3, offsets: [36, 59, 85], names: ['object', 'i']);
|
||||
}
|
||||
|
||||
test_occurrences_disableOccurrences() {
|
||||
indexTestUnit('''
|
||||
test_occurrences_disableOccurrences() async {
|
||||
await indexTestUnit('''
|
||||
int foo() => 42;
|
||||
main() {
|
||||
int a = 1 + foo();
|
||||
@@ -752,8 +752,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_occurrences_ignore_assignmentLeftHandSize() {
|
||||
indexTestUnit('''
|
||||
test_occurrences_ignore_assignmentLeftHandSize() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int v = 1;
|
||||
v = 2;
|
||||
@@ -776,8 +776,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_occurrences_ignore_nameOfVariableDeclaration() {
|
||||
indexTestUnit('''
|
||||
test_occurrences_ignore_nameOfVariableDeclaration() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int v = 1;
|
||||
print(v); // marker
|
||||
@@ -794,8 +794,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_occurrences_singleExpression() {
|
||||
indexTestUnit('''
|
||||
test_occurrences_singleExpression() async {
|
||||
await indexTestUnit('''
|
||||
int foo() => 42;
|
||||
main() {
|
||||
int a = 1 + foo();
|
||||
@@ -814,8 +814,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_occurrences_useDominator() {
|
||||
indexTestUnit('''
|
||||
test_occurrences_useDominator() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
if (true) {
|
||||
print(42);
|
||||
@@ -838,8 +838,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_occurrences_whenComment() {
|
||||
indexTestUnit('''
|
||||
test_occurrences_whenComment() async {
|
||||
await indexTestUnit('''
|
||||
int foo() => 42;
|
||||
main() {
|
||||
/*int a = 1 + foo();*/
|
||||
@@ -858,8 +858,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_occurrences_withSpace() {
|
||||
indexTestUnit('''
|
||||
test_occurrences_withSpace() async {
|
||||
await indexTestUnit('''
|
||||
int foo(String s) => 42;
|
||||
main() {
|
||||
int a = 1 + foo('has space');
|
||||
@@ -879,7 +879,7 @@ main() {
|
||||
}
|
||||
|
||||
test_offsets_lengths() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
int foo() => 42;
|
||||
main() {
|
||||
int a = 1 + foo(); // marker
|
||||
@@ -894,8 +894,8 @@ main() {
|
||||
expect(refactoring.lengths, unorderedEquals([5, 6]));
|
||||
}
|
||||
|
||||
test_singleExpression() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2;
|
||||
}
|
||||
@@ -910,8 +910,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_getter() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_getter() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
int get foo => 42;
|
||||
}
|
||||
@@ -934,9 +934,9 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_hasParseError_expectedSemicolon() {
|
||||
test_singleExpression_hasParseError_expectedSemicolon() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main(p) {
|
||||
foo
|
||||
p.bar.baz;
|
||||
@@ -954,7 +954,7 @@ main(p) {
|
||||
}
|
||||
|
||||
test_singleExpression_inExpressionBody_ofClosure() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
print((x) => x.y * x.y + 1);
|
||||
}
|
||||
@@ -974,7 +974,7 @@ main() {
|
||||
}
|
||||
|
||||
test_singleExpression_inExpressionBody_ofFunction() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
foo(Point p) => p.x * p.x + p.y * p.y;
|
||||
class Point {int x; int y;}
|
||||
''');
|
||||
@@ -992,7 +992,7 @@ class Point {int x; int y;}
|
||||
}
|
||||
|
||||
test_singleExpression_inExpressionBody_ofMethod() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
foo(Point p) => p.x * p.x + p.y * p.y;
|
||||
}
|
||||
@@ -1013,8 +1013,8 @@ class Point {int x; int y;}
|
||||
length: 3, offsets: [35, 57, 63], names: ['x', 'i']);
|
||||
}
|
||||
|
||||
test_singleExpression_inIfElseIf() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_inIfElseIf() async {
|
||||
await indexTestUnit('''
|
||||
main(int p) {
|
||||
if (p == 1) {
|
||||
print(1);
|
||||
@@ -1037,8 +1037,8 @@ main(int p) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_inMethod() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_inMethod() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
main() {
|
||||
print(1 + 2);
|
||||
@@ -1057,8 +1057,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_leadingNotWhitespace() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_leadingNotWhitespace() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 12 + 345;
|
||||
}
|
||||
@@ -1073,8 +1073,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_leadingWhitespace() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_leadingWhitespace() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 /*abc*/ + 2 + 345;
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ main() {
|
||||
}
|
||||
|
||||
test_singleExpression_methodName_reference() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var v = foo().length;
|
||||
}
|
||||
@@ -1108,7 +1108,7 @@ String foo() => '';
|
||||
}
|
||||
|
||||
test_singleExpression_nameOfProperty_prefixedIdentifier() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main(p) {
|
||||
var v = p.value; // marker
|
||||
}
|
||||
@@ -1124,7 +1124,7 @@ main(p) {
|
||||
}
|
||||
|
||||
test_singleExpression_nameOfProperty_propertyAccess() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var v = foo().length; // marker
|
||||
}
|
||||
@@ -1146,8 +1146,8 @@ String foo() => '';
|
||||
* `1 + 2` will be a separate and complete binary expression, so it can be
|
||||
* handled as a single expression.
|
||||
*/
|
||||
test_singleExpression_partOfBinaryExpression() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_partOfBinaryExpression() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2 + 3 + 4;
|
||||
}
|
||||
@@ -1162,8 +1162,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_string() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_string() async {
|
||||
await indexTestUnit('''
|
||||
void main() {
|
||||
print("1234");
|
||||
}
|
||||
@@ -1178,8 +1178,8 @@ void main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_trailingNotWhitespace() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_trailingNotWhitespace() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 12 + 345;
|
||||
}
|
||||
@@ -1194,8 +1194,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_trailingWhitespace() {
|
||||
indexTestUnit('''
|
||||
test_singleExpression_trailingWhitespace() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int a = 1 + 2 ;
|
||||
}
|
||||
@@ -1211,7 +1211,7 @@ main() {
|
||||
}
|
||||
|
||||
test_stringLiteral_part() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
print('abcdefgh');
|
||||
}
|
||||
@@ -1228,7 +1228,7 @@ main() {
|
||||
}
|
||||
|
||||
test_stringLiteral_whole() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
print('abc');
|
||||
}
|
||||
@@ -1246,7 +1246,7 @@ main() {
|
||||
}
|
||||
|
||||
test_stringLiteralPart() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
int x = 1;
|
||||
int y = 2;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@ class InlineLocalTest extends RefactoringTest {
|
||||
InlineLocalRefactoringImpl refactoring;
|
||||
|
||||
test_access() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 1 + 2;
|
||||
print(test);
|
||||
@@ -40,7 +40,7 @@ main() {
|
||||
}
|
||||
|
||||
test_bad_selectionMethod() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
}
|
||||
''');
|
||||
@@ -50,7 +50,7 @@ main() {
|
||||
}
|
||||
|
||||
test_bad_selectionParameter() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
main(int test) {
|
||||
}
|
||||
''');
|
||||
@@ -60,7 +60,7 @@ main(int test) {
|
||||
}
|
||||
|
||||
test_bad_selectionVariable_hasAssignments_1() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
int test = 0;
|
||||
test = 1;
|
||||
@@ -73,7 +73,7 @@ main() {
|
||||
}
|
||||
|
||||
test_bad_selectionVariable_hasAssignments_2() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
int test = 0;
|
||||
test += 1;
|
||||
@@ -86,7 +86,7 @@ main() {
|
||||
}
|
||||
|
||||
test_bad_selectionVariable_notInBlock() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
if (true)
|
||||
int test = 0;
|
||||
@@ -98,7 +98,7 @@ main() {
|
||||
}
|
||||
|
||||
test_bad_selectionVariable_notInitialized() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
int test;
|
||||
}
|
||||
@@ -108,8 +108,8 @@ main() {
|
||||
assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL);
|
||||
}
|
||||
|
||||
test_OK_cascade_intoCascade() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_cascade_intoCascade() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
foo() {}
|
||||
bar() {}
|
||||
@@ -132,8 +132,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_cascade_intoNotCascade() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_cascade_intoNotCascade() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
foo() {}
|
||||
bar() {}
|
||||
@@ -156,8 +156,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_inSwitchCase() {
|
||||
indexTestUnit('''
|
||||
test_OK_inSwitchCase() async {
|
||||
await indexTestUnit('''
|
||||
main(int p) {
|
||||
switch (p) {
|
||||
case 0:
|
||||
@@ -180,8 +180,8 @@ main(int p) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_binaryExpression() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_binaryExpression() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
int test = 1 + 2;
|
||||
print('test = $test');
|
||||
@@ -202,8 +202,8 @@ process(x) {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_simpleIdentifier() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_simpleIdentifier() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
int foo = 1 + 2;
|
||||
int test = foo;
|
||||
@@ -226,8 +226,8 @@ process(x) {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_differentQuotes() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_string_differentQuotes() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
String a = "aaa";
|
||||
String b = '$a bbb';
|
||||
@@ -242,8 +242,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_doubleQuotes() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_string_doubleQuotes() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
String a = "aaa";
|
||||
String b = "$a bbb";
|
||||
@@ -258,8 +258,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_multiLineIntoMulti_leadingSpaces() {
|
||||
indexTestUnit(r"""
|
||||
test_OK_intoStringInterpolation_string_multiLineIntoMulti_leadingSpaces() async {
|
||||
await indexTestUnit(r"""
|
||||
main() {
|
||||
String a = '''\ \
|
||||
a
|
||||
@@ -281,8 +281,8 @@ bbb''';
|
||||
""");
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_multiLineIntoMulti_unixEOL() {
|
||||
indexTestUnit(r"""
|
||||
test_OK_intoStringInterpolation_string_multiLineIntoMulti_unixEOL() async {
|
||||
await indexTestUnit(r"""
|
||||
main() {
|
||||
String a = '''
|
||||
a
|
||||
@@ -306,8 +306,8 @@ bbb''';
|
||||
""");
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_multiLineIntoMulti_windowsEOL() {
|
||||
indexTestUnit(r"""
|
||||
test_OK_intoStringInterpolation_string_multiLineIntoMulti_windowsEOL() async {
|
||||
await indexTestUnit(r"""
|
||||
main() {
|
||||
String a = '''
|
||||
a
|
||||
@@ -333,8 +333,8 @@ bbb''';
|
||||
.replaceAll('\n', '\r\n'));
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_multiLineIntoSingle() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_string_multiLineIntoSingle() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
String a = """aaa""";
|
||||
String b = "$a bbb";
|
||||
@@ -349,8 +349,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_raw() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_string_raw() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
String a = r'an $ignored interpolation';
|
||||
String b = '$a bbb';
|
||||
@@ -365,8 +365,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_singleLineIntoMulti_doubleQuotes() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_string_singleLineIntoMulti_doubleQuotes() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
String a = "aaa";
|
||||
String b = """$a bbb""";
|
||||
@@ -381,8 +381,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_singleLineIntoMulti_singleQuotes() {
|
||||
indexTestUnit(r"""
|
||||
test_OK_intoStringInterpolation_string_singleLineIntoMulti_singleQuotes() async {
|
||||
await indexTestUnit(r"""
|
||||
main() {
|
||||
String a = 'aaa';
|
||||
String b = '''$a bbb''';
|
||||
@@ -397,8 +397,8 @@ main() {
|
||||
""");
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_string_singleQuotes() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_string_singleQuotes() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
String a = 'aaa';
|
||||
String b = '$a bbb';
|
||||
@@ -413,8 +413,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_intoStringInterpolation_stringInterpolation() {
|
||||
indexTestUnit(r'''
|
||||
test_OK_intoStringInterpolation_stringInterpolation() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
String a = 'aaa';
|
||||
String b = '$a bbb';
|
||||
@@ -435,8 +435,8 @@ main() {
|
||||
* <p>
|
||||
* https://code.google.com/p/dart/issues/detail?id=18587
|
||||
*/
|
||||
test_OK_keepNextCommentedLine() {
|
||||
indexTestUnit('''
|
||||
test_OK_keepNextCommentedLine() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 1 + 2;
|
||||
// foo
|
||||
@@ -455,8 +455,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_noUsages_1() {
|
||||
indexTestUnit('''
|
||||
test_OK_noUsages_1() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 1 + 2;
|
||||
print(0);
|
||||
@@ -471,8 +471,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_noUsages_2() {
|
||||
indexTestUnit('''
|
||||
test_OK_noUsages_2() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 1 + 2;
|
||||
}
|
||||
@@ -485,8 +485,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_oneUsage() {
|
||||
indexTestUnit('''
|
||||
test_OK_oneUsage() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 1 + 2;
|
||||
print(test);
|
||||
@@ -501,8 +501,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_parenthesis_decrement_intoNegate() {
|
||||
indexTestUnit('''
|
||||
test_OK_parenthesis_decrement_intoNegate() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var a = 1;
|
||||
var test = --a;
|
||||
@@ -519,8 +519,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_parenthesis_instanceCreation_intoList() {
|
||||
indexTestUnit('''
|
||||
test_OK_parenthesis_instanceCreation_intoList() async {
|
||||
await indexTestUnit('''
|
||||
class A {}
|
||||
main() {
|
||||
var test = new A();
|
||||
@@ -537,8 +537,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_parenthesis_intoIndexExpression_index() {
|
||||
indexTestUnit('''
|
||||
test_OK_parenthesis_intoIndexExpression_index() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var items = [];
|
||||
var test = 1 + 2;
|
||||
@@ -555,8 +555,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_parenthesis_intoParenthesizedExpression() {
|
||||
indexTestUnit('''
|
||||
test_OK_parenthesis_intoParenthesizedExpression() async {
|
||||
await indexTestUnit('''
|
||||
f(m, x, y) {
|
||||
int test = x as int;
|
||||
m[test] = y;
|
||||
@@ -573,8 +573,8 @@ f(m, x, y) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_parenthesis_negate_intoNegate() {
|
||||
indexTestUnit('''
|
||||
test_OK_parenthesis_negate_intoNegate() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var a = 1;
|
||||
var test = -a;
|
||||
@@ -591,8 +591,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_parenthesis_plus_intoMultiply() {
|
||||
indexTestUnit('''
|
||||
test_OK_parenthesis_plus_intoMultiply() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var test = 1 + 2;
|
||||
print(test * 3);
|
||||
@@ -607,8 +607,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_OK_twoUsages() {
|
||||
indexTestUnit('''
|
||||
test_OK_twoUsages() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 1 + 2;
|
||||
print(test);
|
||||
|
||||
@@ -29,7 +29,7 @@ class InlineMethodTest extends RefactoringTest {
|
||||
bool inlineAll;
|
||||
|
||||
test_access_FunctionElement() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ main() {
|
||||
}
|
||||
|
||||
test_access_MethodElement() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
@@ -66,8 +66,8 @@ class A {
|
||||
expect(refactoring.isDeclaration, isTrue);
|
||||
}
|
||||
|
||||
test_bad_async_intoSyncStar() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_async_intoSyncStar() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Future<int> get test async => 42;
|
||||
@@ -81,8 +81,8 @@ class A {
|
||||
return _assertConditionsFatal('Cannot inline async into sync*.');
|
||||
}
|
||||
|
||||
test_bad_async_targetIsSync_doesNotReturnFuture() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_async_targetIsSync_doesNotReturnFuture() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Future<int> get test async => 42;
|
||||
@@ -98,8 +98,8 @@ class A {
|
||||
'Cannot inline async into a function that does not return a Future.');
|
||||
}
|
||||
|
||||
test_bad_asyncStar() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_asyncStar() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Stream<int> test() async* {
|
||||
@@ -117,7 +117,7 @@ class A {
|
||||
}
|
||||
|
||||
test_bad_cascadeInvocation() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
foo() {}
|
||||
bar() {}
|
||||
@@ -137,8 +137,8 @@ main() {
|
||||
expectedContextRange: location);
|
||||
}
|
||||
|
||||
test_bad_constructor() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_constructor() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
A.named() {}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class A {
|
||||
}
|
||||
|
||||
test_bad_deleteSource_inlineOne() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -171,8 +171,8 @@ main() {
|
||||
'All references must be inlined to remove the source.');
|
||||
}
|
||||
|
||||
test_bad_notExecutableElement() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_notExecutableElement() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
}
|
||||
''');
|
||||
@@ -181,8 +181,8 @@ main() {
|
||||
return _assertInvalidSelection();
|
||||
}
|
||||
|
||||
test_bad_notSimpleIdentifier() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_notSimpleIdentifier() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
var test = 42;
|
||||
var res = test;
|
||||
@@ -193,8 +193,8 @@ main() {
|
||||
return _assertInvalidSelection();
|
||||
}
|
||||
|
||||
test_bad_operator() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_operator() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
operator -(other) => this;
|
||||
}
|
||||
@@ -204,8 +204,8 @@ class A {
|
||||
return _assertConditionsFatal('Cannot inline operator.');
|
||||
}
|
||||
|
||||
test_bad_propertyAccessor_synthetic() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_propertyAccessor_synthetic() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
int fff;
|
||||
}
|
||||
@@ -219,8 +219,8 @@ main(A a) {
|
||||
return _assertInvalidSelection();
|
||||
}
|
||||
|
||||
test_bad_reference_toClassMethod() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_reference_toClassMethod() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
test(a, b) {
|
||||
print(a);
|
||||
@@ -236,8 +236,8 @@ main() {
|
||||
return _assertConditionsFatal('Cannot inline class method reference.');
|
||||
}
|
||||
|
||||
test_bad_severalReturns() {
|
||||
indexTestUnit(r'''
|
||||
test_bad_severalReturns() async {
|
||||
await indexTestUnit(r'''
|
||||
test() {
|
||||
if (true) {
|
||||
return 1;
|
||||
@@ -253,8 +253,8 @@ main() {
|
||||
return _assertConditionsError('Ambiguous return value.');
|
||||
}
|
||||
|
||||
test_fieldAccessor_getter() {
|
||||
indexTestUnit(r'''
|
||||
test_fieldAccessor_getter() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
var f;
|
||||
get foo {
|
||||
@@ -279,8 +279,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fieldAccessor_getter_PropertyAccess() {
|
||||
indexTestUnit(r'''
|
||||
test_fieldAccessor_getter_PropertyAccess() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
var f;
|
||||
get foo {
|
||||
@@ -311,8 +311,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fieldAccessor_setter() {
|
||||
indexTestUnit(r'''
|
||||
test_fieldAccessor_setter() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
var f;
|
||||
set foo(x) {
|
||||
@@ -337,8 +337,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fieldAccessor_setter_PropertyAccess() {
|
||||
indexTestUnit(r'''
|
||||
test_fieldAccessor_setter_PropertyAccess() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
var f;
|
||||
set foo(x) {
|
||||
@@ -369,8 +369,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_expressionFunctionBody() {
|
||||
indexTestUnit(r'''
|
||||
test_function_expressionFunctionBody() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) => a + b;
|
||||
main() {
|
||||
print(test(1, 2));
|
||||
@@ -385,8 +385,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_hasReturn_assign() {
|
||||
indexTestUnit(r'''
|
||||
test_function_hasReturn_assign() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
print(a);
|
||||
print(b);
|
||||
@@ -409,8 +409,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_hasReturn_hasReturnType() {
|
||||
indexTestUnit(r'''
|
||||
test_function_hasReturn_hasReturnType() async {
|
||||
await indexTestUnit(r'''
|
||||
int test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -427,8 +427,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_hasReturn_noVars_oneUsage() {
|
||||
indexTestUnit(r'''
|
||||
test_function_hasReturn_noVars_oneUsage() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
print(a);
|
||||
print(b);
|
||||
@@ -449,8 +449,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_multilineString() {
|
||||
indexTestUnit(r"""
|
||||
test_function_multilineString() async {
|
||||
await indexTestUnit(r"""
|
||||
main() {
|
||||
{
|
||||
test();
|
||||
@@ -477,8 +477,8 @@ second line
|
||||
""");
|
||||
}
|
||||
|
||||
test_function_noReturn_hasVars_hasConflict_fieldSuperClass() {
|
||||
indexTestUnit(r'''
|
||||
test_function_noReturn_hasVars_hasConflict_fieldSuperClass() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
var c;
|
||||
}
|
||||
@@ -507,8 +507,8 @@ class B extends A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_noReturn_hasVars_hasConflict_fieldThisClass() {
|
||||
indexTestUnit(r'''
|
||||
test_function_noReturn_hasVars_hasConflict_fieldThisClass() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
var c;
|
||||
foo() {
|
||||
@@ -533,8 +533,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_noReturn_hasVars_hasConflict_localAfter() {
|
||||
indexTestUnit(r'''
|
||||
test_function_noReturn_hasVars_hasConflict_localAfter() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
var c = a + b;
|
||||
print(c);
|
||||
@@ -555,8 +555,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_noReturn_hasVars_hasConflict_localBefore() {
|
||||
indexTestUnit(r'''
|
||||
test_function_noReturn_hasVars_hasConflict_localBefore() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
var c = a + b;
|
||||
print(c);
|
||||
@@ -577,8 +577,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_noReturn_hasVars_noConflict() {
|
||||
indexTestUnit(r'''
|
||||
test_function_noReturn_hasVars_noConflict() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
var c = a + b;
|
||||
print(c);
|
||||
@@ -597,8 +597,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_noReturn_noVars_oneUsage() {
|
||||
indexTestUnit(r'''
|
||||
test_function_noReturn_noVars_oneUsage() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
print(a);
|
||||
print(b);
|
||||
@@ -617,8 +617,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_noReturn_noVars_useIndentation() {
|
||||
indexTestUnit(r'''
|
||||
test_function_noReturn_noVars_useIndentation() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
print(a);
|
||||
print(b);
|
||||
@@ -641,8 +641,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_noReturn_voidReturnType() {
|
||||
indexTestUnit(r'''
|
||||
test_function_noReturn_voidReturnType() async {
|
||||
await indexTestUnit(r'''
|
||||
void test(a, b) {
|
||||
print(a + b);
|
||||
}
|
||||
@@ -659,8 +659,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_notStatement_oneStatement_assign() {
|
||||
indexTestUnit(r'''
|
||||
test_function_notStatement_oneStatement_assign() async {
|
||||
await indexTestUnit(r'''
|
||||
test(int p) {
|
||||
print(p * 2);
|
||||
}
|
||||
@@ -681,8 +681,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_notStatement_oneStatement_variableDeclaration() {
|
||||
indexTestUnit(r'''
|
||||
test_function_notStatement_oneStatement_variableDeclaration() async {
|
||||
await indexTestUnit(r'''
|
||||
test(int p) {
|
||||
print(p * 2);
|
||||
}
|
||||
@@ -701,8 +701,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_notStatement_severalStatements() {
|
||||
indexTestUnit(r'''
|
||||
test_function_notStatement_severalStatements() async {
|
||||
await indexTestUnit(r'''
|
||||
test(int p) {
|
||||
print(p);
|
||||
print(p * 2);
|
||||
@@ -723,8 +723,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_notStatement_zeroStatements() {
|
||||
indexTestUnit(r'''
|
||||
test_function_notStatement_zeroStatements() async {
|
||||
await indexTestUnit(r'''
|
||||
test(int p) {
|
||||
}
|
||||
main() {
|
||||
@@ -741,8 +741,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_function_singleStatement() {
|
||||
indexTestUnit(r'''
|
||||
test_function_singleStatement() async {
|
||||
await indexTestUnit(r'''
|
||||
var topLevelField = 0;
|
||||
test() {
|
||||
print(topLevelField);
|
||||
@@ -761,8 +761,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_getter_async_targetIsAsync() {
|
||||
indexTestUnit(r'''
|
||||
test_getter_async_targetIsAsync() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Future<int> get test async => 42;
|
||||
@@ -783,8 +783,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_getter_async_targetIsAsyncStar() {
|
||||
indexTestUnit(r'''
|
||||
test_getter_async_targetIsAsyncStar() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Future<int> get test async => 42;
|
||||
@@ -805,8 +805,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_getter_async_targetIsSync() {
|
||||
indexTestUnit(r'''
|
||||
test_getter_async_targetIsSync() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Future<int> get test async => 42;
|
||||
@@ -827,8 +827,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_getter_async_targetIsSync2() {
|
||||
indexTestUnit(r'''
|
||||
test_getter_async_targetIsSync2() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Future<int> get test async => 42;
|
||||
@@ -855,8 +855,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_getter_classMember_instance() {
|
||||
indexTestUnit(r'''
|
||||
test_getter_classMember_instance() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
int f;
|
||||
int get result => f + 1;
|
||||
@@ -877,8 +877,8 @@ main(A a) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_getter_classMember_static() {
|
||||
indexTestUnit(r'''
|
||||
test_getter_classMember_static() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
static int get result => 1 + 2;
|
||||
}
|
||||
@@ -897,8 +897,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_getter_topLevel() {
|
||||
indexTestUnit(r'''
|
||||
test_getter_topLevel() async {
|
||||
await indexTestUnit(r'''
|
||||
String get message => 'Hello, World!';
|
||||
main() {
|
||||
print(message);
|
||||
@@ -914,7 +914,7 @@ main() {
|
||||
}
|
||||
|
||||
test_initialMode_all() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -930,7 +930,7 @@ main() {
|
||||
}
|
||||
|
||||
test_initialMode_single() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -947,8 +947,8 @@ main() {
|
||||
expect(refactoring.inlineAll, false);
|
||||
}
|
||||
|
||||
test_method_async() {
|
||||
indexTestUnit(r'''
|
||||
test_method_async() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Future<int> test() async => 42;
|
||||
@@ -969,8 +969,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_async2() {
|
||||
indexTestUnit(r'''
|
||||
test_method_async2() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
class A {
|
||||
Future<int> test() async => 42;
|
||||
@@ -991,8 +991,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_emptyBody() {
|
||||
indexTestUnit(r'''
|
||||
test_method_emptyBody() async {
|
||||
await indexTestUnit(r'''
|
||||
abstract class A {
|
||||
test();
|
||||
}
|
||||
@@ -1005,8 +1005,8 @@ main(A a) {
|
||||
return _assertConditionsFatal('Cannot inline method without body.');
|
||||
}
|
||||
|
||||
test_method_fieldInstance() {
|
||||
indexTestUnit(r'''
|
||||
test_method_fieldInstance() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
var fA;
|
||||
}
|
||||
@@ -1043,8 +1043,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_fieldStatic() {
|
||||
indexTestUnit(r'''
|
||||
test_method_fieldStatic() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
static var FA = 1;
|
||||
}
|
||||
@@ -1081,8 +1081,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_fieldStatic_sameClass() {
|
||||
indexTestUnit(r'''
|
||||
test_method_fieldStatic_sameClass() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
static var F = 1;
|
||||
foo() {
|
||||
@@ -1105,8 +1105,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_methodInstance() {
|
||||
indexTestUnit(r'''
|
||||
test_method_methodInstance() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
ma() {}
|
||||
}
|
||||
@@ -1141,8 +1141,8 @@ main(B b) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_methodStatic() {
|
||||
indexTestUnit(r'''
|
||||
test_method_methodStatic() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
static ma() {}
|
||||
}
|
||||
@@ -1180,8 +1180,8 @@ main(B b) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_singleStatement() {
|
||||
indexTestUnit(r'''
|
||||
test_method_singleStatement() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
test() {
|
||||
print(0);
|
||||
@@ -1202,8 +1202,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_this() {
|
||||
indexTestUnit(r'''
|
||||
test_method_this() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
accept(B b) {}
|
||||
}
|
||||
@@ -1236,8 +1236,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_method_unqualifiedInvocation() {
|
||||
indexTestUnit(r'''
|
||||
test_method_unqualifiedInvocation() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
test(a, b) {
|
||||
print(a);
|
||||
@@ -1262,8 +1262,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_namedArgument_inBody() {
|
||||
indexTestUnit(r'''
|
||||
test_namedArgument_inBody() async {
|
||||
await indexTestUnit(r'''
|
||||
fa(pa) => fb(pb: true);
|
||||
fb({pb: false}) {}
|
||||
main() {
|
||||
@@ -1281,8 +1281,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_namedArguments() {
|
||||
indexTestUnit(r'''
|
||||
test_namedArguments() async {
|
||||
await indexTestUnit(r'''
|
||||
test({a: 0, b: 2}) {
|
||||
print(a + b);
|
||||
}
|
||||
@@ -1301,9 +1301,9 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_noArgument_named_hasDefault() {
|
||||
test_noArgument_named_hasDefault() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
test({a: 42}) {
|
||||
print(a);
|
||||
}
|
||||
@@ -1320,9 +1320,9 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_noArgument_positional_hasDefault() {
|
||||
test_noArgument_positional_hasDefault() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
test([a = 42]) {
|
||||
print(a);
|
||||
}
|
||||
@@ -1339,9 +1339,9 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_noArgument_positional_noDefault() {
|
||||
test_noArgument_positional_noDefault() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
test([a]) {
|
||||
print(a);
|
||||
}
|
||||
@@ -1360,7 +1360,7 @@ main() {
|
||||
|
||||
test_noArgument_required() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
test(a) {
|
||||
print(a);
|
||||
}
|
||||
@@ -1377,8 +1377,8 @@ main() {
|
||||
expectedContextRange: location);
|
||||
}
|
||||
|
||||
test_reference_expressionBody() {
|
||||
indexTestUnit(r'''
|
||||
test_reference_expressionBody() async {
|
||||
await indexTestUnit(r'''
|
||||
String message() => 'Hello, World!';
|
||||
main() {
|
||||
print(message);
|
||||
@@ -1393,8 +1393,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_reference_noStatement() {
|
||||
indexTestUnit(r'''
|
||||
test_reference_noStatement() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a || b;
|
||||
}
|
||||
@@ -1417,8 +1417,8 @@ baz(x) {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_reference_toLocal() {
|
||||
indexTestUnit(r'''
|
||||
test_reference_toLocal() async {
|
||||
await indexTestUnit(r'''
|
||||
main() {
|
||||
test(a, b) {
|
||||
print(a);
|
||||
@@ -1439,8 +1439,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_reference_toTopLevel() {
|
||||
indexTestUnit(r'''
|
||||
test_reference_toTopLevel() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
print(a);
|
||||
print(b);
|
||||
@@ -1461,8 +1461,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_removeEmptyLinesBefore_method() {
|
||||
indexTestUnit(r'''
|
||||
test_removeEmptyLinesBefore_method() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
before() {
|
||||
}
|
||||
@@ -1491,8 +1491,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_setter_classMember_instance() {
|
||||
indexTestUnit(r'''
|
||||
test_setter_classMember_instance() async {
|
||||
await indexTestUnit(r'''
|
||||
class A {
|
||||
int f;
|
||||
void set result(x) {
|
||||
@@ -1515,8 +1515,8 @@ main(A a) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_setter_topLevel() {
|
||||
indexTestUnit(r'''
|
||||
test_setter_topLevel() async {
|
||||
await indexTestUnit(r'''
|
||||
void set result(x) {
|
||||
print(x + 1);
|
||||
}
|
||||
@@ -1533,8 +1533,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_oneUsage() {
|
||||
indexTestUnit(r'''
|
||||
test_singleExpression_oneUsage() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -1551,8 +1551,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_oneUsage_keepMethod() {
|
||||
indexTestUnit(r'''
|
||||
test_singleExpression_oneUsage_keepMethod() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -1573,8 +1573,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_twoUsages() {
|
||||
indexTestUnit(r'''
|
||||
test_singleExpression_twoUsages() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -1593,8 +1593,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_twoUsages_inlineOne() {
|
||||
indexTestUnit(r'''
|
||||
test_singleExpression_twoUsages_inlineOne() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -1616,8 +1616,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_wrapIntoParenthesized_alreadyInMethod() {
|
||||
indexTestUnit(r'''
|
||||
test_singleExpression_wrapIntoParenthesized_alreadyInMethod() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a * (b);
|
||||
}
|
||||
@@ -1634,8 +1634,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_wrapIntoParenthesized_asNeeded() {
|
||||
indexTestUnit(r'''
|
||||
test_singleExpression_wrapIntoParenthesized_asNeeded() async {
|
||||
await indexTestUnit(r'''
|
||||
test(a, b) {
|
||||
return a * b;
|
||||
}
|
||||
@@ -1654,8 +1654,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_singleExpression_wrapIntoParenthesized_bool() {
|
||||
indexTestUnit(r'''
|
||||
test_singleExpression_wrapIntoParenthesized_bool() async {
|
||||
await indexTestUnit(r'''
|
||||
test(bool a, bool b) {
|
||||
return a || b;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ main() {
|
||||
@reflectiveTest
|
||||
class RenameClassMemberTest extends RenameRefactoringTest {
|
||||
test_checkFinalConditions_classNameConflict_sameClass() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class NewName {
|
||||
void test() {}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class NewName {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_classNameConflict_subClass() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
void test() {} // 1
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class NewName extends A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_classNameConflict_superClass() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class NewName {
|
||||
void test() {} // 1
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class B extends NewName {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasMember_MethodElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
newName() {} // existing
|
||||
@@ -92,7 +92,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_OK_dropSuffix() async {
|
||||
indexTestUnit(r'''
|
||||
await indexTestUnit(r'''
|
||||
abstract class A {
|
||||
void testOld();
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class B implements A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_OK_noShadow() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
int newName;
|
||||
}
|
||||
@@ -129,12 +129,12 @@ class C extends A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_publicToPrivate_usedInOtherLibrary() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
''');
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library my.lib;
|
||||
@@ -153,7 +153,7 @@ main(A a) {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowed_byLocalFunction_inSameClass() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
main() {
|
||||
@@ -173,7 +173,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowed_byLocalVariable_inSameClass() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
main() {
|
||||
@@ -193,7 +193,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowed_byLocalVariable_inSubClass() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ class B extends A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowed_byLocalVariable_OK_qualifiedReference() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
main() {
|
||||
@@ -232,7 +232,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowed_byLocalVariable_OK_renamedNotUsed() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
main() {
|
||||
@@ -248,7 +248,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowed_byParameter_inSameClass() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
main(newName) {
|
||||
@@ -267,7 +267,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowedBySub_MethodElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ class B extends A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowsSuper_FieldElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
int newName; // marker
|
||||
}
|
||||
@@ -312,7 +312,7 @@ class C extends B {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowsSuper_MethodElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
newName() {} // marker
|
||||
}
|
||||
@@ -335,8 +335,8 @@ class A {
|
||||
newName() {} // marker
|
||||
}
|
||||
''';
|
||||
indexUnit('/lib.dart', libCode);
|
||||
indexTestUnit('''
|
||||
await indexUnit('/lib.dart', libCode);
|
||||
await indexTestUnit('''
|
||||
import 'lib.dart';
|
||||
class B extends A {
|
||||
test() {}
|
||||
@@ -353,7 +353,7 @@ class B extends A {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_inSDK() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
'abc'.toUpperCase();
|
||||
}
|
||||
@@ -368,7 +368,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_operator() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
operator -(other) => this;
|
||||
}
|
||||
@@ -380,8 +380,8 @@ class A {
|
||||
assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL);
|
||||
}
|
||||
|
||||
test_checkNewName_FieldElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_FieldElement() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
int test;
|
||||
}
|
||||
@@ -397,8 +397,8 @@ class A {
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_checkNewName_MethodElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_MethodElement() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
@@ -425,8 +425,8 @@ class A {
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_createChange_FieldElement() {
|
||||
indexTestUnit('''
|
||||
test_createChange_FieldElement() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
int test; // marker
|
||||
main() {
|
||||
@@ -491,8 +491,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_FieldElement_constructorFieldInitializer() {
|
||||
indexTestUnit('''
|
||||
test_createChange_FieldElement_constructorFieldInitializer() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
final test;
|
||||
A() : test = 5;
|
||||
@@ -512,8 +512,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_FieldElement_fieldFormalParameter() {
|
||||
indexTestUnit('''
|
||||
test_createChange_FieldElement_fieldFormalParameter() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
final test;
|
||||
A(this.test);
|
||||
@@ -533,8 +533,8 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_FieldElement_fieldFormalParameter_named() {
|
||||
indexTestUnit('''
|
||||
test_createChange_FieldElement_fieldFormalParameter_named() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
final test;
|
||||
A({this.test});
|
||||
@@ -560,8 +560,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_FieldElement_invocation() {
|
||||
indexTestUnit('''
|
||||
test_createChange_FieldElement_invocation() async {
|
||||
await indexTestUnit('''
|
||||
typedef F(a);
|
||||
class A {
|
||||
F test;
|
||||
@@ -595,8 +595,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_MethodElement() {
|
||||
indexTestUnit('''
|
||||
test_createChange_MethodElement() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
@@ -664,7 +664,7 @@ main() {
|
||||
}
|
||||
|
||||
test_createChange_MethodElement_potential() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
@@ -695,14 +695,14 @@ main(var a) {
|
||||
|
||||
test_createChange_MethodElement_potential_inPubCache() async {
|
||||
String pkgLib = '/.pub-cache/lib.dart';
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
pkgLib,
|
||||
r'''
|
||||
processObj(p) {
|
||||
p.test();
|
||||
}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
import '$pkgLib';
|
||||
class A {
|
||||
test() {}
|
||||
@@ -731,7 +731,7 @@ main(var a) {
|
||||
}
|
||||
|
||||
test_createChange_MethodElement_potential_private_otherLibrary() async {
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library lib;
|
||||
@@ -739,7 +739,7 @@ main(p) {
|
||||
p._test();
|
||||
}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
_test() {}
|
||||
}
|
||||
@@ -766,8 +766,8 @@ main(var a) {
|
||||
assertNoFileChange('/lib.dart');
|
||||
}
|
||||
|
||||
test_createChange_PropertyAccessorElement_getter() {
|
||||
indexTestUnit('''
|
||||
test_createChange_PropertyAccessorElement_getter() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
get test {} // marker
|
||||
set test(x) {}
|
||||
@@ -821,8 +821,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_PropertyAccessorElement_setter() {
|
||||
indexTestUnit('''
|
||||
test_createChange_PropertyAccessorElement_setter() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
get test {}
|
||||
set test(x) {} // marker
|
||||
@@ -876,8 +876,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_TypeParameterElement() {
|
||||
indexTestUnit('''
|
||||
test_createChange_TypeParameterElement() async {
|
||||
await indexTestUnit('''
|
||||
class A<Test> {
|
||||
Test field;
|
||||
List<Test> items;
|
||||
|
||||
@@ -23,7 +23,7 @@ main() {
|
||||
@reflectiveTest
|
||||
class RenameConstructorTest extends RenameRefactoringTest {
|
||||
test_checkInitialConditions_inSDK() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
new String.fromCharCodes([]);
|
||||
}
|
||||
@@ -37,8 +37,8 @@ main() {
|
||||
"The constructor 'String.fromCharCodes' is defined in the SDK, so cannot be renamed.");
|
||||
}
|
||||
|
||||
test_checkNewName() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A.test() {}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkNewName_hasMember_constructor() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A.test() {}
|
||||
A.newName() {} // existing
|
||||
@@ -82,7 +82,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkNewName_hasMember_method() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A.test() {}
|
||||
newName() {} // existing
|
||||
@@ -98,8 +98,8 @@ class A {
|
||||
expectedContextSearch: 'newName() {} // existing');
|
||||
}
|
||||
|
||||
test_createChange_add() {
|
||||
indexTestUnit('''
|
||||
test_createChange_add() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A() {} // marker
|
||||
}
|
||||
@@ -132,8 +132,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_add_toSynthetic() {
|
||||
indexTestUnit('''
|
||||
test_createChange_add_toSynthetic() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
}
|
||||
class B extends A {
|
||||
@@ -165,8 +165,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_change() {
|
||||
indexTestUnit('''
|
||||
test_createChange_change() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A.test() {} // marker
|
||||
}
|
||||
@@ -199,8 +199,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_remove() {
|
||||
indexTestUnit('''
|
||||
test_createChange_remove() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A.test() {} // marker
|
||||
}
|
||||
@@ -233,7 +233,7 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
void test_newInstance_nullElement() {
|
||||
test_newInstance_nullElement() async {
|
||||
RenameRefactoring refactoring = new RenameRefactoring(searchEngine, null);
|
||||
expect(refactoring, isNull);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class RenameImportTest extends RenameRefactoringTest {
|
||||
test_checkNewName() {
|
||||
indexTestUnit("import 'dart:async' as test;");
|
||||
test_checkNewName() async {
|
||||
await indexTestUnit("import 'dart:async' as test;");
|
||||
_createRefactoring("import 'dart:");
|
||||
expect(refactoring.oldName, 'test');
|
||||
// null
|
||||
@@ -42,8 +42,8 @@ class RenameImportTest extends RenameRefactoringTest {
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_createChange_add() {
|
||||
indexTestUnit('''
|
||||
test_createChange_add() async {
|
||||
await indexTestUnit('''
|
||||
import 'dart:async';
|
||||
import 'dart:math' show Random, min hide max;
|
||||
main() {
|
||||
@@ -68,8 +68,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_add_interpolationExpression_hasCurlyBrackets() {
|
||||
indexTestUnit(r'''
|
||||
test_createChange_add_interpolationExpression_hasCurlyBrackets() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
main() {
|
||||
Future f;
|
||||
@@ -90,8 +90,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_add_interpolationExpression_noCurlyBrackets() {
|
||||
indexTestUnit(r'''
|
||||
test_createChange_add_interpolationExpression_noCurlyBrackets() async {
|
||||
await indexTestUnit(r'''
|
||||
import 'dart:async';
|
||||
main() {
|
||||
Future f;
|
||||
@@ -112,8 +112,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_change_className() {
|
||||
indexTestUnit('''
|
||||
test_createChange_change_className() async {
|
||||
await indexTestUnit('''
|
||||
import 'dart:math' as test;
|
||||
import 'dart:async' as test;
|
||||
main() {
|
||||
@@ -135,8 +135,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_change_function() {
|
||||
indexTestUnit('''
|
||||
test_createChange_change_function() async {
|
||||
await indexTestUnit('''
|
||||
import 'dart:math' as test;
|
||||
import 'dart:async' as test;
|
||||
main() {
|
||||
@@ -160,8 +160,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_change_onPrefixElement() {
|
||||
indexTestUnit('''
|
||||
test_createChange_change_onPrefixElement() async {
|
||||
await indexTestUnit('''
|
||||
import 'dart:async' as test;
|
||||
import 'dart:math' as test;
|
||||
main() {
|
||||
@@ -187,8 +187,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_remove() {
|
||||
indexTestUnit('''
|
||||
test_createChange_remove() async {
|
||||
await indexTestUnit('''
|
||||
import 'dart:math' as test;
|
||||
import 'dart:async' as test;
|
||||
main() {
|
||||
@@ -210,8 +210,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_oldName_empty() {
|
||||
indexTestUnit('''
|
||||
test_oldName_empty() async {
|
||||
await indexTestUnit('''
|
||||
import 'dart:math';
|
||||
import 'dart:async';
|
||||
main() {
|
||||
|
||||
@@ -18,8 +18,8 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class RenameLabelTest extends RenameRefactoringTest {
|
||||
test_checkNewName_LocalVariableElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_LocalVariableElement() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
test:
|
||||
while (true) {
|
||||
@@ -43,8 +43,8 @@ test:
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_createChange() {
|
||||
indexTestUnit('''
|
||||
test_createChange() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
test:
|
||||
while (true) {
|
||||
@@ -68,8 +68,8 @@ newName:
|
||||
''');
|
||||
}
|
||||
|
||||
test_oldName() {
|
||||
indexTestUnit('''
|
||||
test_oldName() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
test:
|
||||
while (true) {
|
||||
|
||||
@@ -19,8 +19,8 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class RenameLibraryTest extends RenameRefactoringTest {
|
||||
void test_checkNewName() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName() async {
|
||||
await indexTestUnit('''
|
||||
library my.app;
|
||||
''');
|
||||
_createRenameRefactoring();
|
||||
@@ -48,7 +48,7 @@ library my.app;
|
||||
'''
|
||||
part of my.app;
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
library my.app;
|
||||
part 'part.dart';
|
||||
''');
|
||||
@@ -76,7 +76,7 @@ part of the.new.name;
|
||||
'''
|
||||
part of my . app;
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
library my . app;
|
||||
part 'part.dart';
|
||||
''');
|
||||
|
||||
@@ -20,7 +20,7 @@ main() {
|
||||
@reflectiveTest
|
||||
class RenameLocalTest extends RenameRefactoringTest {
|
||||
test_checkFinalConditions_hasLocalFunction_after() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 0;
|
||||
newName() => 1;
|
||||
@@ -36,7 +36,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasLocalFunction_before() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
newName() => 1;
|
||||
int test = 0;
|
||||
@@ -51,7 +51,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasLocalVariable_after() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 0;
|
||||
var newName = 1;
|
||||
@@ -69,7 +69,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasLocalVariable_before() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
var newName = 1;
|
||||
int test = 0;
|
||||
@@ -84,8 +84,8 @@ main() {
|
||||
expectedContextSearch: 'newName = 1;');
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasLocalVariable_otherBlock() {
|
||||
indexTestUnit('''
|
||||
test_checkFinalConditions_hasLocalVariable_otherBlock() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
{
|
||||
var newName = 1;
|
||||
@@ -101,8 +101,8 @@ main() {
|
||||
return assertRefactoringConditionsOK();
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasLocalVariable_otherForEachLoop() {
|
||||
indexTestUnit('''
|
||||
test_checkFinalConditions_hasLocalVariable_otherForEachLoop() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
for (int newName in []) {}
|
||||
for (int test in []) {}
|
||||
@@ -114,8 +114,8 @@ main() {
|
||||
return assertRefactoringConditionsOK();
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasLocalVariable_otherForLoop() {
|
||||
indexTestUnit('''
|
||||
test_checkFinalConditions_hasLocalVariable_otherForLoop() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
for (int newName = 0; newName < 10; newName++) {}
|
||||
for (int test = 0; test < 10; test++) {}
|
||||
@@ -127,8 +127,8 @@ main() {
|
||||
return assertRefactoringConditionsOK();
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasLocalVariable_otherFunction() {
|
||||
indexTestUnit('''
|
||||
test_checkFinalConditions_hasLocalVariable_otherFunction() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 0;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ main2() {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadows_classMember() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
var newName = 1;
|
||||
main() {
|
||||
@@ -163,7 +163,7 @@ class A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadows_classMember_namedParameter() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
foo({test: 1}) {
|
||||
}
|
||||
@@ -185,8 +185,8 @@ class B extends A {
|
||||
expectedContextSearch: 'newName);');
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadows_classMemberOK_qualifiedReference() {
|
||||
indexTestUnit('''
|
||||
test_checkFinalConditions_shadows_classMemberOK_qualifiedReference() async {
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
var newName = 1;
|
||||
main() {
|
||||
@@ -201,8 +201,8 @@ class A {
|
||||
return assertRefactoringConditionsOK();
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadows_OK_namedParameterReference() {
|
||||
indexTestUnit('''
|
||||
test_checkFinalConditions_shadows_OK_namedParameterReference() async {
|
||||
await indexTestUnit('''
|
||||
void f({newName}) {}
|
||||
main() {
|
||||
var test = 0;
|
||||
@@ -216,7 +216,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadows_topLevelFunction() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
newName() {}
|
||||
main() {
|
||||
var test = 0;
|
||||
@@ -231,8 +231,8 @@ main() {
|
||||
expectedContextSearch: 'newName(); // ref');
|
||||
}
|
||||
|
||||
test_checkNewName_FunctionElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_FunctionElement() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test() {}
|
||||
}
|
||||
@@ -248,8 +248,8 @@ main() {
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_checkNewName_LocalVariableElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_LocalVariableElement() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 0;
|
||||
}
|
||||
@@ -270,8 +270,8 @@ main() {
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_checkNewName_ParameterElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_ParameterElement() async {
|
||||
await indexTestUnit('''
|
||||
main(test) {
|
||||
}
|
||||
''');
|
||||
@@ -286,8 +286,8 @@ main(test) {
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_createChange_localFunction() {
|
||||
indexTestUnit('''
|
||||
test_createChange_localFunction() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test() => 0;
|
||||
print(test);
|
||||
@@ -309,8 +309,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_localFunction_sameNameDifferenceScopes() {
|
||||
indexTestUnit('''
|
||||
test_createChange_localFunction_sameNameDifferenceScopes() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
{
|
||||
int test() => 0;
|
||||
@@ -349,8 +349,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_localVariable() {
|
||||
indexTestUnit('''
|
||||
test_createChange_localVariable() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 0;
|
||||
test = 1;
|
||||
@@ -374,8 +374,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_localVariable_sameNameDifferenceScopes() {
|
||||
indexTestUnit('''
|
||||
test_createChange_localVariable_sameNameDifferenceScopes() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
{
|
||||
int test = 0;
|
||||
@@ -414,8 +414,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_parameter() {
|
||||
indexTestUnit('''
|
||||
test_createChange_parameter() async {
|
||||
await indexTestUnit('''
|
||||
myFunction({int test}) {
|
||||
test = 1;
|
||||
test += 2;
|
||||
@@ -444,12 +444,12 @@ main() {
|
||||
}
|
||||
|
||||
test_createChange_parameter_named_inOtherFile() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class A {
|
||||
A({test});
|
||||
}
|
||||
''');
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/test2.dart',
|
||||
'''
|
||||
import 'test.dart';
|
||||
@@ -478,7 +478,7 @@ main() {
|
||||
}
|
||||
|
||||
test_createChange_parameter_named_updateHierarchy() async {
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/test2.dart',
|
||||
'''
|
||||
library test2;
|
||||
@@ -493,7 +493,7 @@ class B extends A {
|
||||
}
|
||||
}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
import 'test2.dart';
|
||||
main() {
|
||||
new A().foo(test: 10);
|
||||
@@ -541,8 +541,8 @@ class B extends A {
|
||||
''');
|
||||
}
|
||||
|
||||
test_oldName() {
|
||||
indexTestUnit('''
|
||||
test_oldName() async {
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
int test = 0;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ main() {
|
||||
@reflectiveTest
|
||||
class RenameUnitMemberTest extends RenameRefactoringTest {
|
||||
test_checkFinalConditions_hasTopLevel_ClassElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
class NewName {} // existing
|
||||
''');
|
||||
@@ -34,7 +34,7 @@ class NewName {} // existing
|
||||
}
|
||||
|
||||
test_checkFinalConditions_hasTopLevel_FunctionTypeAliasElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
typedef NewName(); // existing
|
||||
''');
|
||||
@@ -49,7 +49,7 @@ typedef NewName(); // existing
|
||||
}
|
||||
|
||||
test_checkFinalConditions_OK_qualifiedSuper_MethodElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
class A {
|
||||
NewName() {}
|
||||
@@ -68,10 +68,10 @@ class B extends A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_publicToPrivate_usedInOtherLibrary() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
''');
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library my.lib;
|
||||
@@ -90,7 +90,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowedBy_MethodElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
class A {
|
||||
void NewName() {}
|
||||
@@ -110,10 +110,10 @@ class A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowsInSubClass_importedLib() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
''');
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library my.lib;
|
||||
@@ -136,10 +136,10 @@ class B extends A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowsInSubClass_importedLib_hideCombinator() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
''');
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library my.lib;
|
||||
@@ -161,7 +161,7 @@ class B extends A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowsInSubClass_MethodElement() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
class A {
|
||||
NewName() {}
|
||||
@@ -182,7 +182,7 @@ class B extends A {
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowsInSubClass_notImportedLib() async {
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/lib.dart',
|
||||
'''
|
||||
library my.lib;
|
||||
@@ -195,7 +195,7 @@ class B extends A {
|
||||
}",
|
||||
}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
''');
|
||||
createRenameRefactoringAtString('Test {}');
|
||||
@@ -206,7 +206,7 @@ class Test {}
|
||||
}
|
||||
|
||||
test_checkFinalConditions_shadowsInSubClass_notSubClass() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
class A {
|
||||
NewName() {}
|
||||
@@ -230,7 +230,7 @@ class B {
|
||||
r'''
|
||||
class A {}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
import '/.pub-cache/lib.dart';
|
||||
main() {
|
||||
A a;
|
||||
@@ -251,7 +251,7 @@ main() {
|
||||
r'''
|
||||
class A {}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
import '/Pub/Cache/lib.dart';
|
||||
main() {
|
||||
A a;
|
||||
@@ -267,7 +267,7 @@ main() {
|
||||
}
|
||||
|
||||
test_checkInitialConditions_inSDK() async {
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
main() {
|
||||
String s;
|
||||
}
|
||||
@@ -281,8 +281,8 @@ main() {
|
||||
"The class 'String' is defined in the SDK, so cannot be renamed.");
|
||||
}
|
||||
|
||||
test_checkNewName_ClassElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_ClassElement() async {
|
||||
await indexTestUnit('''
|
||||
class Test {}
|
||||
''');
|
||||
createRenameRefactoringAtString('Test {}');
|
||||
@@ -307,8 +307,8 @@ class Test {}
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_checkNewName_FunctionElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_FunctionElement() async {
|
||||
await indexTestUnit('''
|
||||
test() {}
|
||||
''');
|
||||
createRenameRefactoringAtString('test() {}');
|
||||
@@ -327,8 +327,8 @@ test() {}
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_checkNewName_FunctionTypeAliasElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_FunctionTypeAliasElement() async {
|
||||
await indexTestUnit('''
|
||||
typedef Test();
|
||||
''');
|
||||
createRenameRefactoringAtString('Test();');
|
||||
@@ -342,8 +342,8 @@ typedef Test();
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_checkNewName_TopLevelVariableElement() {
|
||||
indexTestUnit('''
|
||||
test_checkNewName_TopLevelVariableElement() async {
|
||||
await indexTestUnit('''
|
||||
var test;
|
||||
''');
|
||||
createRenameRefactoringAtString('test;');
|
||||
@@ -362,8 +362,8 @@ var test;
|
||||
assertRefactoringStatusOK(refactoring.checkNewName());
|
||||
}
|
||||
|
||||
test_createChange_ClassElement() {
|
||||
indexTestUnit('''
|
||||
test_createChange_ClassElement() async {
|
||||
await indexTestUnit('''
|
||||
class Test implements Other {
|
||||
Test() {}
|
||||
Test.named() {}
|
||||
@@ -400,9 +400,9 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_ClassElement_invocation() {
|
||||
test_createChange_ClassElement_invocation() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
class Test {
|
||||
}
|
||||
main() {
|
||||
@@ -425,8 +425,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_ClassElement_parameterTypeNested() {
|
||||
indexTestUnit('''
|
||||
test_createChange_ClassElement_parameterTypeNested() async {
|
||||
await indexTestUnit('''
|
||||
class Test {
|
||||
}
|
||||
main(f(Test p)) {
|
||||
@@ -446,8 +446,8 @@ main(f(NewName p)) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_ClassElement_typeAlias() {
|
||||
indexTestUnit('''
|
||||
test_createChange_ClassElement_typeAlias() async {
|
||||
await indexTestUnit('''
|
||||
class A {}
|
||||
class Test = Object with A;
|
||||
main(Test t) {
|
||||
@@ -468,8 +468,8 @@ main(NewName t) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_FunctionElement() {
|
||||
indexTestUnit('''
|
||||
test_createChange_FunctionElement() async {
|
||||
await indexTestUnit('''
|
||||
test() {}
|
||||
foo() {}
|
||||
main() {
|
||||
@@ -497,13 +497,13 @@ main() {
|
||||
}
|
||||
|
||||
test_createChange_FunctionElement_imported() async {
|
||||
indexUnit(
|
||||
await indexUnit(
|
||||
'/foo.dart',
|
||||
r'''
|
||||
test() {}
|
||||
foo() {}
|
||||
''');
|
||||
indexTestUnit('''
|
||||
await indexTestUnit('''
|
||||
import 'foo.dart';
|
||||
main() {
|
||||
print(test);
|
||||
@@ -534,44 +534,44 @@ foo() {}
|
||||
''');
|
||||
}
|
||||
|
||||
test_createChange_PropertyAccessorElement_getter_declaration() {
|
||||
return _test_createChange_PropertyAccessorElement("test {}");
|
||||
test_createChange_PropertyAccessorElement_getter_declaration() async {
|
||||
await _test_createChange_PropertyAccessorElement("test {}");
|
||||
}
|
||||
|
||||
test_createChange_PropertyAccessorElement_getter_usage() {
|
||||
return _test_createChange_PropertyAccessorElement("test);");
|
||||
test_createChange_PropertyAccessorElement_getter_usage() async {
|
||||
await _test_createChange_PropertyAccessorElement("test);");
|
||||
}
|
||||
|
||||
test_createChange_PropertyAccessorElement_mix() {
|
||||
return _test_createChange_PropertyAccessorElement("test += 2");
|
||||
test_createChange_PropertyAccessorElement_mix() async {
|
||||
await _test_createChange_PropertyAccessorElement("test += 2");
|
||||
}
|
||||
|
||||
test_createChange_PropertyAccessorElement_setter_declaration() {
|
||||
return _test_createChange_PropertyAccessorElement("test(x) {}");
|
||||
test_createChange_PropertyAccessorElement_setter_declaration() async {
|
||||
await _test_createChange_PropertyAccessorElement("test(x) {}");
|
||||
}
|
||||
|
||||
test_createChange_PropertyAccessorElement_setter_usage() {
|
||||
return _test_createChange_PropertyAccessorElement("test = 1");
|
||||
test_createChange_PropertyAccessorElement_setter_usage() async {
|
||||
await _test_createChange_PropertyAccessorElement("test = 1");
|
||||
}
|
||||
|
||||
test_createChange_TopLevelVariableElement_field() {
|
||||
return _test_createChange_TopLevelVariableElement("test = 0");
|
||||
test_createChange_TopLevelVariableElement_field() async {
|
||||
await _test_createChange_TopLevelVariableElement("test = 0");
|
||||
}
|
||||
|
||||
test_createChange_TopLevelVariableElement_getter() {
|
||||
return _test_createChange_TopLevelVariableElement("test);");
|
||||
test_createChange_TopLevelVariableElement_getter() async {
|
||||
await _test_createChange_TopLevelVariableElement("test);");
|
||||
}
|
||||
|
||||
test_createChange_TopLevelVariableElement_mix() {
|
||||
return _test_createChange_TopLevelVariableElement("test += 2");
|
||||
test_createChange_TopLevelVariableElement_mix() async {
|
||||
await _test_createChange_TopLevelVariableElement("test += 2");
|
||||
}
|
||||
|
||||
test_createChange_TopLevelVariableElement_setter() {
|
||||
return _test_createChange_TopLevelVariableElement("test = 1");
|
||||
test_createChange_TopLevelVariableElement_setter() async {
|
||||
await _test_createChange_TopLevelVariableElement("test = 1");
|
||||
}
|
||||
|
||||
_test_createChange_PropertyAccessorElement(String search) {
|
||||
indexTestUnit('''
|
||||
_test_createChange_PropertyAccessorElement(String search) async {
|
||||
await indexTestUnit('''
|
||||
get test {}
|
||||
set test(x) {}
|
||||
main() {
|
||||
@@ -597,8 +597,8 @@ main() {
|
||||
''');
|
||||
}
|
||||
|
||||
_test_createChange_TopLevelVariableElement(String search) {
|
||||
indexTestUnit('''
|
||||
_test_createChange_TopLevelVariableElement(String search) async {
|
||||
await indexTestUnit('''
|
||||
int test = 0;
|
||||
main() {
|
||||
print(test);
|
||||
|
||||
@@ -32,8 +32,8 @@ class HierarchyTest extends AbstractSingleUnitTest {
|
||||
searchEngine = new SearchEngineImpl(index);
|
||||
}
|
||||
|
||||
void test_getClassMembers() {
|
||||
_indexTestUnit('''
|
||||
test_getClassMembers() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A() {}
|
||||
var ma1;
|
||||
@@ -58,8 +58,8 @@ class B extends A {
|
||||
}
|
||||
}
|
||||
|
||||
Future test_getHierarchyMembers_constructors() {
|
||||
_indexTestUnit('''
|
||||
test_getHierarchyMembers_constructors() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A() {}
|
||||
}
|
||||
@@ -80,8 +80,8 @@ class B extends A {
|
||||
return Future.wait([futureA, futureB]);
|
||||
}
|
||||
|
||||
Future test_getHierarchyMembers_fields() {
|
||||
_indexTestUnit('''
|
||||
test_getHierarchyMembers_fields() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
int foo;
|
||||
}
|
||||
@@ -118,8 +118,8 @@ class D {
|
||||
return Future.wait([futureA, futureB, futureC, futureD]);
|
||||
}
|
||||
|
||||
Future test_getHierarchyMembers_fields_static() async {
|
||||
_indexTestUnit('''
|
||||
test_getHierarchyMembers_fields_static() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
static int foo;
|
||||
}
|
||||
@@ -153,8 +153,8 @@ class C extends B {
|
||||
}
|
||||
}
|
||||
|
||||
Future test_getHierarchyMembers_methods() {
|
||||
_indexTestUnit('''
|
||||
test_getHierarchyMembers_methods() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
foo() {}
|
||||
}
|
||||
@@ -199,8 +199,8 @@ class E extends D {
|
||||
return Future.wait([futureA, futureB, futureC, futureD, futureE]);
|
||||
}
|
||||
|
||||
Future test_getHierarchyMembers_methods_static() async {
|
||||
_indexTestUnit('''
|
||||
test_getHierarchyMembers_methods_static() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
static foo() {}
|
||||
}
|
||||
@@ -224,8 +224,8 @@ class B extends A {
|
||||
}
|
||||
}
|
||||
|
||||
Future test_getHierarchyMembers_withInterfaces() {
|
||||
_indexTestUnit('''
|
||||
test_getHierarchyMembers_withInterfaces() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
foo() {}
|
||||
}
|
||||
@@ -259,8 +259,8 @@ class E {
|
||||
return Future.wait([futureA, futureB, futureD]);
|
||||
}
|
||||
|
||||
void test_getMembers() {
|
||||
_indexTestUnit('''
|
||||
test_getMembers() async {
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A() {}
|
||||
var ma1;
|
||||
@@ -307,8 +307,8 @@ class B extends A {
|
||||
}
|
||||
}
|
||||
|
||||
void test_getSuperClasses() {
|
||||
_indexTestUnit('''
|
||||
test_getSuperClasses() async {
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
class B extends A {}
|
||||
class C extends B {}
|
||||
@@ -361,8 +361,8 @@ class F implements A {}
|
||||
}
|
||||
}
|
||||
|
||||
void _indexTestUnit(String code) {
|
||||
resolveTestUnit(code);
|
||||
Future<Null> _indexTestUnit(String code) async {
|
||||
await resolveTestUnit(code);
|
||||
index.indexUnit(testUnit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class SearchEngineImplTest extends AbstractSingleUnitTest {
|
||||
}
|
||||
|
||||
test_searchAllSubtypes() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class T {}
|
||||
class A extends T {}
|
||||
class B extends A {}
|
||||
@@ -90,7 +90,7 @@ class C implements B {}
|
||||
}
|
||||
|
||||
test_searchMemberDeclarations() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class B {
|
||||
}
|
||||
|
||||
test_searchMemberReferences_qualified_resolved() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class C {
|
||||
var test;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ main(C c) {
|
||||
}
|
||||
|
||||
test_searchMemberReferences_qualified_unresolved() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
main(p) {
|
||||
print(p.test);
|
||||
p.test = 1;
|
||||
@@ -152,7 +152,7 @@ main(p) {
|
||||
}
|
||||
|
||||
test_searchMemberReferences_unqualified_resolved() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class C {
|
||||
var test;
|
||||
main() {
|
||||
@@ -170,7 +170,7 @@ class C {
|
||||
|
||||
test_searchMemberReferences_unqualified_unresolved() async {
|
||||
verifyNoTestUnitErrors = false;
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class C {
|
||||
main() {
|
||||
print(test);
|
||||
@@ -193,7 +193,7 @@ class C {
|
||||
}
|
||||
|
||||
test_searchReferences_ClassElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {}
|
||||
main(A p) {
|
||||
A v;
|
||||
@@ -215,7 +215,7 @@ main(A p) {
|
||||
'''
|
||||
part of lib;
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
library lib;
|
||||
part 'my_part.dart';
|
||||
''');
|
||||
@@ -228,7 +228,7 @@ part 'my_part.dart';
|
||||
}
|
||||
|
||||
test_searchReferences_ConstructorElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
A.named() {}
|
||||
}
|
||||
@@ -245,7 +245,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_ConstructorElement_synthetic() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
}
|
||||
main() {
|
||||
@@ -266,7 +266,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_FieldElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
var field;
|
||||
A({this.field});
|
||||
@@ -300,7 +300,7 @@ class A {
|
||||
}
|
||||
|
||||
test_searchReferences_FieldElement_ofEnum() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
enum MyEnum {
|
||||
A, B, C
|
||||
}
|
||||
@@ -326,7 +326,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_FieldElement_synthetic() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
get field => null;
|
||||
set field(x) {}
|
||||
@@ -356,7 +356,7 @@ class A {
|
||||
}
|
||||
|
||||
test_searchReferences_FunctionElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
test() {}
|
||||
main() {
|
||||
test();
|
||||
@@ -373,7 +373,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_FunctionElement_local() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
main() {
|
||||
test() {}
|
||||
test();
|
||||
@@ -390,7 +390,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_FunctionTypeAliasElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
typedef Test();
|
||||
main() {
|
||||
Test a;
|
||||
@@ -408,7 +408,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_ImportElement_noPrefix() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'dart:math' show max, PI, Random hide min;
|
||||
export 'dart:math' show max, PI, Random hide min;
|
||||
main() {
|
||||
@@ -432,7 +432,7 @@ Random bar() => null;
|
||||
}
|
||||
|
||||
test_searchReferences_ImportElement_withPrefix() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'dart:math' as math show max, PI, Random hide min;
|
||||
export 'dart:math' show max, PI, Random hide min;
|
||||
main() {
|
||||
@@ -457,7 +457,7 @@ math.Random bar() => null;
|
||||
}
|
||||
|
||||
test_searchReferences_ImportElement_withPrefix_forMultipleImports() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'dart:async' as p;
|
||||
import 'dart:math' as p;
|
||||
main() {
|
||||
@@ -485,7 +485,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_LabelElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
main() {
|
||||
label:
|
||||
while (true) {
|
||||
@@ -510,7 +510,7 @@ label:
|
||||
var codeB = 'part of lib; // B';
|
||||
addSource('/unitA.dart', codeA);
|
||||
addSource('/unitB.dart', codeB);
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
library lib;
|
||||
part 'unitA.dart';
|
||||
part 'unitB.dart';
|
||||
@@ -530,7 +530,7 @@ part 'unitB.dart';
|
||||
}
|
||||
|
||||
test_searchReferences_LocalVariableElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
main() {
|
||||
var v;
|
||||
v = 1;
|
||||
@@ -551,7 +551,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_LocalVariableElement_inForEachLoop() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
main() {
|
||||
for (var v in []) {
|
||||
v = 1;
|
||||
@@ -573,7 +573,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_MethodElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
m() {}
|
||||
main() {
|
||||
@@ -596,7 +596,7 @@ class A {
|
||||
}
|
||||
|
||||
test_searchReferences_MethodMember() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A<T> {
|
||||
T m() => null;
|
||||
}
|
||||
@@ -613,7 +613,7 @@ main(A<int> a) {
|
||||
}
|
||||
|
||||
test_searchReferences_null_noUnitElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
m() {}
|
||||
}
|
||||
@@ -630,7 +630,7 @@ main(A a) {
|
||||
}
|
||||
|
||||
test_searchReferences_ParameterElement_ofConstructor() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class C {
|
||||
var f;
|
||||
C({p}) : f = p + 1 {
|
||||
@@ -660,7 +660,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_ParameterElement_ofLocalFunction() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
main() {
|
||||
foo({p}) {
|
||||
p = 1;
|
||||
@@ -685,7 +685,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_ParameterElement_ofMethod() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class C {
|
||||
foo({p}) {
|
||||
p = 1;
|
||||
@@ -712,7 +712,7 @@ main(C c) {
|
||||
}
|
||||
|
||||
test_searchReferences_ParameterElement_ofTopLevelFunction() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
foo({p}) {
|
||||
p = 1;
|
||||
p += 2;
|
||||
@@ -737,7 +737,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_PrefixElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'dart:async' as ppp;
|
||||
main() {
|
||||
ppp.Future a;
|
||||
@@ -755,7 +755,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_PropertyAccessorElement_getter() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
get ggg => null;
|
||||
main() {
|
||||
@@ -778,7 +778,7 @@ class A {
|
||||
}
|
||||
|
||||
test_searchReferences_PropertyAccessorElement_setter() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {
|
||||
set s(x) {}
|
||||
main() {
|
||||
@@ -803,7 +803,7 @@ class A {
|
||||
library lib;
|
||||
var V;
|
||||
''');
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
import 'lib.dart' show V; // imp
|
||||
import 'lib.dart' as pref;
|
||||
main() {
|
||||
@@ -833,7 +833,7 @@ main() {
|
||||
}
|
||||
|
||||
test_searchReferences_TypeParameterElement() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A<T> {
|
||||
main(T a, T b) {}
|
||||
}
|
||||
@@ -849,7 +849,7 @@ class A<T> {
|
||||
}
|
||||
|
||||
test_searchSubtypes() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class T {}
|
||||
class A extends T {} // A
|
||||
class B = Object with T; // B
|
||||
@@ -869,7 +869,7 @@ class C implements T {} // C
|
||||
}
|
||||
|
||||
test_searchTopLevelDeclarations() async {
|
||||
_indexTestUnit('''
|
||||
await _indexTestUnit('''
|
||||
class A {} // A
|
||||
class B = Object with A;
|
||||
typedef C();
|
||||
@@ -930,8 +930,8 @@ class NoMatchABCDE {}
|
||||
isQualified: false, isResolved: false, length: length);
|
||||
}
|
||||
|
||||
void _indexTestUnit(String code) {
|
||||
resolveTestUnit(code);
|
||||
Future<Null> _indexTestUnit(String code) async {
|
||||
await resolveTestUnit(code);
|
||||
index.indexUnit(testUnit);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ main() {
|
||||
|
||||
@reflectiveTest
|
||||
class DartChangeBuilderImplTest extends AbstractContextTest {
|
||||
void test_createFileEditBuilder() {
|
||||
test_createFileEditBuilder() async {
|
||||
Source source = addSource('/test.dart', 'library test;');
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
int timeStamp = 54;
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
DartFileEditBuilderImpl fileEditBuilder =
|
||||
@@ -55,9 +55,9 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
return edits[0];
|
||||
}
|
||||
|
||||
void test_writeClassDeclaration_interfaces() {
|
||||
test_writeClassDeclaration_interfaces() async {
|
||||
Source source = addSource('/test.dart', 'class A {}');
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration declaration = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -73,9 +73,9 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
edit.replacement, equalsIgnoringWhitespace('class C implements A { }'));
|
||||
}
|
||||
|
||||
void test_writeClassDeclaration_isAbstract() {
|
||||
test_writeClassDeclaration_isAbstract() async {
|
||||
Source source = addSource('/test.dart', '');
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -88,9 +88,9 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('abstract class C { }'));
|
||||
}
|
||||
|
||||
void test_writeClassDeclaration_memberWriter() {
|
||||
test_writeClassDeclaration_memberWriter() async {
|
||||
Source source = addSource('/test.dart', '');
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -105,9 +105,9 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('class C { /**/ }'));
|
||||
}
|
||||
|
||||
void test_writeClassDeclaration_mixins_noSuperclass() {
|
||||
test_writeClassDeclaration_mixins_noSuperclass() async {
|
||||
Source source = addSource('/test.dart', 'class A {}');
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -123,9 +123,9 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
equalsIgnoringWhitespace('class C extends Object with A { }'));
|
||||
}
|
||||
|
||||
void test_writeClassDeclaration_mixins_superclass() {
|
||||
test_writeClassDeclaration_mixins_superclass() async {
|
||||
Source source = addSource('/test.dart', 'class A {} class B {}');
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
ClassDeclaration classB = unit.declarations[1];
|
||||
|
||||
@@ -145,9 +145,9 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
equalsIgnoringWhitespace('class C extends A with B { }'));
|
||||
}
|
||||
|
||||
void test_writeClassDeclaration_nameGroupName() {
|
||||
test_writeClassDeclaration_nameGroupName() async {
|
||||
Source source = addSource('/test.dart', '');
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -167,9 +167,9 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(group.positions, hasLength(1));
|
||||
}
|
||||
|
||||
void test_writeClassDeclaration_superclass() {
|
||||
test_writeClassDeclaration_superclass() async {
|
||||
Source source = addSource('/test.dart', 'class B {}');
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration declaration = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -185,10 +185,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('class C extends B { }'));
|
||||
}
|
||||
|
||||
void test_writeFieldDeclaration_initializerWriter() {
|
||||
test_writeFieldDeclaration_initializerWriter() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -203,10 +203,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('var f = e;'));
|
||||
}
|
||||
|
||||
void test_writeFieldDeclaration_isConst() {
|
||||
test_writeFieldDeclaration_isConst() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -218,10 +218,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('const f;'));
|
||||
}
|
||||
|
||||
void test_writeFieldDeclaration_isConst_isFinal() {
|
||||
test_writeFieldDeclaration_isConst_isFinal() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -234,10 +234,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('const f;'));
|
||||
}
|
||||
|
||||
void test_writeFieldDeclaration_isFinal() {
|
||||
test_writeFieldDeclaration_isFinal() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -249,10 +249,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('final f;'));
|
||||
}
|
||||
|
||||
void test_writeFieldDeclaration_isStatic() {
|
||||
test_writeFieldDeclaration_isStatic() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -264,10 +264,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('static var f;'));
|
||||
}
|
||||
|
||||
void test_writeFieldDeclaration_nameGroupName() {
|
||||
test_writeFieldDeclaration_nameGroupName() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -289,10 +289,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(position.offset, equals(13));
|
||||
}
|
||||
|
||||
void test_writeFieldDeclaration_type_typeGroupName() {
|
||||
test_writeFieldDeclaration_type_typeGroupName() async {
|
||||
String content = 'class A {} class B {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration declaration = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -318,10 +318,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(position.offset, equals(20));
|
||||
}
|
||||
|
||||
void test_writeGetterDeclaration_bodyWriter() {
|
||||
test_writeGetterDeclaration_bodyWriter() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -336,10 +336,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('get g {}'));
|
||||
}
|
||||
|
||||
void test_writeGetterDeclaration_isStatic() {
|
||||
test_writeGetterDeclaration_isStatic() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -352,10 +352,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('static get g => null;'));
|
||||
}
|
||||
|
||||
void test_writeGetterDeclaration_nameGroupName() {
|
||||
test_writeGetterDeclaration_nameGroupName() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -377,10 +377,10 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(position.offset, equals(13));
|
||||
}
|
||||
|
||||
void test_writeGetterDeclaration_returnType() {
|
||||
test_writeGetterDeclaration_returnType() async {
|
||||
String content = 'class A {} class B {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -405,7 +405,7 @@ class DartEditBuilderImplTest extends AbstractContextTest {
|
||||
expect(position.offset, equals(20));
|
||||
}
|
||||
|
||||
void test_writeOverrideOfInheritedMember() {
|
||||
test_writeOverrideOfInheritedMember() async {
|
||||
String content = '''
|
||||
class A {
|
||||
A add(A a) => null;
|
||||
@@ -413,7 +413,7 @@ class A {
|
||||
class B extends A {
|
||||
}''';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration declaration = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -434,10 +434,10 @@ A add(A a) {
|
||||
}'''));
|
||||
}
|
||||
|
||||
void test_writeParameters_named() {
|
||||
test_writeParameters_named() async {
|
||||
String content = 'f(int i, {String s}) {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
FunctionDeclaration f = unit.declarations[0];
|
||||
FormalParameterList parameters = f.functionExpression.parameters;
|
||||
Iterable<ParameterElement> elements = parameters.parameters
|
||||
@@ -453,10 +453,10 @@ A add(A a) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('(int i, {String s})'));
|
||||
}
|
||||
|
||||
void test_writeParameters_positional() {
|
||||
test_writeParameters_positional() async {
|
||||
String content = 'f(int i, [String s]) {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
FunctionDeclaration f = unit.declarations[0];
|
||||
FormalParameterList parameters = f.functionExpression.parameters;
|
||||
Iterable<ParameterElement> elements = parameters.parameters
|
||||
@@ -472,10 +472,10 @@ A add(A a) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('(int i, [String s])'));
|
||||
}
|
||||
|
||||
void test_writeParameters_required() {
|
||||
test_writeParameters_required() async {
|
||||
String content = 'f(int i, String s) {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
FunctionDeclaration f = unit.declarations[0];
|
||||
FormalParameterList parameters = f.functionExpression.parameters;
|
||||
Iterable<ParameterElement> elements = parameters.parameters
|
||||
@@ -491,13 +491,13 @@ A add(A a) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('(int i, String s)'));
|
||||
}
|
||||
|
||||
void test_writeParametersMatchingArguments_named() {
|
||||
test_writeParametersMatchingArguments_named() async {
|
||||
String content = '''
|
||||
f(int i, String s) {
|
||||
g(s, index: i);
|
||||
}''';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
FunctionDeclaration f = unit.declarations[0];
|
||||
BlockFunctionBody body = f.functionExpression.body;
|
||||
ExpressionStatement statement = body.block.statements[0];
|
||||
@@ -515,13 +515,13 @@ f(int i, String s) {
|
||||
edit.replacement, equalsIgnoringWhitespace('(String s, [int index])'));
|
||||
}
|
||||
|
||||
void test_writeParametersMatchingArguments_required() {
|
||||
test_writeParametersMatchingArguments_required() async {
|
||||
String content = '''
|
||||
f(int i, String s) {
|
||||
g(s, i);
|
||||
}''';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
FunctionDeclaration f = unit.declarations[0];
|
||||
BlockFunctionBody body = f.functionExpression.body;
|
||||
ExpressionStatement statement = body.block.statements[0];
|
||||
@@ -538,10 +538,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('(String s, int i)'));
|
||||
}
|
||||
|
||||
void test_writeParameterSource() {
|
||||
test_writeParameterSource() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -555,10 +555,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('A a'));
|
||||
}
|
||||
|
||||
void test_writeType_dymanic() {
|
||||
test_writeType_dynamic() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -574,10 +574,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace(''));
|
||||
}
|
||||
|
||||
void test_writeType_genericType() {
|
||||
test_writeType_genericType() async {
|
||||
String content = 'class A {} class B<E> {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
ClassDeclaration classB = unit.declarations[1];
|
||||
|
||||
@@ -596,10 +596,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('B<A>'));
|
||||
}
|
||||
|
||||
void test_writeType_groupName() {
|
||||
test_writeType_groupName() async {
|
||||
String content = 'class A {} class B extends A {} class C extends B {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classC = unit.declarations[2];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -620,10 +620,10 @@ f(int i, String s) {
|
||||
expect(group, isNotNull);
|
||||
}
|
||||
|
||||
void test_writeType_groupName_addSupertypeProposals() {
|
||||
test_writeType_groupName_addSupertypeProposals() async {
|
||||
String content = 'class A {} class B extends A {} class C extends B {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classC = unit.declarations[2];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -655,10 +655,10 @@ f(int i, String s) {
|
||||
expect(values, contains('C'));
|
||||
}
|
||||
|
||||
void test_writeType_null() {
|
||||
test_writeType_null() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -670,10 +670,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace(''));
|
||||
}
|
||||
|
||||
void test_writeType_required_dymanic() {
|
||||
test_writeType_required_dynamic() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -691,10 +691,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('var'));
|
||||
}
|
||||
|
||||
void test_writeType_required_notNull() {
|
||||
test_writeType_required_notNull() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -709,10 +709,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('A'));
|
||||
}
|
||||
|
||||
void test_writeType_required_null() {
|
||||
test_writeType_required_null() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -724,10 +724,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('var'));
|
||||
}
|
||||
|
||||
void test_writeType_simpleType() {
|
||||
test_writeType_simpleType() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
@@ -741,10 +741,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('A'));
|
||||
}
|
||||
|
||||
void test_writeTypes_empty() {
|
||||
test_writeTypes_empty() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -756,10 +756,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, isEmpty);
|
||||
}
|
||||
|
||||
void test_writeTypes_noPrefix() {
|
||||
test_writeTypes_noPrefix() async {
|
||||
String content = 'class A {} class B {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
ClassDeclaration classB = unit.declarations[1];
|
||||
|
||||
@@ -776,10 +776,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, equalsIgnoringWhitespace('A, B'));
|
||||
}
|
||||
|
||||
void test_writeTypes_null() {
|
||||
test_writeTypes_null() async {
|
||||
String content = 'class A {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, 1, (FileEditBuilder builder) {
|
||||
@@ -791,10 +791,10 @@ f(int i, String s) {
|
||||
expect(edit.replacement, isEmpty);
|
||||
}
|
||||
|
||||
void test_writeTypes_prefix() {
|
||||
test_writeTypes_prefix() async {
|
||||
String content = 'class A {} class B {}';
|
||||
Source source = addSource('/test.dart', content);
|
||||
CompilationUnit unit = resolveLibraryUnit(source);
|
||||
CompilationUnit unit = await resolveLibraryUnit(source);
|
||||
ClassDeclaration classA = unit.declarations[0];
|
||||
ClassDeclaration classB = unit.declarations[1];
|
||||
|
||||
@@ -814,9 +814,9 @@ f(int i, String s) {
|
||||
|
||||
@reflectiveTest
|
||||
class DartFileEditBuilderImplTest extends AbstractContextTest {
|
||||
void test_createEditBuilder() {
|
||||
test_createEditBuilder() async {
|
||||
Source source = addSource('/test.dart', 'library test;');
|
||||
resolveLibraryUnit(source);
|
||||
await resolveLibraryUnit(source);
|
||||
int timeStamp = 65;
|
||||
DartChangeBuilderImpl builder = new DartChangeBuilderImpl(context);
|
||||
builder.addFileEdit(source, timeStamp, (FileEditBuilder builder) {
|
||||
|
||||
Reference in New Issue
Block a user