Version 2.19.0-71.0.dev
Merge commit '0926b13346496c848fa139086ee9836f2dff53a7' into 'dev'
diff --git a/DEPS b/DEPS
index bf153a9..4d9bade 100644
--- a/DEPS
+++ b/DEPS
@@ -108,7 +108,7 @@
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "d7b73536a8079331c888b7da539b80e6825270ea", # manually rev'd
- "dartdoc_rev": "bd57c0e7b7562abda6d556ce5a386b67fb4ff4c7",
+ "dartdoc_rev": "f419695f57c580f30ea142a0f6e13a9e0001b342",
"devtools_rev": "d131d19091f6b89ac89486bd92440a25a523e8b0",
"ffi_rev": "18b2b549d55009ff594600b04705ff6161681e07",
"file_rev": "0132eeedea2933513bf230513a766a8baeab0c4f",
@@ -135,7 +135,7 @@
"path_rev": "9955b27b9bb98d87591208e19eb01c51d29fd467",
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
"pool_rev": "fa84ddd0e39f45bf3f09dcc5d6b9fbdda7820fef",
- "protobuf_rev": "504eefeae9892602ea50c20159db1db3768012a9",
+ "protobuf_rev": "11983dafc42775c56698af06107d626780e9cb69",
"pub_rev": "ac7db6c07318efa4a8712110275eaf70f96a6d00", # manually rev'd
"pub_semver_rev": "9fd28757ba45961ac5449e0f2b0020670e921475",
"root_certificates_rev": "692f6d6488af68e0121317a9c2c9eb393eb0ee50",
diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart
index 26fc108..4e1308d 100644
--- a/pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart
+++ b/pkg/analysis_server/lib/lsp_protocol/protocol_custom_generated.dart
@@ -271,10 +271,6 @@
json, nullLspJsonReporter)) {
return DartNotImportedCompletionResolutionInfo.fromJson(json);
}
- if (DartSuggestionSetCompletionItemResolutionInfo.canParse(
- json, nullLspJsonReporter)) {
- return DartSuggestionSetCompletionItemResolutionInfo.fromJson(json);
- }
if (PubPackageCompletionItemResolutionInfo.canParse(
json, nullLspJsonReporter)) {
return PubPackageCompletionItemResolutionInfo.fromJson(json);
@@ -429,73 +425,6 @@
String toString() => jsonEncoder.convert(toJson());
}
-class DartSuggestionSetCompletionItemResolutionInfo
- implements CompletionItemResolutionInfo, ToJsonable {
- static const jsonHandler = LspJsonHandler(
- DartSuggestionSetCompletionItemResolutionInfo.canParse,
- DartSuggestionSetCompletionItemResolutionInfo.fromJson,
- );
-
- DartSuggestionSetCompletionItemResolutionInfo({
- required this.file,
- required this.libId,
- });
- static DartSuggestionSetCompletionItemResolutionInfo fromJson(
- Map<String, Object?> json) {
- final fileJson = json['file'];
- final file = fileJson as String;
- final libIdJson = json['libId'];
- final libId = libIdJson as int;
- return DartSuggestionSetCompletionItemResolutionInfo(
- file: file,
- libId: libId,
- );
- }
-
- final String file;
- final int libId;
-
- @override
- Map<String, Object?> toJson() {
- var result = <String, Object?>{};
- result['file'] = file;
- result['libId'] = libId;
- return result;
- }
-
- static bool canParse(Object? obj, LspJsonReporter reporter) {
- if (obj is Map<String, Object?>) {
- if (!_canParseString(obj, reporter, 'file',
- allowsUndefined: false, allowsNull: false)) {
- return false;
- }
- return _canParseInt(obj, reporter, 'libId',
- allowsUndefined: false, allowsNull: false);
- } else {
- reporter.reportError(
- 'must be of type DartSuggestionSetCompletionItemResolutionInfo');
- return false;
- }
- }
-
- @override
- bool operator ==(Object other) {
- return other is DartSuggestionSetCompletionItemResolutionInfo &&
- other.runtimeType == DartSuggestionSetCompletionItemResolutionInfo &&
- file == other.file &&
- libId == other.libId;
- }
-
- @override
- int get hashCode => Object.hash(
- file,
- libId,
- );
-
- @override
- String toString() => jsonEncoder.convert(toJson());
-}
-
class Element implements ToJsonable {
static const jsonHandler = LspJsonHandler(
Element.canParse,
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index b933373..4225e8c 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -11,6 +11,7 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/file_system/overlay_file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
@@ -138,8 +139,9 @@
/// Class that maintains a mapping from included/excluded paths to a set of
/// folders that should correspond to analysis contexts.
class ContextManagerImpl implements ContextManager {
- /// The [ResourceProvider] using which paths are converted into [Resource]s.
- final ResourceProvider resourceProvider;
+ /// The [OverlayResourceProvider] used to check for the existence of overlays
+ /// and to convert paths into [Resource].
+ final OverlayResourceProvider resourceProvider;
/// The manager used to access the SDK that should be associated with a
/// particular context.
@@ -738,7 +740,12 @@
}
var collection = _collection;
- if (collection != null && file_paths.isDart(pathContext, path)) {
+ if (collection != null &&
+ file_paths.isDart(pathContext, path) &&
+ // If this resource has an overlay, then the change on disk will never
+ // affect analysis results so can be skipped. Removing the overlay will
+ // re-read the contents from disk.
+ !resourceProvider.hasOverlay(path)) {
for (var analysisContext in collection.contexts) {
switch (type) {
case ChangeType.ADD:
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 956e51e..1145a54 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
@@ -5,8 +5,6 @@
import 'dart:math' as math;
import 'package:analysis_server/lsp_protocol/protocol.dart' hide Declaration;
-import 'package:analysis_server/protocol/protocol_generated.dart';
-import 'package:analysis_server/src/domains/completion/available_suggestions.dart';
import 'package:analysis_server/src/lsp/client_capabilities.dart';
import 'package:analysis_server/src/lsp/handlers/handlers.dart';
import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
@@ -25,7 +23,6 @@
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/dart/ast/ast.dart' as ast;
import 'package:analyzer/source/line_info.dart';
-import 'package:analyzer/src/services/available_declarations.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer/src/util/performance/operation_performance.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
@@ -38,10 +35,6 @@
/// Whether to include symbols from libraries that have not been imported.
final bool suggestFromUnimportedLibraries;
- /// Whether to use [NotImportedContributor] instead of SuggestionSets to
- /// build completions for not-yet-imported libraries.
- final bool previewNotImportedCompletions;
-
/// The budget to use for [NotImportedContributor] computation.
///
/// This is usually the default value, but can be overridden via
@@ -59,8 +52,8 @@
CancelableToken? previousRequestCancellationToken;
CompletionHandler(super.server, LspInitializationOptions options)
- : suggestFromUnimportedLibraries = options.suggestFromUnimportedLibraries,
- previewNotImportedCompletions = options.previewNotImportedCompletions {
+ : suggestFromUnimportedLibraries =
+ options.suggestFromUnimportedLibraries {
final budgetMs = options.completionBudgetMilliseconds;
completionBudgetDuration = budgetMs != null
? Duration(milliseconds: budgetMs)
@@ -232,35 +225,6 @@
));
}
- /// Build a list of existing imports so we can filter out any suggestions
- /// that resolve to the same underlying declared symbol.
- /// Map with key "elementName/elementDeclaringLibraryUri"
- /// Value is a set of imported URIs that import that element.
- Map<String, Set<String>> _buildLookupOfImportedSymbols(
- ResolvedUnitResult unit) {
- final alreadyImportedSymbols = <String, Set<String>>{};
- final importElementList = unit.libraryElement.libraryImports;
- for (var import in importElementList) {
- final importedLibrary = import.importedLibrary;
- if (importedLibrary == null) continue;
-
- for (var element in import.namespace.definedNames.values) {
- final librarySource = element.librarySource;
- final elementName = element.name;
- if (librarySource != null && elementName != null) {
- final declaringLibraryUri = librarySource.uri;
-
- final key =
- _createImportedSymbolKey(elementName, declaringLibraryUri);
- alreadyImportedSymbols
- .putIfAbsent(key, () => <String>{})
- .add('${importedLibrary.librarySource.uri}');
- }
- }
- }
- return alreadyImportedSymbols;
- }
-
/// The insert length is the shorter of the replacementLength or the
/// difference between the replacementOffset and the caret position.
int _computeInsertLength(
@@ -272,9 +236,6 @@
return insertLength;
}
- String _createImportedSymbolKey(String name, Uri declaringUri) =>
- '$name/$declaringUri';
-
Future<Iterable<CompletionItem>> _getDartSnippetItems({
required LspClientCapabilities clientCapabilities,
required ResolvedUnitResult unit,
@@ -332,12 +293,8 @@
String? triggerCharacter,
CancellationToken token,
) async {
- final useSuggestionSets = suggestFromUnimportedLibraries &&
- capabilities.applyEdit &&
- !previewNotImportedCompletions;
- final useNotImportedCompletions = suggestFromUnimportedLibraries &&
- capabilities.applyEdit &&
- previewNotImportedCompletions;
+ final useNotImportedCompletions =
+ suggestFromUnimportedLibraries && capabilities.applyEdit;
final completionRequest = DartCompletionRequest.forResolvedUnit(
resolvedUnit: unit,
@@ -355,15 +312,8 @@
}
}
- Set<ElementKind>? includedElementKinds;
- Set<String>? includedElementNames;
- List<IncludedSuggestionRelevanceTag>? includedSuggestionRelevanceTags;
NotImportedSuggestions? notImportedSuggestions;
- if (useSuggestionSets) {
- includedElementKinds = <ElementKind>{};
- includedElementNames = <String>{};
- includedSuggestionRelevanceTags = <IncludedSuggestionRelevanceTag>[];
- } else if (useNotImportedCompletions) {
+ if (useNotImportedCompletions) {
notImportedSuggestions = NotImportedSuggestions();
}
@@ -373,9 +323,6 @@
await performance.runAsync('computeSuggestions', (performance) async {
var contributor = DartCompletionManager(
budget: CompletionBudget(completionBudgetDuration),
- includedElementKinds: includedElementKinds,
- includedElementNames: includedElementNames,
- includedSuggestionRelevanceTags: includedSuggestionRelevanceTags,
notImportedSuggestions: notImportedSuggestions,
);
@@ -473,115 +420,6 @@
.toList();
});
- // Now compute items in suggestion sets.
- var includedSuggestionSets = <IncludedSuggestionSet>[];
- final declarationsTracker = server.declarationsTracker;
- if (declarationsTracker != null &&
- includedElementKinds != null &&
- includedElementNames != null &&
- includedSuggestionRelevanceTags != null) {
- performance.run('computeIncludedSetList', (performance) {
- // Checked in `if` above.
- includedElementNames!;
-
- computeIncludedSetList(
- declarationsTracker,
- completionRequest,
- includedSuggestionSets,
- includedElementNames,
- );
- });
-
- // Build a fast lookup for imported symbols so that we can filter out
- // duplicates.
- final alreadyImportedSymbols =
- performance.run('_buildLookupOfImportedSymbols', (performance) {
- return _buildLookupOfImportedSymbols(unit);
- });
-
- /// Helper to check existing imports to ensure we don't already import
- /// this element (this exact element from its declaring
- /// library, not just something with the same name). If we do
- /// we'll want to skip it.
- bool isNotImportedOrLibraryIsFirst(Declaration item, Library library) {
- final declaringUri =
- item.parent?.locationLibraryUri ?? item.locationLibraryUri!;
-
- // For enums and named constructors, only the parent enum/class is in
- // the list of imported symbols so we use the parents name.
- final nameKey = item.kind == DeclarationKind.ENUM_CONSTANT ||
- item.kind == DeclarationKind.CONSTRUCTOR
- ? item.parent!.name
- : item.name;
- final key = _createImportedSymbolKey(nameKey, declaringUri);
- final importingUris = alreadyImportedSymbols[key];
-
- // Keep it only if:
- // - no existing imports include it
- // (in which case all libraries will be offered as
- // auto-imports)
- // - this is the first imported URI that includes it
- // (we don't want to repeat it for each imported library that
- // includes it)
- return importingUris == null ||
- importingUris.first == '${library.uri}';
- }
-
- /// Helper to filter to only the kinds we should return.
- bool shouldIncludeKind(Declaration item) =>
- includedElementKinds!.contains(protocolElementKind(item.kind));
-
- // Only specific types of child declarations should be included.
- // This list matches what's in _protocolAvailableSuggestion in
- // the DAS implementation.
- bool shouldIncludeChild(Declaration child) =>
- child.kind == DeclarationKind.CONSTRUCTOR ||
- child.kind == DeclarationKind.ENUM_CONSTANT;
-
- performance.run('addIncludedSuggestionSets', (performance) {
- // Checked in `if` above.
- includedSuggestionRelevanceTags!;
-
- // Make a fast lookup for tag relevance.
- final tagBoosts = <String, int>{};
- for (final t in includedSuggestionRelevanceTags) {
- tagBoosts[t.tag] = t.relevanceBoost;
- }
-
- for (final includedSet in includedSuggestionSets) {
- final library = declarationsTracker.getLibrary(includedSet.id);
- if (library == null) {
- break;
- }
-
- // Collect declarations and their children.
- final setResults = library.declarations
- .followedBy(library.declarations
- .expand((decl) => decl.children.where(shouldIncludeChild)))
- .where(fuzzy.declarationMatches)
- .where(shouldIncludeKind)
- .where((Declaration item) =>
- isNotImportedOrLibraryIsFirst(item, library))
- .map((item) => declarationToCompletionItem(
- capabilities,
- unit.path,
- includedSet,
- library,
- tagBoosts,
- unit.lineInfo,
- item,
- completionRequest.replacementOffset,
- insertLength,
- completionRequest.replacementLength,
- commitCharactersEnabled: server
- .clientConfiguration.global.previewCommitCharacters,
- completeFunctionCalls: completeFunctionCalls,
- ));
- rankedResults.addAll(setResults);
- }
- });
- }
-
// Add in any snippets.
final snippetsEnabled =
server.clientConfiguration.forResource(unit.path).enableSnippets;
@@ -873,7 +711,4 @@
bool completionSuggestionMatches(CompletionSuggestion item) =>
_matcher.score(item.displayText ?? item.completion) > 0;
-
- bool declarationMatches(Declaration item) =>
- _matcher.score(getDeclarationName(item)) > 0;
}
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart
index 93b22ad..87a6347 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart
@@ -38,9 +38,7 @@
) async {
final resolutionInfo = params.data;
- if (resolutionInfo is DartSuggestionSetCompletionItemResolutionInfo) {
- return resolveDartSuggestionSetCompletion(params, resolutionInfo, token);
- } else if (resolutionInfo is DartNotImportedCompletionResolutionInfo) {
+ if (resolutionInfo is DartNotImportedCompletionResolutionInfo) {
return resolveDartNotImportedCompletion(params, resolutionInfo, token);
} else if (resolutionInfo is PubPackageCompletionItemResolutionInfo) {
return resolvePubPackageCompletion(params, resolutionInfo, token);
@@ -198,35 +196,6 @@
);
}
- Future<ErrorOr<CompletionItem>> resolveDartSuggestionSetCompletion(
- CompletionItem item,
- DartSuggestionSetCompletionItemResolutionInfo data,
- CancellationToken token,
- ) async {
- final clientCapabilities = server.clientCapabilities;
- if (clientCapabilities == null) {
- // This should not happen unless a client misbehaves.
- return serverNotInitializedError;
- }
-
- var library = server.declarationsTracker?.getLibrary(data.libId);
- if (library == null) {
- return error(
- ErrorCodes.InvalidParams,
- 'Library ID is not valid: ${data.libId}',
- data.libId.toString(),
- );
- }
-
- return resolveDartCompletion(
- item,
- clientCapabilities,
- token,
- file: data.file,
- libraryUri: library.uri,
- );
- }
-
Future<ErrorOr<CompletionItem>> resolvePubPackageCompletion(
CompletionItem item,
PubPackageCompletionItemResolutionInfo data,
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 e7f0ca9..465363d 100644
--- a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
+++ b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
@@ -931,7 +931,6 @@
class LspInitializationOptions {
final bool onlyAnalyzeProjectsWithOpenFiles;
- final bool previewNotImportedCompletions;
final bool suggestFromUnimportedLibraries;
final bool closingLabels;
final bool outline;
@@ -941,10 +940,6 @@
LspInitializationOptions(dynamic options)
: onlyAnalyzeProjectsWithOpenFiles = options != null &&
options['onlyAnalyzeProjectsWithOpenFiles'] == true,
- // Undocumented preview flag to allow easy testing of not imported
- // completion contributor.
- previewNotImportedCompletions =
- options != null && options['previewNotImportedCompletions'] == true,
// suggestFromUnimportedLibraries defaults to true, so must be
// explicitly passed as false to disable.
suggestFromUnimportedLibraries = options == null ||
diff --git a/pkg/analysis_server/lib/src/lsp/mapping.dart b/pkg/analysis_server/lib/src/lsp/mapping.dart
index 34e7274..90a335f 100644
--- a/pkg/analysis_server/lib/src/lsp/mapping.dart
+++ b/pkg/analysis_server/lib/src/lsp/mapping.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
-import 'dart:math';
import 'package:analysis_server/lsp_protocol/protocol.dart' hide Declaration;
import 'package:analysis_server/lsp_protocol/protocol.dart' as lsp;
@@ -26,8 +25,6 @@
import 'package:analyzer/src/dart/analysis/search.dart' as server
show DeclarationKind;
import 'package:analyzer/src/error/codes.dart';
-import 'package:analyzer/src/services/available_declarations.dart';
-import 'package:analyzer/src/services/available_declarations.dart' as dec;
import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin;
import 'package:analyzer_plugin/utilities/pair.dart';
import 'package:collection/collection.dart';
@@ -173,48 +170,6 @@
return lsp.WorkspaceEdit(documentChanges: [textDocumentEditsAsUnion]);
}
-lsp.CompletionItemKind? declarationKindToCompletionItemKind(
- Set<lsp.CompletionItemKind> supportedCompletionKinds,
- dec.DeclarationKind kind,
-) {
- bool isSupported(lsp.CompletionItemKind kind) =>
- supportedCompletionKinds.contains(kind);
-
- List<lsp.CompletionItemKind> getKindPreferences() {
- switch (kind) {
- case dec.DeclarationKind.CLASS:
- case dec.DeclarationKind.CLASS_TYPE_ALIAS:
- case dec.DeclarationKind.MIXIN:
- return const [lsp.CompletionItemKind.Class];
- case dec.DeclarationKind.CONSTRUCTOR:
- return const [lsp.CompletionItemKind.Constructor];
- case dec.DeclarationKind.ENUM:
- return const [lsp.CompletionItemKind.Enum];
- case dec.DeclarationKind.ENUM_CONSTANT:
- return const [
- lsp.CompletionItemKind.EnumMember,
- lsp.CompletionItemKind.Enum,
- ];
- case dec.DeclarationKind.FUNCTION:
- return const [lsp.CompletionItemKind.Function];
- case dec.DeclarationKind.FUNCTION_TYPE_ALIAS:
- return const [lsp.CompletionItemKind.Class];
- case dec.DeclarationKind.GETTER:
- return const [lsp.CompletionItemKind.Property];
- case dec.DeclarationKind.SETTER:
- return const [lsp.CompletionItemKind.Property];
- case dec.DeclarationKind.TYPE_ALIAS:
- return const [lsp.CompletionItemKind.Class];
- case dec.DeclarationKind.VARIABLE:
- return const [lsp.CompletionItemKind.Variable];
- default:
- return const [];
- }
- }
-
- return getKindPreferences().firstWhereOrNull(isSupported);
-}
-
lsp.SymbolKind declarationKindToSymbolKind(
Set<lsp.SymbolKind> supportedSymbolKinds,
server.DeclarationKind? kind,
@@ -266,125 +221,6 @@
.firstWhere(isSupported, orElse: () => lsp.SymbolKind.Obj);
}
-lsp.CompletionItem declarationToCompletionItem(
- LspClientCapabilities capabilities,
- String file,
- server.IncludedSuggestionSet includedSuggestionSet,
- Library library,
- Map<String, int> tagBoosts,
- server.LineInfo lineInfo,
- dec.Declaration declaration,
- int replacementOffset,
- int insertLength,
- int replacementLength, {
- required bool commitCharactersEnabled,
- required bool completeFunctionCalls,
-}) {
- final supportsSnippets = capabilities.completionSnippets;
-
- // By default, label is the same as the completion text, but may be added to
- // later (parens/snippets).
- final completion = getDeclarationName(declaration);
- var label = completion;
-
- // isCallable is used to suffix the label with parens so it's clear the item
- // is callable.
- final declarationKind = declaration.kind;
- final isCallable = declarationKind == DeclarationKind.CONSTRUCTOR ||
- declarationKind == DeclarationKind.FUNCTION ||
- declarationKind == DeclarationKind.METHOD;
-
- if (isCallable) {
- label += declaration.parameterNames?.isNotEmpty ?? false ? '(…)' : '()';
- }
-
- final insertionRange = toRange(lineInfo, replacementOffset, insertLength);
- final replacementRange =
- toRange(lineInfo, replacementOffset, replacementLength);
-
- final insertTextInfo = _buildInsertText(
- supportsSnippets: supportsSnippets,
- commitCharactersEnabled: commitCharactersEnabled,
- completeFunctionCalls: completeFunctionCalls,
- isCallable: isCallable,
- // For SuggestionSets, we don't have a CompletionKind to check if it's
- // an invocation, but since they do not show in show/hide combinators
- // we can assume if an item is callable it's probably being used in a context
- // that can invoke it.
- isInvocation: isCallable,
- requiredArgumentListString: declaration.defaultArgumentListString,
- requiredArgumentListTextRanges: declaration.defaultArgumentListTextRanges,
- hasOptionalParameters: declaration.parameterNames?.isNotEmpty ?? false,
- completion: completion,
- selectionOffset: 0,
- selectionLength: 0,
- );
- final insertText = insertTextInfo.first;
- final insertTextFormat = insertTextInfo.last;
- final isMultilineCompletion = insertText.contains('\n');
-
- final supportsDeprecatedFlag = capabilities.completionDeprecatedFlag;
- final supportsDeprecatedTag = capabilities.completionItemTags
- .contains(lsp.CompletionItemTag.Deprecated);
- final supportsAsIsInsertMode =
- capabilities.completionInsertTextModes.contains(InsertTextMode.asIs);
- final supportsInsertReplace = capabilities.insertReplaceCompletionRanges;
-
- final completionKind = declarationKindToCompletionItemKind(
- capabilities.completionItemKinds, declaration.kind);
-
- var relevanceBoost = 0;
- for (var t in declaration.relevanceTags) {
- relevanceBoost = max(relevanceBoost, tagBoosts[t] ?? 0);
- }
- final itemRelevance = includedSuggestionSet.relevance + relevanceBoost;
-
- // Because we potentially send thousands of these items, we should minimise
- // the generated JSON as much as possible - for example using nulls in place
- // of empty lists/false where possible.
- return lsp.CompletionItem(
- label: label,
- kind: completionKind,
- tags: nullIfEmpty([
- if (supportsDeprecatedTag && declaration.isDeprecated)
- lsp.CompletionItemTag.Deprecated
- ]),
- detail: getDeclarationCompletionDetail(declaration, completionKind,
- supportsDeprecatedFlag || supportsDeprecatedTag),
- deprecated:
- supportsDeprecatedFlag && declaration.isDeprecated ? true : null,
- sortText: relevanceToSortText(itemRelevance),
- filterText: completion != label
- ? completion
- : null, // filterText uses label if not set
- insertTextFormat: insertTextFormat != lsp.InsertTextFormat.PlainText
- ? insertTextFormat
- : null, // Defaults to PlainText if not supplied
- insertTextMode: supportsAsIsInsertMode && isMultilineCompletion
- ? InsertTextMode.asIs
- : null,
- textEdit: supportsInsertReplace && insertionRange != replacementRange
- ? Either2<InsertReplaceEdit, TextEdit>.t1(
- InsertReplaceEdit(
- insert: insertionRange,
- replace: replacementRange,
- newText: insertText,
- ),
- )
- : Either2<InsertReplaceEdit, TextEdit>.t2(
- TextEdit(
- range: replacementRange,
- newText: insertText,
- ),
- ),
- // data, used for completionItem/resolve.
- data: lsp.DartSuggestionSetCompletionItemResolutionInfo(
- file: file,
- libId: includedSuggestionSet.id,
- ),
- );
-}
-
lsp.CompletionItemKind? elementKindToCompletionItemKind(
Set<lsp.CompletionItemKind> supportedCompletionKinds,
server.ElementKind kind,
@@ -575,74 +411,6 @@
}
}
-String? getDeclarationCompletionDetail(
- dec.Declaration declaration,
- lsp.CompletionItemKind? completionKind,
- bool supportsDeprecated,
-) {
- final parameters = declaration.parameters;
- final hasParameters = parameters != null && parameters.isNotEmpty;
- final returnType = declaration.returnType;
- final hasReturnType = returnType != null && returnType.isNotEmpty;
-
- final prefix =
- supportsDeprecated || !declaration.isDeprecated ? '' : '(Deprecated) ';
-
- if (completionKind == lsp.CompletionItemKind.Property) {
- // Setters appear as methods with one arg but they also cause getters to not
- // appear in the completion list, so displaying them as setters is misleading.
- // To avoid this, always show only the return type, whether it's a getter
- // or a setter.
- var suffix = '';
- if (declaration.kind == dec.DeclarationKind.GETTER) {
- suffix = declaration.returnType ?? '';
- } else {
- // Don't assume setters always have parameters
- // See https://github.com/dart-lang/sdk/issues/27747
- if (parameters != null && parameters.isNotEmpty) {
- // Extract the type part from `(MyType value)`, if there is a type.
- var spaceIndex = parameters.lastIndexOf(' ');
- if (spaceIndex > 0) {
- suffix = parameters.substring(1, spaceIndex);
- }
- }
- }
- return prefix + suffix;
- } else if (hasParameters && hasReturnType) {
- return '$prefix${declaration.parameters} → ${declaration.returnType}';
- } else if (hasReturnType) {
- return '$prefix${declaration.returnType}';
- } else {
- return prefix.isNotEmpty ? prefix : null;
- }
-}
-
-String getDeclarationName(Declaration declaration) {
- final parent = declaration.parent;
- String completion;
- switch (declaration.kind) {
- case DeclarationKind.ENUM_CONSTANT:
- completion = '${parent!.name}.${declaration.name}';
- break;
- case DeclarationKind.GETTER:
- case DeclarationKind.FIELD:
- completion = parent != null && parent.name.isNotEmpty
- ? '${parent.name}.${declaration.name}'
- : declaration.name;
- break;
- case DeclarationKind.CONSTRUCTOR:
- completion = parent!.name;
- if (declaration.name.isNotEmpty) {
- completion += '.${declaration.name}';
- }
- break;
- default:
- completion = declaration.name;
- break;
- }
- return completion;
-}
-
List<lsp.DiagnosticTag>? getDiagnosticTags(
Set<lsp.DiagnosticTag>? supportedTags, plugin.AnalysisError error) {
if (supportedTags == null) {
diff --git a/pkg/analysis_server/test/lsp/completion_dart_test.dart b/pkg/analysis_server/test/lsp/completion_dart_test.dart
index 9684d3f..a777674 100644
--- a/pkg/analysis_server/test/lsp/completion_dart_test.dart
+++ b/pkg/analysis_server/test/lsp/completion_dart_test.dart
@@ -35,7 +35,6 @@
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(CompletionTest);
- defineReflectiveTests(CompletionWithPreviewNotImportedCompletionsTest);
defineReflectiveTests(DartSnippetCompletionTest);
defineReflectiveTests(FlutterSnippetCompletionTest);
defineReflectiveTests(FlutterSnippetCompletionWithoutNullSafetyTest);
@@ -45,9 +44,8 @@
@reflectiveTest
class CompletionTest extends AbstractLspAnalysisServerTest
with CompletionTestMixin {
- CompletionTest({bool previewNotImportedCompletions = false}) {
+ CompletionTest() {
defaultInitializationOptions = {
- 'previewNotImportedCompletions': previewNotImportedCompletions,
// Default to a high budget for tests because everything is cold and
// may take longer to return.
'completionBudgetMilliseconds': 50000
@@ -2329,12 +2327,6 @@
}
Future<void> test_unimportedSymbols_isIncompleteSetIfBudgetExhausted() async {
- // This test only applies to notImportedCompletions because the completion
- // will not be truncated due to exhausted budget for suggestion sets.
- if (this is! CompletionWithPreviewNotImportedCompletionsTest) {
- return;
- }
-
newFile(
join(projectFolderPath, 'lib', 'other_file.dart'),
'class InOtherFile {}',
@@ -2678,12 +2670,6 @@
}
@reflectiveTest
-class CompletionWithPreviewNotImportedCompletionsTest extends CompletionTest {
- CompletionWithPreviewNotImportedCompletionsTest()
- : super(previewNotImportedCompletions: true);
-}
-
-@reflectiveTest
class DartSnippetCompletionTest extends SnippetCompletionTest {
Future<void> test_snippets_class() async {
final content = '''
diff --git a/pkg/analysis_server/tool/lsp_spec/generate_all.dart b/pkg/analysis_server/tool/lsp_spec/generate_all.dart
index 9bf5828..c13c828 100644
--- a/pkg/analysis_server/tool/lsp_spec/generate_all.dart
+++ b/pkg/analysis_server/tool/lsp_spec/generate_all.dart
@@ -295,16 +295,6 @@
[],
),
interface(
- 'DartSuggestionSetCompletionItemResolutionInfo',
- [
- // These fields have short-ish names because they're on the payload
- // for all suggestion-set backed completions.
- field('file', type: 'string'),
- field('libId', type: 'int'),
- ],
- baseType: 'CompletionItemResolutionInfo',
- ),
- interface(
'DartNotImportedCompletionResolutionInfo',
[
field(
diff --git a/tools/VERSION b/tools/VERSION
index adb3629..cf00c49 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 19
PATCH 0
-PRERELEASE 70
+PRERELEASE 71
PRERELEASE_PATCH 0
\ No newline at end of file