mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
More fixes for failures on the Windows bot
R=paulberry@google.com Review URL: https://codereview.chromium.org//1266923004 .
This commit is contained in:
parent
6377f18587
commit
908708d655
|
@ -437,7 +437,7 @@ class ContextManagerImpl implements ContextManager {
|
|||
*/
|
||||
ContextInfo getContextInfoFor(Folder folder) {
|
||||
ContextInfo info = _getInnermostContextInfoFor(folder.path);
|
||||
if (folder == info.folder) {
|
||||
if (info != null && folder == info.folder) {
|
||||
return info;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -13,9 +13,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(GetErrorsTest);
|
||||
}
|
||||
|
||||
|
@ -50,7 +51,9 @@ main() {
|
|||
|
||||
test_fileWithoutContext() {
|
||||
String file = '/outside.dart';
|
||||
addFile(file, '''
|
||||
addFile(
|
||||
file,
|
||||
'''
|
||||
main() {
|
||||
print(42);
|
||||
}
|
||||
|
|
|
@ -11,9 +11,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisHoverTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,11 @@ import 'package:analyzer/file_system/file_system.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'notification_navigation_test.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(GetNavigationTest);
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,9 @@ main() {
|
|||
|
||||
test_fileWithoutContext() {
|
||||
String file = '/outside.dart';
|
||||
addFile(file, '''
|
||||
addFile(
|
||||
file,
|
||||
'''
|
||||
main() {
|
||||
print(42);
|
||||
}
|
||||
|
|
|
@ -13,9 +13,10 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisNotificationAnalyzedFilesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(NotificationErrorsTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisNotificationHighlightsTest);
|
||||
defineReflectiveTests(HighlightTypeTest);
|
||||
}
|
||||
|
@ -995,7 +997,9 @@ class A<T> {
|
|||
}
|
||||
|
||||
void _addLibraryForTestPart() {
|
||||
addFile('$testFolder/my_lib.dart', '''
|
||||
addFile(
|
||||
'$testFolder/my_lib.dart',
|
||||
'''
|
||||
library lib;
|
||||
part 'test.dart';
|
||||
''');
|
||||
|
|
|
@ -12,8 +12,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisNotificationHighlightsTest);
|
||||
defineReflectiveTests(HighlightTypeTest);
|
||||
}
|
||||
|
@ -1061,7 +1063,9 @@ class A<T> {
|
|||
}
|
||||
|
||||
void _addLibraryForTestPart() {
|
||||
addFile('$testFolder/my_lib.dart', '''
|
||||
addFile(
|
||||
'$testFolder/my_lib.dart',
|
||||
'''
|
||||
library lib;
|
||||
part 'test.dart';
|
||||
''');
|
||||
|
|
|
@ -12,9 +12,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisNotificationNavigationTest);
|
||||
}
|
||||
|
||||
|
@ -44,7 +45,8 @@ class AbstractNavigationTest extends AbstractAnalysisTest {
|
|||
}
|
||||
fail(
|
||||
'Expected to find target (file=$file; offset=$offset; length=$length) in\n'
|
||||
'${testRegion} in\n' '${testTargets.join('\n')}');
|
||||
'${testRegion} in\n'
|
||||
'${testTargets.join('\n')}');
|
||||
}
|
||||
|
||||
void assertHasOperatorRegion(String regionSearch, int regionLength,
|
||||
|
|
|
@ -12,9 +12,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisNotificationOccurrencesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(_AnalysisNotificationOutlineTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisNotificationOverridesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(ReanalyzeTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ library test.analysis;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'get_errors_test.dart' as get_errors_test;
|
||||
import 'get_hover_test.dart' as get_hover_test;
|
||||
import 'get_navigation_test.dart' as get_navigation_test;
|
||||
|
@ -23,7 +24,7 @@ import 'update_content_test.dart' as update_content_test;
|
|||
* Utility for manually running all tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('search', () {
|
||||
get_errors_test.main();
|
||||
get_hover_test.main();
|
||||
|
|
|
@ -17,9 +17,10 @@ import 'package:typed_mock/typed_mock.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(UpdateContentTest);
|
||||
}
|
||||
|
||||
|
@ -55,8 +56,9 @@ class UpdateContentTest extends AbstractAnalysisTest {
|
|||
createProject();
|
||||
addTestFile('');
|
||||
await server.onAnalysisComplete;
|
||||
server.setAnalysisSubscriptions(
|
||||
{AnalysisService.NAVIGATION: [testFile].toSet()});
|
||||
server.setAnalysisSubscriptions({
|
||||
AnalysisService.NAVIGATION: [testFile].toSet()
|
||||
});
|
||||
// update file, analyze, but don't sent notifications
|
||||
navigationCount = 0;
|
||||
server.updateContent('1', {testFile: new AddContentOverlay('foo() {}')});
|
||||
|
@ -110,17 +112,23 @@ class UpdateContentTest extends AbstractAnalysisTest {
|
|||
|
||||
test_multiple_contexts() async {
|
||||
String fooPath = '/project1/foo.dart';
|
||||
resourceProvider.newFile(fooPath, '''
|
||||
resourceProvider.newFile(
|
||||
fooPath,
|
||||
'''
|
||||
library foo;
|
||||
import '../project2/baz.dart';
|
||||
main() { f(); }''');
|
||||
String barPath = '/project2/bar.dart';
|
||||
resourceProvider.newFile(barPath, '''
|
||||
resourceProvider.newFile(
|
||||
barPath,
|
||||
'''
|
||||
library bar;
|
||||
import 'baz.dart';
|
||||
main() { f(); }''');
|
||||
String bazPath = '/project2/baz.dart';
|
||||
resourceProvider.newFile(bazPath, '''
|
||||
resourceProvider.newFile(
|
||||
bazPath,
|
||||
'''
|
||||
library baz;
|
||||
f(int i) {}
|
||||
''');
|
||||
|
|
|
@ -27,9 +27,10 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import 'mock_sdk.dart';
|
||||
import 'mocks.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisServerTest);
|
||||
}
|
||||
|
||||
|
@ -53,12 +54,16 @@ class AnalysisServerTest {
|
|||
// bar.dart.
|
||||
resourceProvider.newFolder('/foo');
|
||||
resourceProvider.newFolder('/bar');
|
||||
File foo = resourceProvider.newFile('/foo/foo.dart', '''
|
||||
File foo = resourceProvider.newFile(
|
||||
'/foo/foo.dart',
|
||||
'''
|
||||
libary foo;
|
||||
import "../bar/bar.dart";
|
||||
''');
|
||||
Source fooSource = foo.createSource();
|
||||
File bar = resourceProvider.newFile('/bar/bar.dart', '''
|
||||
File bar = resourceProvider.newFile(
|
||||
'/bar/bar.dart',
|
||||
'''
|
||||
library bar;
|
||||
import "../foo/foo.dart";
|
||||
''');
|
||||
|
@ -121,9 +126,16 @@ import "../foo/foo.dart";
|
|||
ExtensionManager manager = new ExtensionManager();
|
||||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
server = new AnalysisServer(channel, resourceProvider, packageMapProvider,
|
||||
null, serverPlugin, new AnalysisServerOptions(), new MockSdk(),
|
||||
InstrumentationService.NULL_SERVICE, rethrowExceptions: true);
|
||||
server = new AnalysisServer(
|
||||
channel,
|
||||
resourceProvider,
|
||||
packageMapProvider,
|
||||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new MockSdk(),
|
||||
InstrumentationService.NULL_SERVICE,
|
||||
rethrowExceptions: true);
|
||||
}
|
||||
|
||||
Future test_contextDisposed() {
|
||||
|
@ -405,8 +417,8 @@ import "../foo/foo.dart";
|
|||
|
||||
void test_rethrowExceptions() {
|
||||
Exception exceptionToThrow = new Exception('test exception');
|
||||
MockServerOperation operation = new MockServerOperation(
|
||||
ServerOperationPriority.ANALYSIS, (_) {
|
||||
MockServerOperation operation =
|
||||
new MockServerOperation(ServerOperationPriority.ANALYSIS, (_) {
|
||||
throw exceptionToThrow;
|
||||
});
|
||||
server.operationQueue.add(operation);
|
||||
|
|
|
@ -14,8 +14,10 @@ import 'package:analyzer/instrumentation/instrumentation.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
group('ByteStreamClientChannel', () {
|
||||
setUp(ByteStreamClientChannelTest.setUp);
|
||||
test('close', ByteStreamClientChannelTest.close);
|
||||
|
@ -215,8 +217,9 @@ class ByteStreamServerChannelTest {
|
|||
|
||||
static Future sendNotification() {
|
||||
channel.sendNotification(new Notification('foo'));
|
||||
return outputLineStream.first.timeout(new Duration(seconds: 1)).then(
|
||||
(String notification) {
|
||||
return outputLineStream.first
|
||||
.timeout(new Duration(seconds: 1))
|
||||
.then((String notification) {
|
||||
var jsonNotification = new JsonCodec().decode(notification);
|
||||
expect(jsonNotification, isMap);
|
||||
expect(jsonNotification, contains('event'));
|
||||
|
@ -226,8 +229,9 @@ class ByteStreamServerChannelTest {
|
|||
|
||||
static Future sendResponse() {
|
||||
channel.sendResponse(new Response('foo'));
|
||||
return outputLineStream.first.timeout(new Duration(seconds: 1)).then(
|
||||
(String response) {
|
||||
return outputLineStream.first
|
||||
.timeout(new Duration(seconds: 1))
|
||||
.then((String response) {
|
||||
var jsonResponse = new JsonCodec().decode(response);
|
||||
expect(jsonResponse, isMap);
|
||||
expect(jsonResponse, contains('id'));
|
||||
|
|
|
@ -6,6 +6,7 @@ library test.channel.all;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'byte_stream_channel_test.dart' as byte_stream_channel_test;
|
||||
import 'web_socket_channel_test.dart' as web_socket_channel_test;
|
||||
|
||||
|
@ -13,7 +14,7 @@ import 'web_socket_channel_test.dart' as web_socket_channel_test;
|
|||
* Utility for manually running all tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('computer', () {
|
||||
byte_stream_channel_test.main();
|
||||
web_socket_channel_test.main();
|
||||
|
|
|
@ -12,8 +12,10 @@ import 'package:analyzer/instrumentation/instrumentation.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
group('WebSocketChannel', () {
|
||||
setUp(WebSocketChannelTest.setUp);
|
||||
test('close', WebSocketChannelTest.close);
|
||||
|
@ -128,8 +130,9 @@ class WebSocketChannelTest {
|
|||
|
||||
static Future response() {
|
||||
server.sendResponse(new Response('myId'));
|
||||
return client.responseStream.first.timeout(new Duration(seconds: 1)).then(
|
||||
(Response response) {
|
||||
return client.responseStream.first
|
||||
.timeout(new Duration(seconds: 1))
|
||||
.then((Response response) {
|
||||
expect(response.id, equals('myId'));
|
||||
expectMsgCount(responseCount: 1);
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,9 +19,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AbstractContextManagerTest);
|
||||
}
|
||||
|
||||
|
@ -96,10 +97,11 @@ class AbstractContextManagerTest {
|
|||
}
|
||||
|
||||
void test_contextsInAnalysisRoot_nestedContext() {
|
||||
String subProjPath = join(projPath, 'subproj');
|
||||
String subProjPath = posix.join(projPath, 'subproj');
|
||||
Folder subProjFolder = resourceProvider.newFolder(subProjPath);
|
||||
resourceProvider.newFile(join(subProjPath, 'pubspec.yaml'), 'contents');
|
||||
String subProjFilePath = join(subProjPath, 'file.dart');
|
||||
resourceProvider.newFile(
|
||||
posix.join(subProjPath, 'pubspec.yaml'), 'contents');
|
||||
String subProjFilePath = posix.join(subProjPath, 'file.dart');
|
||||
resourceProvider.newFile(subProjFilePath, 'contents');
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
// Make sure that there really are contexts for both the main project and
|
||||
|
@ -151,10 +153,11 @@ class AbstractContextManagerTest {
|
|||
}
|
||||
|
||||
void test_isInAnalysisRoot_inNestedContext() {
|
||||
String subProjPath = join(projPath, 'subproj');
|
||||
String subProjPath = posix.join(projPath, 'subproj');
|
||||
Folder subProjFolder = resourceProvider.newFolder(subProjPath);
|
||||
resourceProvider.newFile(join(subProjPath, 'pubspec.yaml'), 'contents');
|
||||
String subProjFilePath = join(subProjPath, 'file.dart');
|
||||
resourceProvider.newFile(
|
||||
posix.join(subProjPath, 'pubspec.yaml'), 'contents');
|
||||
String subProjFilePath = posix.join(subProjPath, 'file.dart');
|
||||
resourceProvider.newFile(subProjFilePath, 'contents');
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
// Make sure that there really is a context for the subproject.
|
||||
|
@ -214,7 +217,9 @@ class AbstractContextManagerTest {
|
|||
String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']);
|
||||
newFile([sdkExtSrcPath, 'part.dart']);
|
||||
// Setup analysis options file with ignore list.
|
||||
newFile([projPath, '.analysis_options'], r'''
|
||||
newFile(
|
||||
[projPath, '.analysis_options'],
|
||||
r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- lib/nope.dart
|
||||
|
@ -235,17 +240,23 @@ analyzer:
|
|||
// Create files.
|
||||
String libPath = newFolder([projPath, LIB_NAME]);
|
||||
newFile([libPath, 'main.dart']);
|
||||
newFile([libPath, 'pubspec.yaml'], r'''
|
||||
newFile(
|
||||
[libPath, 'pubspec.yaml'],
|
||||
r'''
|
||||
name: foobar
|
||||
''');
|
||||
String otherLibPath = newFolder([projPath, 'other_lib']);
|
||||
newFile([otherLibPath, 'entry.dart']);
|
||||
newFile([otherLibPath, 'pubspec.yaml'], r'''
|
||||
newFile(
|
||||
[otherLibPath, 'pubspec.yaml'],
|
||||
r'''
|
||||
name: other_lib
|
||||
''');
|
||||
// Setup analysis options file with ignore list that ignores the 'other_lib'
|
||||
// directory by name.
|
||||
newFile([projPath, '.analysis_options'], r'''
|
||||
newFile(
|
||||
[projPath, '.analysis_options'],
|
||||
r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- 'other_lib'
|
||||
|
@ -254,38 +265,8 @@ analyzer:
|
|||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
// Verify that the context in other_lib wasn't created and that the
|
||||
// context in lib was created.
|
||||
var contexts = manager.contextsInAnalysisRoot(
|
||||
resourceProvider.newFolder(projPath));
|
||||
expect(contexts.length, 2);
|
||||
expect(contexts[0].name, equals('/my/proj'));
|
||||
expect(contexts[1].name, equals('/my/proj/lib'));
|
||||
}
|
||||
|
||||
test_path_filter_wildcard_child_contexts_option() async {
|
||||
// Create files.
|
||||
String libPath = newFolder([projPath, LIB_NAME]);
|
||||
newFile([libPath, 'main.dart']);
|
||||
newFile([libPath, 'pubspec.yaml'], r'''
|
||||
name: foobar
|
||||
''');
|
||||
String otherLibPath = newFolder([projPath, 'other_lib']);
|
||||
newFile([otherLibPath, 'entry.dart']);
|
||||
newFile([otherLibPath, 'pubspec.yaml'], r'''
|
||||
name: other_lib
|
||||
''');
|
||||
// Setup analysis options file with ignore list that ignores 'other_lib'
|
||||
// and all immediate children.
|
||||
newFile([projPath, '.analysis_options'], r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- 'other_lib/*'
|
||||
''');
|
||||
// Setup context.
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
// Verify that the context in other_lib wasn't created and that the
|
||||
// context in lib was created.
|
||||
var contexts = manager.contextsInAnalysisRoot(
|
||||
resourceProvider.newFolder(projPath));
|
||||
var contexts =
|
||||
manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
|
||||
expect(contexts.length, 2);
|
||||
expect(contexts[0].name, equals('/my/proj'));
|
||||
expect(contexts[1].name, equals('/my/proj/lib'));
|
||||
|
@ -295,17 +276,23 @@ analyzer:
|
|||
// Create files.
|
||||
String libPath = newFolder([projPath, LIB_NAME]);
|
||||
newFile([libPath, 'main.dart']);
|
||||
newFile([libPath, 'pubspec.yaml'], r'''
|
||||
newFile(
|
||||
[libPath, 'pubspec.yaml'],
|
||||
r'''
|
||||
name: foobar
|
||||
''');
|
||||
String otherLibPath = newFolder([projPath, 'other_lib']);
|
||||
newFile([otherLibPath, 'entry.dart']);
|
||||
newFile([otherLibPath, 'pubspec.yaml'], r'''
|
||||
newFile(
|
||||
[otherLibPath, 'pubspec.yaml'],
|
||||
r'''
|
||||
name: other_lib
|
||||
''');
|
||||
// Setup analysis options file with ignore list that ignores 'other_lib'
|
||||
// and all descendants.
|
||||
newFile([projPath, '.analysis_options'], r'''
|
||||
newFile(
|
||||
[projPath, '.analysis_options'],
|
||||
r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- 'other_lib/**'
|
||||
|
@ -314,8 +301,44 @@ analyzer:
|
|||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
// Verify that the context in other_lib wasn't created and that the
|
||||
// context in lib was created.
|
||||
var contexts = manager.contextsInAnalysisRoot(
|
||||
resourceProvider.newFolder(projPath));
|
||||
var contexts =
|
||||
manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
|
||||
expect(contexts.length, 2);
|
||||
expect(contexts[0].name, equals('/my/proj'));
|
||||
expect(contexts[1].name, equals('/my/proj/lib'));
|
||||
}
|
||||
|
||||
test_path_filter_wildcard_child_contexts_option() async {
|
||||
// Create files.
|
||||
String libPath = newFolder([projPath, LIB_NAME]);
|
||||
newFile([libPath, 'main.dart']);
|
||||
newFile(
|
||||
[libPath, 'pubspec.yaml'],
|
||||
r'''
|
||||
name: foobar
|
||||
''');
|
||||
String otherLibPath = newFolder([projPath, 'other_lib']);
|
||||
newFile([otherLibPath, 'entry.dart']);
|
||||
newFile(
|
||||
[otherLibPath, 'pubspec.yaml'],
|
||||
r'''
|
||||
name: other_lib
|
||||
''');
|
||||
// Setup analysis options file with ignore list that ignores 'other_lib'
|
||||
// and all immediate children.
|
||||
newFile(
|
||||
[projPath, '.analysis_options'],
|
||||
r'''
|
||||
analyzer:
|
||||
exclude:
|
||||
- 'other_lib/*'
|
||||
''');
|
||||
// Setup context.
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
// Verify that the context in other_lib wasn't created and that the
|
||||
// context in lib was created.
|
||||
var contexts =
|
||||
manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
|
||||
expect(contexts.length, 2);
|
||||
expect(contexts[0].name, equals('/my/proj'));
|
||||
expect(contexts[1].name, equals('/my/proj/lib'));
|
||||
|
@ -474,8 +497,9 @@ analyzer:
|
|||
newFile([examplePath, ContextManagerImpl.PACKAGE_SPEC_NAME]);
|
||||
newFile([examplePath, 'example.dart']);
|
||||
|
||||
packageMapProvider.packageMap['proj'] =
|
||||
[resourceProvider.getResource(libPath)];
|
||||
packageMapProvider.packageMap['proj'] = [
|
||||
resourceProvider.getResource(libPath)
|
||||
];
|
||||
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
|
||||
|
@ -502,8 +526,9 @@ analyzer:
|
|||
newFile([examplePath, ContextManagerImpl.PUBSPEC_NAME]);
|
||||
newFile([examplePath, 'example.dart']);
|
||||
|
||||
packageMapProvider.packageMap['proj'] =
|
||||
[resourceProvider.getResource(libPath)];
|
||||
packageMapProvider.packageMap['proj'] = [
|
||||
resourceProvider.getResource(libPath)
|
||||
];
|
||||
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
|
||||
|
@ -587,8 +612,9 @@ analyzer:
|
|||
newFile([srcPath, 'internal.dart']);
|
||||
String testFilePath = newFile([testPath, 'main_test.dart']);
|
||||
|
||||
packageMapProvider.packageMap['proj'] =
|
||||
[resourceProvider.getResource(libPath)];
|
||||
packageMapProvider.packageMap['proj'] = [
|
||||
resourceProvider.getResource(libPath)
|
||||
];
|
||||
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
Set<Source> sources = callbacks.currentContextSources[projPath];
|
||||
|
@ -647,8 +673,12 @@ analyzer:
|
|||
resourceProvider.newFile(subProjectB_file, 'library b;');
|
||||
// configure package maps
|
||||
packageMapProvider.packageMaps = {
|
||||
subProjectA: {'foo': [resourceProvider.newFolder('/package/foo')]},
|
||||
subProjectB: {'bar': [resourceProvider.newFolder('/package/bar')]},
|
||||
subProjectA: {
|
||||
'foo': [resourceProvider.newFolder('/package/foo')]
|
||||
},
|
||||
subProjectB: {
|
||||
'bar': [resourceProvider.newFolder('/package/bar')]
|
||||
},
|
||||
};
|
||||
// set roots
|
||||
manager.setRoots(<String>[root], <String>[], <String, String>{});
|
||||
|
@ -669,14 +699,15 @@ analyzer:
|
|||
String packagePathFoo = '/package1/foo';
|
||||
String packageRootPath = '/package2/foo';
|
||||
Folder packageFolder = resourceProvider.newFolder(packagePathFoo);
|
||||
packageMapProvider.packageMap = {'foo': [packageFolder]};
|
||||
packageMapProvider.packageMap = {
|
||||
'foo': [packageFolder]
|
||||
};
|
||||
List<String> includedPaths = <String>[projPath];
|
||||
List<String> excludedPaths = <String>[];
|
||||
manager.setRoots(includedPaths, excludedPaths, <String, String>{});
|
||||
_checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
||||
manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
||||
projPath: packageRootPath
|
||||
});
|
||||
manager.setRoots(includedPaths, excludedPaths,
|
||||
<String, String>{projPath: packageRootPath});
|
||||
_checkPackageRoot(projPath, equals(packageRootPath));
|
||||
}
|
||||
|
||||
|
@ -685,13 +716,11 @@ analyzer:
|
|||
String packageRootPath2 = '/package2';
|
||||
List<String> includedPaths = <String>[projPath];
|
||||
List<String> excludedPaths = <String>[];
|
||||
manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
||||
projPath: packageRootPath1
|
||||
});
|
||||
manager.setRoots(includedPaths, excludedPaths,
|
||||
<String, String>{projPath: packageRootPath1});
|
||||
_checkPackageRoot(projPath, equals(packageRootPath1));
|
||||
manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
||||
projPath: packageRootPath2
|
||||
});
|
||||
manager.setRoots(includedPaths, excludedPaths,
|
||||
<String, String>{projPath: packageRootPath2});
|
||||
_checkPackageRoot(projPath, equals(packageRootPath2));
|
||||
}
|
||||
|
||||
|
@ -821,16 +850,17 @@ analyzer:
|
|||
|
||||
void test_setRoots_newFolderWithPackageRoot() {
|
||||
String packageRootPath = '/package';
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{
|
||||
projPath: packageRootPath
|
||||
});
|
||||
manager.setRoots(<String>[projPath], <String>[],
|
||||
<String, String>{projPath: packageRootPath});
|
||||
_checkPackageRoot(projPath, equals(packageRootPath));
|
||||
}
|
||||
|
||||
void test_setRoots_newlyAddedFoldersGetProperPackageMap() {
|
||||
String packagePath = '/package/foo';
|
||||
Folder packageFolder = resourceProvider.newFolder(packagePath);
|
||||
packageMapProvider.packageMap = {'foo': [packageFolder]};
|
||||
packageMapProvider.packageMap = {
|
||||
'foo': [packageFolder]
|
||||
};
|
||||
manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
||||
_checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
||||
}
|
||||
|
@ -963,12 +993,13 @@ analyzer:
|
|||
String packagePathFoo = '/package1/foo';
|
||||
String packageRootPath = '/package2/foo';
|
||||
Folder packageFolder = resourceProvider.newFolder(packagePathFoo);
|
||||
packageMapProvider.packageMap = {'foo': [packageFolder]};
|
||||
packageMapProvider.packageMap = {
|
||||
'foo': [packageFolder]
|
||||
};
|
||||
List<String> includedPaths = <String>[projPath];
|
||||
List<String> excludedPaths = <String>[];
|
||||
manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
||||
projPath: packageRootPath
|
||||
});
|
||||
manager.setRoots(includedPaths, excludedPaths,
|
||||
<String, String>{projPath: packageRootPath});
|
||||
_checkPackageRoot(projPath, equals(packageRootPath));
|
||||
manager.setRoots(includedPaths, excludedPaths, <String, String>{});
|
||||
_checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
||||
|
@ -1511,8 +1542,8 @@ class TestContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
* A map from the paths of contexts to a set of the sources that should be
|
||||
* explicitly analyzed in those contexts.
|
||||
*/
|
||||
final Map<String, Set<Source>> currentContextSources = <String, Set<Source>>{
|
||||
};
|
||||
final Map<String, Set<Source>> currentContextSources =
|
||||
<String, Set<Source>>{};
|
||||
|
||||
/**
|
||||
* Map from context to folder disposition.
|
||||
|
|
|
@ -21,9 +21,10 @@ import 'package:unittest/unittest.dart';
|
|||
import 'analysis_abstract.dart';
|
||||
import 'mock_sdk.dart';
|
||||
import 'mocks.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
|
||||
defineReflectiveTests(AnalysisDomainTest);
|
||||
defineReflectiveTests(SetSubscriptionsTest);
|
||||
|
@ -39,9 +40,14 @@ main() {
|
|||
ExtensionManager manager = new ExtensionManager();
|
||||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
server = new AnalysisServer(serverChannel, resourceProvider,
|
||||
new MockPackageMapProvider(), null, serverPlugin,
|
||||
new AnalysisServerOptions(), new MockSdk(),
|
||||
server = new AnalysisServer(
|
||||
serverChannel,
|
||||
resourceProvider,
|
||||
new MockPackageMapProvider(),
|
||||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new MockSdk(),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new AnalysisDomainHandler(server);
|
||||
});
|
||||
|
@ -132,8 +138,9 @@ main() {
|
|||
|
||||
group('updateOptions', () {
|
||||
test('invalid', () {
|
||||
var request = new Request(
|
||||
'0', ANALYSIS_UPDATE_OPTIONS, {OPTIONS: {'not-an-option': true}});
|
||||
var request = new Request('0', ANALYSIS_UPDATE_OPTIONS, {
|
||||
OPTIONS: {'not-an-option': true}
|
||||
});
|
||||
var response = handler.handleRequest(request);
|
||||
// Invalid options should be silently ignored.
|
||||
expect(response, isResponseSuccess('0'));
|
||||
|
@ -156,7 +163,9 @@ testUpdateContent() {
|
|||
helper.createSingleFileProject('// empty');
|
||||
return helper.onAnalysisComplete.then((_) {
|
||||
Request request = new Request('0', ANALYSIS_UPDATE_CONTENT, {
|
||||
'files': {helper.testFile: {TYPE: 'foo',}}
|
||||
'files': {
|
||||
helper.testFile: {TYPE: 'foo',}
|
||||
}
|
||||
});
|
||||
Response response = helper.handler.handleRequest(request);
|
||||
expect(response, isResponseFailure('0'));
|
||||
|
@ -291,7 +300,9 @@ class AnalysisDomainTest extends AbstractAnalysisTest {
|
|||
// Prepare a source file that has errors because it refers to an unknown
|
||||
// package.
|
||||
String pkgFile = '/packages/pkgA/libA.dart';
|
||||
resourceProvider.newFile(pkgFile, '''
|
||||
resourceProvider.newFile(
|
||||
pkgFile,
|
||||
'''
|
||||
library lib_a;
|
||||
class A {}
|
||||
''');
|
||||
|
@ -322,12 +333,15 @@ f(A a) {
|
|||
test_setRoots_packages() {
|
||||
// prepare package
|
||||
String pkgFile = '/packages/pkgA/libA.dart';
|
||||
resourceProvider.newFile(pkgFile, '''
|
||||
resourceProvider.newFile(
|
||||
pkgFile,
|
||||
'''
|
||||
library lib_a;
|
||||
class A {}
|
||||
''');
|
||||
packageMapProvider.packageMap['pkgA'] =
|
||||
[resourceProvider.getResource('/packages/pkgA')];
|
||||
packageMapProvider.packageMap['pkgA'] = [
|
||||
resourceProvider.getResource('/packages/pkgA')
|
||||
];
|
||||
addTestFile('''
|
||||
import 'package:pkgA/libA.dart';
|
||||
main(A a) {
|
||||
|
@ -368,9 +382,14 @@ class AnalysisTestHelper {
|
|||
ExtensionManager manager = new ExtensionManager();
|
||||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
server = new AnalysisServer(serverChannel, resourceProvider,
|
||||
new MockPackageMapProvider(), null, serverPlugin,
|
||||
new AnalysisServerOptions(), new MockSdk(),
|
||||
server = new AnalysisServer(
|
||||
serverChannel,
|
||||
resourceProvider,
|
||||
new MockPackageMapProvider(),
|
||||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new MockSdk(),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new AnalysisDomainHandler(server);
|
||||
// listen for notifications
|
||||
|
@ -593,7 +612,9 @@ class SetSubscriptionsTest extends AbstractAnalysisTest {
|
|||
|
||||
test_afterAnalysis_packageFile_external() async {
|
||||
String pkgFile = '/packages/pkgA/lib/libA.dart';
|
||||
resourceProvider.newFile(pkgFile, '''
|
||||
resourceProvider.newFile(
|
||||
pkgFile,
|
||||
'''
|
||||
library lib_a;
|
||||
class A {}
|
||||
''');
|
||||
|
@ -623,11 +644,15 @@ main() {
|
|||
String pkgB = '/pkgA';
|
||||
String pkgFileA = '$pkgA/lib/libA.dart';
|
||||
String pkgFileB = '$pkgA/lib/libB.dart';
|
||||
resourceProvider.newFile(pkgFileA, '''
|
||||
resourceProvider.newFile(
|
||||
pkgFileA,
|
||||
'''
|
||||
library lib_a;
|
||||
class A {}
|
||||
''');
|
||||
resourceProvider.newFile(pkgFileB, '''
|
||||
resourceProvider.newFile(
|
||||
pkgFileB,
|
||||
'''
|
||||
import 'package:pkgA/libA.dart';
|
||||
main() {
|
||||
new A();
|
||||
|
@ -657,7 +682,9 @@ main() {
|
|||
|
||||
test_afterAnalysis_packageFile_notUsed() async {
|
||||
String pkgFile = '/packages/pkgA/lib/libA.dart';
|
||||
resourceProvider.newFile(pkgFile, '''
|
||||
resourceProvider.newFile(
|
||||
pkgFile,
|
||||
'''
|
||||
library lib_a;
|
||||
class A {}
|
||||
''');
|
||||
|
|
|
@ -34,9 +34,10 @@ import 'package:unittest/unittest.dart';
|
|||
import 'analysis_abstract.dart';
|
||||
import 'mock_sdk.dart';
|
||||
import 'mocks.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(CompletionManagerTest);
|
||||
defineReflectiveTests(CompletionTest);
|
||||
defineReflectiveTests(_NoSearchEngine);
|
||||
|
@ -54,9 +55,14 @@ class CompletionManagerTest extends AbstractAnalysisTest {
|
|||
ExtensionManager manager = new ExtensionManager();
|
||||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
return new Test_AnalysisServer(super.serverChannel, super.resourceProvider,
|
||||
super.packageMapProvider, index, serverPlugin,
|
||||
new AnalysisServerOptions(), new MockSdk(),
|
||||
return new Test_AnalysisServer(
|
||||
super.serverChannel,
|
||||
super.resourceProvider,
|
||||
super.packageMapProvider,
|
||||
index,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new MockSdk(),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
}
|
||||
|
||||
|
@ -277,7 +283,8 @@ class CompletionTest extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
void assertHasResult(CompletionSuggestionKind kind, String completion,
|
||||
[int relevance = DART_RELEVANCE_DEFAULT, bool isDeprecated = false,
|
||||
[int relevance = DART_RELEVANCE_DEFAULT,
|
||||
bool isDeprecated = false,
|
||||
bool isPotential = false]) {
|
||||
var cs;
|
||||
suggestions.forEach((s) {
|
||||
|
@ -475,7 +482,9 @@ class B extends A {m() {^}}
|
|||
}
|
||||
|
||||
test_partFile() {
|
||||
addFile('/project/bin/testA.dart', '''
|
||||
addFile(
|
||||
'/project/bin/testA.dart',
|
||||
'''
|
||||
library libA;
|
||||
part "$testFile";
|
||||
import 'dart:html';
|
||||
|
@ -495,7 +504,9 @@ class B extends A {m() {^}}
|
|||
}
|
||||
|
||||
test_partFile2() {
|
||||
addFile('/testA.dart', '''
|
||||
addFile(
|
||||
'/testA.dart',
|
||||
'''
|
||||
part of libA;
|
||||
class A { }''');
|
||||
addTestFile('''
|
||||
|
@ -655,14 +666,24 @@ class MockSubscription<E> implements StreamSubscription<E> {
|
|||
class Test_AnalysisServer extends AnalysisServer {
|
||||
final MockContext mockContext = new MockContext();
|
||||
|
||||
Test_AnalysisServer(ServerCommunicationChannel channel,
|
||||
Test_AnalysisServer(
|
||||
ServerCommunicationChannel channel,
|
||||
ResourceProvider resourceProvider,
|
||||
PubPackageMapProvider packageMapProvider, Index index,
|
||||
ServerPlugin serverPlugin, AnalysisServerOptions analysisServerOptions,
|
||||
DartSdk defaultSdk, InstrumentationService instrumentationService)
|
||||
: super(channel, resourceProvider, packageMapProvider, index,
|
||||
serverPlugin, analysisServerOptions, defaultSdk,
|
||||
instrumentationService);
|
||||
PubPackageMapProvider packageMapProvider,
|
||||
Index index,
|
||||
ServerPlugin serverPlugin,
|
||||
AnalysisServerOptions analysisServerOptions,
|
||||
DartSdk defaultSdk,
|
||||
InstrumentationService instrumentationService)
|
||||
: super(
|
||||
channel,
|
||||
resourceProvider,
|
||||
packageMapProvider,
|
||||
index,
|
||||
serverPlugin,
|
||||
analysisServerOptions,
|
||||
defaultSdk,
|
||||
instrumentationService);
|
||||
|
||||
@override
|
||||
AnalysisContext getAnalysisContext(String path) {
|
||||
|
|
|
@ -25,8 +25,10 @@ import 'package:unittest/unittest.dart';
|
|||
import 'mock_sdk.dart';
|
||||
import 'mocks.dart';
|
||||
import 'operation/operation_queue_test.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
group('ExecutionDomainHandler', () {
|
||||
MemoryResourceProvider provider = new MemoryResourceProvider();
|
||||
AnalysisServer server;
|
||||
|
@ -36,9 +38,14 @@ main() {
|
|||
ExtensionManager manager = new ExtensionManager();
|
||||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
server = new AnalysisServer(new MockServerChannel(), provider,
|
||||
new MockPackageMapProvider(), null, serverPlugin,
|
||||
new AnalysisServerOptions(), new MockSdk(),
|
||||
server = new AnalysisServer(
|
||||
new MockServerChannel(),
|
||||
provider,
|
||||
new MockPackageMapProvider(),
|
||||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new MockSdk(),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new ExecutionDomainHandler(server);
|
||||
});
|
||||
|
|
|
@ -16,20 +16,28 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import 'mock_sdk.dart';
|
||||
import 'mocks.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
main() {
|
||||
AnalysisServer server;
|
||||
ServerDomainHandler handler;
|
||||
|
||||
initializeTestEnvironment();
|
||||
|
||||
setUp(() {
|
||||
var serverChannel = new MockServerChannel();
|
||||
var resourceProvider = new MemoryResourceProvider();
|
||||
ExtensionManager manager = new ExtensionManager();
|
||||
ServerPlugin serverPlugin = new ServerPlugin();
|
||||
manager.processPlugins([serverPlugin]);
|
||||
server = new AnalysisServer(serverChannel, resourceProvider,
|
||||
new MockPackageMapProvider(), null, serverPlugin,
|
||||
new AnalysisServerOptions(), new MockSdk(),
|
||||
server = new AnalysisServer(
|
||||
serverChannel,
|
||||
resourceProvider,
|
||||
new MockPackageMapProvider(),
|
||||
null,
|
||||
serverPlugin,
|
||||
new AnalysisServerOptions(),
|
||||
new MockSdk(),
|
||||
InstrumentationService.NULL_SERVICE);
|
||||
handler = new ServerDomainHandler(server);
|
||||
});
|
||||
|
@ -38,16 +46,19 @@ main() {
|
|||
test('getVersion', () {
|
||||
var request = new ServerGetVersionParams().toRequest('0');
|
||||
var response = handler.handleRequest(request);
|
||||
expect(response.toJson(), equals({
|
||||
Response.ID: '0',
|
||||
Response.RESULT: {VERSION: AnalysisServer.VERSION}
|
||||
}));
|
||||
expect(
|
||||
response.toJson(),
|
||||
equals({
|
||||
Response.ID: '0',
|
||||
Response.RESULT: {VERSION: AnalysisServer.VERSION}
|
||||
}));
|
||||
});
|
||||
|
||||
group('setSubscriptions', () {
|
||||
test('invalid service name', () {
|
||||
Request request = new Request(
|
||||
'0', SERVER_SET_SUBSCRIPTIONS, {SUBSCRIPTIONS: ['noSuchService']});
|
||||
Request request = new Request('0', SERVER_SET_SUBSCRIPTIONS, {
|
||||
SUBSCRIPTIONS: ['noSuchService']
|
||||
});
|
||||
var response = handler.handleRequest(request);
|
||||
expect(response, isResponseFailure('0'));
|
||||
});
|
||||
|
|
|
@ -13,9 +13,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart' hide ERROR;
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AssistsTest);
|
||||
}
|
||||
|
||||
|
@ -53,7 +54,9 @@ main() {
|
|||
''');
|
||||
await waitForTasksFinished();
|
||||
prepareAssists('v =');
|
||||
_assertHasChange('Remove type annotation', '''
|
||||
_assertHasChange(
|
||||
'Remove type annotation',
|
||||
'''
|
||||
main() {
|
||||
var v = 1;
|
||||
}
|
||||
|
@ -68,7 +71,9 @@ main() {
|
|||
''');
|
||||
await waitForTasksFinished();
|
||||
prepareAssists('v =');
|
||||
_assertHasChange('Split variable declaration', '''
|
||||
_assertHasChange(
|
||||
'Split variable declaration',
|
||||
'''
|
||||
main() {
|
||||
int v;
|
||||
v = 1;
|
||||
|
@ -87,7 +92,9 @@ main() {
|
|||
int offset = findOffset(' print(1)');
|
||||
int length = findOffset('}') - offset;
|
||||
prepareAssistsAt(offset, length);
|
||||
_assertHasChange("Surround with 'if'", '''
|
||||
_assertHasChange(
|
||||
"Surround with 'if'",
|
||||
'''
|
||||
main() {
|
||||
if (condition) {
|
||||
print(1);
|
||||
|
|
|
@ -15,9 +15,10 @@ import 'package:unittest/unittest.dart' hide ERROR;
|
|||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(FixesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@ import 'package:unittest/unittest.dart' hide ERROR;
|
|||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(FormatTest);
|
||||
}
|
||||
|
||||
|
@ -31,6 +32,24 @@ class FormatTest extends AbstractAnalysisTest {
|
|||
handler = new EditDomainHandler(server);
|
||||
}
|
||||
|
||||
Future test_format_longLine() {
|
||||
String content = '''
|
||||
fun(firstParam, secondParam, thirdParam, fourthParam) {
|
||||
if (firstParam.noNull && secondParam.noNull && thirdParam.noNull && fourthParam.noNull) {}
|
||||
}
|
||||
''';
|
||||
addTestFile(content);
|
||||
return waitForTasksFinished().then((_) {
|
||||
EditFormatResult formatResult = _formatAt(0, 3, lineLength: 100);
|
||||
|
||||
expect(formatResult.edits, isNotNull);
|
||||
expect(formatResult.edits, hasLength(0));
|
||||
|
||||
expect(formatResult.selectionOffset, equals(0));
|
||||
expect(formatResult.selectionLength, equals(3));
|
||||
});
|
||||
}
|
||||
|
||||
Future test_format_noOp() {
|
||||
// Already formatted source
|
||||
addTestFile('''
|
||||
|
@ -86,24 +105,6 @@ main() {
|
|||
});
|
||||
}
|
||||
|
||||
Future test_format_longLine() {
|
||||
String content = '''
|
||||
fun(firstParam, secondParam, thirdParam, fourthParam) {
|
||||
if (firstParam.noNull && secondParam.noNull && thirdParam.noNull && fourthParam.noNull) {}
|
||||
}
|
||||
''';
|
||||
addTestFile(content);
|
||||
return waitForTasksFinished().then((_) {
|
||||
EditFormatResult formatResult = _formatAt(0, 3, lineLength: 100);
|
||||
|
||||
expect(formatResult.edits, isNotNull);
|
||||
expect(formatResult.edits, hasLength(0));
|
||||
|
||||
expect(formatResult.selectionOffset, equals(0));
|
||||
expect(formatResult.selectionLength, equals(3));
|
||||
});
|
||||
}
|
||||
|
||||
Future test_format_withErrors() {
|
||||
addTestFile('''
|
||||
main() { int x =
|
||||
|
@ -115,9 +116,11 @@ main() { int x =
|
|||
});
|
||||
}
|
||||
|
||||
EditFormatResult _formatAt(int selectionOffset, int selectionLength, {int lineLength}) {
|
||||
EditFormatResult _formatAt(int selectionOffset, int selectionLength,
|
||||
{int lineLength}) {
|
||||
Request request = new EditFormatParams(
|
||||
testFile, selectionOffset, selectionLength, lineLength: lineLength).toRequest('0');
|
||||
testFile, selectionOffset, selectionLength,
|
||||
lineLength: lineLength).toRequest('0');
|
||||
Response response = handleSuccessfulRequest(request);
|
||||
return new EditFormatResult.fromResponse(response);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,10 @@ import 'package:unittest/unittest.dart' hide ERROR;
|
|||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(OrganizeDirectivesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,10 @@ import 'package:unittest/unittest.dart' hide ERROR;
|
|||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(ConvertGetterMethodToMethodTest);
|
||||
defineReflectiveTests(ConvertMethodToGetterTest);
|
||||
defineReflectiveTests(ExtractLocalVariableTest);
|
||||
|
@ -43,7 +44,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendConvertRequest('test =>');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
int test() => 42;
|
||||
main() {
|
||||
var a = 1 + test();
|
||||
|
@ -92,7 +94,8 @@ main(A a, B b, C c, D d) {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendConvertRequest('test => 2');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
int test() => 1;
|
||||
}
|
||||
|
@ -116,8 +119,11 @@ main(A a, B b, C c, D d) {
|
|||
|
||||
Future<Response> _sendConvertRequest(String search) {
|
||||
Request request = new EditGetRefactoringParams(
|
||||
RefactoringKind.CONVERT_GETTER_TO_METHOD, testFile, findOffset(search),
|
||||
0, false).toRequest('0');
|
||||
RefactoringKind.CONVERT_GETTER_TO_METHOD,
|
||||
testFile,
|
||||
findOffset(search),
|
||||
0,
|
||||
false).toRequest('0');
|
||||
return serverChannel.sendRequest(request);
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +140,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendConvertRequest('test() =>');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
int get test => 42;
|
||||
main() {
|
||||
var a = 1 + test;
|
||||
|
@ -200,7 +207,8 @@ main(A a, B b, C c, D d) {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendConvertRequest('test() => 2');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
int get test => 1;
|
||||
}
|
||||
|
@ -224,8 +232,11 @@ main(A a, B b, C c, D d) {
|
|||
|
||||
Future<Response> _sendConvertRequest(String search) {
|
||||
Request request = new EditGetRefactoringParams(
|
||||
RefactoringKind.CONVERT_METHOD_TO_GETTER, testFile, findOffset(search),
|
||||
0, false).toRequest('0');
|
||||
RefactoringKind.CONVERT_METHOD_TO_GETTER,
|
||||
testFile,
|
||||
findOffset(search),
|
||||
0,
|
||||
false).toRequest('0');
|
||||
return serverChannel.sendRequest(request);
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +281,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendStringRequest('1 + 2', 'res', true);
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
main() {
|
||||
var res = 1 + 2;
|
||||
print(res);
|
||||
|
@ -288,7 +300,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendStringSuffixRequest('1 + 2', '); // marker', 'res', false);
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
main() {
|
||||
print(1 + 2);
|
||||
var res = 1 + 2;
|
||||
|
@ -327,7 +340,9 @@ main() {
|
|||
assertResultProblemsWarning(result.optionsProblems,
|
||||
'Variable name should start with a lowercase letter.');
|
||||
// ...but there is still a change
|
||||
assertTestRefactoringResult(result, '''
|
||||
assertTestRefactoringResult(
|
||||
result,
|
||||
'''
|
||||
main() {
|
||||
var Name = 1 + 2;
|
||||
print(Name);
|
||||
|
@ -413,7 +428,9 @@ main() {
|
|||
}
|
||||
''');
|
||||
_setOffsetLengthForString('1 + 2');
|
||||
return assertSuccessfulRefactoring(_computeChange, '''
|
||||
return assertSuccessfulRefactoring(
|
||||
_computeChange,
|
||||
'''
|
||||
main() {
|
||||
print(res());
|
||||
print(res());
|
||||
|
@ -433,7 +450,9 @@ main() {
|
|||
}
|
||||
''');
|
||||
_setOffsetLengthForString('a + b');
|
||||
return assertSuccessfulRefactoring(_computeChange, '''
|
||||
return assertSuccessfulRefactoring(
|
||||
_computeChange,
|
||||
'''
|
||||
main() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
@ -463,7 +482,9 @@ main() {
|
|||
parameters[1].type = 'num';
|
||||
parameters.insert(0, parameters.removeLast());
|
||||
options.parameters = parameters;
|
||||
return assertSuccessfulRefactoring(_sendExtractRequest, '''
|
||||
return assertSuccessfulRefactoring(
|
||||
_sendExtractRequest,
|
||||
'''
|
||||
main() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
@ -542,7 +563,9 @@ main() {
|
|||
}
|
||||
''');
|
||||
_setOffsetLengthForStartEnd();
|
||||
return assertSuccessfulRefactoring(_computeChange, '''
|
||||
return assertSuccessfulRefactoring(
|
||||
_computeChange,
|
||||
'''
|
||||
main() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
@ -675,9 +698,13 @@ class GetAvailableRefactoringsTest extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
Future test_convertMethodToGetter_hasElement() {
|
||||
return assertHasKind('''
|
||||
return assertHasKind(
|
||||
'''
|
||||
int getValue() => 42;
|
||||
''', 'getValue', RefactoringKind.CONVERT_METHOD_TO_GETTER, true);
|
||||
''',
|
||||
'getValue',
|
||||
RefactoringKind.CONVERT_METHOD_TO_GETTER,
|
||||
true);
|
||||
}
|
||||
|
||||
Future test_extractLocal() async {
|
||||
|
@ -693,108 +720,130 @@ main() {
|
|||
}
|
||||
|
||||
Future test_rename_hasElement_class() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
class Test {}
|
||||
main() {
|
||||
Test v;
|
||||
}
|
||||
''', 'Test v');
|
||||
''',
|
||||
'Test v');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_constructor() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
class A {
|
||||
A.test() {}
|
||||
}
|
||||
main() {
|
||||
new A.test();
|
||||
}
|
||||
''', 'test();');
|
||||
''',
|
||||
'test();');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_function() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
main() {
|
||||
test();
|
||||
}
|
||||
test() {}
|
||||
''', 'test();');
|
||||
''',
|
||||
'test();');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_importElement_directive() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
import 'dart:math' as math;
|
||||
main() {
|
||||
math.PI;
|
||||
}
|
||||
''', 'import ');
|
||||
''',
|
||||
'import ');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_importElement_prefixDecl() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
import 'dart:math' as math;
|
||||
main() {
|
||||
math.PI;
|
||||
}
|
||||
''', 'math;');
|
||||
''',
|
||||
'math;');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_importElement_prefixRef() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
import 'dart:async' as test;
|
||||
import 'dart:math' as test;
|
||||
main() {
|
||||
test.PI;
|
||||
}
|
||||
''', 'test.PI;');
|
||||
''',
|
||||
'test.PI;');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_instanceGetter() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
class A {
|
||||
get test => 0;
|
||||
}
|
||||
main(A a) {
|
||||
a.test;
|
||||
}
|
||||
''', 'test;');
|
||||
''',
|
||||
'test;');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_instanceSetter() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
class A {
|
||||
set test(x) {}
|
||||
}
|
||||
main(A a) {
|
||||
a.test = 2;
|
||||
}
|
||||
''', 'test = 2;');
|
||||
''',
|
||||
'test = 2;');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_library() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
library my.lib;
|
||||
''', 'library ');
|
||||
''',
|
||||
'library ');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_localVariable() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
main() {
|
||||
int test = 0;
|
||||
print(test);
|
||||
}
|
||||
''', 'test = 0;');
|
||||
''',
|
||||
'test = 0;');
|
||||
}
|
||||
|
||||
Future test_rename_hasElement_method() {
|
||||
return assertHasRenameRefactoring('''
|
||||
return assertHasRenameRefactoring(
|
||||
'''
|
||||
class A {
|
||||
test() {}
|
||||
}
|
||||
main(A a) {
|
||||
a.test();
|
||||
}
|
||||
''', 'test();');
|
||||
''',
|
||||
'test();');
|
||||
}
|
||||
|
||||
Future test_rename_noElement() async {
|
||||
|
@ -850,7 +899,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendInlineRequest('test + 2');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
main() {
|
||||
int a = 42 + 2;
|
||||
print(42);
|
||||
|
@ -860,7 +910,10 @@ main() {
|
|||
|
||||
Future<Response> _sendInlineRequest(String search) {
|
||||
Request request = new EditGetRefactoringParams(
|
||||
RefactoringKind.INLINE_LOCAL_VARIABLE, testFile, findOffset(search), 0,
|
||||
RefactoringKind.INLINE_LOCAL_VARIABLE,
|
||||
testFile,
|
||||
findOffset(search),
|
||||
0,
|
||||
false).toRequest('0');
|
||||
return serverChannel.sendRequest(request);
|
||||
}
|
||||
|
@ -921,7 +974,8 @@ main(A a) {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendInlineRequest('test(int p)');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
int f;
|
||||
main() {
|
||||
|
@ -946,7 +1000,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendInlineRequest('test(a');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
main() {
|
||||
print(1 + 2);
|
||||
print(10 + 20);
|
||||
|
@ -968,7 +1023,8 @@ main() {
|
|||
options.inlineAll = false;
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendInlineRequest('test(10,');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
test(a, b) {
|
||||
print(a + b);
|
||||
}
|
||||
|
@ -1000,7 +1056,8 @@ import 'lib.dart';
|
|||
_setOptions('/project/test.dart');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return _sendMoveRequest();
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
import 'dart:math';
|
||||
import 'bin/lib.dart';
|
||||
''');
|
||||
|
@ -1008,8 +1065,8 @@ import 'bin/lib.dart';
|
|||
|
||||
Future<Response> _sendMoveRequest() {
|
||||
Request request = new EditGetRefactoringParams(
|
||||
RefactoringKind.MOVE_FILE, testFile, 0, 0, false, options: options)
|
||||
.toRequest('0');
|
||||
RefactoringKind.MOVE_FILE, testFile, 0, 0, false,
|
||||
options: options).toRequest('0');
|
||||
return serverChannel.sendRequest(request);
|
||||
}
|
||||
|
||||
|
@ -1063,7 +1120,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('Test {', 'NewName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class NewName {
|
||||
NewName() {}
|
||||
NewName.named() {}
|
||||
|
@ -1124,7 +1182,9 @@ main() {
|
|||
assertResultProblemsWarning(result.optionsProblems,
|
||||
'Class name should start with an uppercase letter.');
|
||||
// ...but there is still a change
|
||||
assertTestRefactoringResult(result, '''
|
||||
assertTestRefactoringResult(
|
||||
result,
|
||||
'''
|
||||
class newName {}
|
||||
main() {
|
||||
newName v;
|
||||
|
@ -1137,7 +1197,9 @@ main() {
|
|||
}).then((result) {
|
||||
assertResultProblemsOK(result);
|
||||
// ...and there is a new change
|
||||
assertTestRefactoringResult(result, '''
|
||||
assertTestRefactoringResult(
|
||||
result,
|
||||
'''
|
||||
class NewName {}
|
||||
main() {
|
||||
NewName v;
|
||||
|
@ -1159,7 +1221,8 @@ class A {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test = 0', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
var newName = 0;
|
||||
A(this.newName);
|
||||
|
@ -1182,7 +1245,8 @@ class A {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test);', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
var newName = 0;
|
||||
A(this.newName);
|
||||
|
@ -1205,7 +1269,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test: 42', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
final int newName;
|
||||
A({this.newName: 0});
|
||||
|
@ -1227,7 +1292,8 @@ class A {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test =>', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
get newName => 0;
|
||||
main() {
|
||||
|
@ -1251,7 +1317,8 @@ main(A a) {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test() {}', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
newName() {}
|
||||
main() {
|
||||
|
@ -1302,7 +1369,8 @@ class A {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test = 0', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
set newName(x) {}
|
||||
main() {
|
||||
|
@ -1323,7 +1391,8 @@ class B {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('B;', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
A() = B.newName;
|
||||
}
|
||||
|
@ -1344,7 +1413,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test();', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
A.newName() {}
|
||||
}
|
||||
|
@ -1365,7 +1435,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('A();', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
A.newName() {}
|
||||
}
|
||||
|
@ -1386,7 +1457,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('new A();', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
class A {
|
||||
A.newName() {}
|
||||
}
|
||||
|
@ -1423,7 +1495,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test() {}', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
newName() {}
|
||||
main() {
|
||||
newName();
|
||||
|
@ -1443,7 +1516,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest("import 'dart:async';", 'new_name');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
import 'dart:math';
|
||||
import 'dart:async' as new_name;
|
||||
main() {
|
||||
|
@ -1464,7 +1538,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest("import 'dart:async' as test;", '');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
import 'dart:math' as test;
|
||||
import 'dart:async';
|
||||
main() {
|
||||
|
@ -1492,7 +1567,8 @@ library aaa.bbb.ccc;
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('library aaa', 'my.new_name');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
library my.new_name;
|
||||
''');
|
||||
}
|
||||
|
@ -1503,7 +1579,8 @@ library aaa.bbb.ccc;
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('aaa', 'my.new_name');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
library my.new_name;
|
||||
''');
|
||||
}
|
||||
|
@ -1514,7 +1591,8 @@ library aaa.bbb.ccc;
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('.bbb', 'my.new_name');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
library my.new_name;
|
||||
''');
|
||||
}
|
||||
|
@ -1530,7 +1608,8 @@ main() {
|
|||
''');
|
||||
return assertSuccessfulRefactoring(() {
|
||||
return sendRenameRequest('test = 1', 'newName');
|
||||
}, '''
|
||||
},
|
||||
'''
|
||||
main() {
|
||||
int newName = 0;
|
||||
newName = 1;
|
||||
|
@ -1701,8 +1780,8 @@ class _AbstractGetRefactoring_Test extends AbstractAnalysisTest {
|
|||
RefactoringKind kind, int offset, int length, RefactoringOptions options,
|
||||
[bool validateOnly = false]) {
|
||||
Request request = new EditGetRefactoringParams(
|
||||
kind, testFile, offset, length, validateOnly, options: options)
|
||||
.toRequest('0');
|
||||
kind, testFile, offset, length, validateOnly,
|
||||
options: options).toRequest('0');
|
||||
return serverChannel.sendRequest(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@ import 'package:unittest/unittest.dart' hide ERROR;
|
|||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(SortMembersTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ library test.edit.all;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'assists_test.dart' as assists_test;
|
||||
import 'fixes_test.dart' as fixes_test;
|
||||
import 'format_test.dart' as format_test;
|
||||
|
@ -17,7 +18,7 @@ import 'sort_members_test.dart' as sort_members_test;
|
|||
* Utility for manually running all tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('edit', () {
|
||||
assists_test.main();
|
||||
fixes_test.main();
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisErrorIntegrationTest);
|
||||
}
|
||||
|
||||
|
@ -19,7 +21,9 @@ class AnalysisErrorIntegrationTest
|
|||
extends AbstractAnalysisServerIntegrationTest {
|
||||
test_detect_simple_error() {
|
||||
String pathname = sourcePath('test.dart');
|
||||
writeFile(pathname, '''
|
||||
writeFile(
|
||||
pathname,
|
||||
'''
|
||||
main() {
|
||||
print(null) // parse error: missing ';'
|
||||
}''');
|
||||
|
|
|
@ -6,9 +6,11 @@ library test.integration.analysis.get.errors.after.analysis;
|
|||
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'get_errors.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,11 @@ library test.integration.analysis.get.errors.before.analysis;
|
|||
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'get_errors.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,11 @@ import 'package:path/path.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisGetHoverIntegrationTest);
|
||||
}
|
||||
|
||||
|
@ -62,9 +64,13 @@ main() {
|
|||
* expected propagated type of the element.
|
||||
*/
|
||||
checkHover(String target, int length, List<String> descriptionRegexps,
|
||||
String kind, List<String> staticTypeRegexps, {bool isLocal: false,
|
||||
bool isCore: false, String docRegexp: null, bool isLiteral: false,
|
||||
List<String> parameterRegexps: null, propagatedType: null}) {
|
||||
String kind, List<String> staticTypeRegexps,
|
||||
{bool isLocal: false,
|
||||
bool isCore: false,
|
||||
String docRegexp: null,
|
||||
bool isLiteral: false,
|
||||
List<String> parameterRegexps: null,
|
||||
propagatedType: null}) {
|
||||
int offset = text.indexOf(target);
|
||||
return sendAnalysisGetHover(pathname, offset).then((result) {
|
||||
expect(result.hovers, hasLength(1));
|
||||
|
@ -141,10 +147,8 @@ main() {
|
|||
// request is made. So wait for analysis to finish before testing anything.
|
||||
return analysisFinished.then((_) {
|
||||
List<Future> tests = [];
|
||||
tests.add(checkHover('topLevelVar;', 11, [
|
||||
'List',
|
||||
'topLevelVar'
|
||||
], 'top level variable', ['List']));
|
||||
tests.add(checkHover('topLevelVar;', 11, ['List', 'topLevelVar'],
|
||||
'top level variable', ['List']));
|
||||
tests.add(checkHover(
|
||||
'func(', 4, ['func', 'int', 'param'], 'function', ['int', 'void'],
|
||||
docRegexp: 'Documentation for func'));
|
||||
|
@ -157,10 +161,8 @@ main() {
|
|||
tests.add(checkHover(
|
||||
'localVar =', 8, ['num', 'localVar'], 'local variable', ['num'],
|
||||
isLocal: true, propagatedType: 'int'));
|
||||
tests.add(checkHover('topLevelVar.length;', 11, [
|
||||
'List',
|
||||
'topLevelVar'
|
||||
], 'top level variable', ['List']));
|
||||
tests.add(checkHover('topLevelVar.length;', 11, ['List', 'topLevelVar'],
|
||||
'top level variable', ['List']));
|
||||
tests.add(checkHover(
|
||||
'length;', 6, ['get', 'length', 'int'], 'getter', ['int'],
|
||||
isCore: true, docRegexp: '.*'));
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisHighlightsTest);
|
||||
}
|
||||
|
||||
|
@ -70,7 +72,9 @@ int topLevelVariable;
|
|||
''';
|
||||
writeFile(pathname, text);
|
||||
standardAnalysisSetup();
|
||||
sendAnalysisSetSubscriptions({AnalysisService.HIGHLIGHTS: [pathname]});
|
||||
sendAnalysisSetSubscriptions({
|
||||
AnalysisService.HIGHLIGHTS: [pathname]
|
||||
});
|
||||
// Map from highlight type to highlighted text
|
||||
Map<HighlightRegionType, Set<String>> highlights;
|
||||
onAnalysisHighlights.listen((AnalysisHighlightsParams params) {
|
||||
|
@ -96,21 +100,10 @@ int topLevelVariable;
|
|||
highlights.remove(type);
|
||||
}
|
||||
check(HighlightRegionType.ANNOTATION, ['@override']);
|
||||
check(HighlightRegionType.BUILT_IN, [
|
||||
'as',
|
||||
'get',
|
||||
'import',
|
||||
'set',
|
||||
'static',
|
||||
'typedef'
|
||||
]);
|
||||
check(HighlightRegionType.CLASS, [
|
||||
'Class',
|
||||
'Class2',
|
||||
'Future',
|
||||
'Map',
|
||||
'int'
|
||||
]);
|
||||
check(HighlightRegionType.BUILT_IN,
|
||||
['as', 'get', 'import', 'set', 'static', 'typedef']);
|
||||
check(HighlightRegionType.CLASS,
|
||||
['Class', 'Class2', 'Future', 'Map', 'int']);
|
||||
check(HighlightRegionType.COMMENT_BLOCK, ['/* Block comment */']);
|
||||
check(HighlightRegionType.COMMENT_DOCUMENTATION,
|
||||
['/**\n * Doc comment\n */']);
|
||||
|
@ -132,10 +125,8 @@ int topLevelVariable;
|
|||
check(HighlightRegionType.LITERAL_DOUBLE, ['1.0']);
|
||||
check(HighlightRegionType.LITERAL_INTEGER, ['2', '42']);
|
||||
check(HighlightRegionType.LITERAL_LIST, ['[]']);
|
||||
check(HighlightRegionType.LITERAL_MAP, [
|
||||
'{1.0: [].toList()}',
|
||||
'{2: local}'
|
||||
]);
|
||||
check(HighlightRegionType.LITERAL_MAP,
|
||||
['{1.0: [].toList()}', '{2: local}']);
|
||||
check(HighlightRegionType.LITERAL_STRING, ["'dart:async'", "'string'"]);
|
||||
check(HighlightRegionType.LOCAL_VARIABLE, ['local']);
|
||||
check(HighlightRegionType.LOCAL_VARIABLE_DECLARATION, ['local']);
|
||||
|
@ -145,10 +136,8 @@ int topLevelVariable;
|
|||
check(HighlightRegionType.METHOD_STATIC, ['wait']);
|
||||
check(HighlightRegionType.PARAMETER, ['parameter']);
|
||||
check(HighlightRegionType.SETTER_DECLARATION, ['setter']);
|
||||
check(HighlightRegionType.TOP_LEVEL_VARIABLE, [
|
||||
'override',
|
||||
'topLevelVariable'
|
||||
]);
|
||||
check(HighlightRegionType.TOP_LEVEL_VARIABLE,
|
||||
['override', 'topLevelVariable']);
|
||||
check(HighlightRegionType.TYPE_NAME_DYNAMIC, ['dynamic']);
|
||||
check(HighlightRegionType.TYPE_PARAMETER, ['TypeParameter']);
|
||||
expect(highlights, isEmpty);
|
||||
|
|
|
@ -10,9 +10,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisHighlightsTest);
|
||||
}
|
||||
|
||||
|
@ -77,7 +79,9 @@ int topLevelVariable;
|
|||
''';
|
||||
writeFile(pathname, text);
|
||||
standardAnalysisSetup();
|
||||
sendAnalysisSetSubscriptions({AnalysisService.HIGHLIGHTS: [pathname]});
|
||||
sendAnalysisSetSubscriptions({
|
||||
AnalysisService.HIGHLIGHTS: [pathname]
|
||||
});
|
||||
// Map from highlight type to highlighted text
|
||||
Map<HighlightRegionType, Set<String>> highlights;
|
||||
onAnalysisHighlights.listen((AnalysisHighlightsParams params) {
|
||||
|
@ -103,21 +107,10 @@ int topLevelVariable;
|
|||
highlights.remove(type);
|
||||
}
|
||||
check(HighlightRegionType.ANNOTATION, ['@override']);
|
||||
check(HighlightRegionType.BUILT_IN, [
|
||||
'as',
|
||||
'get',
|
||||
'import',
|
||||
'set',
|
||||
'static',
|
||||
'typedef'
|
||||
]);
|
||||
check(HighlightRegionType.CLASS, [
|
||||
'Class',
|
||||
'Class2',
|
||||
'Future',
|
||||
'Map',
|
||||
'int'
|
||||
]);
|
||||
check(HighlightRegionType.BUILT_IN,
|
||||
['as', 'get', 'import', 'set', 'static', 'typedef']);
|
||||
check(HighlightRegionType.CLASS,
|
||||
['Class', 'Class2', 'Future', 'Map', 'int']);
|
||||
check(HighlightRegionType.COMMENT_BLOCK, ['/* Block comment */']);
|
||||
check(HighlightRegionType.COMMENT_DOCUMENTATION,
|
||||
['/**\n * Doc comment\n */']);
|
||||
|
@ -140,10 +133,8 @@ int topLevelVariable;
|
|||
check(HighlightRegionType.LITERAL_DOUBLE, ['1.0']);
|
||||
check(HighlightRegionType.LITERAL_INTEGER, ['2', '42']);
|
||||
check(HighlightRegionType.LITERAL_LIST, ['[]']);
|
||||
check(HighlightRegionType.LITERAL_MAP, [
|
||||
'{1.0: [].toList()}',
|
||||
'{2: local}'
|
||||
]);
|
||||
check(HighlightRegionType.LITERAL_MAP,
|
||||
['{1.0: [].toList()}', '{2: local}']);
|
||||
check(HighlightRegionType.LITERAL_STRING, ["'dart:async'", "'string'"]);
|
||||
check(HighlightRegionType.LOCAL_VARIABLE_DECLARATION, ['local']);
|
||||
check(HighlightRegionType.LOCAL_VARIABLE_REFERENCE, ['local']);
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisNavigationTest);
|
||||
}
|
||||
|
||||
|
@ -54,7 +56,9 @@ part of foo;
|
|||
''';
|
||||
writeFile(pathname2, text2);
|
||||
standardAnalysisSetup();
|
||||
sendAnalysisSetSubscriptions({AnalysisService.NAVIGATION: [pathname1]});
|
||||
sendAnalysisSetSubscriptions({
|
||||
AnalysisService.NAVIGATION: [pathname1]
|
||||
});
|
||||
List<NavigationRegion> regions;
|
||||
List<NavigationTarget> targets;
|
||||
List<String> targetFiles;
|
||||
|
@ -101,10 +105,12 @@ part of foo;
|
|||
checkLocal('Class<int>', 'Class<TypeParameter>', ElementKind.CLASS);
|
||||
checkRemote(
|
||||
"'test2.dart';", r'test2.dart$', ElementKind.COMPILATION_UNIT);
|
||||
checkLocal('Class<int>.constructor',
|
||||
checkLocal(
|
||||
'Class<int>.constructor',
|
||||
'constructor(); /* constructor declaration */',
|
||||
ElementKind.CONSTRUCTOR);
|
||||
checkLocal('constructor(); // usage',
|
||||
checkLocal(
|
||||
'constructor(); // usage',
|
||||
'constructor(); /* constructor declaration */',
|
||||
ElementKind.CONSTRUCTOR);
|
||||
checkLocal('field;', 'field;', ElementKind.FIELD);
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
@ -31,7 +33,9 @@ main() {
|
|||
''';
|
||||
writeFile(pathname, text);
|
||||
standardAnalysisSetup();
|
||||
sendAnalysisSetSubscriptions({AnalysisService.OCCURRENCES: [pathname]});
|
||||
sendAnalysisSetSubscriptions({
|
||||
AnalysisService.OCCURRENCES: [pathname]
|
||||
});
|
||||
List<Occurrences> occurrences;
|
||||
onAnalysisOccurrences.listen((AnalysisOccurrencesParams params) {
|
||||
expect(params.file, equals(pathname));
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
@ -53,7 +55,9 @@ class Class2 {
|
|||
''';
|
||||
writeFile(pathname, text);
|
||||
standardAnalysisSetup();
|
||||
sendAnalysisSetSubscriptions({AnalysisService.OUTLINE: [pathname]});
|
||||
sendAnalysisSetSubscriptions({
|
||||
AnalysisService.OUTLINE: [pathname]
|
||||
});
|
||||
Outline outline;
|
||||
onAnalysisOutline.listen((AnalysisOutlineParams params) {
|
||||
expect(params.file, equals(pathname));
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
@ -53,7 +55,9 @@ class Target extends Base implements Interface1, Interface2 {
|
|||
''';
|
||||
writeFile(pathname, text);
|
||||
standardAnalysisSetup();
|
||||
sendAnalysisSetSubscriptions({AnalysisService.OVERRIDES: [pathname]});
|
||||
sendAnalysisSetSubscriptions({
|
||||
AnalysisService.OVERRIDES: [pathname]
|
||||
});
|
||||
List<Override> overrides;
|
||||
onAnalysisOverrides.listen((AnalysisOverridesParams params) {
|
||||
expect(params.file, equals(pathname));
|
||||
|
|
|
@ -9,9 +9,11 @@ import 'package:path/path.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
@ -39,7 +41,9 @@ f() {}
|
|||
writeFile(mainPath, mainText);
|
||||
String normalizedFooBarPath = writeFile(fooBarPath, fooBarText);
|
||||
sendServerSetSubscriptions([ServerService.STATUS]);
|
||||
sendAnalysisSetSubscriptions({AnalysisService.NAVIGATION: [mainPath]});
|
||||
sendAnalysisSetSubscriptions({
|
||||
AnalysisService.NAVIGATION: [mainPath]
|
||||
});
|
||||
List<NavigationRegion> navigationRegions;
|
||||
List<NavigationTarget> navigationTargets;
|
||||
List<String> navigationTargetFiles;
|
||||
|
|
|
@ -14,9 +14,11 @@ import 'dart:async';
|
|||
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ library test.integration.analysis.all;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'error_test.dart' as error_test;
|
||||
import 'get_errors_after_analysis_test.dart' as get_errors_after_analysis_test;
|
||||
import 'get_errors_before_analysis_test.dart'
|
||||
|
@ -27,7 +28,7 @@ import 'update_content_test.dart' as update_content_test;
|
|||
* Utility for manually running all integration tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('analysis', () {
|
||||
error_test.main();
|
||||
get_errors_after_analysis_test.main();
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,11 @@ import 'dart:async';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
// defineReflectiveTests(AsynchronyIntegrationTest);
|
||||
}
|
||||
|
||||
|
@ -58,7 +60,6 @@ class AsynchronyIntegrationTest {
|
|||
// received them all. If the server is blocked waiting for us to read
|
||||
// its responses, the flush will never complete.
|
||||
return server.flushCommands().then((_) {
|
||||
|
||||
// Begin processing responses from the server.
|
||||
server.listenToOutput((String event, params) {
|
||||
// The only expected notification is server.connected.
|
||||
|
|
|
@ -8,9 +8,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
@ -32,7 +34,9 @@ class Test extends AbstractAnalysisServerIntegrationTest {
|
|||
}
|
||||
|
||||
test_getSuggestions() async {
|
||||
setTestSource('test.dart', r'''
|
||||
setTestSource(
|
||||
'test.dart',
|
||||
r'''
|
||||
String test = '';
|
||||
main() {
|
||||
test.^
|
||||
|
@ -54,7 +58,9 @@ main() {
|
|||
}
|
||||
|
||||
test_getSuggestions_onlyOverlay() async {
|
||||
setTestSource('test.dart', r'''
|
||||
setTestSource(
|
||||
'test.dart',
|
||||
r'''
|
||||
String test = '';
|
||||
main() {
|
||||
test.^
|
||||
|
@ -78,7 +84,9 @@ main() {
|
|||
}
|
||||
|
||||
test_getSuggestions_onlyOverlay_noWait() async {
|
||||
setTestSource('test.dart', r'''
|
||||
setTestSource(
|
||||
'test.dart',
|
||||
r'''
|
||||
String test = '';
|
||||
main() {
|
||||
test.^
|
||||
|
|
|
@ -6,13 +6,14 @@ library test.integration.completion.all;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'get_suggestions_test.dart' as get_suggestions_test;
|
||||
|
||||
/**
|
||||
* Utility for manually running all integration tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('completion', () {
|
||||
get_suggestions_test.main();
|
||||
});
|
||||
|
|
|
@ -10,9 +10,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,14 @@ library test.integration.search.all;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'get_type_hierarchy_test.dart' as get_type_hierarchy_test;
|
||||
|
||||
/**
|
||||
* Utility for manually running all integration tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('search', () {
|
||||
get_type_hierarchy_test.main();
|
||||
});
|
||||
|
|
|
@ -6,9 +6,11 @@ library test.integration.server.get.version;
|
|||
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,11 @@ library test.integration.server.set.subscriptions.invalid.service;
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
@ -18,9 +20,9 @@ class Test extends AbstractAnalysisServerIntegrationTest {
|
|||
test_setSubscriptions_invalidService() {
|
||||
// TODO(paulberry): verify that if an invalid service is specified, the
|
||||
// current subscriptions are unchanged.
|
||||
return server
|
||||
.send("server.setSubscriptions", {'subscriptions': ['bogus']})
|
||||
.then((_) {
|
||||
return server.send("server.setSubscriptions", {
|
||||
'subscriptions': ['bogus']
|
||||
}).then((_) {
|
||||
fail('setSubscriptions should have produced an error');
|
||||
}, onError: (error) {
|
||||
// The expected error occurred.
|
||||
|
|
|
@ -10,9 +10,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
@ -31,7 +33,9 @@ class Test extends AbstractAnalysisServerIntegrationTest {
|
|||
});
|
||||
return sendServerSetSubscriptions([]).then((_) {
|
||||
String pathname = sourcePath('test.dart');
|
||||
writeFile(pathname, '''
|
||||
writeFile(
|
||||
pathname,
|
||||
'''
|
||||
main() {
|
||||
var x;
|
||||
}''');
|
||||
|
@ -42,7 +46,9 @@ main() {
|
|||
expect(statusReceived, isFalse);
|
||||
return sendServerSetSubscriptions([ServerService.STATUS]).then((_) {
|
||||
// Tickle test.dart just in case analysis has already completed.
|
||||
writeFile(pathname, '''
|
||||
writeFile(
|
||||
pathname,
|
||||
'''
|
||||
main() {
|
||||
var y;
|
||||
}''');
|
||||
|
|
|
@ -9,9 +9,11 @@ import 'dart:async';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../integration_tests.dart';
|
||||
|
||||
main() {
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(Test);
|
||||
}
|
||||
|
||||
|
@ -35,7 +37,9 @@ class Test extends AbstractAnalysisServerIntegrationTest {
|
|||
}
|
||||
}
|
||||
});
|
||||
writeFile(sourcePath('test.dart'), '''
|
||||
writeFile(
|
||||
sourcePath('test.dart'),
|
||||
'''
|
||||
main() {
|
||||
var x;
|
||||
}''');
|
||||
|
|
|
@ -6,6 +6,7 @@ library test.integration.server.all;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'get_version_test.dart' as get_version_test;
|
||||
import 'set_subscriptions_invalid_service_test.dart'
|
||||
as set_subscriptions_invalid_service_test;
|
||||
|
@ -17,7 +18,7 @@ import 'status_test.dart' as status_test;
|
|||
* Utility for manually running all integration tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('server', () {
|
||||
get_version_test.main();
|
||||
set_subscriptions_test.main();
|
||||
|
|
|
@ -6,6 +6,7 @@ library test.integration.all;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'analysis/test_all.dart' as analysis_test_all;
|
||||
import 'asynchrony_test.dart' as asynchrony_test;
|
||||
import 'completion/test_all.dart' as completion_test_all;
|
||||
|
@ -16,7 +17,7 @@ import 'server/test_all.dart' as server_test_all;
|
|||
* Utility for manually running all integration tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('analysis_server_integration', () {
|
||||
analysis_test_all.main();
|
||||
asynchrony_test.main();
|
||||
|
|
|
@ -18,9 +18,10 @@ import 'package:typed_mock/typed_mock.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(ServerOperationQueueTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,10 @@ library test.operation;
|
|||
import 'package:analysis_server/src/operation/operation.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
|
||||
group('ServerOperationPriority', () {
|
||||
test('toString', () {
|
||||
|
|
|
@ -6,6 +6,7 @@ library test.operation.all;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'operation_queue_test.dart' as operation_queue_test;
|
||||
import 'operation_test.dart' as operation_test;
|
||||
|
||||
|
@ -13,7 +14,7 @@ import 'operation_test.dart' as operation_test;
|
|||
* Utility for manually running all tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('operation', () {
|
||||
operation_queue_test.main();
|
||||
operation_test.main();
|
||||
|
|
|
@ -19,9 +19,10 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import 'abstract_context.dart';
|
||||
import 'mocks.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AnalysisErrorTest);
|
||||
defineReflectiveTests(ElementTest);
|
||||
defineReflectiveTests(ElementKindTest);
|
||||
|
@ -193,7 +194,9 @@ class ElementTest extends AbstractContextTest {
|
|||
}
|
||||
|
||||
void test_fromElement_CLASS() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
@deprecated
|
||||
abstract class _A {}
|
||||
class B<K, V> {}''');
|
||||
|
@ -214,9 +217,11 @@ class B<K, V> {}''');
|
|||
expect(location.startColumn, 16);
|
||||
}
|
||||
expect(element.parameters, isNull);
|
||||
expect(element.flags, Element.FLAG_ABSTRACT |
|
||||
Element.FLAG_DEPRECATED |
|
||||
Element.FLAG_PRIVATE);
|
||||
expect(
|
||||
element.flags,
|
||||
Element.FLAG_ABSTRACT |
|
||||
Element.FLAG_DEPRECATED |
|
||||
Element.FLAG_PRIVATE);
|
||||
}
|
||||
{
|
||||
engine.ClassElement engineElement = findElementInUnit(unit, 'B');
|
||||
|
@ -230,7 +235,9 @@ class B<K, V> {}''');
|
|||
}
|
||||
|
||||
void test_fromElement_CONSTRUCTOR() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
const A.myConstructor(int a, [String b]);
|
||||
}''');
|
||||
|
@ -268,7 +275,9 @@ class A {
|
|||
}
|
||||
|
||||
void test_fromElement_ENUM() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
@deprecated
|
||||
enum _E1 { one, two }
|
||||
enum E2 { three, four }''');
|
||||
|
@ -290,7 +299,8 @@ enum E2 { three, four }''');
|
|||
expect(location.startColumn, 6);
|
||||
}
|
||||
expect(element.parameters, isNull);
|
||||
expect(element.flags,
|
||||
expect(
|
||||
element.flags,
|
||||
(engineElement.isDeprecated ? Element.FLAG_DEPRECATED : 0) |
|
||||
Element.FLAG_PRIVATE);
|
||||
}
|
||||
|
@ -306,7 +316,9 @@ enum E2 { three, four }''');
|
|||
}
|
||||
|
||||
void test_fromElement_ENUM_CONSTANT() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
@deprecated
|
||||
enum _E1 { one, two }
|
||||
enum E2 { three, four }''');
|
||||
|
@ -330,7 +342,8 @@ enum E2 { three, four }''');
|
|||
// TODO(danrubel) determine why enum constant is not marked as deprecated
|
||||
//engine.ClassElement classElement = engineElement.enclosingElement;
|
||||
//expect(classElement.isDeprecated, isTrue);
|
||||
expect(element.flags,
|
||||
expect(
|
||||
element.flags,
|
||||
// Element.FLAG_DEPRECATED |
|
||||
Element.FLAG_CONST | Element.FLAG_STATIC);
|
||||
}
|
||||
|
@ -391,7 +404,9 @@ enum E2 { three, four }''');
|
|||
}
|
||||
|
||||
void test_fromElement_FIELD() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
static const myField = 42;
|
||||
}''');
|
||||
|
@ -415,7 +430,9 @@ class A {
|
|||
}
|
||||
|
||||
void test_fromElement_FUNCTION_TYPE_ALIAS() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
typedef int F<T>(String x);
|
||||
''');
|
||||
engine.CompilationUnit unit = resolveLibraryUnit(source);
|
||||
|
@ -440,7 +457,9 @@ typedef int F<T>(String x);
|
|||
}
|
||||
|
||||
void test_fromElement_GETTER() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
String get myGetter => 42;
|
||||
}''');
|
||||
|
@ -465,7 +484,9 @@ class A {
|
|||
}
|
||||
|
||||
void test_fromElement_LABEL() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
main() {
|
||||
myLabel:
|
||||
while (true) {
|
||||
|
@ -492,7 +513,9 @@ myLabel:
|
|||
}
|
||||
|
||||
void test_fromElement_METHOD() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
static List<String> myMethod(int a, {String b}) {
|
||||
return null;
|
||||
|
@ -518,7 +541,9 @@ class A {
|
|||
}
|
||||
|
||||
void test_fromElement_SETTER() {
|
||||
engine.Source source = addSource('/test.dart', '''
|
||||
engine.Source source = addSource(
|
||||
'/test.dart',
|
||||
'''
|
||||
class A {
|
||||
set mySetter(String x) {}
|
||||
}''');
|
||||
|
@ -560,8 +585,8 @@ class EnumTest {
|
|||
}
|
||||
|
||||
void test_ElementKind() {
|
||||
new EnumTester<engine.ElementKind, ElementKind>().run(
|
||||
newElementKind_fromEngine, exceptions: {
|
||||
new EnumTester<engine.ElementKind, ElementKind>()
|
||||
.run(newElementKind_fromEngine, exceptions: {
|
||||
// TODO(paulberry): do any of the exceptions below constitute bugs?
|
||||
engine.ElementKind.DYNAMIC: ElementKind.UNKNOWN,
|
||||
engine.ElementKind.EMBEDDED_HTML_SCRIPT: ElementKind.UNKNOWN,
|
||||
|
|
|
@ -11,8 +11,10 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(NotificationTest);
|
||||
defineReflectiveTests(RequestTest);
|
||||
defineReflectiveTests(RequestErrorTest);
|
||||
|
@ -77,7 +79,11 @@ class NotificationTest {
|
|||
expect(notification.event, equals('foo'));
|
||||
expect(notification.toJson()['params'], equals({'x': 'y'}));
|
||||
expect(
|
||||
notification.toJson(), equals({'event': 'foo', 'params': {'x': 'y'}}));
|
||||
notification.toJson(),
|
||||
equals({
|
||||
'event': 'foo',
|
||||
'params': {'x': 'y'}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,12 +114,10 @@ class RequestErrorTest {
|
|||
void test_toJson() {
|
||||
var trace = 'a stack trace\r\nbar';
|
||||
RequestError error = new RequestError(
|
||||
RequestErrorCode.UNKNOWN_REQUEST, 'msg', stackTrace: trace);
|
||||
expect(error.toJson(), {
|
||||
CODE: 'UNKNOWN_REQUEST',
|
||||
MESSAGE: 'msg',
|
||||
STACK_TRACE: trace
|
||||
});
|
||||
RequestErrorCode.UNKNOWN_REQUEST, 'msg',
|
||||
stackTrace: trace);
|
||||
expect(error.toJson(),
|
||||
{CODE: 'UNKNOWN_REQUEST', MESSAGE: 'msg', STACK_TRACE: trace});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,11 +188,13 @@ class RequestTest {
|
|||
|
||||
void test_toJson_withParams() {
|
||||
Request request = new Request('one', 'aMethod', {'foo': 'bar'});
|
||||
expect(request.toJson(), equals({
|
||||
Request.ID: 'one',
|
||||
Request.METHOD: 'aMethod',
|
||||
Request.PARAMS: {'foo': 'bar'}
|
||||
}));
|
||||
expect(
|
||||
request.toJson(),
|
||||
equals({
|
||||
Request.ID: 'one',
|
||||
Request.METHOD: 'aMethod',
|
||||
Request.PARAMS: {'foo': 'bar'}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,33 +204,45 @@ class ResponseTest {
|
|||
Response response = new Response.invalidRequestFormat();
|
||||
expect(response.id, equals(''));
|
||||
expect(response.error, isNotNull);
|
||||
expect(response.toJson(), equals({
|
||||
Response.ID: '',
|
||||
Response.ERROR: {'code': 'INVALID_REQUEST', 'message': 'Invalid request'}
|
||||
}));
|
||||
expect(
|
||||
response.toJson(),
|
||||
equals({
|
||||
Response.ID: '',
|
||||
Response.ERROR: {
|
||||
'code': 'INVALID_REQUEST',
|
||||
'message': 'Invalid request'
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void test_create_unanalyzedPriorityFiles() {
|
||||
Response response = new Response.unanalyzedPriorityFiles('0', 'file list');
|
||||
expect(response.id, equals('0'));
|
||||
expect(response.error, isNotNull);
|
||||
expect(response.toJson(), equals({
|
||||
Response.ID: '0',
|
||||
Response.ERROR: {
|
||||
'code': 'UNANALYZED_PRIORITY_FILES',
|
||||
'message': "Unanalyzed files cannot be a priority: 'file list'"
|
||||
}
|
||||
}));
|
||||
expect(
|
||||
response.toJson(),
|
||||
equals({
|
||||
Response.ID: '0',
|
||||
Response.ERROR: {
|
||||
'code': 'UNANALYZED_PRIORITY_FILES',
|
||||
'message': "Unanalyzed files cannot be a priority: 'file list'"
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void test_create_unknownRequest() {
|
||||
Response response = new Response.unknownRequest(new Request('0', ''));
|
||||
expect(response.id, equals('0'));
|
||||
expect(response.error, isNotNull);
|
||||
expect(response.toJson(), equals({
|
||||
Response.ID: '0',
|
||||
Response.ERROR: {'code': 'UNKNOWN_REQUEST', 'message': 'Unknown request'}
|
||||
}));
|
||||
expect(
|
||||
response.toJson(),
|
||||
equals({
|
||||
Response.ID: '0',
|
||||
Response.ERROR: {
|
||||
'code': 'UNKNOWN_REQUEST',
|
||||
'message': 'Unknown request'
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void test_fromJson() {
|
||||
|
|
|
@ -11,10 +11,11 @@ import 'package:analysis_server/src/services/index/index.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'abstract_search_domain.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(ElementReferencesTest);
|
||||
defineReflectiveTests(_NoSearchEngine);
|
||||
}
|
||||
|
@ -453,7 +454,9 @@ class B {
|
|||
''');
|
||||
await findElementReferences('A {}', false);
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'A a = null;');
|
||||
expect(getPathString(result.path), '''
|
||||
expect(
|
||||
getPathString(result.path),
|
||||
'''
|
||||
LOCAL_VARIABLE a
|
||||
CONSTRUCTOR named
|
||||
CLASS B
|
||||
|
@ -473,7 +476,9 @@ class B {
|
|||
''');
|
||||
await findElementReferences('A {}', false);
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'A a = null;');
|
||||
expect(getPathString(result.path), '''
|
||||
expect(
|
||||
getPathString(result.path),
|
||||
'''
|
||||
LOCAL_VARIABLE a
|
||||
CONSTRUCTOR
|
||||
CLASS B
|
||||
|
@ -491,7 +496,9 @@ main() {
|
|||
''');
|
||||
await findElementReferences('A {}', false);
|
||||
assertHasResult(SearchResultKind.REFERENCE, 'A a = null;');
|
||||
expect(getPathString(result.path), '''
|
||||
expect(
|
||||
getPathString(result.path),
|
||||
'''
|
||||
LOCAL_VARIABLE a
|
||||
FUNCTION main
|
||||
COMPILATION_UNIT test.dart
|
||||
|
|
|
@ -10,10 +10,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'abstract_search_domain.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(MemberDeclarationsTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'abstract_search_domain.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(MemberReferencesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@ import 'package:analysis_server/src/services/search/search_engine.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(SearchResultKindTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ library test.search;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'element_references_test.dart' as element_references_test;
|
||||
import 'member_declarations_test.dart' as member_declarations;
|
||||
import 'member_references_test.dart' as member_references_test;
|
||||
|
@ -16,7 +17,7 @@ import 'type_hierarchy_test.dart' as type_hierarchy_test;
|
|||
* Utility for manually running all tests.
|
||||
*/
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('search', () {
|
||||
element_references_test.main();
|
||||
member_declarations.main();
|
||||
|
|
|
@ -10,10 +10,11 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
import 'abstract_search_domain.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(TopLevelDeclarationsTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../analysis_abstract.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(GetTypeHierarchyTest);
|
||||
}
|
||||
|
||||
|
@ -109,13 +110,16 @@ class B extends A<int> {
|
|||
test_class_extends_fileAndPackageUris() async {
|
||||
// prepare packages
|
||||
String pkgFile = '/packages/pkgA/libA.dart';
|
||||
resourceProvider.newFile(pkgFile, '''
|
||||
resourceProvider.newFile(
|
||||
pkgFile,
|
||||
'''
|
||||
library lib_a;
|
||||
class A {}
|
||||
class B extends A {}
|
||||
''');
|
||||
packageMapProvider.packageMap['pkgA'] =
|
||||
[resourceProvider.getResource('/packages/pkgA')];
|
||||
packageMapProvider.packageMap['pkgA'] = [
|
||||
resourceProvider.getResource('/packages/pkgA')
|
||||
];
|
||||
// reference the package from a project
|
||||
addTestFile('''
|
||||
import 'package:pkgA/libA.dart';
|
||||
|
@ -797,8 +801,8 @@ class D extends C {
|
|||
Request request = _createGetTypeHierarchyRequest(search);
|
||||
Response response = await serverChannel.sendRequest(request);
|
||||
expect(serverErrors, isEmpty);
|
||||
return new SearchGetTypeHierarchyResult.fromResponse(
|
||||
response).hierarchyItems;
|
||||
return new SearchGetTypeHierarchyResult.fromResponse(response)
|
||||
.hierarchyItems;
|
||||
}
|
||||
|
||||
List _toJson(List<TypeHierarchyItem> items) {
|
||||
|
|
|
@ -10,8 +10,10 @@ library analysis_server.test.server_options;
|
|||
import 'package:analysis_server/src/server_options.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
void main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
|
||||
group('server_options', () {
|
||||
test('basic - []', () {
|
||||
|
|
|
@ -10,10 +10,11 @@ import 'package:analysis_server/src/services/completion/dart_completion_manager.
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'completion_test_util.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(ArgListContributorTest);
|
||||
}
|
||||
|
||||
|
@ -41,8 +42,10 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
assertNoOtherSuggestions([cs]);
|
||||
}
|
||||
|
||||
void assertSuggestArgumentList_params(List<String> expectedNames,
|
||||
List<String> expectedTypes, List<String> actualNames,
|
||||
void assertSuggestArgumentList_params(
|
||||
List<String> expectedNames,
|
||||
List<String> expectedTypes,
|
||||
List<String> actualNames,
|
||||
List<String> actualTypes) {
|
||||
if (actualNames != null &&
|
||||
actualNames.length == expectedNames.length &&
|
||||
|
@ -97,7 +100,9 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_ArgumentList_imported_function_0() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
expect() { }
|
||||
|
@ -115,7 +120,9 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_ArgumentList_imported_function_1() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
expect(String arg) { }
|
||||
|
@ -133,7 +140,9 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_ArgumentList_imported_function_2() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
expect(String arg1, int arg2) { }
|
||||
|
@ -151,7 +160,9 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_ArgumentList_imported_function_3() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
|
@ -169,7 +180,9 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_ArgumentList_imported_function_3a() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
|
@ -187,7 +200,9 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_ArgumentList_imported_function_3b() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
|
@ -205,7 +220,9 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_ArgumentList_imported_function_3c() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
|
@ -223,7 +240,9 @@ class ArgListContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_ArgumentList_imported_function_3d() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
|
@ -419,7 +438,9 @@ main() { f("16", radix: ^);}''');
|
|||
|
||||
test_ArgumentList_local_method_0() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
void baz() { }''');
|
||||
|
@ -437,7 +458,9 @@ main() { f("16", radix: ^);}''');
|
|||
|
||||
test_ArgumentList_local_method_2() {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
library A;
|
||||
bool hasLength(int expected) { }
|
||||
void baz() { }''');
|
||||
|
|
|
@ -8,12 +8,12 @@ import 'package:analysis_server/src/protocol.dart';
|
|||
import 'package:analysis_server/src/services/completion/combinator_contributor.dart';
|
||||
import 'package:analysis_server/src/services/completion/dart_completion_manager.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'completion_test_util.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(CombinatorContributorTest);
|
||||
}
|
||||
|
||||
|
@ -40,17 +40,23 @@ class CombinatorContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_Combinator_hide() {
|
||||
// SimpleIdentifier HideCombinator ImportDirective
|
||||
addSource('/testAB.dart', '''
|
||||
addSource(
|
||||
'/testAB.dart',
|
||||
'''
|
||||
library libAB;
|
||||
part '/partAB.dart';
|
||||
class A { }
|
||||
class B { }''');
|
||||
addSource('/partAB.dart', '''
|
||||
addSource(
|
||||
'/partAB.dart',
|
||||
'''
|
||||
part of libAB;
|
||||
var T1;
|
||||
PB F1() => new PB();
|
||||
class PB { }''');
|
||||
addSource('/testCD.dart', '''
|
||||
addSource(
|
||||
'/testCD.dart',
|
||||
'''
|
||||
class C { }
|
||||
class D { }''');
|
||||
addTestSource('''
|
||||
|
@ -81,19 +87,25 @@ class CombinatorContributorTest extends AbstractCompletionTest {
|
|||
|
||||
test_Combinator_show() {
|
||||
// SimpleIdentifier HideCombinator ImportDirective
|
||||
addSource('/testAB.dart', '''
|
||||
addSource(
|
||||
'/testAB.dart',
|
||||
'''
|
||||
library libAB;
|
||||
part '/partAB.dart';
|
||||
class A { }
|
||||
class B { }''');
|
||||
addSource('/partAB.dart', '''
|
||||
addSource(
|
||||
'/partAB.dart',
|
||||
'''
|
||||
part of libAB;
|
||||
var T1;
|
||||
PB F1() => new PB();
|
||||
typedef PB2 F2(int blat);
|
||||
class Clz = Object with Object;
|
||||
class PB { }''');
|
||||
addSource('/testCD.dart', '''
|
||||
addSource(
|
||||
'/testCD.dart',
|
||||
'''
|
||||
class C { }
|
||||
class D { }''');
|
||||
addTestSource('''
|
||||
|
|
|
@ -23,9 +23,10 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import '../../analysis_abstract.dart';
|
||||
import '../../mocks.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(CommonUsageComputerTest);
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,8 @@ class CommonUsageComputerTest extends AbstractAnalysisTest {
|
|||
}
|
||||
|
||||
void assertHasResult(CompletionSuggestionKind kind, String completion,
|
||||
[int relevance = DART_RELEVANCE_DEFAULT, bool isDeprecated = false,
|
||||
[int relevance = DART_RELEVANCE_DEFAULT,
|
||||
bool isDeprecated = false,
|
||||
bool isPotential = false]) {
|
||||
var cs;
|
||||
suggestions.forEach((s) {
|
||||
|
@ -99,9 +101,13 @@ class CommonUsageComputerTest extends AbstractAnalysisTest {
|
|||
ContextSourcePair contextSource = server.getContextSourcePair(params.file);
|
||||
AnalysisContext context = contextSource.context;
|
||||
Source source = contextSource.source;
|
||||
DartCompletionManager completionManager = new DartCompletionManager(context,
|
||||
server.searchEngine, source, new DartCompletionCache(context, source),
|
||||
null, new CommonUsageComputer(selectorRelevance));
|
||||
DartCompletionManager completionManager = new DartCompletionManager(
|
||||
context,
|
||||
server.searchEngine,
|
||||
source,
|
||||
new DartCompletionCache(context, source),
|
||||
null,
|
||||
new CommonUsageComputer(selectorRelevance));
|
||||
|
||||
Response response =
|
||||
domainHandler.processRequest(request, completionManager);
|
||||
|
@ -137,7 +143,9 @@ class CommonUsageComputerTest extends AbstractAnalysisTest {
|
|||
test_ConstructorName() async {
|
||||
// SimpleIdentifier ConstructorName InstanceCreationExpression
|
||||
addTestFile('import "dart:async"; class A {x() {new Future.^}}');
|
||||
await getSuggestions({'dart.async.Future': ['value', 'wait']});
|
||||
await getSuggestions({
|
||||
'dart.async.Future': ['value', 'wait']
|
||||
});
|
||||
expect(replacementOffset, equals(completionOffset));
|
||||
expect(replacementLength, equals(0));
|
||||
assertHasResult(CompletionSuggestionKind.INVOCATION, 'delayed');
|
||||
|
@ -151,7 +159,9 @@ class CommonUsageComputerTest extends AbstractAnalysisTest {
|
|||
test_PrefixedIdentifier_field() async {
|
||||
// SimpleIdentifier PrefixedIdentifeir ExpressionStatement
|
||||
addTestFile('class A {static int s1; static int s2; x() {A.^}}');
|
||||
await getSuggestions({'.A': ['s2']});
|
||||
await getSuggestions({
|
||||
'.A': ['s2']
|
||||
});
|
||||
expect(replacementOffset, equals(completionOffset));
|
||||
expect(replacementLength, equals(0));
|
||||
assertHasResult(CompletionSuggestionKind.INVOCATION, 's1');
|
||||
|
@ -165,7 +175,9 @@ class CommonUsageComputerTest extends AbstractAnalysisTest {
|
|||
test_PrefixedIdentifier_getter() async {
|
||||
// SimpleIdentifier PrefixedIdentifeir ExpressionStatement
|
||||
addTestFile('class A {int get g1 => 1; int get g2 => 2; x() {new A().^}}');
|
||||
await getSuggestions({'.A': ['g2']});
|
||||
await getSuggestions({
|
||||
'.A': ['g2']
|
||||
});
|
||||
expect(replacementOffset, equals(completionOffset));
|
||||
expect(replacementLength, equals(0));
|
||||
assertHasResult(CompletionSuggestionKind.INVOCATION, 'g1');
|
||||
|
@ -179,7 +191,9 @@ class CommonUsageComputerTest extends AbstractAnalysisTest {
|
|||
test_PrefixedIdentifier_setter() async {
|
||||
// SimpleIdentifier PrefixedIdentifeir ExpressionStatement
|
||||
addTestFile('class A {set s1(v) {}; set s2(v) {}; x() {new A().^}}');
|
||||
await getSuggestions({'.A': ['s2']});
|
||||
await getSuggestions({
|
||||
'.A': ['s2']
|
||||
});
|
||||
expect(replacementOffset, equals(completionOffset));
|
||||
expect(replacementLength, equals(0));
|
||||
assertHasResult(CompletionSuggestionKind.INVOCATION, 's1');
|
||||
|
@ -193,7 +207,9 @@ class CommonUsageComputerTest extends AbstractAnalysisTest {
|
|||
test_PrefixedIdentifier_static_method() async {
|
||||
// SimpleIdentifier PrefixedIdentifeir ExpressionStatement
|
||||
addTestFile('import "dart:async"; class A {x() {Future.^}}');
|
||||
await getSuggestions({'dart.async.Future': ['value', 'wait']});
|
||||
await getSuggestions({
|
||||
'dart.async.Future': ['value', 'wait']
|
||||
});
|
||||
expect(replacementOffset, equals(completionOffset));
|
||||
expect(replacementLength, equals(0));
|
||||
assertHasResult(CompletionSuggestionKind.INVOCATION, 'wait',
|
||||
|
@ -206,7 +222,9 @@ class CommonUsageComputerTest extends AbstractAnalysisTest {
|
|||
test_PropertyAccess() async {
|
||||
// SimpleIdentifier PropertyAccess ExpressionStatement
|
||||
addTestFile('import "dart:math"; class A {x() {new Random().^}}');
|
||||
await getSuggestions({'dart.math.Random': ['nextInt', 'nextDouble']});
|
||||
await getSuggestions({
|
||||
'dart.math.Random': ['nextInt', 'nextDouble']
|
||||
});
|
||||
expect(replacementOffset, equals(completionOffset));
|
||||
expect(replacementLength, equals(0));
|
||||
assertHasResult(CompletionSuggestionKind.INVOCATION, 'nextBool');
|
||||
|
|
|
@ -23,9 +23,10 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import '../../abstract_single_unit.dart';
|
||||
import '../../operation/operation_queue_test.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(DartCompletionManagerTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_context.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(CompletionManagerTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_context.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(CompletionTargetTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,11 @@ import 'package:path/path.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'completion_test_util.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(ImportUriContributorTest);
|
||||
}
|
||||
|
||||
|
@ -112,7 +113,8 @@ class ImportUriContributorTest extends AbstractCompletionTest {
|
|||
assertNotSuggested('other.dart');
|
||||
assertNotSuggested('foo');
|
||||
assertNotSuggested('foo${separator}');
|
||||
assertSuggest('foo${separator}bar.dart', csKind: CompletionSuggestionKind.IMPORT);
|
||||
assertSuggest('foo${separator}bar.dart',
|
||||
csKind: CompletionSuggestionKind.IMPORT);
|
||||
assertNotSuggested('..${separator}blat.dart');
|
||||
}
|
||||
|
||||
|
@ -132,7 +134,8 @@ class ImportUriContributorTest extends AbstractCompletionTest {
|
|||
assertNotSuggested('foo');
|
||||
assertNotSuggested('foo${separator}');
|
||||
assertNotSuggested('foo${separator}bar.dart');
|
||||
assertSuggest('..${separator}blat.dart', csKind: CompletionSuggestionKind.IMPORT);
|
||||
assertSuggest('..${separator}blat.dart',
|
||||
csKind: CompletionSuggestionKind.IMPORT);
|
||||
}
|
||||
|
||||
test_import_package() {
|
||||
|
@ -245,7 +248,8 @@ class ImportUriContributorTest extends AbstractCompletionTest {
|
|||
assertNotSuggested('other.dart');
|
||||
assertNotSuggested('foo');
|
||||
assertNotSuggested('foo${separator}');
|
||||
assertSuggest('foo${separator}bar.dart', csKind: CompletionSuggestionKind.IMPORT);
|
||||
assertSuggest('foo${separator}bar.dart',
|
||||
csKind: CompletionSuggestionKind.IMPORT);
|
||||
assertNotSuggested('..${separator}blat.dart');
|
||||
}
|
||||
|
||||
|
@ -265,6 +269,7 @@ class ImportUriContributorTest extends AbstractCompletionTest {
|
|||
assertNotSuggested('foo');
|
||||
assertNotSuggested('foo${separator}');
|
||||
assertNotSuggested('foo${separator}bar.dart');
|
||||
assertSuggest('..${separator}blat.dart', csKind: CompletionSuggestionKind.IMPORT);
|
||||
assertSuggest('..${separator}blat.dart',
|
||||
csKind: CompletionSuggestionKind.IMPORT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,11 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import '../../abstract_context.dart';
|
||||
import '../../operation/operation_queue_test.dart';
|
||||
import '../../utils.dart';
|
||||
import 'completion_test_util.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(ImportedReferenceContributorTest);
|
||||
}
|
||||
|
||||
|
@ -45,7 +46,8 @@ class ImportedReferenceContributorTest extends AbstractSelectorSuggestionTest {
|
|||
*/
|
||||
@override
|
||||
assertCachedCompute(_) {
|
||||
if (!(contributor as ImportedReferenceContributor).shouldWaitForLowPrioritySuggestions) {
|
||||
if (!(contributor as ImportedReferenceContributor)
|
||||
.shouldWaitForLowPrioritySuggestions) {
|
||||
return null;
|
||||
}
|
||||
List<CompletionSuggestion> oldSuggestions = request.suggestions;
|
||||
|
@ -152,7 +154,8 @@ class ImportedReferenceContributorTest extends AbstractSelectorSuggestionTest {
|
|||
CompletionSuggestion assertSuggestImportedFunction(
|
||||
String name, String returnType,
|
||||
{CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
|
||||
bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT,
|
||||
bool deprecated: false,
|
||||
int relevance: DART_RELEVANCE_DEFAULT,
|
||||
String importUri}) {
|
||||
return assertSuggestFunction(name, returnType,
|
||||
kind: kind,
|
||||
|
@ -163,7 +166,8 @@ class ImportedReferenceContributorTest extends AbstractSelectorSuggestionTest {
|
|||
|
||||
@override
|
||||
CompletionSuggestion assertSuggestImportedFunctionTypeAlias(
|
||||
String name, String returnType, [bool isDeprecated = false,
|
||||
String name, String returnType,
|
||||
[bool isDeprecated = false,
|
||||
int relevance = DART_RELEVANCE_DEFAULT,
|
||||
CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
|
||||
String importUri]) {
|
||||
|
@ -192,7 +196,8 @@ class ImportedReferenceContributorTest extends AbstractSelectorSuggestionTest {
|
|||
|
||||
@override
|
||||
CompletionSuggestion assertSuggestImportedTopLevelVar(
|
||||
String name, String returnType, [int relevance = DART_RELEVANCE_DEFAULT,
|
||||
String name, String returnType,
|
||||
[int relevance = DART_RELEVANCE_DEFAULT,
|
||||
CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
|
||||
String importUri]) {
|
||||
return assertSuggestTopLevelVar(
|
||||
|
@ -284,21 +289,29 @@ class ImportedReferenceContributorTest extends AbstractSelectorSuggestionTest {
|
|||
|
||||
test_Block_partial_results() {
|
||||
// Block BlockFunctionBody MethodDeclaration
|
||||
addSource('/testAB.dart', '''
|
||||
addSource(
|
||||
'/testAB.dart',
|
||||
'''
|
||||
export "dart:math" hide max;
|
||||
class A {int x;}
|
||||
@deprecated D1() {int x;}
|
||||
class _B { }''');
|
||||
addSource('/testCD.dart', '''
|
||||
addSource(
|
||||
'/testCD.dart',
|
||||
'''
|
||||
String T1;
|
||||
var _T2;
|
||||
class C { }
|
||||
class D { }''');
|
||||
addSource('/testEEF.dart', '''
|
||||
addSource(
|
||||
'/testEEF.dart',
|
||||
'''
|
||||
class EE { }
|
||||
class F { }''');
|
||||
addSource('/testG.dart', 'class G { }');
|
||||
addSource('/testH.dart', '''
|
||||
addSource(
|
||||
'/testH.dart',
|
||||
'''
|
||||
class H { }
|
||||
int T3;
|
||||
var _T4;'''); // not imported
|
||||
|
@ -334,7 +347,9 @@ class ImportedReferenceContributorTest extends AbstractSelectorSuggestionTest {
|
|||
}
|
||||
|
||||
test_function_parameters_mixed_required_and_named() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
void m(x, {int y}) {}
|
||||
''');
|
||||
addTestSource('''
|
||||
|
@ -356,7 +371,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_function_parameters_mixed_required_and_positional() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
void m(x, [int y]) {}
|
||||
''');
|
||||
addTestSource('''
|
||||
|
@ -378,7 +395,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_function_parameters_named() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
void m({x, int y}) {}
|
||||
''');
|
||||
addTestSource('''
|
||||
|
@ -400,7 +419,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_function_parameters_none() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
void m() {}
|
||||
''');
|
||||
addTestSource('''
|
||||
|
@ -420,7 +441,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_function_parameters_positional() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
void m([x, int y]) {}
|
||||
''');
|
||||
addTestSource('''
|
||||
|
@ -442,7 +465,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_function_parameters_required() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
void m(x, int y) {}
|
||||
''');
|
||||
addTestSource('''
|
||||
|
@ -464,7 +489,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_InstanceCreationExpression() {
|
||||
addSource('/testA.dart', '''
|
||||
addSource(
|
||||
'/testA.dart',
|
||||
'''
|
||||
class A {foo(){var f; {var x;}}}
|
||||
class B {B(this.x, [String boo]) { } int x;}
|
||||
class C {C.bar({boo: 'hoo', int z: 0}) { } }''');
|
||||
|
@ -526,7 +553,9 @@ main() {new ^ String x = "hello";}''');
|
|||
}
|
||||
|
||||
test_method_parameters_mixed_required_and_named() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
void m(x, {int y}) {}
|
||||
}
|
||||
|
@ -551,7 +580,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_method_parameters_mixed_required_and_positional() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
void m(x, [int y]) {}
|
||||
}
|
||||
|
@ -576,7 +607,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_method_parameters_named() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
void m({x, int y}) {}
|
||||
}
|
||||
|
@ -601,7 +634,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_method_parameters_none() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
void m() {}
|
||||
}
|
||||
|
@ -624,7 +659,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_method_parameters_positional() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
void m([x, int y]) {}
|
||||
}
|
||||
|
@ -649,7 +686,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_method_parameters_required() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
void m(x, int y) {}
|
||||
}
|
||||
|
@ -674,7 +713,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_mixin_ordering() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class B {}
|
||||
class M1 {
|
||||
void m() {}
|
||||
|
@ -700,7 +741,6 @@ class C extends B with M1, M2 {
|
|||
* Ensure that completions in one context don't appear in another
|
||||
*/
|
||||
test_multiple_contexts() {
|
||||
|
||||
// Create a 2nd context with source
|
||||
var context2 = AnalysisEngine.instance.createAnalysisContext();
|
||||
context2.sourceFactory =
|
||||
|
@ -726,7 +766,9 @@ class C extends B with M1, M2 {
|
|||
}
|
||||
|
||||
// Check that source in 2nd context does not appear in completion in 1st
|
||||
addSource('/context1/libA.dart', '''
|
||||
addSource(
|
||||
'/context1/libA.dart',
|
||||
'''
|
||||
library libA;
|
||||
class ClassInLocalContext {int x;}''');
|
||||
testFile = '/context1/completionTest.dart';
|
||||
|
@ -744,7 +786,9 @@ class C extends B with M1, M2 {
|
|||
}
|
||||
|
||||
test_no_parameters_field() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
int x;
|
||||
}
|
||||
|
@ -762,7 +806,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_no_parameters_getter() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
int get x => null;
|
||||
}
|
||||
|
@ -780,7 +826,9 @@ class B extends A {
|
|||
}
|
||||
|
||||
test_no_parameters_setter() {
|
||||
addSource('/libA.dart', '''
|
||||
addSource(
|
||||
'/libA.dart',
|
||||
'''
|
||||
class A {
|
||||
set x(int value) {};
|
||||
}
|
||||
|
|
|
@ -11,10 +11,11 @@ import 'package:analyzer/src/generated/scanner.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'completion_test_util.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(KeywordContributorTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,10 @@ import 'package:analyzer/src/generated/scanner.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(LocalDeclarationVisitorTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,11 @@ import 'package:analysis_server/src/services/completion/local_reference_contribu
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'completion_test_util.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(LocalReferenceContributorTest);
|
||||
}
|
||||
|
||||
|
@ -57,7 +58,8 @@ class LocalReferenceContributorTest extends AbstractSelectorSuggestionTest {
|
|||
CompletionSuggestion assertSuggestLocalFunction(
|
||||
String name, String returnType,
|
||||
{CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
|
||||
bool deprecated: false, int relevance: DART_RELEVANCE_LOCAL_FUNCTION}) {
|
||||
bool deprecated: false,
|
||||
int relevance: DART_RELEVANCE_LOCAL_FUNCTION}) {
|
||||
return assertSuggestFunction(name, returnType,
|
||||
kind: kind, deprecated: deprecated, relevance: relevance);
|
||||
}
|
||||
|
|
|
@ -13,9 +13,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_context.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(OpTypeTest);
|
||||
}
|
||||
|
||||
|
@ -42,9 +43,14 @@ class OpTypeTest {
|
|||
visitor = new OpType.forCompletion(completionTarget, offset);
|
||||
}
|
||||
|
||||
void assertOpType({bool prefixed: false, bool returnValue: false,
|
||||
bool typeNames: false, bool voidReturn: false, bool statementLabel: false,
|
||||
bool caseLabel: false, bool constructors: false}) {
|
||||
void assertOpType(
|
||||
{bool prefixed: false,
|
||||
bool returnValue: false,
|
||||
bool typeNames: false,
|
||||
bool voidReturn: false,
|
||||
bool statementLabel: false,
|
||||
bool caseLabel: false,
|
||||
bool constructors: false}) {
|
||||
expect(visitor.includeReturnValueSuggestions, returnValue,
|
||||
reason: 'returnValue');
|
||||
expect(visitor.includeTypeNameSuggestions, typeNames, reason: 'typeNames');
|
||||
|
|
|
@ -12,10 +12,11 @@ import 'package:analysis_server/src/services/completion/prefixed_element_contrib
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'completion_test_util.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(PrefixedElementContributorTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ library test.services.completion;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'arglist_contributor_test.dart' as arglist_test;
|
||||
import 'combinator_contributor_test.dart' as combinator_test;
|
||||
import 'common_usage_computer_test.dart' as common_usage_computer_test;
|
||||
|
@ -23,7 +24,7 @@ import 'prefixed_element_contributor_test.dart' as invocation_test;
|
|||
|
||||
/// Utility for manually running all tests.
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('completion', () {
|
||||
arglist_test.main();
|
||||
combinator_test.main();
|
||||
|
|
|
@ -14,9 +14,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_single_unit.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(AssistProcessorTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@ import 'package:analyzer/src/generated/source.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(ChangeTest);
|
||||
defineReflectiveTests(EditTest);
|
||||
defineReflectiveTests(FileEditTest);
|
||||
|
@ -152,13 +154,10 @@ class EditTest {
|
|||
expect(edit.offset, 1);
|
||||
expect(edit.length, 2);
|
||||
expect(edit.replacement, 'foo');
|
||||
expect(edit.toJson(), {
|
||||
'offset': 1,
|
||||
'length': 2,
|
||||
'replacement': 'foo',
|
||||
'id': 'my-id'
|
||||
});
|
||||
expect(edit.toJson(),
|
||||
{'offset': 1, 'length': 2, 'replacement': 'foo', 'id': 'my-id'});
|
||||
}
|
||||
|
||||
void test_toJson() {
|
||||
SourceEdit edit = new SourceEdit(1, 2, 'foo');
|
||||
var expectedJson = {OFFSET: 1, LENGTH: 2, REPLACEMENT: 'foo'};
|
||||
|
@ -195,7 +194,9 @@ class FileEditTest {
|
|||
SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 100);
|
||||
fileEdit.add(new SourceEdit(1, 2, 'aaa'));
|
||||
fileEdit.add(new SourceEdit(10, 20, 'bbb'));
|
||||
expect(fileEdit.toString(), '{"file":"/test.dart","fileStamp":100,"edits":['
|
||||
expect(
|
||||
fileEdit.toString(),
|
||||
'{"file":"/test.dart","fileStamp":100,"edits":['
|
||||
'{"offset":10,"length":20,"replacement":"bbb"},'
|
||||
'{"offset":1,"length":2,"replacement":"aaa"}]}');
|
||||
}
|
||||
|
@ -222,7 +223,10 @@ class LinkedEditGroupTest {
|
|||
LinkedEditGroup group = new LinkedEditGroup.empty();
|
||||
group.addPosition(new Position('/a.dart', 1), 2);
|
||||
group.addPosition(new Position('/b.dart', 10), 2);
|
||||
expect(group.toString(), '{"positions":[' '{"file":"/a.dart","offset":1},'
|
||||
expect(
|
||||
group.toString(),
|
||||
'{"positions":['
|
||||
'{"file":"/a.dart","offset":1},'
|
||||
'{"file":"/b.dart","offset":10}],"length":2,"suggestions":[]}');
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,10 @@ import 'package:unittest/unittest.dart';
|
|||
|
||||
import '../../abstract_context.dart';
|
||||
import '../../abstract_single_unit.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(FixProcessorTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@ import 'package:analysis_server/src/services/correction/levenshtein.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(LevenshteinTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_single_unit.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(VariableNameSuggestionTest);
|
||||
}
|
||||
|
||||
|
@ -57,11 +58,13 @@ main() {
|
|||
DartType expectedType = (findElement('res') as LocalVariableElement).type;
|
||||
Expression assignedExpression = findNodeAtString('0.0;');
|
||||
// first choice for "double" is "d"
|
||||
expect(getVariableNameSuggestionsForExpression(
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
expectedType, assignedExpression, new Set.from([])),
|
||||
unorderedEquals(['d']));
|
||||
// if "d" is used, try "e", "f", etc
|
||||
expect(getVariableNameSuggestionsForExpression(
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
expectedType, assignedExpression, new Set.from(['d', 'e'])),
|
||||
unorderedEquals(['f']));
|
||||
}
|
||||
|
@ -75,11 +78,13 @@ main() {
|
|||
DartType expectedType = (findElement('res') as LocalVariableElement).type;
|
||||
Expression assignedExpression = findNodeAtString('0;');
|
||||
// first choice for "int" is "i"
|
||||
expect(getVariableNameSuggestionsForExpression(
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
expectedType, assignedExpression, new Set.from([])),
|
||||
unorderedEquals(['i']));
|
||||
// if "i" is used, try "j", "k", etc
|
||||
expect(getVariableNameSuggestionsForExpression(
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
expectedType, assignedExpression, new Set.from(['i', 'j'])),
|
||||
unorderedEquals(['k']));
|
||||
}
|
||||
|
@ -93,7 +98,8 @@ main() {
|
|||
DartType expectedType = (findElement('res') as LocalVariableElement).type;
|
||||
Expression assignedExpression = findNodeAtString("'abc';");
|
||||
// first choice for "String" is "s"
|
||||
expect(getVariableNameSuggestionsForExpression(
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
expectedType, assignedExpression, new Set.from([])),
|
||||
unorderedEquals(['s']));
|
||||
}
|
||||
|
@ -109,10 +115,12 @@ main(p) {
|
|||
}
|
||||
''');
|
||||
var excluded = new Set.from([]);
|
||||
expect(getVariableNameSuggestionsForExpression(
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
null, findNodeAtString('new NoSuchClass()'), excluded),
|
||||
unorderedEquals(['noSuchClass', 'suchClass', 'class']));
|
||||
expect(getVariableNameSuggestionsForExpression(
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
null, findNodeAtString('new NoSuchClass.named()'), excluded),
|
||||
unorderedEquals(['noSuchClass', 'suchClass', 'class']));
|
||||
// TODO(scheglov) This test does not work.
|
||||
|
@ -238,9 +246,12 @@ main(p) {
|
|||
}
|
||||
''');
|
||||
var excluded = new Set.from([]);
|
||||
expect(getVariableNameSuggestionsForExpression(null,
|
||||
findNodeAtString('p.sorted', (node) => node is PrefixedIdentifier),
|
||||
excluded), unorderedEquals(['sortedNodes', 'nodes']));
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
null,
|
||||
findNodeAtString('p.sorted', (node) => node is PrefixedIdentifier),
|
||||
excluded),
|
||||
unorderedEquals(['sortedNodes', 'nodes']));
|
||||
}
|
||||
|
||||
void test_forExpression_privateName() {
|
||||
|
@ -251,12 +262,18 @@ main(p) {
|
|||
}
|
||||
''');
|
||||
var excluded = new Set.from([]);
|
||||
expect(getVariableNameSuggestionsForExpression(null,
|
||||
findNodeAtString('p._name', (node) => node is PrefixedIdentifier),
|
||||
excluded), unorderedEquals(['name']));
|
||||
expect(getVariableNameSuggestionsForExpression(null,
|
||||
findNodeAtString('p._compute', (node) => node is MethodInvocation),
|
||||
excluded), unorderedEquals(['computeSuffix', 'suffix']));
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
null,
|
||||
findNodeAtString('p._name', (node) => node is PrefixedIdentifier),
|
||||
excluded),
|
||||
unorderedEquals(['name']));
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
null,
|
||||
findNodeAtString('p._compute', (node) => node is MethodInvocation),
|
||||
excluded),
|
||||
unorderedEquals(['computeSuffix', 'suffix']));
|
||||
}
|
||||
|
||||
void test_forExpression_propertyAccess() {
|
||||
|
@ -293,8 +310,12 @@ main(p) {
|
|||
}
|
||||
''');
|
||||
var excluded = new Set.from([]);
|
||||
expect(getVariableNameSuggestionsForExpression(null, findNodeAtString(
|
||||
'getSortedNodes();', (node) => node is MethodInvocation), excluded),
|
||||
expect(
|
||||
getVariableNameSuggestionsForExpression(
|
||||
null,
|
||||
findNodeAtString(
|
||||
'getSortedNodes();', (node) => node is MethodInvocation),
|
||||
excluded),
|
||||
unorderedEquals(['sortedNodes', 'nodes']));
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_single_unit.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(OrganizeDirectivesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_single_unit.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(SortMembersTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_single_unit.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(SourceRangesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_single_unit.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(RefactoringLocationTest);
|
||||
defineReflectiveTests(RefactoringStatusTest);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@ import 'package:analysis_server/src/services/correction/strings.dart';
|
|||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
import 'package:unittest/unittest.dart' hide isEmpty;
|
||||
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(StringsTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ library test.services.correction;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'assist_test.dart' as assist_test;
|
||||
import 'change_test.dart' as change_test;
|
||||
import 'fix_test.dart' as fix_test;
|
||||
|
@ -19,7 +20,7 @@ import 'strings_test.dart' as strings_test;
|
|||
|
||||
/// Utility for manually running all tests.
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('correction', () {
|
||||
assist_test.main();
|
||||
change_test.main();
|
||||
|
|
|
@ -9,9 +9,10 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../abstract_context.dart';
|
||||
import '../../utils.dart';
|
||||
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
defineReflectiveTests(LibraryDependenciesTest);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@ library test.services.dependencies;
|
|||
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
import 'library_dependencies_test.dart' as library_dependencies_test;
|
||||
|
||||
/// Utility for manually running all tests.
|
||||
main() {
|
||||
groupSep = ' | ';
|
||||
initializeTestEnvironment();
|
||||
group('dependencies', () {
|
||||
library_dependencies_test.main();
|
||||
});
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue