| 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..5a3d4ee7af7d59cfaa12c392f7ae92cbf4d77068 100644
|
| --- a/pkg/analysis_server/test/services/correction/util_test.dart
|
| +++ b/pkg/analysis_server/test/services/correction/util_test.dart
|
| @@ -7,8 +7,6 @@ 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:test_reflective_loader/test_reflective_loader.dart';
|
|
|
| @@ -27,9 +25,9 @@ class UtilTest extends AbstractSingleUnitTest {
|
| import 'dart:async';
|
| import 'dart:math';
|
| ''');
|
| - LibraryElement newLibrary = _getDartLibrary('dart:collection');
|
| + SourceInfo newLibrary = _getDartSourceInfo('dart:collection');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary],
|
| + <SourceInfo>[newLibrary],
|
| '''
|
| import 'dart:async';
|
| import 'dart:collection';
|
| @@ -42,9 +40,9 @@ import 'dart:math';
|
| import 'dart:collection';
|
| import 'dart:math';
|
| ''');
|
| - LibraryElement newLibrary = _getDartLibrary('dart:async');
|
| + SourceInfo newLibrary = _getDartSourceInfo('dart:async');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary],
|
| + <SourceInfo>[newLibrary],
|
| '''
|
| import 'dart:async';
|
| import 'dart:collection';
|
| @@ -57,9 +55,9 @@ import 'dart:math';
|
| import 'dart:async';
|
| import 'dart:collection';
|
| ''');
|
| - LibraryElement newLibrary = _getDartLibrary('dart:math');
|
| + SourceInfo newLibrary = _getDartSourceInfo('dart:math');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary],
|
| + <SourceInfo>[newLibrary],
|
| '''
|
| import 'dart:async';
|
| import 'dart:collection';
|
| @@ -72,10 +70,10 @@ import 'dart:math';
|
| import 'dart:collection';
|
| import 'dart:math';
|
| ''');
|
| - LibraryElement newLibrary1 = _getDartLibrary('dart:async');
|
| - LibraryElement newLibrary2 = _getDartLibrary('dart:html');
|
| + SourceInfo newLibrary1 = _getDartSourceInfo('dart:async');
|
| + SourceInfo newLibrary2 = _getDartSourceInfo('dart:html');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary1, newLibrary2],
|
| + <SourceInfo>[newLibrary1, newLibrary2],
|
| '''
|
| import 'dart:async';
|
| import 'dart:collection';
|
| @@ -89,10 +87,10 @@ import 'dart:math';
|
| import 'dart:html';
|
| import 'dart:math';
|
| ''');
|
| - LibraryElement newLibrary1 = _getDartLibrary('dart:async');
|
| - LibraryElement newLibrary2 = _getDartLibrary('dart:collection');
|
| + SourceInfo newLibrary1 = _getDartSourceInfo('dart:async');
|
| + SourceInfo newLibrary2 = _getDartSourceInfo('dart:collection');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary1, newLibrary2],
|
| + <SourceInfo>[newLibrary1, newLibrary2],
|
| '''
|
| import 'dart:async';
|
| import 'dart:collection';
|
| @@ -106,10 +104,10 @@ import 'dart:math';
|
| import 'dart:async';
|
| import 'dart:collection';
|
| ''');
|
| - LibraryElement newLibrary1 = _getDartLibrary('dart:html');
|
| - LibraryElement newLibrary2 = _getDartLibrary('dart:math');
|
| + SourceInfo newLibrary1 = _getDartSourceInfo('dart:html');
|
| + SourceInfo newLibrary2 = _getDartSourceInfo('dart:math');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary1, newLibrary2],
|
| + <SourceInfo>[newLibrary1, newLibrary2],
|
| '''
|
| import 'dart:async';
|
| import 'dart:collection';
|
| @@ -124,10 +122,10 @@ library test;
|
|
|
| class A {}
|
| ''');
|
| - LibraryElement newLibrary1 = _getDartLibrary('dart:math');
|
| - LibraryElement newLibrary2 = _getDartLibrary('dart:async');
|
| + SourceInfo newLibrary1 = _getDartSourceInfo('dart:math');
|
| + SourceInfo newLibrary2 = _getDartSourceInfo('dart:async');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary1, newLibrary2],
|
| + <SourceInfo>[newLibrary1, newLibrary2],
|
| '''
|
| library test;
|
|
|
| @@ -144,10 +142,10 @@ class A {}
|
|
|
| class A {}
|
| ''');
|
| - LibraryElement newLibrary1 = _getDartLibrary('dart:math');
|
| - LibraryElement newLibrary2 = _getDartLibrary('dart:async');
|
| + SourceInfo newLibrary1 = _getDartSourceInfo('dart:math');
|
| + SourceInfo newLibrary2 = _getDartSourceInfo('dart:async');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary1, newLibrary2],
|
| + <SourceInfo>[newLibrary1, newLibrary2],
|
| '''
|
| /// Comment.
|
|
|
| @@ -164,10 +162,10 @@ class A {}
|
|
|
| class A {}
|
| ''');
|
| - LibraryElement newLibrary1 = _getDartLibrary('dart:math');
|
| - LibraryElement newLibrary2 = _getDartLibrary('dart:async');
|
| + SourceInfo newLibrary1 = _getDartSourceInfo('dart:math');
|
| + SourceInfo newLibrary2 = _getDartSourceInfo('dart:async');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary1, newLibrary2],
|
| + <SourceInfo>[newLibrary1, newLibrary2],
|
| '''
|
| #!/bin/dart
|
|
|
| @@ -182,10 +180,10 @@ class A {}
|
| resolveTestUnit('''
|
| class A {}
|
| ''');
|
| - LibraryElement newLibrary1 = _getDartLibrary('dart:math');
|
| - LibraryElement newLibrary2 = _getDartLibrary('dart:async');
|
| + SourceInfo newLibrary1 = _getDartSourceInfo('dart:math');
|
| + SourceInfo newLibrary2 = _getDartSourceInfo('dart:async');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary1, newLibrary2],
|
| + <SourceInfo>[newLibrary1, newLibrary2],
|
| '''
|
| import 'dart:async';
|
| import 'dart:math';
|
| @@ -200,10 +198,10 @@ import 'dart:async';
|
|
|
| import 'package:aaa/aaa.dart';
|
| ''');
|
| - LibraryElement newLibrary =
|
| - _mockLibraryElement('/lib/bbb.dart', 'package:bbb/bbb.dart');
|
| + SourceInfo newLibrary =
|
| + _getSourceInfo('/lib/bbb.dart', 'package:bbb/bbb.dart');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary],
|
| + <SourceInfo>[newLibrary],
|
| '''
|
| import 'dart:async';
|
|
|
| @@ -218,10 +216,10 @@ import 'dart:async';
|
|
|
| import 'package:bbb/bbb.dart';
|
| ''');
|
| - LibraryElement newLibrary =
|
| - _mockLibraryElement('/lib/aaa.dart', 'package:aaa/aaa.dart');
|
| + SourceInfo newLibrary =
|
| + _getSourceInfo('/lib/aaa.dart', 'package:aaa/aaa.dart');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary],
|
| + <SourceInfo>[newLibrary],
|
| '''
|
| import 'dart:async';
|
|
|
| @@ -235,12 +233,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');
|
| + SourceInfo newLibrary1 =
|
| + _getSourceInfo('/lib/bbb.dart', 'package:bbb/bbb.dart');
|
| + SourceInfo newLibrary2 =
|
| + _getSourceInfo('/lib/ccc.dart', 'package:ccc/ccc.dart');
|
| _assertAddLibraryImport(
|
| - <LibraryElement>[newLibrary1, newLibrary2],
|
| + <SourceInfo>[newLibrary1, newLibrary2],
|
| '''
|
| import 'package:aaa/aaa.dart';
|
| import 'package:bbb/bbb.dart';
|
| @@ -250,7 +248,7 @@ import 'package:ddd/ddd.dart';
|
| }
|
|
|
| void _assertAddLibraryImport(
|
| - List<LibraryElement> newLibraries, String expectedCode) {
|
| + List<SourceInfo> newLibraries, String expectedCode) {
|
| SourceChange change = new SourceChange('');
|
| addLibraryImports(change, testLibraryElement, newLibraries.toSet());
|
| SourceFileEdit testEdit = change.getFileEdit(testFile);
|
| @@ -259,35 +257,12 @@ import 'package:ddd/ddd.dart';
|
| expect(resultCode, expectedCode);
|
| }
|
|
|
| - LibraryElement _getDartLibrary(String uri) {
|
| + SourceInfo _getDartSourceInfo(String uri) {
|
| String path = removeStart(uri, 'dart:');
|
| - Source newSource = new _SourceMock('/sdk/lib/$path.dart', Uri.parse(uri));
|
| - return new _LibraryElementMock(newSource);
|
| + return new SourceInfo('/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);
|
| + SourceInfo _getSourceInfo(String path, String uri) {
|
| + return new SourceInfo(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;
|
| -
|
| - @override
|
| - final Uri uri;
|
| -
|
| - _SourceMock(this.fullName, this.uri);
|
| -
|
| - noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
| -}
|
|
|