Index: pkg/analysis_server/test/services/correction/util_test.dart |
diff --git a/pkg/analysis_server/test/services/correction/util_test.dart b/pkg/analysis_server/test/services/correction/util_test.dart |
index 2eb68bb26422deebd40f4dabc918e1223cfd925b..9f945ea6d5d6e2dbccb42d814f39c321725c14bb 100644 |
--- a/pkg/analysis_server/test/services/correction/util_test.dart |
+++ b/pkg/analysis_server/test/services/correction/util_test.dart |
@@ -7,9 +7,8 @@ library test.services.correction.util; |
import 'package:analysis_server/plugin/protocol/protocol.dart'; |
import 'package:analysis_server/src/services/correction/strings.dart'; |
import 'package:analysis_server/src/services/correction/util.dart'; |
-import 'package:analyzer/dart/element/element.dart'; |
-import 'package:analyzer/src/generated/source.dart'; |
import 'package:test/test.dart'; |
+import 'package:analyzer/src/generated/source.dart'; |
import 'package:test_reflective_loader/test_reflective_loader.dart'; |
import '../../abstract_single_unit.dart'; |
@@ -27,9 +26,9 @@ class UtilTest extends AbstractSingleUnitTest { |
import 'dart:async'; |
import 'dart:math'; |
'''); |
- LibraryElement newLibrary = _getDartLibrary('dart:collection'); |
+ Source newLibrary = _getDartSourceInfo('dart:collection'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary], |
+ <Source>[newLibrary], |
''' |
import 'dart:async'; |
import 'dart:collection'; |
@@ -42,9 +41,9 @@ import 'dart:math'; |
import 'dart:collection'; |
import 'dart:math'; |
'''); |
- LibraryElement newLibrary = _getDartLibrary('dart:async'); |
+ Source newLibrary = _getDartSourceInfo('dart:async'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary], |
+ <Source>[newLibrary], |
''' |
import 'dart:async'; |
import 'dart:collection'; |
@@ -57,9 +56,9 @@ import 'dart:math'; |
import 'dart:async'; |
import 'dart:collection'; |
'''); |
- LibraryElement newLibrary = _getDartLibrary('dart:math'); |
+ Source newLibrary = _getDartSourceInfo('dart:math'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary], |
+ <Source>[newLibrary], |
''' |
import 'dart:async'; |
import 'dart:collection'; |
@@ -72,10 +71,10 @@ import 'dart:math'; |
import 'dart:collection'; |
import 'dart:math'; |
'''); |
- LibraryElement newLibrary1 = _getDartLibrary('dart:async'); |
- LibraryElement newLibrary2 = _getDartLibrary('dart:html'); |
+ Source newLibrary1 = _getDartSourceInfo('dart:async'); |
+ Source newLibrary2 = _getDartSourceInfo('dart:html'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary1, newLibrary2], |
+ <Source>[newLibrary1, newLibrary2], |
''' |
import 'dart:async'; |
import 'dart:collection'; |
@@ -89,10 +88,10 @@ import 'dart:math'; |
import 'dart:html'; |
import 'dart:math'; |
'''); |
- LibraryElement newLibrary1 = _getDartLibrary('dart:async'); |
- LibraryElement newLibrary2 = _getDartLibrary('dart:collection'); |
+ Source newLibrary1 = _getDartSourceInfo('dart:async'); |
+ Source newLibrary2 = _getDartSourceInfo('dart:collection'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary1, newLibrary2], |
+ <Source>[newLibrary1, newLibrary2], |
''' |
import 'dart:async'; |
import 'dart:collection'; |
@@ -106,10 +105,10 @@ import 'dart:math'; |
import 'dart:async'; |
import 'dart:collection'; |
'''); |
- LibraryElement newLibrary1 = _getDartLibrary('dart:html'); |
- LibraryElement newLibrary2 = _getDartLibrary('dart:math'); |
+ Source newLibrary1 = _getDartSourceInfo('dart:html'); |
+ Source newLibrary2 = _getDartSourceInfo('dart:math'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary1, newLibrary2], |
+ <Source>[newLibrary1, newLibrary2], |
''' |
import 'dart:async'; |
import 'dart:collection'; |
@@ -124,10 +123,10 @@ library test; |
class A {} |
'''); |
- LibraryElement newLibrary1 = _getDartLibrary('dart:math'); |
- LibraryElement newLibrary2 = _getDartLibrary('dart:async'); |
+ Source newLibrary1 = _getDartSourceInfo('dart:math'); |
+ Source newLibrary2 = _getDartSourceInfo('dart:async'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary1, newLibrary2], |
+ <Source>[newLibrary1, newLibrary2], |
''' |
library test; |
@@ -144,10 +143,10 @@ class A {} |
class A {} |
'''); |
- LibraryElement newLibrary1 = _getDartLibrary('dart:math'); |
- LibraryElement newLibrary2 = _getDartLibrary('dart:async'); |
+ Source newLibrary1 = _getDartSourceInfo('dart:math'); |
+ Source newLibrary2 = _getDartSourceInfo('dart:async'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary1, newLibrary2], |
+ <Source>[newLibrary1, newLibrary2], |
''' |
/// Comment. |
@@ -164,10 +163,10 @@ class A {} |
class A {} |
'''); |
- LibraryElement newLibrary1 = _getDartLibrary('dart:math'); |
- LibraryElement newLibrary2 = _getDartLibrary('dart:async'); |
+ Source newLibrary1 = _getDartSourceInfo('dart:math'); |
+ Source newLibrary2 = _getDartSourceInfo('dart:async'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary1, newLibrary2], |
+ <Source>[newLibrary1, newLibrary2], |
''' |
#!/bin/dart |
@@ -182,10 +181,10 @@ class A {} |
resolveTestUnit(''' |
class A {} |
'''); |
- LibraryElement newLibrary1 = _getDartLibrary('dart:math'); |
- LibraryElement newLibrary2 = _getDartLibrary('dart:async'); |
+ Source newLibrary1 = _getDartSourceInfo('dart:math'); |
+ Source newLibrary2 = _getDartSourceInfo('dart:async'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary1, newLibrary2], |
+ <Source>[newLibrary1, newLibrary2], |
''' |
import 'dart:async'; |
import 'dart:math'; |
@@ -200,10 +199,10 @@ import 'dart:async'; |
import 'package:aaa/aaa.dart'; |
'''); |
- LibraryElement newLibrary = |
- _mockLibraryElement('/lib/bbb.dart', 'package:bbb/bbb.dart'); |
+ Source newLibrary = |
+ _getSourceInfo('/lib/bbb.dart', 'package:bbb/bbb.dart'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary], |
+ <Source>[newLibrary], |
''' |
import 'dart:async'; |
@@ -218,10 +217,10 @@ import 'dart:async'; |
import 'package:bbb/bbb.dart'; |
'''); |
- LibraryElement newLibrary = |
- _mockLibraryElement('/lib/aaa.dart', 'package:aaa/aaa.dart'); |
+ Source newLibrary = |
+ _getSourceInfo('/lib/aaa.dart', 'package:aaa/aaa.dart'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary], |
+ <Source>[newLibrary], |
''' |
import 'dart:async'; |
@@ -235,12 +234,12 @@ import 'package:bbb/bbb.dart'; |
import 'package:aaa/aaa.dart'; |
import 'package:ddd/ddd.dart'; |
'''); |
- LibraryElement newLibrary1 = |
- _mockLibraryElement('/lib/bbb.dart', 'package:bbb/bbb.dart'); |
- LibraryElement newLibrary2 = |
- _mockLibraryElement('/lib/ccc.dart', 'package:ccc/ccc.dart'); |
+ Source newLibrary1 = |
+ _getSourceInfo('/lib/bbb.dart', 'package:bbb/bbb.dart'); |
+ Source newLibrary2 = |
+ _getSourceInfo('/lib/ccc.dart', 'package:ccc/ccc.dart'); |
_assertAddLibraryImport( |
- <LibraryElement>[newLibrary1, newLibrary2], |
+ <Source>[newLibrary1, newLibrary2], |
''' |
import 'package:aaa/aaa.dart'; |
import 'package:bbb/bbb.dart'; |
@@ -250,7 +249,7 @@ import 'package:ddd/ddd.dart'; |
} |
void _assertAddLibraryImport( |
- List<LibraryElement> newLibraries, String expectedCode) { |
+ List<Source> newLibraries, String expectedCode) { |
SourceChange change = new SourceChange(''); |
addLibraryImports(change, testLibraryElement, newLibraries.toSet()); |
SourceFileEdit testEdit = change.getFileEdit(testFile); |
@@ -259,27 +258,16 @@ import 'package:ddd/ddd.dart'; |
expect(resultCode, expectedCode); |
} |
- LibraryElement _getDartLibrary(String uri) { |
+ Source _getDartSourceInfo(String uri) { |
Brian Wilkerson
2016/12/01 18:20:42
Maybe drop the "Info" here and in _getSourceInfo?
scheglov
2016/12/01 18:21:29
Done.
|
String path = removeStart(uri, 'dart:'); |
- Source newSource = new _SourceMock('/sdk/lib/$path.dart', Uri.parse(uri)); |
- return new _LibraryElementMock(newSource); |
+ return new _SourceMock('/sdk/lib/$path.dart', Uri.parse(uri)); |
} |
- LibraryElement _mockLibraryElement(String path, String uri) { |
- Source newSource = new _SourceMock(path, Uri.parse(uri)); |
- return new _LibraryElementMock(newSource); |
+ Source _getSourceInfo(String path, String uri) { |
+ return new _SourceMock(path, Uri.parse(uri)); |
} |
} |
-class _LibraryElementMock implements LibraryElement { |
- @override |
- final Source source; |
- |
- _LibraryElementMock(this.source); |
- |
- noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
-} |
- |
class _SourceMock implements Source { |
@override |
final String fullName; |