Migration: remove references from analysis_server to nnbd_migration.
Change-Id: I90b562b8b3e82b770f197d7ef2c4e10ac9f99100 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148160 Reviewed-by: Janice Collins <jcollins@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
2d57c1f86e
commit
c38742cdbc
@@ -7,6 +7,7 @@ import 'dart:core';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:analysis_server/src/analysis_server.dart';
|
||||
import 'package:analysis_server/src/api_for_nnbd_migration.dart';
|
||||
import 'package:analysis_server/src/collections.dart';
|
||||
import 'package:analysis_server/src/context_manager.dart';
|
||||
import 'package:analysis_server/src/domains/completion/available_suggestions.dart';
|
||||
@@ -47,7 +48,6 @@ import 'package:analyzer/src/generated/engine.dart';
|
||||
import 'package:analyzer/src/generated/sdk.dart';
|
||||
import 'package:analyzer/src/services/available_declarations.dart';
|
||||
import 'package:analyzer/src/util/glob.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/driver_provider.dart';
|
||||
|
||||
/// Implementations of [AbstractAnalysisServer] implement a server that listens
|
||||
/// on a [CommunicationChannel] for analysis messages and process them.
|
||||
|
||||
+22
-1
@@ -2,10 +2,17 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/dart/analysis/session.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/driver_provider.dart';
|
||||
|
||||
/// Abstract interface formerly used by NNBD migration to report changes to the
|
||||
/// analysis server. Now that the analysis server no longer integrates with
|
||||
/// NNBD migration, this exists only to support some tests that haven't yet been
|
||||
/// modified to use the new NNBD migration infrastructure.
|
||||
///
|
||||
/// TODO(paulberry): remove this interface once it's no longer needed.
|
||||
abstract class DartFixListenerInterface {
|
||||
DriverProvider get server;
|
||||
|
||||
@@ -34,3 +41,17 @@ abstract class DartFixListenerInterface {
|
||||
/// [addEditWithoutRecommendation].
|
||||
void addSuggestion(String description, Location location);
|
||||
}
|
||||
|
||||
/// Abstract interface formerly used by NNBD migration to access the resource
|
||||
/// provider and the analysis session. Now that the analysis server no longer
|
||||
/// integrates with NNBD migration, this exists only to support some tests that
|
||||
/// haven't yet been modified to use the new NNBD migration infrastructure.
|
||||
///
|
||||
/// TODO(paulberry): remove this interface once it's no longer needed.
|
||||
abstract class DriverProvider {
|
||||
ResourceProvider get resourceProvider;
|
||||
|
||||
/// Return the appropriate analysis session for the file with the given
|
||||
/// [path].
|
||||
AnalysisSession getAnalysisSession(String path);
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import 'package:analysis_server/src/edit/fix/fix_lint_task.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/analysis/session.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/dart/analysis/driver.dart';
|
||||
import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
|
||||
import 'package:analyzer/src/generated/source.dart' show SourceKind;
|
||||
|
||||
@@ -122,9 +121,6 @@ class EditDartFix
|
||||
};
|
||||
});
|
||||
|
||||
// Set up the rerun function on the NNBD migration for interactivity.
|
||||
nonNullableFixTask?.rerunFunction = rerunTasks;
|
||||
|
||||
bool hasErrors;
|
||||
try {
|
||||
hasErrors = await runAllTasks();
|
||||
@@ -148,7 +144,6 @@ class EditDartFix
|
||||
hasErrors,
|
||||
listener.sourceChange.edits,
|
||||
details: listener.details,
|
||||
urls: nonNullableFixTask?.previewUrls,
|
||||
).toResponse(request.id);
|
||||
}
|
||||
|
||||
@@ -250,26 +245,6 @@ class EditDartFix
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> rerunTasks([List<String> changedPaths]) async {
|
||||
listener.reset();
|
||||
if (changedPaths == null) {
|
||||
final drivers = <AnalysisDriver>{};
|
||||
for (var path in getPathsToProcess()) {
|
||||
drivers.add(server.getAnalysisDriver(path));
|
||||
}
|
||||
for (final driver in drivers) {
|
||||
driver.knownFiles.forEach(driver.changeFile);
|
||||
}
|
||||
} else {
|
||||
for (var path in changedPaths) {
|
||||
var driver = server.getAnalysisDriver(path);
|
||||
driver.changeFile(path);
|
||||
}
|
||||
}
|
||||
|
||||
return await runAllTasks();
|
||||
}
|
||||
|
||||
Future<bool> runAllTasks() async {
|
||||
// Process each package
|
||||
for (var pkgFolder in pkgFolders) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:analysis_server/src/edit/fix/dartfix_listener.dart';
|
||||
import 'package:analysis_server/src/edit/fix/dartfix_registrar.dart';
|
||||
import 'package:analysis_server/src/edit/fix/fix_error_task.dart';
|
||||
import 'package:analysis_server/src/edit/fix/fix_lint_task.dart';
|
||||
import 'package:analysis_server/src/edit/fix/non_nullable_fix.dart';
|
||||
import 'package:analysis_server/src/edit/fix/prefer_mixin_fix.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/src/lint/registry.dart';
|
||||
@@ -96,17 +95,6 @@ final allFixes = <DartFixInfo>[
|
||||
LintFixInfo.unnecessaryThis,
|
||||
LintFixInfo.useFunctionTypeSyntaxForParameters,
|
||||
LintFixInfo.useRethrowWhenPossible,
|
||||
//
|
||||
// Experimental fixes
|
||||
//
|
||||
DartFixInfo(
|
||||
'non-nullable',
|
||||
'''
|
||||
EXPERIMENTAL: Update sources to be non-nullable by default.
|
||||
This requires the experimental non-nullable flag to be enabled
|
||||
when running the updated application.''',
|
||||
NonNullableFix.task,
|
||||
),
|
||||
];
|
||||
|
||||
/// [DartFixInfo] represents a fix that can be applied by [EditDartFix].
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/analysis_server.dart';
|
||||
import 'package:analysis_server/src/api_for_nnbd_migration.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart'
|
||||
show Location, SourceChange, SourceEdit, SourceFileEdit;
|
||||
import 'package:nnbd_migration/api_for_analysis_server/dartfix_listener_interface.dart';
|
||||
|
||||
/// Tasks use this API to report results.
|
||||
class DartFixListener implements DartFixListenerInterface {
|
||||
@@ -100,15 +100,4 @@ class DartFixListener implements DartFixListenerInterface {
|
||||
result.path, offset, length, locInfo.lineNumber, locInfo.columnNumber);
|
||||
return location;
|
||||
}
|
||||
|
||||
/// Reset this listener so that it can accrue a new set of changes.
|
||||
void reset() {
|
||||
suggestions.clear();
|
||||
otherSuggestions.clear();
|
||||
sourceChange
|
||||
..edits.clear()
|
||||
..linkedEditGroups.clear()
|
||||
..selection = null
|
||||
..id = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import 'dart:math' show max;
|
||||
|
||||
import 'package:analysis_server/src/edit/edit_dartfix.dart';
|
||||
import 'package:analysis_server/src/edit/fix/non_nullable_fix.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
|
||||
@@ -15,16 +14,6 @@ mixin FixCodeProcessor {
|
||||
|
||||
int _numPhases = 0;
|
||||
|
||||
/// Return the task used to migrate to NNBD.
|
||||
NonNullableFix get nonNullableFixTask {
|
||||
for (var task in _codeTasks) {
|
||||
if (task is NonNullableFix) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int get numPhases => _numPhases;
|
||||
|
||||
Future<void> finishCodeTasks() async {
|
||||
|
||||
@@ -16,7 +16,6 @@ dependencies:
|
||||
linter: any
|
||||
logging: any
|
||||
meta: any
|
||||
nnbd_migration: any
|
||||
pub_semver: any
|
||||
source_span: any
|
||||
stream_channel: any
|
||||
|
||||
@@ -68,7 +68,6 @@ class EditDartfixDomainHandlerTest extends AbstractAnalysisTest {
|
||||
|
||||
var fix = EditDartFix(server, request);
|
||||
final response = await fix.compute();
|
||||
fix.nonNullableFixTask?.shutdownServer();
|
||||
expect(response.id, id);
|
||||
return response;
|
||||
}
|
||||
@@ -161,91 +160,6 @@ const double myDouble = 42.0;
|
||||
expect(result.error, isNotNull);
|
||||
}
|
||||
|
||||
Future<void> test_nonNullable() async {
|
||||
createAnalysisOptionsFile(experiments: ['non-nullable']);
|
||||
addTestFile('''
|
||||
int f(int i) => 0;
|
||||
int g(int i) => f(i);
|
||||
void test() {
|
||||
g(null);
|
||||
}
|
||||
''');
|
||||
createProject();
|
||||
expectLater(() async => await performFix(includedFixes: ['non-nullable']),
|
||||
throwsA(TypeMatcher<StateError>()));
|
||||
}
|
||||
|
||||
Future<void> test_nonNullable_pubspec_environmentAdded() async {
|
||||
var originalContent = '''
|
||||
name: foo
|
||||
''';
|
||||
newFile('/project/pubspec.yaml', content: originalContent);
|
||||
createProject();
|
||||
var result = await performFix(includedFixes: ['non-nullable']);
|
||||
expect(result.suggestions.length, greaterThanOrEqualTo(1));
|
||||
expect(result.hasErrors, isFalse);
|
||||
expect(result.edits, hasLength(1));
|
||||
expectFileEdits(originalContent, result.edits[0], '''
|
||||
environment:
|
||||
sdk: '>=2.9.0 <2.10.0'
|
||||
|
||||
name: foo
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_nonNullable_pubspec_sdkAdded() async {
|
||||
var originalContent = '''
|
||||
name: foo
|
||||
environment:
|
||||
x: y
|
||||
''';
|
||||
newFile('/project/pubspec.yaml', content: originalContent);
|
||||
createProject();
|
||||
var result = await performFix(includedFixes: ['non-nullable']);
|
||||
expect(result.suggestions.length, greaterThanOrEqualTo(1));
|
||||
expect(result.hasErrors, isFalse);
|
||||
expect(result.edits, hasLength(1));
|
||||
expectFileEdits(originalContent, result.edits[0], '''
|
||||
name: foo
|
||||
environment:
|
||||
x: y
|
||||
sdk: '>=2.9.0 <2.10.0'
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_nonNullable_pubspec_sdkNotUpdated() async {
|
||||
var originalContent = '''
|
||||
name: foo
|
||||
environment:
|
||||
sdk: '>=2.9.0 <2.10.0'
|
||||
''';
|
||||
newFile('/project/pubspec.yaml', content: originalContent);
|
||||
createProject();
|
||||
var result = await performFix(includedFixes: ['non-nullable']);
|
||||
expect(result.suggestions, isEmpty);
|
||||
expect(result.hasErrors, isFalse);
|
||||
expect(result.edits, isEmpty);
|
||||
}
|
||||
|
||||
Future<void> test_nonNullable_pubspec_sdkUpdated() async {
|
||||
var originalContent = '''
|
||||
name: foo
|
||||
environment:
|
||||
sdk: '>=2.7.0 <3.0.0'
|
||||
''';
|
||||
newFile('/project/pubspec.yaml', content: originalContent);
|
||||
createProject();
|
||||
var result = await performFix(includedFixes: ['non-nullable']);
|
||||
expect(result.suggestions.length, greaterThanOrEqualTo(1));
|
||||
expect(result.hasErrors, isFalse);
|
||||
expect(result.edits, hasLength(1));
|
||||
expectFileEdits(originalContent, result.edits[0], '''
|
||||
name: foo
|
||||
environment:
|
||||
sdk: '>=2.9.0 <2.10.0'
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_partFile() async {
|
||||
newFile('/project/lib/lib.dart', content: '''
|
||||
library lib2;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/src/edit/fix/dartfix_listener.dart';
|
||||
import 'package:analysis_server/src/protocol_server.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(DartFixListenerTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class DartFixListenerTest {
|
||||
DartFixListener listener;
|
||||
|
||||
void setUp() {
|
||||
listener = DartFixListener(null);
|
||||
}
|
||||
|
||||
void test_clear_clears_edits() {
|
||||
listener.addSourceChange(
|
||||
'Example',
|
||||
null,
|
||||
SourceChange('foo')
|
||||
..edits = [
|
||||
SourceFileEdit('foo', 2, edits: [SourceEdit(0, 0, 'foo')])
|
||||
]);
|
||||
expect(listener.sourceChange.edits, hasLength(1));
|
||||
listener.reset();
|
||||
expect(listener.sourceChange.edits, isEmpty);
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/edit/edit_dartfix.dart';
|
||||
import 'package:analysis_server/src/edit/fix/dartfix_listener.dart';
|
||||
import 'package:analysis_server/src/edit/fix/non_nullable_fix.dart';
|
||||
import 'package:analyzer/file_system/memory_file_system.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../../../analysis_abstract.dart';
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(NonNullableFixTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class NonNullableFixTest extends AbstractAnalysisTest {
|
||||
int requestId = 30;
|
||||
|
||||
path.Context context;
|
||||
|
||||
DartFixListener listener;
|
||||
|
||||
String get nextRequestId => (++requestId).toString();
|
||||
|
||||
Future<EditDartfixResult> performFix({List<String> included}) async {
|
||||
final id = nextRequestId;
|
||||
final params = EditDartfixParams(included);
|
||||
params.includedFixes = ['non-nullable'];
|
||||
var request = Request(id, 'edit.dartfix', params.toJson());
|
||||
var response = await EditDartFix(server, request).compute();
|
||||
expect(response.id, id);
|
||||
expect(response.error, isNull);
|
||||
return EditDartfixResult.fromResponse(response);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setUp() async {
|
||||
context = path.style == path.Style.windows
|
||||
// On Windows, ensure that the current drive matches
|
||||
// the drive inserted by MemoryResourceProvider.convertPath
|
||||
// so that packages are mapped to the correct drive
|
||||
? path.Context(current: 'C:\\project')
|
||||
: path.Context(current: '/project');
|
||||
resourceProvider = MemoryResourceProvider(context: context);
|
||||
super.setUp();
|
||||
newFile('/project/bin/bin.dart', content: 'var x = 1;');
|
||||
newFile('/project/lib/lib1.dart', content: 'var x = 1;');
|
||||
newFile('/project/lib/lib2.dart', content: 'var x = 1;');
|
||||
newFile('/project/lib/src/lib3.dart', content: 'var x = 1;');
|
||||
newFile('/project/test/test.dart', content: 'var x = 1;');
|
||||
newFile('/project2/bin/bin.dart', content: 'var x = 1;');
|
||||
newFile('/project2/lib/lib1.dart', content: 'var x = 1;');
|
||||
newFile('/project2/lib/lib2.dart', content: 'var x = 1;');
|
||||
newFile('/project2/lib/src/lib3.dart', content: 'var x = 1;');
|
||||
newFile('/project2/test/test.dart', content: 'var x = 1;');
|
||||
// Compute the analysis results.
|
||||
server.setAnalysisRoots(
|
||||
'0', [resourceProvider.pathContext.dirname(testFile)], [], {});
|
||||
await server
|
||||
.getAnalysisDriver(testFile)
|
||||
.currentSession
|
||||
.getResolvedUnit(testFile);
|
||||
listener = DartFixListener(server);
|
||||
}
|
||||
|
||||
Future<void> test_included_multipleRelativeDirectories() async {
|
||||
var fix =
|
||||
NonNullableFix(listener, resourceProvider, included: ['lib', 'test']);
|
||||
expect(fix.includedRoot, equals(convertPath('/project')));
|
||||
}
|
||||
|
||||
Future<void> test_included_multipleRelativeDirectories_nonCanonical() async {
|
||||
var fix = NonNullableFix(listener, resourceProvider, included: [
|
||||
convertPath('../project2/lib'),
|
||||
convertPath('../project2/lib/src')
|
||||
]);
|
||||
expect(fix.includedRoot, equals(convertPath('/project2/lib')));
|
||||
}
|
||||
|
||||
Future<void>
|
||||
test_included_multipleRelativeDirectories_nonCanonical_atRoot() async {
|
||||
var fix = NonNullableFix(listener, resourceProvider, included: [
|
||||
convertPath('../project2/lib'),
|
||||
convertPath('../project/lib')
|
||||
]);
|
||||
expect(fix.includedRoot, equals(convertPath('/')));
|
||||
}
|
||||
|
||||
Future<void>
|
||||
test_included_multipleRelativeDirectories_subAndSuperDirectories() async {
|
||||
var fix =
|
||||
NonNullableFix(listener, resourceProvider, included: ['lib', '.']);
|
||||
expect(fix.includedRoot, equals(convertPath('/project')));
|
||||
}
|
||||
|
||||
Future<void> test_included_multipleRelativeFiles() async {
|
||||
var fix = NonNullableFix(listener, resourceProvider, included: [
|
||||
convertPath('lib/lib1.dart'),
|
||||
convertPath('test/test.dart')
|
||||
]);
|
||||
expect(fix.includedRoot, equals(convertPath('/project')));
|
||||
}
|
||||
|
||||
Future<void> test_included_multipleRelativeFiles_sameDirectory() async {
|
||||
var fix = NonNullableFix(listener, resourceProvider,
|
||||
included: [convertPath('lib/lib1.dart'), convertPath('lib/lib2.dart')]);
|
||||
expect(fix.includedRoot, equals(convertPath('/project/lib')));
|
||||
}
|
||||
|
||||
Future<void> test_included_multipleRelativeFilesAndDirectories() async {
|
||||
var fix = NonNullableFix(listener, resourceProvider, included: [
|
||||
convertPath('lib/lib1.dart'),
|
||||
convertPath('lib/src'),
|
||||
convertPath('../project/lib/src/lib3.dart')
|
||||
]);
|
||||
expect(fix.includedRoot, equals(convertPath('/project/lib')));
|
||||
}
|
||||
|
||||
Future<void> test_included_singleAbsoluteDirectory() async {
|
||||
var fix = NonNullableFix(listener, resourceProvider,
|
||||
included: [convertPath('/project')]);
|
||||
expect(fix.includedRoot, equals(convertPath('/project')));
|
||||
}
|
||||
|
||||
Future<void> test_included_singleAbsoluteFile() async {
|
||||
var fix = NonNullableFix(listener, resourceProvider,
|
||||
included: [convertPath('/project/bin/bin.dart')]);
|
||||
expect(fix.includedRoot, equals(convertPath('/project/bin')));
|
||||
}
|
||||
|
||||
Future<void> test_included_singleRelativeDirectory() async {
|
||||
var fix = NonNullableFix(listener, resourceProvider, included: ['.']);
|
||||
expect(fix.includedRoot, equals(convertPath('/project')));
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'dartfix_listener_test.dart' as dartfix_listener;
|
||||
import 'non_nullable_fix_test.dart' as non_nullable_fix;
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
dartfix_listener.main();
|
||||
non_nullable_fix.main();
|
||||
}, name: 'fix');
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'fix/test_all.dart' as fix;
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
fix.main();
|
||||
}, name: 'edit');
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import 'cider/test_all.dart' as cider;
|
||||
import 'computer/test_all.dart' as computer;
|
||||
import 'domain_abstract_test.dart' as domain_abstract;
|
||||
import 'domains/test_all.dart' as domains;
|
||||
import 'edit/test_all.dart' as edit;
|
||||
import 'flutter/test_all.dart' as flutter;
|
||||
import 'lsp/test_all.dart' as lsp;
|
||||
import 'plugin/test_all.dart' as plugin;
|
||||
@@ -22,7 +21,6 @@ void main() {
|
||||
computer.main();
|
||||
domain_abstract.main();
|
||||
domains.main();
|
||||
edit.main();
|
||||
flutter.main();
|
||||
lsp.main();
|
||||
plugin.main();
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/dart/analysis/session.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
|
||||
abstract class DriverProvider {
|
||||
ResourceProvider get resourceProvider;
|
||||
|
||||
/// Return the appropriate analysis session for the file with the given
|
||||
/// [path].
|
||||
AnalysisSession getAnalysisSession(String path);
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io' hide File;
|
||||
|
||||
import 'package:analysis_server/src/api_for_nnbd_migration.dart';
|
||||
import 'package:analysis_server/src/edit/fix/fix_code_task.dart';
|
||||
import 'package:analysis_server/src/edit/fix/non_nullable_fix.dart';
|
||||
import 'package:analyzer/dart/analysis/analysis_context.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/analysis/session.dart';
|
||||
@@ -26,9 +26,8 @@ import 'package:args/args.dart';
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:cli_util/cli_logging.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/dartfix_listener_interface.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/driver_provider.dart';
|
||||
import 'package:nnbd_migration/src/edit_plan.dart';
|
||||
import 'package:nnbd_migration/src/front_end/non_nullable_fix.dart';
|
||||
import 'package:nnbd_migration/src/utilities/source_edit_diff_formatter.dart';
|
||||
import 'package:path/path.dart' show Context;
|
||||
|
||||
@@ -274,6 +273,7 @@ class MigrationCli {
|
||||
summaryPath: options.summary);
|
||||
nonNullableFix.rerunFunction = _rerunFunction;
|
||||
_fixCodeProcessor.registerCodeTask(nonNullableFix);
|
||||
_fixCodeProcessor.nonNullableFixTask = nonNullableFix;
|
||||
|
||||
try {
|
||||
await _fixCodeProcessor.runFirstPhase();
|
||||
@@ -660,6 +660,9 @@ class _FixCodeProcessor extends Object with FixCodeProcessor {
|
||||
|
||||
final MigrationCli _migrationCli;
|
||||
|
||||
/// The task used to migrate to NNBD.
|
||||
NonNullableFix nonNullableFixTask;
|
||||
|
||||
_FixCodeProcessor(this.context, this._migrationCli)
|
||||
: pathsToProcess = _computePathsToProcess(context);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:analysis_server/src/api_for_nnbd_migration.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
@@ -13,8 +14,6 @@ import 'package:analyzer_plugin/protocol/protocol_common.dart' as protocol;
|
||||
import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart';
|
||||
import 'package:analyzer_plugin/utilities/navigation/navigation_dart.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/dartfix_listener_interface.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/driver_provider.dart';
|
||||
import 'package:nnbd_migration/fix_reason_target.dart';
|
||||
import 'package:nnbd_migration/instrumentation.dart';
|
||||
import 'package:nnbd_migration/nnbd_migration.dart';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:nnbd_migration/api_for_analysis_server/dartfix_listener_interface.dart';
|
||||
import 'package:analysis_server/src/api_for_nnbd_migration.dart';
|
||||
import 'package:nnbd_migration/nnbd_migration.dart';
|
||||
import 'package:nnbd_migration/instrumentation.dart';
|
||||
import 'package:nnbd_migration/src/front_end/info_builder.dart';
|
||||
|
||||
+3
-3
@@ -3,6 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/api_for_nnbd_migration.dart';
|
||||
import 'package:analysis_server/src/edit/fix/dartfix_listener.dart';
|
||||
import 'package:analysis_server/src/edit/fix/dartfix_registrar.dart';
|
||||
import 'package:analysis_server/src/edit/fix/fix_code_task.dart';
|
||||
@@ -13,7 +14,6 @@ import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:charcode/charcode.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/dartfix_listener_interface.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/http_preview_server.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/instrumentation_listener.dart';
|
||||
import 'package:nnbd_migration/api_for_analysis_server/migration_state.dart';
|
||||
@@ -147,7 +147,7 @@ class NonNullableFix extends FixCodeTask {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
pubspecMap = loadYaml(pubspecContent);
|
||||
pubspecMap = loadYaml(pubspecContent) as YamlNode;
|
||||
} on YamlException catch (e) {
|
||||
processYamlException('parse', pubspecFile.path, e);
|
||||
return;
|
||||
@@ -207,7 +207,7 @@ environment:
|
||||
sdk: '$_intendedSdkVersionConstraint'""";
|
||||
insertAfterParent(environmentOptions.span, content);
|
||||
} else if (sdk is YamlScalar) {
|
||||
var currentConstraint = VersionConstraint.parse(sdk.value);
|
||||
var currentConstraint = VersionConstraint.parse(sdk.value as String);
|
||||
var minimumVersion = Version.parse(_intendedMinimumSdkVersion);
|
||||
if (currentConstraint is VersionRange &&
|
||||
currentConstraint.min >= minimumVersion) {
|
||||
@@ -3,7 +3,6 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/src/edit/fix/dartfix_listener.dart';
|
||||
import 'package:analysis_server/src/edit/fix/non_nullable_fix.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/source/line_info.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
@@ -12,6 +11,7 @@ import 'package:nnbd_migration/instrumentation.dart';
|
||||
import 'package:nnbd_migration/src/front_end/info_builder.dart';
|
||||
import 'package:nnbd_migration/src/front_end/instrumentation_listener.dart';
|
||||
import 'package:nnbd_migration/src/front_end/migration_info.dart';
|
||||
import 'package:nnbd_migration/src/front_end/non_nullable_fix.dart';
|
||||
import 'package:nnbd_migration/src/front_end/offset_mapper.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -157,7 +157,8 @@ class NnbdMigrationTestBase extends AbstractAnalysisTest {
|
||||
removeViaComments: removeViaComments, warnOnWeakCode: warnOnWeakCode);
|
||||
// Ignore info for dart:core.
|
||||
var filteredInfos = [
|
||||
for (var info in infos) if (!info.path.contains('core.dart')) info
|
||||
for (var info in infos)
|
||||
if (!info.path.contains('core.dart')) info
|
||||
];
|
||||
expect(filteredInfos, hasLength(1));
|
||||
var unit = filteredInfos[0];
|
||||
@@ -180,7 +181,8 @@ class NnbdMigrationTestBase extends AbstractAnalysisTest {
|
||||
await _buildMigrationInfo(testPaths, includedRoot: includedRoot);
|
||||
// Ignore info for dart:core.
|
||||
var filteredInfos = [
|
||||
for (var info in infos) if (!info.path.contains('core.dart')) info
|
||||
for (var info in infos)
|
||||
if (!info.path.contains('core.dart')) info
|
||||
];
|
||||
return filteredInfos;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analysis_server/src/edit/fix/non_nullable_fix.dart';
|
||||
import 'package:analyzer/file_system/memory_file_system.dart';
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/src/test_utilities/mock_sdk.dart' as mock_sdk;
|
||||
@@ -15,6 +14,7 @@ import 'package:cli_util/cli_logging.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:nnbd_migration/migration_cli.dart';
|
||||
import 'package:nnbd_migration/src/front_end/non_nullable_fix.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
Reference in New Issue
Block a user