Version 2.13.0-199.0.dev
Merge commit '34873853d879babc49565fb5505d32a265f19397' into 'dev'
diff --git a/pkg/analysis_server/lib/plugin/analysis/occurrences/occurrences_core.dart b/pkg/analysis_server/lib/plugin/analysis/occurrences/occurrences_core.dart
index afc2f1a..7483aa4 100644
--- a/pkg/analysis_server/lib/plugin/analysis/occurrences/occurrences_core.dart
+++ b/pkg/analysis_server/lib/plugin/analysis/occurrences/occurrences_core.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analyzer_plugin/protocol/protocol_common.dart' show Occurrences;
/// An object used to record occurrences into.
diff --git a/pkg/analysis_server/lib/plugin/edit/assist/assist_core.dart b/pkg/analysis_server/lib/plugin/edit/assist/assist_core.dart
index 113cbcf..c4469ea 100644
--- a/pkg/analysis_server/lib/plugin/edit/assist/assist_core.dart
+++ b/pkg/analysis_server/lib/plugin/edit/assist/assist_core.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analyzer_plugin/protocol/protocol_common.dart'
show SourceChange;
import 'package:analyzer_plugin/utilities/assist/assist.dart';
diff --git a/pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart b/pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart
index b8a9946..3154306 100644
--- a/pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart
+++ b/pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/instrumentation/service.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_workspace.dart';
diff --git a/pkg/analysis_server/lib/plugin/edit/fix/fix_core.dart b/pkg/analysis_server/lib/plugin/edit/fix/fix_core.dart
index db3b1b8..f3873dc 100644
--- a/pkg/analysis_server/lib/plugin/edit/fix/fix_core.dart
+++ b/pkg/analysis_server/lib/plugin/edit/fix/fix_core.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analyzer/error/error.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart'
show SourceChange;
diff --git a/pkg/analysis_server/lib/src/plugin/plugin_locator.dart b/pkg/analysis_server/lib/src/plugin/plugin_locator.dart
index 58f8aa2..4453aea 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_locator.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_locator.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analyzer/file_system/file_system.dart';
/// An object used to locate a plugin within a package.
@@ -26,7 +24,7 @@
/// The resource provider used to access the file system.
final ResourceProvider resourceProvider;
- final Map<String, String> pluginMap = <String, String>{};
+ final Map<String, String?> pluginMap = {};
/// Initialize a newly created plugin locator to use the given
/// [resourceProvider] to access the file system.
@@ -48,12 +46,12 @@
///
/// This method does not validate the content of the plugin directory before
/// returning it.
- String findPlugin(String packageRoot) {
+ String? findPlugin(String packageRoot) {
return pluginMap.putIfAbsent(packageRoot, () => _findPlugin(packageRoot));
}
/// The implementation of [findPlugin].
- String _findPlugin(String packageRoot) {
+ String? _findPlugin(String packageRoot) {
var packageFolder = resourceProvider.getFolder(packageRoot);
// TODO(brianwilkerson) Re-enable this after deciding how we want to deal
// with discovery of plugins.
diff --git a/pkg/analysis_server/lib/src/plugin/request_converter.dart b/pkg/analysis_server/lib/src/plugin/request_converter.dart
index 0909ca1..559d7ee 100644
--- a/pkg/analysis_server/lib/src/plugin/request_converter.dart
+++ b/pkg/analysis_server/lib/src/plugin/request_converter.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/protocol/protocol_generated.dart' as server;
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
@@ -24,10 +22,10 @@
server.AnalysisSetSubscriptionsParams params) {
var serverSubscriptions = params.subscriptions;
var pluginSubscriptions = <plugin.AnalysisService, List<String>>{};
- for (var service in serverSubscriptions.keys) {
+ for (var entry in serverSubscriptions.entries) {
+ var service = entry.key;
try {
- pluginSubscriptions[convertAnalysisService(service)] =
- serverSubscriptions[service];
+ pluginSubscriptions[convertAnalysisService(service)] = entry.value;
} catch (exception) {
// Ignore the exception. It indicates that the service isn't one that
// should be passed along to plugins.
diff --git a/pkg/analysis_server/lib/src/plugin/result_collector.dart b/pkg/analysis_server/lib/src/plugin/result_collector.dart
index a016ed1..7d695f3 100644
--- a/pkg/analysis_server/lib/src/plugin/result_collector.dart
+++ b/pkg/analysis_server/lib/src/plugin/result_collector.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
/// A function used to determine whether results should be collected for the
/// file with the given [path].
typedef ShouldCollectPredicate = bool Function(String path);
@@ -16,7 +14,7 @@
/// A function used to determine whether results should be collected for the
/// file whose path is passed in as an argument.
- final ShouldCollectPredicate _shouldCollect;
+ final ShouldCollectPredicate? _shouldCollect;
/// A multi-keyed map, where the first key is the (normalized and absolute)
/// path to the file associated with the results, and the second is the id of
@@ -25,7 +23,7 @@
final Map<String, Map<String, E>> resultMap = <String, Map<String, E>>{};
/// Initialize a newly created result manager.
- ResultCollector(this.serverId, {ShouldCollectPredicate predicate})
+ ResultCollector(this.serverId, {ShouldCollectPredicate? predicate})
: _shouldCollect = predicate;
/// Clear any results that have been contributed for the file with the given
@@ -65,8 +63,9 @@
/// Return `true` if this collector is collecting results associated with the
/// given [filePath].
bool isCollectingFor(String filePath) {
- if (_shouldCollect != null) {
- return _shouldCollect(filePath);
+ var predicate = _shouldCollect;
+ if (predicate != null) {
+ return predicate(filePath);
}
return resultMap.containsKey(filePath);
}
@@ -76,7 +75,8 @@
void putResults(String filePath, String pluginId, E partialResults) {
var fileResults = resultMap[filePath];
if (fileResults == null) {
- if (_shouldCollect != null && _shouldCollect(filePath)) {
+ var predicate = _shouldCollect;
+ if (predicate != null && predicate(filePath)) {
resultMap[filePath] = <String, E>{pluginId: partialResults};
}
} else {
diff --git a/pkg/analysis_server/lib/src/plugin/result_converter.dart b/pkg/analysis_server/lib/src/plugin/result_converter.dart
index a4cd788..3a0983b 100644
--- a/pkg/analysis_server/lib/src/plugin/result_converter.dart
+++ b/pkg/analysis_server/lib/src/plugin/result_converter.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/protocol/protocol_generated.dart' as server;
import 'package:analysis_server/src/protocol/protocol_internal.dart' as server;
import 'package:analyzer_plugin/protocol/protocol_common.dart';
diff --git a/pkg/analysis_server/lib/src/plugin/result_merger.dart b/pkg/analysis_server/lib/src/plugin/result_merger.dart
index 5194674..be59bb0 100644
--- a/pkg/analysis_server/lib/src/plugin/result_merger.dart
+++ b/pkg/analysis_server/lib/src/plugin/result_merger.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'dart:collection';
import 'package:analysis_server/protocol/protocol_generated.dart';
@@ -209,7 +207,7 @@
/// the plugins. If a plugin contributes a navigation region that overlaps a
/// region from a previous plugin, the overlapping region will be omitted.
/// (For these purposes, nested regions are considered to be overlapping.)
- AnalysisNavigationParams mergeNavigation(
+ AnalysisNavigationParams? mergeNavigation(
List<AnalysisNavigationParams> partialResultList) {
var count = partialResultList.length;
if (count == 0) {
@@ -284,7 +282,7 @@
for (var j = 0; j < targets.length; j++) {
var target = targets[j];
var newIndex = fileMap[target.fileIndex];
- if (target.fileIndex != newIndex) {
+ if (newIndex != null && target.fileIndex != newIndex) {
target = NavigationTarget(target.kind, newIndex, target.offset,
target.length, target.startLine, target.startColumn,
codeOffset: target.codeOffset, codeLength: target.codeLength);
@@ -303,7 +301,8 @@
var region = regions[j];
var newTargets = region.targets
.map((int oldTarget) => targetMap[oldTarget])
- .toList();
+ .toList()
+ .cast<int>();
if (region.targets != newTargets) {
region = NavigationRegion(region.offset, region.length, newTargets);
}
@@ -429,23 +428,27 @@
/// Merge the children of the [newOutline] into the list of children of the
/// [mergedOutline].
void mergeChildren(Outline mergedOutline, Outline newOutline) {
- for (var newChild in newOutline.children) {
- var mergedChild = outlineMap[computeKey(newChild.element)];
- if (mergedChild == null) {
- // The [newChild] isn't in the existing list.
- var copiedOutline = copyMap.putIfAbsent(
- mergedOutline,
- () => Outline(
- mergedOutline.element,
- mergedOutline.offset,
- mergedOutline.length,
- mergedOutline.codeOffset,
- mergedOutline.codeLength,
- children: mergedOutline.children.toList()));
- copiedOutline.children.add(newChild);
- addToMap(newChild);
- } else {
- mergeChildren(mergedChild, newChild);
+ var newChildren = newOutline.children;
+ if (newChildren != null) {
+ for (var newChild in newChildren) {
+ var mergedChild = outlineMap[computeKey(newChild.element)];
+ if (mergedChild == null) {
+ // The [newChild] isn't in the existing list.
+ var mergedChildren = _copyList(mergedOutline.children);
+ mergedChildren.add(newChild);
+ copyMap.putIfAbsent(
+ mergedOutline,
+ () => Outline(
+ mergedOutline.element,
+ mergedOutline.offset,
+ mergedOutline.length,
+ mergedOutline.codeOffset,
+ mergedOutline.codeLength,
+ children: mergedChildren));
+ addToMap(newChild);
+ } else {
+ mergeChildren(mergedChild, newChild);
+ }
}
}
}
@@ -533,7 +536,7 @@
///
/// The feedbacks in the [partialResultList] are expected to all be of the
/// same type. If that expectation is violated, and exception might be thrown.
- RefactoringFeedback mergeRefactoringFeedbacks(
+ RefactoringFeedback? mergeRefactoringFeedbacks(
List<RefactoringFeedback> feedbacks) {
var count = feedbacks.length;
if (count == 0) {
@@ -549,24 +552,24 @@
// The feedbacks are empty, so there's nothing to merge.
return first;
} else if (first is ExtractLocalVariableFeedback) {
- var coveringExpressionOffsets = first.coveringExpressionOffsets == null
- ? <int>[]
- : first.coveringExpressionOffsets.toList();
- var coveringExpressionLengths = first.coveringExpressionLengths == null
- ? <int>[]
- : first.coveringExpressionLengths.toList();
+ var coveringExpressionOffsets =
+ _copyList(first.coveringExpressionOffsets);
+ var coveringExpressionLengths =
+ _copyList(first.coveringExpressionLengths);
var names = first.names.toList();
var offsets = first.offsets.toList();
var lengths = first.lengths.toList();
for (var i = 1; i < count; i++) {
- ExtractLocalVariableFeedback feedback = feedbacks[i];
+ var feedback = feedbacks[i] as ExtractLocalVariableFeedback;
// TODO(brianwilkerson) This doesn't ensure that the covering data is in
// the right order and consistent.
- if (feedback.coveringExpressionOffsets != null) {
- coveringExpressionOffsets.addAll(feedback.coveringExpressionOffsets);
+ var coveringOffsets = feedback.coveringExpressionOffsets;
+ if (coveringOffsets != null) {
+ coveringExpressionOffsets.addAll(coveringOffsets);
}
- if (feedback.coveringExpressionLengths != null) {
- coveringExpressionLengths.addAll(feedback.coveringExpressionLengths);
+ var coveringLengths = feedback.coveringExpressionLengths;
+ if (coveringLengths != null) {
+ coveringExpressionLengths.addAll(coveringLengths);
}
for (var name in feedback.names) {
if (!names.contains(name)) {
@@ -593,7 +596,7 @@
var offsets = first.offsets.toList();
var lengths = first.lengths.toList();
for (var i = 1; i < count; i++) {
- ExtractMethodFeedback feedback = feedbacks[i];
+ var feedback = feedbacks[i] as ExtractMethodFeedback;
if (returnType.isEmpty) {
returnType = feedback.returnType;
}
@@ -667,7 +670,7 @@
/// The returned result will contain the concatenation of the potential edits.
/// If two or more plugins produce the same potential edit, then the resulting
/// list of potential edits will contain duplications.
- EditGetRefactoringResult mergeRefactorings(
+ EditGetRefactoringResult? mergeRefactorings(
List<EditGetRefactoringResult> partialResultList) {
/// Return the result of merging the given list of source [changes] into a
/// single source change.
@@ -679,7 +682,7 @@
/// edits will be merged at the level of the file being edited, but will be
/// a concatenation of the individual edits within each file, even if
/// multiple plugins contribute duplicate or conflicting edits.
- SourceChange mergeChanges(List<SourceChange> changes) {
+ SourceChange? mergeChanges(List<SourceChange> changes) {
var count = changes.length;
if (count == 0) {
return null;
@@ -711,7 +714,6 @@
}
}
linkedEditGroups.addAll(change.linkedEditGroups);
- message ??= change.message;
selection ??= change.selection;
}
return SourceChange(message,
@@ -731,26 +733,33 @@
var optionsProblems = result.optionsProblems.toList();
var finalProblems = result.finalProblems.toList();
var feedbacks = <RefactoringFeedback>[];
- if (result.feedback != null) {
- feedbacks.add(result.feedback);
+ var feedback = result.feedback;
+ if (feedback != null) {
+ feedbacks.add(feedback);
}
var changes = <SourceChange>[];
- if (result.change != null) {
- changes.add(result.change);
+ var change = result.change;
+ if (change != null) {
+ changes.add(change);
}
- var potentialEdits = result.potentialEdits.toList();
+ var potentialEdits = _copyList(result.potentialEdits);
for (var i = 1; i < count; i++) {
var result = partialResultList[1];
initialProblems.addAll(result.initialProblems);
optionsProblems.addAll(result.optionsProblems);
finalProblems.addAll(result.finalProblems);
- if (result.feedback != null) {
- feedbacks.add(result.feedback);
+ var feedback = result.feedback;
+ if (feedback != null) {
+ feedbacks.add(feedback);
}
- if (result.change != null) {
- changes.add(result.change);
+ var change = result.change;
+ if (change != null) {
+ changes.add(change);
}
- potentialEdits.addAll(result.potentialEdits);
+ var edits = result.potentialEdits;
+ if (edits != null) {
+ potentialEdits.addAll(edits);
+ }
}
return EditGetRefactoringResult(
initialProblems, optionsProblems, finalProblems,
@@ -797,4 +806,7 @@
return !((leftStart <= rightStart && rightEnd <= leftEnd) ||
(rightStart <= leftStart && leftEnd <= rightEnd));
}
+
+ /// Return a copy of the [list], or an empty list if [list] is `null`.
+ List<E> _copyList<E>(List<E>? list) => list == null ? <E>[] : list.toList();
}
diff --git a/pkg/analysis_server/lib/src/services/correction/assist.dart b/pkg/analysis_server/lib/src/services/correction/assist.dart
index 6b01848..2929cc2 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/plugin/edit/assist/assist_dart.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/instrumentation/service.dart';
diff --git a/pkg/analysis_server/test/src/plugin/plugin_locator_test.dart b/pkg/analysis_server/test/src/plugin/plugin_locator_test.dart
index 5b71ce6..cf45244 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_locator_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_locator_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/src/plugin/plugin_locator.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
import 'package:test/test.dart';
@@ -17,10 +15,10 @@
@reflectiveTest
class PluginLocatorTest with ResourceProviderMixin {
- String packageRoot;
- String pubspecPath;
- String defaultDirPath;
- PluginLocator locator;
+ late String packageRoot;
+ late String pubspecPath;
+ late String defaultDirPath;
+ late PluginLocator locator;
void setUp() {
packageRoot = newFolder('/package').path;
diff --git a/pkg/analysis_server/test/src/plugin/request_converter_test.dart b/pkg/analysis_server/test/src/plugin/request_converter_test.dart
index 42125bb..7ca3d2a 100644
--- a/pkg/analysis_server/test/src/plugin/request_converter_test.dart
+++ b/pkg/analysis_server/test/src/plugin/request_converter_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/protocol/protocol_generated.dart' as server;
import 'package:analysis_server/src/plugin/request_converter.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
@@ -62,7 +60,7 @@
}
void test_convertAnalysisUpdateContentParams() {
- var serverFiles = <String, dynamic>{
+ var serverFiles = <String, Object>{
'file1': AddContentOverlay('content1'),
'file2': AddContentOverlay('content2'),
};
diff --git a/pkg/analysis_server/test/src/plugin/result_collector_test.dart b/pkg/analysis_server/test/src/plugin/result_collector_test.dart
index a8892b5..39a4486 100644
--- a/pkg/analysis_server/test/src/plugin/result_collector_test.dart
+++ b/pkg/analysis_server/test/src/plugin/result_collector_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/src/plugin/result_collector.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/src/plugin/result_converter_test.dart b/pkg/analysis_server/test/src/plugin/result_converter_test.dart
index 7eaaa6e..220ca9a 100644
--- a/pkg/analysis_server/test/src/plugin/result_converter_test.dart
+++ b/pkg/analysis_server/test/src/plugin/result_converter_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/protocol/protocol_generated.dart' as server;
import 'package:analysis_server/src/plugin/result_converter.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
diff --git a/pkg/analysis_server/test/src/plugin/result_merger_test.dart b/pkg/analysis_server/test/src/plugin/result_merger_test.dart
index 0116e27..934e335 100644
--- a/pkg/analysis_server/test/src/plugin/result_merger_test.dart
+++ b/pkg/analysis_server/test/src/plugin/result_merger_test.dart
@@ -2,8 +2,6 @@
// 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.
-// @dart = 2.9
-
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analysis_server/src/plugin/result_merger.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
diff --git a/pkg/analysis_server/test/stress/utilities/server.dart b/pkg/analysis_server/test/stress/utilities/server.dart
index 81d3c23..888056a 100644
--- a/pkg/analysis_server/test/stress/utilities/server.dart
+++ b/pkg/analysis_server/test/stress/utilities/server.dart
@@ -307,7 +307,7 @@
/// Remove any existing overlays.
void removeAllOverlays() {
- Map<String, dynamic> files = HashMap<String, dynamic>();
+ var files = <String, Object>{};
for (var path in filesWithOverlays) {
files[path] = RemoveContentOverlay();
}
@@ -370,8 +370,8 @@
_send('analysis.setSubscriptions', params);
}
- void sendAnalysisUpdateContent(Map<String, dynamic> files) {
- files.forEach((String path, dynamic overlay) {
+ void sendAnalysisUpdateContent(Map<String, Object> files) {
+ files.forEach((path, overlay) {
if (overlay is AddContentOverlay) {
filesWithOverlays.add(path);
} else if (overlay is RemoveContentOverlay) {
diff --git a/tools/VERSION b/tools/VERSION
index 77ebaab..f94b5ca 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 13
PATCH 0
-PRERELEASE 198
+PRERELEASE 199
PRERELEASE_PATCH 0
\ No newline at end of file