Version 3.7.0-298.0.dev Merge 9d040aaea9467f8649a2aa1530ab54dae8ed1143 into dev
diff --git a/pkg/analysis_server/analyzer_use_new_elements.txt b/pkg/analysis_server/analyzer_use_new_elements.txt index e4b658a..a24e185 100644 --- a/pkg/analysis_server/analyzer_use_new_elements.txt +++ b/pkg/analysis_server/analyzer_use_new_elements.txt
@@ -1,18 +1,15 @@ lib/plugin/protocol/protocol_dart.dart lib/src/analysis_server.dart lib/src/cider/rename.dart -lib/src/domains/analysis/occurrences_dart.dart lib/src/handler/legacy/edit_get_available_refactorings.dart lib/src/handler/legacy/search_find_element_references.dart lib/src/lsp/handlers/handler_completion.dart lib/src/lsp/handlers/handler_completion_resolve.dart -lib/src/lsp/handlers/handler_references.dart lib/src/lsp/handlers/handler_rename.dart lib/src/protocol_server.dart lib/src/services/correction/namespace.dart lib/src/services/kythe/kythe_visitors.dart lib/src/services/refactoring/legacy/extract_method.dart -lib/src/services/refactoring/legacy/move_file.dart lib/src/services/refactoring/legacy/refactoring.dart lib/src/services/refactoring/legacy/refactoring_manager.dart lib/src/services/refactoring/legacy/rename.dart
diff --git a/pkg/analysis_server/lib/src/channel/channel.dart b/pkg/analysis_server/lib/src/channel/channel.dart index 855729a..2c00681 100644 --- a/pkg/analysis_server/lib/src/channel/channel.dart +++ b/pkg/analysis_server/lib/src/channel/channel.dart
@@ -2,6 +2,9 @@ // 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. +/// @docImport 'package:analysis_server/src/analysis_server.dart'; +library; + import 'dart:convert'; import 'package:analysis_server/protocol/protocol.dart';
diff --git a/pkg/analysis_server/lib/src/cider/fixes.dart b/pkg/analysis_server/lib/src/cider/fixes.dart index 87fb28b..9bb1b46 100644 --- a/pkg/analysis_server/lib/src/cider/fixes.dart +++ b/pkg/analysis_server/lib/src/cider/fixes.dart
@@ -36,7 +36,7 @@ CiderFixesComputer(this._logger, this._fileResolver); - /// Compute quick fixes for errors on the line with the [offset]. + /// Compute quick fixes for errors on the line at [lineNumber]. Future<List<CiderErrorFixes>> compute(String path, int lineNumber) async { var result = <CiderErrorFixes>[]; var resolvedLibrary = await _fileResolver.resolveLibrary2(path: path);
diff --git a/pkg/analysis_server/lib/src/cider/rename.dart b/pkg/analysis_server/lib/src/cider/rename.dart index 28dfdd1..2712702 100644 --- a/pkg/analysis_server/lib/src/cider/rename.dart +++ b/pkg/analysis_server/lib/src/cider/rename.dart
@@ -335,7 +335,7 @@ return FlutterWidgetRename(stateName, match, replacements); } - /// If the given [reference] is before an interpolated [SimpleIdentifier] in + /// If the reference at [loc] is before an interpolated [SimpleIdentifier] in /// an [InterpolationExpression] without surrounding curly brackets, return /// it. Otherwise return `null`. Future<SimpleIdentifier?> _getInterpolationIdentifier(
diff --git a/pkg/analysis_server/lib/src/computer/computer_call_hierarchy.dart b/pkg/analysis_server/lib/src/computer/computer_call_hierarchy.dart index 9c6d616..f3b664a 100644 --- a/pkg/analysis_server/lib/src/computer/computer_call_hierarchy.dart +++ b/pkg/analysis_server/lib/src/computer/computer_call_hierarchy.dart
@@ -15,7 +15,7 @@ /// Returns the container for [element] that should be used in Call Hierarchy. /// -/// Returns `null` if none of [elements] are valid containers. +/// Returns `null` if none of [element]'s ancestors are valid containers. /// /// This is used to construct (and group calls by) a [CallHierarchyItem] that /// contains calls and also locate their containers for additional labelling. @@ -316,7 +316,7 @@ /// Finds a target for starting call hierarchy navigation at [offset]. /// - /// If [offset] is an invocation, returns information about the [Element] it + /// If [offset] is an invocation, returns information about the [Element2] it /// refers to. CallHierarchyItem? findTarget(int offset) { var node = _findTargetNode(offset); @@ -359,7 +359,7 @@ return node; } - /// Return the [Element] of the given [node], or `null` if [node] is `null`, + /// Return the [Element2] of the given [node], or `null` if [node] is `null`, /// does not have an element, or the element is not a valid target for call /// hierarchy. Element2? _getElementOfNode(AstNode? node) {
diff --git a/pkg/analysis_server/lib/src/computer/computer_color.dart b/pkg/analysis_server/lib/src/computer/computer_color.dart index fc0b04c..7a57c4a 100644 --- a/pkg/analysis_server/lib/src/computer/computer_color.dart +++ b/pkg/analysis_server/lib/src/computer/computer_color.dart
@@ -412,7 +412,7 @@ } extension _DartObjectExtensions on DartObject { - /// Reads the value of the field [field] from this object. + /// Reads the value of the field named [fieldName] from this object. /// /// If the field is not found, recurses up the super classes. DartObject? getFieldFromHierarchy(String fieldName) =>
diff --git a/pkg/analysis_server/lib/src/computer/computer_inlay_hint.dart b/pkg/analysis_server/lib/src/computer/computer_inlay_hint.dart index a540a73..9cf92ee 100644 --- a/pkg/analysis_server/lib/src/computer/computer_inlay_hint.dart +++ b/pkg/analysis_server/lib/src/computer/computer_inlay_hint.dart
@@ -35,12 +35,12 @@ return _hints; } - /// Adds a parameter name hint before [node] showing a the name for + /// Adds a parameter name hint before [nodeOrToken] showing a the name for /// [parameter]. /// /// If the parameter has no name, no hint will be added. /// - /// A colon and padding will be added between the hint and [node] + /// A colon and padding will be added between the hint and [nodeOrToken] /// automatically. void _addParameterNamePrefix( SyntacticEntity nodeOrToken, @@ -68,7 +68,8 @@ ); } - /// Adds a type hint for [node] showing a label for type arguments [types]. + /// Adds a type hint for [nodeOrToken] showing a label for type arguments + /// [types]. /// /// Hints will be added before the node unless [suffix] is `true`. /// @@ -98,9 +99,9 @@ ); } - /// Adds a type hint before [node] showing a label for the type [type]. + /// Adds a type hint before [nodeOrToken] showing a label for the type [type]. /// - /// Padding will be added between the hint and [node] automatically. + /// Padding will be added between the hint and [nodeOrToken] automatically. void _addTypePrefix(SyntacticEntity nodeOrToken, DartType type) { var offset = nodeOrToken.offset; var position = toPosition(_lineInfo.getLocation(offset));
diff --git a/pkg/analysis_server/lib/src/computer/computer_lazy_type_hierarchy.dart b/pkg/analysis_server/lib/src/computer/computer_lazy_type_hierarchy.dart index 814c4cd..58f5a88 100644 --- a/pkg/analysis_server/lib/src/computer/computer_lazy_type_hierarchy.dart +++ b/pkg/analysis_server/lib/src/computer/computer_lazy_type_hierarchy.dart
@@ -112,7 +112,7 @@ return element is InterfaceElement2 ? element : null; } - /// Gets immediate sub types for the class/mixin [element]. + /// Gets immediate subtypes for the class/mixin [target]. Future<List<TypeHierarchyRelatedItem>> _getSubtypes( InterfaceElement2 target, SearchEngine searchEngine,
diff --git a/pkg/analysis_server/lib/src/computer/computer_overrides.dart b/pkg/analysis_server/lib/src/computer/computer_overrides.dart index 8c0bf0a..1e2ad8a 100644 --- a/pkg/analysis_server/lib/src/computer/computer_overrides.dart +++ b/pkg/analysis_server/lib/src/computer/computer_overrides.dart
@@ -40,7 +40,8 @@ return _overrides; } - /// Add a new [Override] for the declaration with the given name [token]. + /// Add a new [proto.Override] for the declaration with the given name + /// [token]. void _addOverride(Token token, Element2? element) { if (element != null) { var overridesResult = _OverriddenElementsFinder(element).find();
diff --git a/pkg/analysis_server/lib/src/computer/import_elements_computer.dart b/pkg/analysis_server/lib/src/computer/import_elements_computer.dart index bb79073..c870197 100644 --- a/pkg/analysis_server/lib/src/computer/import_elements_computer.dart +++ b/pkg/analysis_server/lib/src/computer/import_elements_computer.dart
@@ -28,8 +28,8 @@ /// Initialize a newly created builder. ImportElementsComputer(this.resourceProvider, this.libraryResult); - /// Create the edits that will cause the list of [importedElements] to be - /// imported into the library at the given [path]. + /// Creates the edits that will cause the list of [importedElementsList] to be + /// imported into the library. Future<SourceChange> createEdits( List<ImportedElements> importedElementsList, ) async {
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart index 4cf68fd..4409bc4 100644 --- a/pkg/analysis_server/lib/src/context_manager.dart +++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -768,8 +768,7 @@ } } - /// Establishes watch(es) for the Blaze generated files provided in - /// [notification]. + /// Establishes watch(es) for the Blaze-generated files provided in [folder]. /// /// Whenever the files change, we trigger re-analysis. This allows us to react /// to creation/modification of files that were generated by Blaze.
diff --git a/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart b/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart index 88d8e33..86e34ec 100644 --- a/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart +++ b/pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart
@@ -6,7 +6,7 @@ import 'package:analysis_server/src/protocol_server.dart' as protocol; import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/src/dart/ast/extensions.dart'; import 'package:analyzer/src/dart/element/element.dart'; @@ -14,19 +14,19 @@ var visitor = _DartUnitOccurrencesComputerVisitor(); unit.accept(visitor); visitor.elementsOffsets.forEach((engineElement, offsets) { - var length = engineElement.nameLength; - var serverElement = protocol.convertElement(engineElement); + var length = engineElement.name3?.length ?? 0; + var serverElement = protocol.convertElement2(engineElement); var occurrences = protocol.Occurrences(serverElement, offsets, length); collector.addOccurrences(occurrences); }); } class _DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> { - final Map<Element, List<int>> elementsOffsets = <Element, List<int>>{}; + final Map<Element2, List<int>> elementsOffsets = {}; @override void visitAssignedVariablePattern(AssignedVariablePattern node) { - var element = node.element; + var element = node.element2; if (element != null) { _addOccurrence(element, node.name.offset); } @@ -36,14 +36,14 @@ @override void visitClassDeclaration(ClassDeclaration node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitClassDeclaration(node); } @override void visitClassTypeAlias(ClassTypeAlias node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitClassTypeAlias(node); } @@ -51,7 +51,7 @@ @override void visitConstructorDeclaration(ConstructorDeclaration node) { if (node.name case var name?) { - _addOccurrence(node.declaredElement!, name.offset); + _addOccurrence(node.declaredFragment!.element, name.offset); } super.visitConstructorDeclaration(node); @@ -59,44 +59,44 @@ @override void visitDeclaredIdentifier(DeclaredIdentifier node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitDeclaredIdentifier(node); } @override void visitDeclaredVariablePattern(DeclaredVariablePattern node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredElement2!, node.name.offset); super.visitDeclaredVariablePattern(node); } @override void visitEnumConstantDeclaration(EnumConstantDeclaration node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitEnumConstantDeclaration(node); } @override void visitEnumDeclaration(EnumDeclaration node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitEnumDeclaration(node); } @override void visitExtensionTypeDeclaration(ExtensionTypeDeclaration node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitExtensionTypeDeclaration(node); } @override void visitFieldFormalParameter(FieldFormalParameter node) { - var declaredElement = node.declaredElement; - if (declaredElement is FieldFormalParameterElement) { - var field = declaredElement.field; + var declaredElement = node.declaredFragment?.element; + if (declaredElement is FieldFormalParameterElement2) { + var field = declaredElement.field2; if (field != null) { _addOccurrence(field, node.name.offset); } @@ -107,40 +107,40 @@ @override void visitFunctionDeclaration(FunctionDeclaration node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitFunctionDeclaration(node); } @override void visitFunctionTypeAlias(FunctionTypeAlias node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitFunctionTypeAlias(node); } @override void visitGenericTypeAlias(GenericTypeAlias node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitGenericTypeAlias(node); } @override void visitMethodDeclaration(MethodDeclaration node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitMethodDeclaration(node); } @override void visitMixinDeclaration(MixinDeclaration node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitMixinDeclaration(node); } @override void visitNamedType(NamedType node) { - var element = node.element; + var element = node.element2; if (element != null) { _addOccurrence(element, node.name2.offset); } @@ -150,7 +150,7 @@ @override void visitPatternField(PatternField node) { - var element = node.element; + var element = node.element2; var pattern = node.pattern; // If no explicit field name, use the variables name. var name = @@ -166,7 +166,10 @@ @override void visitRepresentationDeclaration(RepresentationDeclaration node) { if (node.constructorName case var constructorName?) { - _addOccurrence(node.constructorElement!, constructorName.name.offset); + _addOccurrence( + node.constructorFragment!.element, + constructorName.name.offset, + ); } super.visitRepresentationDeclaration(node); @@ -176,7 +179,7 @@ void visitSimpleFormalParameter(SimpleFormalParameter node) { var nameToken = node.name; if (nameToken != null) { - _addOccurrence(node.declaredElement!, nameToken.offset); + _addOccurrence(node.declaredFragment!.element, nameToken.offset); } super.visitSimpleFormalParameter(node); @@ -184,7 +187,7 @@ @override void visitSimpleIdentifier(SimpleIdentifier node) { - var element = node.writeOrReadElement; + var element = node.writeOrReadElement2; if (element != null) { _addOccurrence(element, node.offset); } @@ -193,17 +196,17 @@ @override void visitSuperFormalParameter(SuperFormalParameter node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitSuperFormalParameter(node); } @override void visitVariableDeclaration(VariableDeclaration node) { - _addOccurrence(node.declaredElement!, node.name.offset); + _addOccurrence(node.declaredFragment!.element, node.name.offset); super.visitVariableDeclaration(node); } - void _addOccurrence(Element element, int offset) { + void _addOccurrence(Element2 element, int offset) { var canonicalElement = _canonicalizeElement(element); if (canonicalElement == null || element == DynamicElementImpl.instance) { return; @@ -216,13 +219,13 @@ offsets.add(offset); } - Element? _canonicalizeElement(Element element) { - Element? canonicalElement = element; - if (canonicalElement is FieldFormalParameterElement) { - canonicalElement = canonicalElement.field; - } else if (canonicalElement is PropertyAccessorElement) { - canonicalElement = canonicalElement.variable2; + Element2? _canonicalizeElement(Element2 element) { + Element2? canonicalElement = element; + if (canonicalElement is FieldFormalParameterElement2) { + canonicalElement = canonicalElement.field2; + } else if (canonicalElement is PropertyAccessorElement2) { + canonicalElement = canonicalElement.variable3; } - return canonicalElement?.declaration; + return canonicalElement?.baseElement; } }
diff --git a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart index 319fdfd..d8ab4f2 100644 --- a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart +++ b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart
@@ -33,11 +33,12 @@ super.performance, ); - /// Compute completion results for the given request and append them to the - /// stream. Clients should not call this method directly as it is + /// Computes completion results for [request] and append them to the stream. + /// + /// Clients should not call this method directly as it is /// automatically called when a client listens to the stream returned by - /// [results]. Subclasses should override this method, append at least one - /// result to the [controller], and close the controller stream once complete. + /// 'results'. Subclasses should override this method, append at least one + /// result to the controller, and close the controller stream once complete. Future<List<CompletionSuggestionBuilder>> computeSuggestions({ required CompletionBudget budget, required OperationPerformanceImpl performance, @@ -46,7 +47,6 @@ NotImportedSuggestions? notImportedSuggestions, required bool useFilter, }) async { - // // Compute completions generated by server. // @@ -262,4 +262,3 @@ } } } -
diff --git a/pkg/analysis_server/lib/src/lsp/completion_utils.dart b/pkg/analysis_server/lib/src/lsp/completion_utils.dart index 395c3c2..5e3d739 100644 --- a/pkg/analysis_server/lib/src/lsp/completion_utils.dart +++ b/pkg/analysis_server/lib/src/lsp/completion_utils.dart
@@ -369,8 +369,8 @@ ); } -/// Return the [lsp.CompletionItemKind] or [null] for the given -/// [CandidateSuggestion] and the set of supported [lsp.CompletionItemKind]'s. +/// Returns the [lsp.CompletionItemKind] or `null` for the given +/// [CandidateSuggestion] and the set of supported [lsp.CompletionItemKind]s. lsp.CompletionItemKind? _candidateToCompletionItemKind( Set<lsp.CompletionItemKind> supportedCompletionKinds, CandidateSuggestion suggestion,
diff --git a/pkg/analysis_server/lib/src/lsp/error_or.dart b/pkg/analysis_server/lib/src/lsp/error_or.dart index 3a38f74..0dab6ca 100644 --- a/pkg/analysis_server/lib/src/lsp/error_or.dart +++ b/pkg/analysis_server/lib/src/lsp/error_or.dart
@@ -53,9 +53,10 @@ return isError ? error : null; } - /// Returns true if this object is an error, false if it is a result. Prefer - /// [mapResult] instead of checking this flag if [errors] will simply be - /// propagated as-is. + /// Returns `true` if this object is an error, `false` if it is a result. + /// + /// Prefer [mapResult] instead of checking this flag if the errors will simply + /// be propagated as-is. bool get isError => map((_) => true, (_) => false); /// Returns true if this object is aa result, false if it is an error. Prefer
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 c5dff02..2ae8777 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
@@ -327,7 +327,8 @@ .toList(); } - /// Creates a comparer for [CodeActions] that compares the column distance from [pos]. + /// Creates a comparer for [CodeAction]s that compares the column distance from + /// [pos]. int Function(CodeAction a, CodeAction b) _codeActionColumnDistanceComparer( Position pos, ) {
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart index c7a8b00..f1815ce 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
@@ -50,7 +50,7 @@ /// Whether to include symbols from libraries that have not been imported. final bool suggestFromUnimportedLibraries; - /// The budget to use for [NotImportedContributor] computation. + /// The budget to use for [NotImportedSuggestions] computation. /// /// This is usually the default value, but can be overridden via /// initializationOptions (used for tests, but may also be useful for
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color.dart index 2acefbd..518fb10 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color.dart
@@ -2,6 +2,9 @@ // 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. +/// @docImport 'package:analysis_server/src/lsp/handlers/handler_document_color_presentation.dart'; +library; + import 'package:analysis_server/lsp_protocol/protocol.dart'; import 'package:analysis_server/src/computer/computer_color.dart' show ColorComputer, ColorReference;
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart index 28b4492..dd92085 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart
@@ -67,9 +67,6 @@ /// called. This will be replaced into [editRange] and any required import /// statement will produce additional edits. /// - /// [label] is the visible label shown to the user and should roughly reflect - /// the code that will be inserted. - /// /// [invocationString] is written immediately after [colorType] in [editRange]. Future<ColorPresentation> _createColorPresentation({ required ResolvedUnitResult unit,
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_type_hierarchy.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_type_hierarchy.dart index f7cf56d..58c7ef6 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_type_hierarchy.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_type_hierarchy.dart
@@ -269,7 +269,7 @@ /// Converts multiple server [type_hierarchy.TypeHierarchyItem] to an LSP /// [TypeHierarchyItem]. /// - /// Reads [LineInfo]s from [unit.session], caching them for items in the same + /// Reads [LineInfo]s from `unit.session`, caching them for items in the same /// file. List<TypeHierarchyItem> _convertItems( ResolvedUnitResult unit,
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart b/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart index 3039343..08b6ab8 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart
@@ -134,7 +134,7 @@ } } - /// Returns whether [doc] is a user-editable document or not. + /// Returns whether the file at [uri] is a user-editable document. /// /// Only editable documents have overlays and can be modified by the client. bool isEditableDocument(Uri uri) { @@ -424,7 +424,7 @@ /// provided to a handler. class MessageInfo { /// Returns the amount of time (in milliseconds) since the client sent this - /// request or `null` if the client did not provide [clientRequestTime]. + /// request or `null` if the client did not provide `clientRequestTime`. final int? timeSinceRequest; final OperationPerformanceImpl performance; @@ -441,8 +441,8 @@ final LspClientCapabilities? clientCapabilities; /// The completer used to indicate that the handler is paused waiting on user - /// response. The completer, if any, is set to complete before a dialog is - /// shown. + /// response. The completer, if any, is set to complete before a dialog is + /// shown. final Completer<void>? completer; MessageInfo({
diff --git a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart index 57ce164..1bf225d 100644 --- a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart +++ b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
@@ -52,8 +52,8 @@ import 'package:path/path.dart' as path; /// Instances of the class [LspAnalysisServer] implement an LSP-based server -/// that listens on a [CommunicationChannel] for LSP messages and processes -/// them. +/// that listens on a [LspServerCommunicationChannel] for LSP messages and +/// processes them. class LspAnalysisServer extends AnalysisServer { /// The capabilities of the LSP client. Will be null prior to initialization. LspClientCapabilities? _clientCapabilities; @@ -393,7 +393,7 @@ /// returning an [OptionalVersionedTextDocumentIdentifier] with a version of /// `null` if the document version is not known. /// - /// Prefer using [LspHandlerHelperMixin.extractDocumentVersion] when you + /// Prefer using [HandlerHelperMixin.extractDocumentVersion] when you /// already have a [TextDocumentIdentifier] from the client because it is /// guaranteed to be what the client expected and not just the current version /// the server has. @@ -861,8 +861,9 @@ channel.sendNotification(notification); } - /// Send the given [request] to the client and wait for a response. Completes - /// with the raw [ResponseMessage] which could be an error response. + /// Sends a request with the given [params] to the client and wait for a + /// response. Completes with the raw [ResponseMessage] which could be an + /// error response. Future<ResponseMessage> sendRequest(Method method, Object params) { var requestId = nextRequestId++; var completer = Completer<ResponseMessage>();
diff --git a/pkg/analysis_server/lib/src/lsp/mapping.dart b/pkg/analysis_server/lib/src/lsp/mapping.dart index 63cb767..2790d9a 100644 --- a/pkg/analysis_server/lib/src/lsp/mapping.dart +++ b/pkg/analysis_server/lib/src/lsp/mapping.dart
@@ -151,10 +151,10 @@ /// Creates a [lsp.WorkspaceEdit] from simple [server.SourceFileEdit]s. /// -/// [clientCapabilities] should be for the client that will handle this edit, which -/// is not necessarily the client that triggered the request that called this -/// function (for example a DTD client may call a request that triggers an edit -/// that will be sent to the editor). +/// [clientCapabilities] should be for the client that will handle this edit, +/// which is not necessarily the client that triggered the request that called +/// this function (for example a DTD client may call a request that triggers an +/// edit that will be sent to the editor). /// /// If [annotateChanges] is set, change annotations will be produced and /// marked as needing confirmation from the user (depending on the value). @@ -163,7 +163,7 @@ /// it's important to call this immediately after computing edits to ensure /// the document is not modified before the version number is read. lsp.WorkspaceEdit createPlainWorkspaceEdit( - AnalysisServer server, + AnalysisServer analysisServer, LspClientCapabilities clientCapabilities, List<server.SourceFileEdit> edits, { ChangeAnnotations annotateChanges = ChangeAnnotations.none, @@ -174,14 +174,15 @@ edits .map( (e) => FileEditInformation( - server.getVersionedDocumentIdentifier(e.file), - // If we expect to create the file, server.getLineInfo() won't + analysisServer.getVersionedDocumentIdentifier(e.file), + // If we expect to create the file, `server.getLineInfo()` won't // provide a LineInfo so create one from empty contents. e.fileStamp == -1 ? LineInfo.fromContent('') - : server.getLineInfo(e.file)!, + : analysisServer.getLineInfo(e.file)!, e.edits, - // fileStamp == 1 is used by the server to indicate the file needs creating. + // `fileStamp == 1` is used by the server to indicate the file needs + // creating. newFile: e.fileStamp == -1, ), ) @@ -214,7 +215,7 @@ /// Creates a [lsp.WorkspaceEdit] from a [server.SourceChange]. /// -/// Can return experimental [server.SnippetTextEdit]s if the following are true: +/// Can return experimental [lsp.SnippetTextEdit]s if the following are true: /// - the client has indicated support for in the experimental section of their /// client capabilities, and /// - [allowSnippets] is true, and @@ -225,7 +226,7 @@ /// it's important to call this immediately after computing edits to ensure /// the document is not modified before the version number is read. lsp.WorkspaceEdit createWorkspaceEdit( - AnalysisServer server, + AnalysisServer analysisServer, LspClientCapabilities clientCapabilities, server.SourceChange change, { ChangeAnnotations annotateChanges = ChangeAnnotations.none, @@ -253,7 +254,7 @@ change.edits.single.edits.length != 1 || (change.selection == null && change.linkedEditGroups.isEmpty)) { return createPlainWorkspaceEdit( - server, + analysisServer, clientCapabilities, change.edits, annotateChanges: annotateChanges, @@ -272,7 +273,7 @@ // Compile the edits into a TextDocumentEdit for this file. var textDocumentEdit = lsp.TextDocumentEdit( - textDocument: server.getVersionedDocumentIdentifier(fileEdit.file), + textDocument: analysisServer.getVersionedDocumentIdentifier(fileEdit.file), edits: snippetEdits .map( @@ -873,7 +874,7 @@ /// edits, so [editOffset] must to take into account both the offset of the edit /// _and_ any delta from edits prior to this one in the file. /// -/// [selectionOffset] is also absolute and assumes [edit.replacement] will be +/// [selectionOffset] is also absolute and assumes `edit.replacement` will be /// inserted at [editOffset]. lsp.SnippetTextEdit snippetTextEditFromEditGroups( String filePath, @@ -900,7 +901,8 @@ /// Creates a SnippetTextEdit for an edit with a selection placeholder. /// -/// [selectionOffset] is relative to (and therefore must be within) the edit. +/// [selectionOffsetRelative] is relative to (and therefore must be within) the +/// edit. lsp.SnippetTextEdit snippetTextEditWithSelection( server.LineInfo lineInfo, server.SourceEdit edit, { @@ -1731,7 +1733,7 @@ /// Creates an [lsp.WorkspaceEdit] for [edits]. /// -/// [clientCpabilities] should be for the client that will handle this edit, +/// [clientCapabilities] should be for the client that will handle this edit, /// which is not necessarily the client that triggered the request that called /// this function (for example a DTD client may call a request that triggers an /// edit that will be sent to the editor).
diff --git a/pkg/analysis_server/lib/src/lsp/temporary_overlay_operation.dart b/pkg/analysis_server/lib/src/lsp/temporary_overlay_operation.dart index 6f35d60..4acf203 100644 --- a/pkg/analysis_server/lib/src/lsp/temporary_overlay_operation.dart +++ b/pkg/analysis_server/lib/src/lsp/temporary_overlay_operation.dart
@@ -78,9 +78,9 @@ } /// Locks the server from processing incoming messages until [operation] - /// completes just like [lockRequestsWhile] but additionally provides a - /// function for writing temporary overlays that will be reverted when the - /// operation completes. + /// completes just like [LspAnalysisServer.lockRequestsWhile] but + /// additionally provides a function for writing temporary overlays that will + /// be reverted when the operation completes. /// /// Additionally, sending diagnostics, outlines, etc. are suppressed by the /// temporary overlays and re-enabled after the overlays are restored.
diff --git a/pkg/analysis_server/lib/src/plugin/result_merger.dart b/pkg/analysis_server/lib/src/plugin/result_merger.dart index 17c926d..034c7e3 100644 --- a/pkg/analysis_server/lib/src/plugin/result_merger.dart +++ b/pkg/analysis_server/lib/src/plugin/result_merger.dart
@@ -545,15 +545,15 @@ } /// Return a refactoring feedback composed by merging the refactoring - /// feedbacks in the [partialResultList]. + /// feedbacks in [feedbacks]. /// /// The content of the resulting feedback depends on the kind of feedbacks /// being merged. /// /// Throw an exception if the refactoring feedbacks are of an unhandled type. /// - /// The feedbacks in the [partialResultList] are expected to all be of the - /// same type. If that expectation is violated, and exception might be thrown. + /// The [feedbacks] are expected to all be of the same type. If that + /// expectation is violated, and exception might be thrown. RefactoringFeedback? mergeRefactoringFeedbacks( List<RefactoringFeedback> feedbacks, ) { @@ -702,7 +702,7 @@ /// /// The returned result will contain a merged list of refactoring feedbacks /// (as defined by [mergeRefactoringFeedbacks]) and a merged list of source - /// changes (as defined by [mergeChanges]). + /// changes (as defined by `mergeChanges`). /// /// The returned result will contain the concatenation of the potential edits. /// If two or more plugins produce the same potential edit, then the resulting
diff --git a/pkg/analysis_server/lib/src/protocol_server.dart b/pkg/analysis_server/lib/src/protocol_server.dart index a34e208..f2c6352 100644 --- a/pkg/analysis_server/lib/src/protocol_server.dart +++ b/pkg/analysis_server/lib/src/protocol_server.dart
@@ -477,8 +477,15 @@ } /// Creates a new [Location]. -Location _locationForArgs2(engine.Fragment fragment, engine.SourceRange range) { - var lineInfo = fragment.libraryFragment!.lineInfo; +Location? _locationForArgs2( + engine.Fragment fragment, + engine.SourceRange range, +) { + var libraryFragment = fragment.libraryFragment; + if (libraryFragment == null) { + return null; + } + var lineInfo = libraryFragment.lineInfo; var startLocation = lineInfo.getLocation(range.offset); var endLocation = lineInfo.getLocation(range.end);
diff --git a/pkg/analysis_server/lib/src/services/refactoring/legacy/inline_method.dart b/pkg/analysis_server/lib/src/services/refactoring/legacy/inline_method.dart index 2f14237..662caeb 100644 --- a/pkg/analysis_server/lib/src/services/refactoring/legacy/inline_method.dart +++ b/pkg/analysis_server/lib/src/services/refactoring/legacy/inline_method.dart
@@ -761,14 +761,16 @@ Expression usage = _node; Expression? target; var cascade = false; - if (nodeParent is PrefixedIdentifier) { - var propertyAccess = nodeParent; - usage = propertyAccess; - target = propertyAccess.prefix; + if (nodeParent case PrefixedIdentifier prefixedIdentifier) { + if (prefixedIdentifier.prefix == _node) { + usage = prefixedIdentifier.prefix; + } else { + usage = prefixedIdentifier; + target = prefixedIdentifier.prefix; + } cascade = false; } - if (nodeParent is PropertyAccess) { - var propertyAccess = nodeParent; + if (nodeParent case PropertyAccess propertyAccess) { usage = propertyAccess; target = propertyAccess.realTarget; cascade = propertyAccess.isCascaded;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/legacy/move_file.dart b/pkg/analysis_server/lib/src/services/refactoring/legacy/move_file.dart index fc16cc2..53524b6 100644 --- a/pkg/analysis_server/lib/src/services/refactoring/legacy/move_file.dart +++ b/pkg/analysis_server/lib/src/services/refactoring/legacy/move_file.dart
@@ -16,7 +16,6 @@ import 'package:analyzer/src/dart/analysis/driver.dart'; import 'package:analyzer/src/dart/analysis/search.dart'; import 'package:analyzer/src/dart/ast/ast.dart'; -import 'package:analyzer/src/utilities/extensions/element.dart'; import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart'; import 'package:analyzer_plugin/utilities/range_factory.dart'; import 'package:path/path.dart' as path show posix, Context; @@ -204,8 +203,8 @@ return; } - var element = resolvedUnit.unit.declaredElement; - if (element == null) { + var libraryFragment = resolvedUnit.unit.declaredFragment; + if (libraryFragment == null) { return; } @@ -224,12 +223,12 @@ )); } - var libraryElement = element.library; + var libraryElement = libraryFragment.element; // If this element is a library, handle inbound 'part of' directives which // are not included in `searchEngine.searchReferences` below. - if (element == libraryElement.definingCompilationUnit) { - var libraryResult = await _session.getResolvedLibraryByElement( + if (libraryFragment == libraryElement.firstFragment) { + var libraryResult = await _session.getResolvedLibraryByElement2( libraryElement, ); if (libraryResult is! ResolvedLibraryResult) { @@ -247,7 +246,7 @@ for (var uriString in partOfs) { recordReference( range: range.node(uriString), - sourceFile: result.unit.declaredElement!.source.fullName, + sourceFile: result.unit.declaredFragment!.source.fullName, targetFile: oldPath, quotedUriValue: uriString.literal.lexeme, ); @@ -271,7 +270,7 @@ if (uriValue == null) continue; recordReference( range: range.node(uriString), - sourceFile: element.source.fullName, + sourceFile: libraryFragment.source.fullName, targetFile: pathContext.normalize( pathContext.join(oldDir, _uriToPath(uriValue)), ), @@ -283,7 +282,7 @@ // Finally, locate all other incoming references to this file. var references = await refactoringWorkspace.searchEngine - .searchLibraryFragmentReferences(element.asElement2); + .searchLibraryFragmentReferences(libraryFragment); for (var reference in references) { recordReference( range: reference.range,
diff --git a/pkg/analysis_server/test/analysis/notification_occurrences_test.dart b/pkg/analysis_server/test/analysis/notification_occurrences_test.dart index 873e205..29f8a49 100644 --- a/pkg/analysis_server/test/analysis/notification_occurrences_test.dart +++ b/pkg/analysis_server/test/analysis/notification_occurrences_test.dart
@@ -655,16 +655,13 @@ } Future<void> test_type_dynamic() async { - addTestFile(''' + await assertOccurrences(kind: ElementKind.UNKNOWN, ''' void f() { - dynamic a = 1; - dynamic b = 2; + /*[0*/dynamic/*0]*/ a = 1; + /*[1*/dynamic/*1]*/ b = 2; } -dynamic V = 3; +/*[2*/dynamic/*2]*/ V = 3; '''); - await prepareOccurrences(); - var offset = findOffset('dynamic a'); - findRegion(offset, 'dynamic'.length, exists: false); } Future<void> test_type_void() async {
diff --git a/pkg/analysis_server/test/services/refactoring/legacy/inline_method_test.dart b/pkg/analysis_server/test/services/refactoring/legacy/inline_method_test.dart index c10af04..4c37a5c 100644 --- a/pkg/analysis_server/test/services/refactoring/legacy/inline_method_test.dart +++ b/pkg/analysis_server/test/services/refactoring/legacy/inline_method_test.dart
@@ -1112,6 +1112,23 @@ '''); } + Future<void> test_getter_topLevel_prefixedIdentifier_target() async { + await indexTestUnit(r''' +void f() { + test.isEven; +} + +int get test => [0].first; +'''); + _createRefactoring('test =>'); + // validate change + return _assertSuccessfulRefactoring(r''' +void f() { + [0].first.isEven; +} +'''); + } + Future<void> test_initialMode_all() async { await indexTestUnit(r''' test(a, b) {
diff --git a/pkg/analysis_server_plugin/analyzer_use_new_elements.txt b/pkg/analysis_server_plugin/analyzer_use_new_elements.txt index 84fab9b..e69de29 100644 --- a/pkg/analysis_server_plugin/analyzer_use_new_elements.txt +++ b/pkg/analysis_server_plugin/analyzer_use_new_elements.txt
@@ -1 +0,0 @@ -lib/edit/dart/correction_producer.dart
diff --git a/pkg/analysis_server_plugin/lib/edit/dart/correction_producer.dart b/pkg/analysis_server_plugin/lib/edit/dart/correction_producer.dart index 81e8f29..268865b 100644 --- a/pkg/analysis_server_plugin/lib/edit/dart/correction_producer.dart +++ b/pkg/analysis_server_plugin/lib/edit/dart/correction_producer.dart
@@ -11,7 +11,6 @@ import 'package:analyzer/dart/analysis/analysis_options.dart'; import 'package:analyzer/dart/analysis/code_style_options.dart'; import 'package:analyzer/dart/analysis/results.dart'; -import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/dart/element/nullability_suffix.dart'; import 'package:analyzer/dart/element/type.dart'; @@ -341,10 +340,6 @@ /// The library element for the library in which a correction is being /// produced. - LibraryElement get libraryElement => unitResult.libraryElement; - - /// The library element for the library in which a correction is being - /// produced. LibraryElement2 get libraryElement2 => unitResult.libraryElement2; @override @@ -375,7 +370,7 @@ .getAnalysisOptionsForFile(unitResult.file); InheritanceManager3 get inheritanceManager { - return (libraryElement as LibraryElementImpl).session.inheritanceManager; + return (libraryElement2 as LibraryElementImpl).session.inheritanceManager; } /// Whether [node] is in a static context. @@ -396,10 +391,6 @@ /// The library element for the library in which a correction is being /// produced. - LibraryElement get libraryElement => unitResult.libraryElement; - - /// The library element for the library in which a correction is being - /// produced. LibraryElement2 get libraryElement2 => unitResult.libraryElement2; @override @@ -466,21 +457,6 @@ /// Returns the class element associated with the [target], or `null` if there /// is no such element. - InterfaceElement? getTargetInterfaceElement(Expression target) { - var type = target.staticType; - if (type is InterfaceType) { - return type.element; - } else if (target is Identifier) { - var element = target.staticElement; - if (element is InterfaceElement) { - return element; - } - } - return null; - } - - /// Returns the class element associated with the [target], or `null` if there - /// is no such element. InterfaceElement2? getTargetInterfaceElement2(Expression target) { var type = target.staticType; if (type is InterfaceType) { @@ -512,7 +488,7 @@ if (conditionalExpression.condition == expression) { return _coreTypeBool; } else { - var type = conditionalExpression.staticParameterElement?.type; + var type = conditionalExpression.correspondingParameter?.type; if (type is InterfaceType && type.isDartCoreFunction) { return FunctionTypeImpl( typeFormals: const [], @@ -526,19 +502,19 @@ } // `=> myFunction();`. if (parent is ExpressionFunctionBody) { - var executable = expression.enclosingExecutableElement; + var executable = expression.enclosingExecutableElement2; return executable?.returnType; } // `return myFunction();`. if (parent is ReturnStatement) { - var executable = expression.enclosingExecutableElement; + var executable = expression.enclosingExecutableElement2; return executable?.returnType; } // `int v = myFunction();`. if (parent is VariableDeclaration) { var variableDeclaration = parent; if (variableDeclaration.initializer == expression) { - var variableElement = variableDeclaration.declaredElement; + var variableElement = variableDeclaration.declaredFragment?.element; if (variableElement != null) { return variableElement.type; } @@ -561,9 +537,9 @@ return assignment.writeType; } else { // `v += myFunction();`. - var method = assignment.staticElement; + var method = assignment.element; if (method != null) { - var parameters = method.parameters; + var parameters = method.formalParameters; if (parameters.length == 1) { return parameters[0].type; } @@ -574,17 +550,17 @@ // `v + myFunction();`. if (parent is BinaryExpression) { var binary = parent; - var method = binary.staticElement; + var method = binary.element; if (method != null) { if (binary.rightOperand == expression) { - var parameters = method.parameters; + var parameters = method.formalParameters; return parameters.length == 1 ? parameters[0].type : null; } } } // `foo( myFunction() );`. if (parent is ArgumentList) { - var parameter = expression.staticParameterElement; + var parameter = expression.correspondingParameter; return parameter?.type; } // `bool`.
diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart index 256069b..42e7daf 100644 --- a/pkg/analyzer/lib/src/summary/format.dart +++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -1852,185 +1852,6 @@ String toString() => convert.json.encode(toJson()); } -class AvailableFileBuilder extends Object - with _AvailableFileMixin - implements idl.AvailableFile { - DirectiveInfoBuilder? _directiveInfo; - List<String>? _exports; - List<String>? _parts; - - @override - DirectiveInfoBuilder? get directiveInfo => _directiveInfo; - - /// The Dartdoc directives in the file. - set directiveInfo(DirectiveInfoBuilder? value) { - this._directiveInfo = value; - } - - @override - List<String> get exports => _exports ??= <String>[]; - - /// Exports directives of the file. - set exports(List<String> value) { - this._exports = value; - } - - @override - List<String> get parts => _parts ??= <String>[]; - - /// URIs of `part` directives. - set parts(List<String> value) { - this._parts = value; - } - - AvailableFileBuilder( - {DirectiveInfoBuilder? directiveInfo, - List<String>? exports, - List<String>? parts}) - : _directiveInfo = directiveInfo, - _exports = exports, - _parts = parts; - - /// Flush [informative] data recursively. - void flushInformative() { - _directiveInfo?.flushInformative(); - } - - /// Accumulate non-[informative] data into [signature]. - void collectApiSignature(api_sig.ApiSignature signatureSink) { - signatureSink.addBool(this._directiveInfo != null); - this._directiveInfo?.collectApiSignature(signatureSink); - var exports = this._exports; - if (exports == null) { - signatureSink.addInt(0); - } else { - signatureSink.addInt(exports.length); - for (var x in exports) { - signatureSink.addString(x); - } - } - var parts = this._parts; - if (parts == null) { - signatureSink.addInt(0); - } else { - signatureSink.addInt(parts.length); - for (var x in parts) { - signatureSink.addString(x); - } - } - } - - typed_data.Uint8List toBuffer() { - fb.Builder fbBuilder = fb.Builder(); - return fbBuilder.finish(finish(fbBuilder), "UICF"); - } - - fb.Offset finish(fb.Builder fbBuilder) { - fb.Offset? offset_directiveInfo; - fb.Offset? offset_exports; - fb.Offset? offset_parts; - var directiveInfo = _directiveInfo; - if (directiveInfo != null) { - offset_directiveInfo = directiveInfo.finish(fbBuilder); - } - var exports = _exports; - if (!(exports == null || exports.isEmpty)) { - offset_exports = fbBuilder - .writeList(exports.map((b) => fbBuilder.writeString(b)).toList()); - } - var parts = _parts; - if (!(parts == null || parts.isEmpty)) { - offset_parts = fbBuilder - .writeList(parts.map((b) => fbBuilder.writeString(b)).toList()); - } - fbBuilder.startTable(); - if (offset_directiveInfo != null) { - fbBuilder.addOffset(0, offset_directiveInfo); - } - if (offset_exports != null) { - fbBuilder.addOffset(1, offset_exports); - } - if (offset_parts != null) { - fbBuilder.addOffset(2, offset_parts); - } - return fbBuilder.endTable(); - } -} - -idl.AvailableFile readAvailableFile(List<int> buffer) { - fb.BufferContext rootRef = fb.BufferContext.fromBytes(buffer); - return const _AvailableFileReader().read(rootRef, 0); -} - -class _AvailableFileReader extends fb.TableReader<_AvailableFileImpl> { - const _AvailableFileReader(); - - @override - _AvailableFileImpl createObject(fb.BufferContext bc, int offset) => - _AvailableFileImpl(bc, offset); -} - -class _AvailableFileImpl extends Object - with _AvailableFileMixin - implements idl.AvailableFile { - final fb.BufferContext _bc; - final int _bcOffset; - - _AvailableFileImpl(this._bc, this._bcOffset); - - idl.DirectiveInfo? _directiveInfo; - List<String>? _exports; - List<String>? _parts; - - @override - idl.DirectiveInfo? get directiveInfo { - return _directiveInfo ??= - const _DirectiveInfoReader().vTableGetOrNull(_bc, _bcOffset, 0); - } - - @override - List<String> get exports { - return _exports ??= const fb.ListReader<String>(fb.StringReader()) - .vTableGet(_bc, _bcOffset, 1, const <String>[]); - } - - @override - List<String> get parts { - return _parts ??= const fb.ListReader<String>(fb.StringReader()) - .vTableGet(_bc, _bcOffset, 2, const <String>[]); - } -} - -mixin _AvailableFileMixin implements idl.AvailableFile { - @override - Map<String, Object> toJson() { - Map<String, Object> result = <String, Object>{}; - var local_directiveInfo = directiveInfo; - if (local_directiveInfo != null) { - result["directiveInfo"] = local_directiveInfo.toJson(); - } - var local_exports = exports; - if (local_exports.isNotEmpty) { - result["exports"] = local_exports; - } - var local_parts = parts; - if (local_parts.isNotEmpty) { - result["parts"] = local_parts; - } - return result; - } - - @override - Map<String, Object?> toMap() => { - "directiveInfo": directiveInfo, - "exports": exports, - "parts": parts, - }; - - @override - String toString() => convert.json.encode(toJson()); -} - class CiderUnitErrorsBuilder extends Object with _CiderUnitErrorsMixin implements idl.CiderUnitErrors { @@ -2333,136 +2154,3 @@ @override String toString() => convert.json.encode(toJson()); } - -class DirectiveInfoBuilder extends Object - with _DirectiveInfoMixin - implements idl.DirectiveInfo { - List<String>? _templateNames; - List<String>? _templateValues; - - @override - List<String> get templateNames => _templateNames ??= <String>[]; - - /// The names of the defined templates. - set templateNames(List<String> value) { - this._templateNames = value; - } - - @override - List<String> get templateValues => _templateValues ??= <String>[]; - - /// The values of the defined templates. - set templateValues(List<String> value) { - this._templateValues = value; - } - - DirectiveInfoBuilder( - {List<String>? templateNames, List<String>? templateValues}) - : _templateNames = templateNames, - _templateValues = templateValues; - - /// Flush [informative] data recursively. - void flushInformative() {} - - /// Accumulate non-[informative] data into [signature]. - void collectApiSignature(api_sig.ApiSignature signatureSink) { - var templateNames = this._templateNames; - if (templateNames == null) { - signatureSink.addInt(0); - } else { - signatureSink.addInt(templateNames.length); - for (var x in templateNames) { - signatureSink.addString(x); - } - } - var templateValues = this._templateValues; - if (templateValues == null) { - signatureSink.addInt(0); - } else { - signatureSink.addInt(templateValues.length); - for (var x in templateValues) { - signatureSink.addString(x); - } - } - } - - fb.Offset finish(fb.Builder fbBuilder) { - fb.Offset? offset_templateNames; - fb.Offset? offset_templateValues; - var templateNames = _templateNames; - if (!(templateNames == null || templateNames.isEmpty)) { - offset_templateNames = fbBuilder.writeList( - templateNames.map((b) => fbBuilder.writeString(b)).toList()); - } - var templateValues = _templateValues; - if (!(templateValues == null || templateValues.isEmpty)) { - offset_templateValues = fbBuilder.writeList( - templateValues.map((b) => fbBuilder.writeString(b)).toList()); - } - fbBuilder.startTable(); - if (offset_templateNames != null) { - fbBuilder.addOffset(0, offset_templateNames); - } - if (offset_templateValues != null) { - fbBuilder.addOffset(1, offset_templateValues); - } - return fbBuilder.endTable(); - } -} - -class _DirectiveInfoReader extends fb.TableReader<_DirectiveInfoImpl> { - const _DirectiveInfoReader(); - - @override - _DirectiveInfoImpl createObject(fb.BufferContext bc, int offset) => - _DirectiveInfoImpl(bc, offset); -} - -class _DirectiveInfoImpl extends Object - with _DirectiveInfoMixin - implements idl.DirectiveInfo { - final fb.BufferContext _bc; - final int _bcOffset; - - _DirectiveInfoImpl(this._bc, this._bcOffset); - - List<String>? _templateNames; - List<String>? _templateValues; - - @override - List<String> get templateNames { - return _templateNames ??= const fb.ListReader<String>(fb.StringReader()) - .vTableGet(_bc, _bcOffset, 0, const <String>[]); - } - - @override - List<String> get templateValues { - return _templateValues ??= const fb.ListReader<String>(fb.StringReader()) - .vTableGet(_bc, _bcOffset, 1, const <String>[]); - } -} - -mixin _DirectiveInfoMixin implements idl.DirectiveInfo { - @override - Map<String, Object> toJson() { - Map<String, Object> result = <String, Object>{}; - var local_templateNames = templateNames; - if (local_templateNames.isNotEmpty) { - result["templateNames"] = local_templateNames; - } - var local_templateValues = templateValues; - if (local_templateValues.isNotEmpty) { - result["templateValues"] = local_templateValues; - } - return result; - } - - @override - Map<String, Object?> toMap() => { - "templateNames": templateNames, - "templateValues": templateValues, - }; - - @override - String toString() => convert.json.encode(toJson()); -}
diff --git a/pkg/analyzer/lib/src/summary/format.fbs b/pkg/analyzer/lib/src/summary/format.fbs index d980dd2..1dd1362 100644 --- a/pkg/analyzer/lib/src/summary/format.fbs +++ b/pkg/analyzer/lib/src/summary/format.fbs
@@ -275,18 +275,6 @@ usedNames:[uint] (id: 14); } -/// Information about an available, even if not yet imported file. -table AvailableFile { - /// The Dartdoc directives in the file. - directiveInfo:DirectiveInfo (id: 0); - - /// Exports directives of the file. - exports:[string] (id: 1); - - /// URIs of `part` directives. - parts:[string] (id: 2); -} - /// Errors for a single unit. table CiderUnitErrors { errors:[AnalysisDriverUnitError] (id: 0); @@ -310,15 +298,6 @@ url:string (id: 4); } -/// Information about the Dartdoc directives in an [AvailableFile]. -table DirectiveInfo { - /// The names of the defined templates. - templateNames:[string] (id: 0); - - /// The values of the defined templates. - templateValues:[string] (id: 1); -} - root_type AnalysisDriverResolvedUnit; file_identifier "ADRU";
diff --git a/pkg/analyzer/lib/src/summary/idl.dart b/pkg/analyzer/lib/src/summary/idl.dart index e39f707..255c517 100644 --- a/pkg/analyzer/lib/src/summary/idl.dart +++ b/pkg/analyzer/lib/src/summary/idl.dart
@@ -266,25 +266,6 @@ List<int> get usedNames; } -/// Information about an available, even if not yet imported file. -@TopLevel('UICF') -abstract class AvailableFile extends base.SummaryClass { - factory AvailableFile.fromBuffer(List<int> buffer) => - generated.readAvailableFile(buffer); - - /// The Dartdoc directives in the file. - @Id(0) - DirectiveInfo? get directiveInfo; - - /// Exports directives of the file. - @Id(1) - List<String> get exports; - - /// URIs of `part` directives. - @Id(2) - List<String> get parts; -} - /// Errors for a single unit. @TopLevel('CUEr') abstract class CiderUnitErrors extends base.SummaryClass { @@ -318,17 +299,6 @@ String get url; } -/// Information about the Dartdoc directives in an [AvailableFile]. -abstract class DirectiveInfo extends base.SummaryClass { - /// The names of the defined templates. - @Id(0) - List<String> get templateNames; - - /// The values of the defined templates. - @Id(1) - List<String> get templateValues; -} - /// Enum used to indicate the kind of an index relation. enum IndexRelationKind { /// Left: class.
diff --git a/pkg/analyzer/lib/src/utilities/extensions/ast.dart b/pkg/analyzer/lib/src/utilities/extensions/ast.dart index ae5df27..ebb8eec 100644 --- a/pkg/analyzer/lib/src/utilities/extensions/ast.dart +++ b/pkg/analyzer/lib/src/utilities/extensions/ast.dart
@@ -5,6 +5,7 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/src/dart/element/element.dart'; extension AstNodeExtension on AstNode { @@ -42,6 +43,22 @@ return null; } + /// The [ExecutableElement2] of the enclosing executable [AstNode]. + ExecutableElement2? get enclosingExecutableElement2 { + for (var node in withParents) { + if (node is FunctionDeclaration) { + return node.declaredFragment?.element; + } + if (node is ConstructorDeclaration) { + return node.declaredFragment?.element; + } + if (node is MethodDeclaration) { + return node.declaredFragment?.element; + } + } + return null; + } + AstNode? get enclosingUnitChild { for (var node in withParents) { if (node.parent is CompilationUnit) {
diff --git a/pkg/linter/analyzer_use_new_elements.txt b/pkg/linter/analyzer_use_new_elements.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/pkg/linter/analyzer_use_new_elements.txt
diff --git a/tools/VERSION b/tools/VERSION index b84ff98..aa0faab 100644 --- a/tools/VERSION +++ b/tools/VERSION
@@ -27,5 +27,5 @@ MAJOR 3 MINOR 7 PATCH 0 -PRERELEASE 297 +PRERELEASE 298 PRERELEASE_PATCH 0