Version 2.16.0-102.0.dev
Merge commit '4122236c30352fdcdb2ecdc6292d47bc3e755311' into 'dev'
diff --git a/pkg/analysis_server/lib/src/cider/fixes.dart b/pkg/analysis_server/lib/src/cider/fixes.dart
index 2ee7754..279cbd1 100644
--- a/pkg/analysis_server/lib/src/cider/fixes.dart
+++ b/pkg/analysis_server/lib/src/cider/fixes.dart
@@ -7,12 +7,14 @@
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart';
import 'package:analysis_server/src/services/correction/fix_internal.dart';
+import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/instrumentation/service.dart';
import 'package:analyzer/source/line_info.dart';
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
import 'package:analyzer/src/dart/micro/resolve_file.dart';
+import 'package:analyzer_plugin/utilities/change_builder/change_workspace.dart';
class CiderErrorFixes {
final AnalysisError error;
@@ -47,12 +49,11 @@
var errorLine = lineInfo.getLocation(error.offset).lineNumber;
if (errorLine == lineNumber) {
var workspace = DartChangeWorkspace([resolvedUnit.session]);
- var context = DartFixContextImpl(
- InstrumentationService.NULL_SERVICE,
+ var context = _CiderDartFixContextImpl(
+ _fileResolver,
workspace,
resolvedUnit,
error,
- _topLevelDeclarations,
);
var fixes = await DartFixContributor().computeFixes(context);
@@ -67,9 +68,23 @@
return result;
}
+}
- Future<Map<LibraryElement, List<Element>>> _topLevelDeclarations(
- String name) async {
+class _CiderDartFixContextImpl extends DartFixContextImpl {
+ final FileResolver _fileResolver;
+
+ _CiderDartFixContextImpl(
+ this._fileResolver,
+ ChangeWorkspace workspace,
+ ResolvedUnitResult resolvedUnit,
+ AnalysisError error,
+ ) : super(InstrumentationService.NULL_SERVICE, workspace, resolvedUnit,
+ error);
+
+ @override
+ Future<Map<LibraryElement, List<Element>>> getTopLevelDeclarations(
+ String name,
+ ) async {
var result = <LibraryElement, List<Element>>{};
var files = _fileResolver.getFilesWithTopLevelDeclarations(name);
for (var file in files) {
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index b6df480..ceb6b14 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -15,7 +15,6 @@
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
import 'package:analyzer/src/dart/analysis/file_content_cache.dart';
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
-import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/lint/linter.dart';
@@ -279,7 +278,7 @@
var convertedErrors = const <protocol.AnalysisError>[];
try {
var content = _readFile(path);
- var lineInfo = _computeLineInfo(content);
+ var lineInfo = LineInfo.fromContent(content);
var errors = analyzeAnalysisOptions(
resourceProvider.getFile(path).createSource(),
content,
@@ -304,7 +303,7 @@
var content = _readFile(path);
var validator =
ManifestValidator(resourceProvider.getFile(path).createSource());
- var lineInfo = _computeLineInfo(content);
+ var lineInfo = LineInfo.fromContent(content);
var errors = validator.validate(
content, driver.analysisOptions.chromeOsManifestChecks);
var converter = AnalyzerConverter();
@@ -331,7 +330,8 @@
parser.parse(content);
var converter = AnalyzerConverter();
convertedErrors = converter.convertAnalysisErrors(errorListener.errors,
- lineInfo: _computeLineInfo(content), options: driver.analysisOptions);
+ lineInfo: LineInfo.fromContent(content),
+ options: driver.analysisOptions);
} catch (exception) {
// If the file cannot be analyzed, fall through to clear any previous
// errors.
@@ -349,7 +349,7 @@
if (node is YamlMap) {
var validator = PubspecValidator(
resourceProvider, resourceProvider.getFile(path).createSource());
- var lineInfo = _computeLineInfo(content);
+ var lineInfo = LineInfo.fromContent(content);
var errors = validator.validate(node.nodes);
var converter = AnalyzerConverter();
convertedErrors = converter.convertAnalysisErrors(errors,
@@ -412,12 +412,6 @@
}
}
- /// Compute line information for the given [content].
- LineInfo _computeLineInfo(String content) {
- var lineStarts = StringUtilities.computeLineStarts(content);
- return LineInfo(lineStarts);
- }
-
void _createAnalysisContexts() {
_destroyAnalysisContexts();
_fileContentCache.invalidateAll();
diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
index 18290c6..7605699 100644
--- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
@@ -23,7 +23,6 @@
import 'package:analysis_server/src/services/correction/change_workspace.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analysis_server/src/services/correction/fix/analysis_options/fix_generator.dart';
-import 'package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart';
import 'package:analysis_server/src/services/correction/fix/manifest/fix_generator.dart';
import 'package:analysis_server/src/services/correction/fix/pubspec/fix_generator.dart';
import 'package:analysis_server/src/services/correction/fix_internal.dart';
@@ -605,9 +604,7 @@
var workspace = DartChangeWorkspace(server.currentSessions);
var context = DartFixContextImpl(
server.instrumentationService, workspace, result, error,
- (name) async {
- return TopLevelDeclarations(result).withName(name);
- }, extensionCache: server.getExtensionCacheFor(result));
+ extensionCache: server.getExtensionCacheFor(result));
List<Fix> fixes;
try {
diff --git a/pkg/analysis_server/lib/src/g3/fixes.dart b/pkg/analysis_server/lib/src/g3/fixes.dart
index 91b812a..17f045c 100644
--- a/pkg/analysis_server/lib/src/g3/fixes.dart
+++ b/pkg/analysis_server/lib/src/g3/fixes.dart
@@ -96,7 +96,6 @@
workspace,
unitResult,
error,
- (name) async => const {},
);
List<Fix> fixes;
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
index eb8cdc0..82ba7c1 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_code_actions.dart
@@ -14,7 +14,6 @@
import 'package:analysis_server/src/services/correction/assist_internal.dart';
import 'package:analysis_server/src/services/correction/change_workspace.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart';
import 'package:analysis_server/src/services/correction/fix_internal.dart';
import 'package:analysis_server/src/services/refactoring/refactoring.dart';
import 'package:analyzer/dart/analysis/results.dart';
@@ -348,9 +347,7 @@
var workspace = DartChangeWorkspace(server.currentSessions);
var context = DartFixContextImpl(
server.instrumentationService, workspace, unit, error,
- (name) async {
- return TopLevelDeclarations(unit).withName(name);
- }, extensionCache: server.getExtensionCacheFor(unit));
+ extensionCache: server.getExtensionCacheFor(unit));
final fixes = await fixContributor.computeFixes(context);
if (fixes.isNotEmpty) {
final diagnostic = toDiagnostic(
diff --git a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
index 35764c0..5f286c8 100644
--- a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
+++ b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
@@ -220,7 +220,6 @@
workspace,
unit,
error,
- (name) async => {},
);
await _fixSingleError(fixContext, unit, error, overrideSet);
}
@@ -266,7 +265,6 @@
workspace,
result,
diagnostic,
- (name) async => {},
);
}
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index b764b6f..962ffde 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -4,6 +4,7 @@
import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
import 'package:analysis_server/src/services/completion/dart/extension_cache.dart';
+import 'package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart';
import 'package:analysis_server/src/services/correction/fix_internal.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -58,18 +59,15 @@
@override
final ExtensionCache extensionCache;
- final Future<Map<LibraryElement, List<Element>>> Function(String name)
- getTopLevelDeclarationsFunction;
-
DartFixContextImpl(this.instrumentationService, this.workspace,
- this.resolveResult, this.error, this.getTopLevelDeclarationsFunction,
+ this.resolveResult, this.error,
{ExtensionCache? extensionCache})
: extensionCache = extensionCache ?? ExtensionCache();
@override
Future<Map<LibraryElement, List<Element>>> getTopLevelDeclarations(
- String name) {
- return getTopLevelDeclarationsFunction(name);
+ String name) async {
+ return TopLevelDeclarations(resolveResult).withName(name);
}
}
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 947f69c..b3a9980 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -251,7 +251,6 @@
workspace,
resolveResult,
error,
- (name) async => {},
extensionCache: context.extensionCache,
);
fixState = await _fixError(fixContext, fixState, generator(), error);
diff --git a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
index a3ab6fc..8c39cb0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
@@ -7,7 +7,6 @@
import 'package:analysis_server/src/services/correction/bulk_fix_processor.dart';
import 'package:analysis_server/src/services/correction/change_workspace.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart';
import 'package:analysis_server/src/services/correction/fix_internal.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/error/error.dart';
@@ -202,9 +201,6 @@
workspace,
testAnalysisResult,
error,
- (name) async {
- return TopLevelDeclarations(testAnalysisResult).withName(name);
- },
);
var fixes = await FixInFileProcessor(context).compute();
@@ -522,9 +518,6 @@
workspace,
testAnalysisResult,
error,
- (name) async {
- return TopLevelDeclarations(testAnalysisResult).withName(name);
- },
extensionCache: extensionCache,
);
return await DartFixContributor().computeFixes(context);
diff --git a/pkg/analysis_server/test/stress/replay/replay.dart b/pkg/analysis_server/test/stress/replay/replay.dart
index e11cf1b..a674281 100644
--- a/pkg/analysis_server/test/stress/replay/replay.dart
+++ b/pkg/analysis_server/test/stress/replay/replay.dart
@@ -12,7 +12,6 @@
import 'package:analyzer/error/listener.dart' as error;
import 'package:analyzer/src/dart/scanner/reader.dart';
import 'package:analyzer/src/dart/scanner/scanner.dart';
-import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/util/glob.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
@@ -497,7 +496,7 @@
throw ArgumentError('Unhandled change of type ${record.status}');
} else {
content = File(filePath).readAsStringSync();
- lineInfo = LineInfo(StringUtilities.computeLineStarts(content));
+ lineInfo = LineInfo.fromContent(content);
}
currentContent = content;
}
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index a38bdd2..36944a5 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -16,6 +16,7 @@
* Removed deprecated `path` and `uri` from `AnalysisResult`.
* Removed deprecated methods from `AnalysisSession`.
* Removed `TypeName` and corresponding methods.
+* Removed deprecated methods from `TypeProvider`.
## 2.8.0
* Deprecations and renames for `getXyz` methods in `AnalysisDriver`.
diff --git a/pkg/analyzer/lib/dart/element/type_provider.dart b/pkg/analyzer/lib/dart/element/type_provider.dart
index 752df98..e75d460 100644
--- a/pkg/analyzer/lib/dart/element/type_provider.dart
+++ b/pkg/analyzer/lib/dart/element/type_provider.dart
@@ -84,11 +84,6 @@
/// Return the type representing the built-in type `Never`.
DartType get neverType;
- /// Return a list containing all of the types that cannot be either extended
- /// or implemented.
- @Deprecated('Use isNonSubtypableClass instead')
- Set<ClassElement> get nonSubtypableClasses;
-
/// Return the element representing the built-in class `Null`.
ClassElement get nullElement;
@@ -138,20 +133,10 @@
/// given [valueType]. The type has the nullability suffix of this provider.
InterfaceType futureOrType(DartType valueType);
- /// Return the instantiation of the built-in class `FutureOr` with the
- /// given [valueType]. The type has the nullability suffix of this provider.
- @Deprecated('Use futureOrType instead')
- InterfaceType futureOrType2(DartType valueType);
-
/// Return the instantiation of the built-in class `Future` with the
/// given [valueType]. The type has the nullability suffix of this provider.
InterfaceType futureType(DartType valueType);
- /// Return the instantiation of the built-in class `Future` with the
- /// given [valueType]. The type has the nullability suffix of this provider.
- @Deprecated('Use futureType instead')
- InterfaceType futureType2(DartType valueType);
-
/// Return `true` if [element] cannot be extended, implemented, or mixed in.
bool isNonSubtypableClass(ClassElement element);
@@ -169,46 +154,20 @@
/// given [elementType]. The type has the nullability suffix of this provider.
InterfaceType iterableType(DartType elementType);
- /// Return the instantiation of the built-in class `Iterable` with the
- /// given [elementType]. The type has the nullability suffix of this provider.
- @Deprecated('Use iterableType instead')
- InterfaceType iterableType2(DartType elementType);
-
/// Return the instantiation of the built-in class `List` with the
/// given [elementType]. The type has the nullability suffix of this provider.
InterfaceType listType(DartType elementType);
/// Return the instantiation of the built-in class `List` with the
- /// given [elementType]. The type has the nullability suffix of this provider.
- @Deprecated('Use listType instead')
- InterfaceType listType2(DartType elementType);
-
- /// Return the instantiation of the built-in class `List` with the
/// given [keyType] and [valueType]. The type has the nullability suffix of
/// this provider.
InterfaceType mapType(DartType keyType, DartType valueType);
- /// Return the instantiation of the built-in class `List` with the
- /// given [keyType] and [valueType]. The type has the nullability suffix of
- /// this provider.
- @Deprecated('Use mapType instead')
- InterfaceType mapType2(DartType keyType, DartType valueType);
-
/// Return the instantiation of the built-in class `Set` with the
/// given [elementType]. The type has the nullability suffix of this provider.
InterfaceType setType(DartType elementType);
- /// Return the instantiation of the built-in class `Set` with the
- /// given [elementType]. The type has the nullability suffix of this provider.
- @Deprecated('Use setType instead')
- InterfaceType setType2(DartType elementType);
-
/// Return the instantiation of the built-in class `Stream` with the
/// given [elementType]. The type has the nullability suffix of this provider.
InterfaceType streamType(DartType elementType);
-
- /// Return the instantiation of the built-in class `Stream` with the
- /// given [elementType]. The type has the nullability suffix of this provider.
- @Deprecated('Use streamType instead')
- InterfaceType streamType2(DartType elementType);
}
diff --git a/pkg/analyzer/lib/source/line_info.dart b/pkg/analyzer/lib/source/line_info.dart
index b552a35..41ce1ac 100644
--- a/pkg/analyzer/lib/source/line_info.dart
+++ b/pkg/analyzer/lib/source/line_info.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.
-import 'package:analyzer/src/generated/java_engine.dart';
-
/// The location of a character represented as a line and column pair.
class CharacterLocation {
/// The one-based index of the line containing the character.
@@ -45,9 +43,32 @@
}
/// Initialize a newly created set of line information corresponding to the
- /// given file [content].
- factory LineInfo.fromContent(String content) =>
- LineInfo(StringUtilities.computeLineStarts(content));
+ /// given file [content]. Lines end with `\r`, `\n` or `\r\n`.
+ factory LineInfo.fromContent(String content) {
+ const slashN = 0x0A;
+ const slashR = 0x0D;
+
+ var lineStarts = <int>[0];
+ var length = content.length;
+ for (var i = 0; i < length; i++) {
+ var unit = content.codeUnitAt(i);
+ // Special-case \r\n.
+ if (unit == slashR) {
+ // Peek ahead to detect a following \n.
+ if (i + 1 < length && content.codeUnitAt(i + 1) == slashN) {
+ // Line start will get registered at next index at the \n.
+ } else {
+ lineStarts.add(i + 1);
+ }
+ }
+ // \n
+ if (unit == slashN) {
+ lineStarts.add(i + 1);
+ }
+ }
+
+ return LineInfo(lineStarts);
+ }
/// The number of lines.
int get lineCount => lineStarts.length;
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 6a41913..aad1d18 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -390,7 +390,7 @@
// TODO (jwren) revisit- should we append '=' here or require clients to
// include it?
// Do we need the check for isSetter below?
- if (!StringUtilities.endsWithChar(setterName, 0x3D)) {
+ if (!setterName.endsWith('=')) {
setterName += '=';
}
for (PropertyAccessorElement accessor in accessors) {
@@ -2085,8 +2085,7 @@
/// Initialize a newly created element to have the given [name] at the given
/// [_nameOffset].
- ElementImpl(String? name, this._nameOffset, {this.reference}) {
- _name = name != null ? StringUtilities.intern(name) : null;
+ ElementImpl(this._name, this._nameOffset, {this.reference}) {
reference?.element = this;
}
@@ -4723,8 +4722,8 @@
@override
final ParameterKind parameterKind;
- /// The Dart code of the default value.
- String? _defaultValueCode;
+ @override
+ String? defaultValueCode;
/// True if this parameter inherits from a covariant parameter. This happens
/// when it overrides a method in a supertype that has a corresponding
@@ -4756,18 +4755,6 @@
ParameterElement get declaration => this;
@override
- String? get defaultValueCode {
- return _defaultValueCode;
- }
-
- /// Set Dart code of the default value.
- set defaultValueCode(String? defaultValueCode) {
- _defaultValueCode = defaultValueCode != null
- ? StringUtilities.intern(defaultValueCode)
- : null;
- }
-
- @override
bool get hasDefaultValue {
return defaultValueCode != null;
}
diff --git a/pkg/analyzer/lib/src/dart/element/type_provider.dart b/pkg/analyzer/lib/src/dart/element/type_provider.dart
index 948b8c448..15242b5 100644
--- a/pkg/analyzer/lib/src/dart/element/type_provider.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_provider.dart
@@ -149,8 +149,6 @@
InterfaceType? _nullStar;
- Set<ClassElement>? _nonSubtypableClasses;
-
/// Initialize a newly created type provider to provide the types defined in
/// the given [coreLibrary] and [asyncLibrary].
TypeProviderImpl({
@@ -353,18 +351,6 @@
? NeverTypeImpl.instance
: NeverTypeImpl.instanceLegacy;
- @Deprecated('Use isNonSubtypableClass instead')
- @override
- Set<ClassElement> get nonSubtypableClasses => _nonSubtypableClasses ??= {
- boolElement,
- doubleElement,
- futureOrElement,
- intElement,
- nullElement,
- numElement,
- stringElement,
- };
-
@override
ClassElement get nullElement {
return _nullElement ??= _getClassElement(_coreLibrary, 'Null');
@@ -473,12 +459,6 @@
);
}
- @Deprecated('Use futureOrType instead')
- @override
- InterfaceType futureOrType2(DartType valueType) {
- return futureOrType(valueType);
- }
-
@override
InterfaceType futureType(DartType valueType) {
return futureElement.instantiate(
@@ -487,12 +467,6 @@
);
}
- @Deprecated('Use futureType instead')
- @override
- InterfaceType futureType2(DartType valueType) {
- return futureType(valueType);
- }
-
@override
bool isNonSubtypableClass(ClassElement element) {
var name = element.name;
@@ -512,12 +486,6 @@
);
}
- @Deprecated('Use iterableType instead')
- @override
- InterfaceType iterableType2(DartType elementType) {
- return iterableType(elementType);
- }
-
@override
InterfaceType listType(DartType elementType) {
return listElement.instantiate(
@@ -526,12 +494,6 @@
);
}
- @Deprecated('Use listType instead')
- @override
- InterfaceType listType2(DartType elementType) {
- return listType(elementType);
- }
-
@override
InterfaceType mapType(DartType keyType, DartType valueType) {
return mapElement.instantiate(
@@ -540,12 +502,6 @@
);
}
- @Deprecated('Use mapType instead')
- @override
- InterfaceType mapType2(DartType keyType, DartType valueType) {
- return mapType(keyType, valueType);
- }
-
@override
InterfaceType setType(DartType elementType) {
return setElement.instantiate(
@@ -554,12 +510,6 @@
);
}
- @Deprecated('Use setType instead')
- @override
- InterfaceType setType2(DartType elementType) {
- return setType(elementType);
- }
-
@override
InterfaceType streamType(DartType elementType) {
return streamElement.instantiate(
@@ -568,12 +518,6 @@
);
}
- @Deprecated('Use streamType instead')
- @override
- InterfaceType streamType2(DartType elementType) {
- return streamType(elementType);
- }
-
/// Return the class with the given [name] from the given [library], or
/// throw a [StateError] if there is no class with the given name.
ClassElement _getClassElement(LibraryElement library, String name) {
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 0279e72..1200ffb 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -42,7 +42,6 @@
import 'package:analyzer/src/generated/element_resolver.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/error_detection_helpers.dart';
-import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
import 'package:analyzer/src/generated/this_access_tracker.dart';
import 'package:analyzer/src/utilities/extensions/string.dart';
@@ -4935,11 +4934,11 @@
/// Return the name of the library that defines given [element].
String _getLibraryName(Element? element) {
if (element == null) {
- return StringUtilities.EMPTY;
+ return '';
}
var library = element.library;
if (library == null) {
- return StringUtilities.EMPTY;
+ return '';
}
List<ImportElement> imports = _currentLibrary.imports;
int count = imports.length;
diff --git a/pkg/analyzer/lib/src/generated/java_engine.dart b/pkg/analyzer/lib/src/generated/java_engine.dart
index c2e9773..01ccfba 100644
--- a/pkg/analyzer/lib/src/generated/java_engine.dart
+++ b/pkg/analyzer/lib/src/generated/java_engine.dart
@@ -10,40 +10,7 @@
typedef Predicate<E> = bool Function(E argument);
class StringUtilities {
- static const String EMPTY = '';
- static const List<String> EMPTY_ARRAY = <String>[];
-
static Interner INTERNER = NullInterner();
- /// Compute line starts for the given [content].
- /// Lines end with `\r`, `\n` or `\r\n`.
- static List<int> computeLineStarts(String content) {
- List<int> lineStarts = <int>[0];
- int length = content.length;
- int unit;
- for (int index = 0; index < length; index++) {
- unit = content.codeUnitAt(index);
- // Special-case \r\n.
- if (unit == 0x0D /* \r */) {
- // Peek ahead to detect a following \n.
- if ((index + 1 < length) && content.codeUnitAt(index + 1) == 0x0A) {
- // Line start will get registered at next index at the \n.
- } else {
- lineStarts.add(index + 1);
- }
- }
- // \n
- if (unit == 0x0A) {
- lineStarts.add(index + 1);
- }
- }
- return lineStarts;
- }
-
- static bool endsWithChar(String str, int c) {
- int length = str.length;
- return length > 0 && str.codeUnitAt(length - 1) == c;
- }
-
static String intern(String string) => INTERNER.intern(string);
}
diff --git a/pkg/analyzer/test/generated/utilities_test.dart b/pkg/analyzer/test/generated/utilities_test.dart
index d3beec6..8ff080e 100644
--- a/pkg/analyzer/test/generated/utilities_test.dart
+++ b/pkg/analyzer/test/generated/utilities_test.dart
@@ -9,7 +9,6 @@
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/dart/ast/ast_factory.dart';
import 'package:analyzer/src/dart/ast/utilities.dart';
-import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
import 'package:analyzer/src/generated/utilities_collection.dart';
@@ -23,7 +22,6 @@
defineReflectiveTests(LineInfoTest);
defineReflectiveTests(NodeReplacerTest);
defineReflectiveTests(SourceRangeTest);
- defineReflectiveTests(StringUtilitiesTest);
});
}
@@ -1045,6 +1043,21 @@
}, throwsArgumentError);
}
+ void test_fromContent_n() {
+ var lineInfo = LineInfo.fromContent('a\nbb\nccc');
+ expect(lineInfo.lineStarts, <int>[0, 2, 5]);
+ }
+
+ void test_fromContent_r() {
+ var lineInfo = LineInfo.fromContent('a\rbb\rccc');
+ expect(lineInfo.lineStarts, <int>[0, 2, 5]);
+ }
+
+ void test_fromContent_rn() {
+ var lineInfo = LineInfo.fromContent('a\r\nbb\r\nccc');
+ expect(lineInfo.lineStarts, <int>[0, 3, 7]);
+ }
+
void test_getLocation_firstLine() {
LineInfo info = LineInfo(<int>[0, 12, 34]);
var location = info.getLocation(4);
@@ -2560,36 +2573,3 @@
expect(r.toString(), "[offset=10, length=1]");
}
}
-
-@reflectiveTest
-class StringUtilitiesTest {
- void test_computeLineStarts_n() {
- List<int> starts = StringUtilities.computeLineStarts('a\nbb\nccc');
- expect(starts, <int>[0, 2, 5]);
- }
-
- void test_computeLineStarts_r() {
- List<int> starts = StringUtilities.computeLineStarts('a\rbb\rccc');
- expect(starts, <int>[0, 2, 5]);
- }
-
- void test_computeLineStarts_rn() {
- List<int> starts = StringUtilities.computeLineStarts('a\r\nbb\r\nccc');
- expect(starts, <int>[0, 3, 7]);
- }
-
- void test_EMPTY() {
- expect(StringUtilities.EMPTY, "");
- expect(StringUtilities.EMPTY.isEmpty, isTrue);
- }
-
- void test_EMPTY_ARRAY() {
- expect(StringUtilities.EMPTY_ARRAY.length, 0);
- }
-
- void test_endsWithChar() {
- expect(StringUtilities.endsWithChar("a", 0x61), isTrue);
- expect(StringUtilities.endsWithChar("b", 0x61), isFalse);
- expect(StringUtilities.endsWithChar("", 0x61), isFalse);
- }
-}
diff --git a/pkg/analyzer_cli/lib/src/driver.dart b/pkg/analyzer_cli/lib/src/driver.dart
index b2dd53f..de1d3c0 100644
--- a/pkg/analyzer_cli/lib/src/driver.dart
+++ b/pkg/analyzer_cli/lib/src/driver.dart
@@ -17,8 +17,6 @@
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/dart/analysis/results.dart';
import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/interner.dart';
-import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/lint/linter.dart';
import 'package:analyzer/src/lint/pub.dart';
@@ -95,8 +93,6 @@
_isStarted = true;
var startTime = DateTime.now().millisecondsSinceEpoch;
- StringUtilities.INTERNER = MappedInterner();
-
linter.registerLintRules();
// Parse commandline options.
diff --git a/tools/VERSION b/tools/VERSION
index 406d617..fb77d66 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 16
PATCH 0
-PRERELEASE 101
+PRERELEASE 102
PRERELEASE_PATCH 0
\ No newline at end of file