Skip to content

Commit

Permalink
[Elements.migrate] Migrate InScopeCompletionPass.
Browse files Browse the repository at this point in the history
Change-Id: I5801f9882487e4f3255d75f5e44b7a5e9fdb3b79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398941
Commit-Queue: Keerti Parthasarathy <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
  • Loading branch information
keertip authored and Commit Queue committed Dec 4, 2024
1 parent da3e12f commit f773702
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 97 deletions.
1 change: 0 additions & 1 deletion pkg/analysis_server/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ lib/src/search/type_hierarchy.dart
lib/src/services/completion/dart/completion_manager.dart
lib/src/services/completion/dart/declaration_helper.dart
lib/src/services/completion/dart/identifier_helper.dart
lib/src/services/completion/dart/in_scope_completion_pass.dart
lib/src/services/completion/dart/visibility_tracker.dart
lib/src/services/correction/dart/import_library.dart
lib/src/services/correction/dart/use_different_division_operator.dart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ class DeclarationHelper {
}
}

/// Add suggestions for all constructors of [element].
void addConstructorNamesForElement2({required InterfaceElement2 element}) {
addConstructorNamesForElement(element: element.asElement);
}

/// Add suggestions for all of the named constructors in the [type]. If
/// [exclude] is not `null` it is the name of a constructor that should be
/// omitted from the list, typically because suggesting it would result in an
Expand Down Expand Up @@ -229,6 +234,11 @@ class DeclarationHelper {
}
}

/// Add suggestions for declarations through [prefixElement].
void addDeclarationsThroughImportPrefix2(PrefixElement2 prefixElement) {
addDeclarationsThroughImportPrefix(prefixElement.asElement);
}

/// Add any fields that can be initialized in the initializer list of the
/// given [constructor]. If a [fieldToInclude] is provided, then it should not
/// be skipped because the cursor is inside that field's name.
Expand Down Expand Up @@ -277,6 +287,19 @@ class DeclarationHelper {
}
}

/// Add any fields that can be initialized in the initializer list of the
/// given [constructor]. If a [fieldToInclude] is provided, then it should not
/// be skipped because the cursor is inside that field's name.
void addFieldsForInitializers2(
ConstructorDeclaration constructor,
FieldElement2? fieldToInclude,
) {
addFieldsForInitializers(
constructor,
fieldToInclude == null ? null : fieldToInclude.asElement as FieldElement,
);
}

/// Add suggestions for all of the top-level declarations that are exported
/// from the [library] except for those whose name is in the set of
/// [excludedNames].
Expand All @@ -288,6 +311,17 @@ class DeclarationHelper {
}
}

/// Add suggestions for all of the top-level declarations that are exported
/// from the [library] except for those whose name is in the set of
/// [excludedNames].
void addFromLibrary2(LibraryElement2 library, Set<String> excludedNames) {
for (var entry in library.exportNamespace.definedNames.entries) {
if (!excludedNames.contains(entry.key)) {
_addImportedElement(entry.value);
}
}
}

/// Adds suggestions for the getters defined by the [type], except for those
/// whose names are in the set of [excludedGetters].
void addGetters({
Expand Down Expand Up @@ -457,6 +491,17 @@ class DeclarationHelper {
}
}

/// Add members from the given [ExtensionElement2].
void addMembersFromExtensionElement2(
ExtensionElement2 extension, {
ImportData? importData,
}) {
addMembersFromExtensionElement(
extension.asElement as ExtensionElement,
importData: importData,
);
}

/// Adds suggestions for any constructors that are visible within the not yet
/// imported [library].
void addNotImportedConstructors(LibraryElement2 library) {
Expand Down Expand Up @@ -599,6 +644,18 @@ class DeclarationHelper {
}
}

/// Add suggestions for all of the constructor in the [library] that could be
/// a redirection target for the [redirectingConstructor].
void addPossibleRedirectionsInLibrary2(
ConstructorElement2 redirectingConstructor,
LibraryElement2 library,
) {
addPossibleRedirectionsInLibrary(
redirectingConstructor.asElement,
library.asElement,
);
}

/// Add any static members defined by the given [element].
void addStaticMembersOfElement(Element element) {
if (element is TypeAliasElement) {
Expand Down Expand Up @@ -638,6 +695,11 @@ class DeclarationHelper {
}
}

/// Add any static members defined by the given [element].
void addStaticMembersOfElement2(Element2 element) {
addStaticMembersOfElement(element.asElement!);
}

/// Adds suggestions for any constructors that are declared within the
/// [library].
void _addConstructors(LibraryElement library, ImportData importData) {
Expand Down
Loading

0 comments on commit f773702

Please sign in to comment.