Skip to content

Commit

Permalink
Version 3.6.0-206.0.dev
Browse files Browse the repository at this point in the history
Merge 8de1422 into dev
  • Loading branch information
Dart CI committed Sep 1, 2024
2 parents 1b20c24 + 8de1422 commit f412b5e
Show file tree
Hide file tree
Showing 184 changed files with 1,111 additions and 642 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor<void> {
if (element.isOperator) {
return;
}
if (element.enclosingElement is! CompilationUnitElement) {
if (element.enclosingElement3 is! CompilationUnitElement) {
return;
}
var returnType = element.returnType;
Expand Down Expand Up @@ -134,7 +134,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor<void> {
(opType.includeAnnotationSuggestions &&
variable != null &&
variable.isConst)) {
var parent = element.enclosingElement;
var parent = element.enclosingElement3;
if (parent is InterfaceElement || parent is ExtensionElement) {
if (element.isSynthetic) {
if (element.isGetter) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/analysis_server/lib/src/cider/rename.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CanRenameResponse {

void _analyzePossibleConflicts(
ConstructorElement element, RefactoringStatus result, String newName) {
var parentClass = element.enclosingElement;
var parentClass = element.enclosingElement3;
// Check if the "newName" is the name of the enclosing class.
if (parentClass.name == newName) {
result.addError('The constructor should not have the same name '
Expand Down Expand Up @@ -254,8 +254,8 @@ class CheckNameResponse {
var stateName = flutterState.newName;
var match = await canRename._fileResolver.findReferences2(stateClass);
var sourcePath = stateClass.source.fullName;
var location =
stateClass.enclosingElement.lineInfo.getLocation(stateClass.nameOffset);
var location = stateClass.enclosingElement3.lineInfo
.getLocation(stateClass.nameOffset);
CiderSearchMatch ciderMatch;
var searchInfo =
CiderSearchInfo(location, stateClass.nameLength, MatchKind.DECLARATION);
Expand Down Expand Up @@ -297,7 +297,7 @@ class CheckNameResponse {

Future<CiderReplaceMatch?> _replaceSyntheticConstructor() async {
var element = canRename.refactoringElement.element;
var interfaceElement = element.enclosingElement;
var interfaceElement = element.enclosingElement3;

var fileResolver = canRename._fileResolver;
var libraryPath = interfaceElement!.library!.source.fullName;
Expand Down Expand Up @@ -382,7 +382,7 @@ class CiderRenameComputer {
}

bool _canRenameElement(Element element) {
var enclosingElement = element.enclosingElement;
var enclosingElement = element.enclosingElement3;
if (element is ConstructorElement) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class CallHierarchyItem {
codeRange = _codeRangeForElement(element),
file = element.source!.fullName,
kind = CallHierarchyKind.forElement(element) {
var enclosingElement = element.enclosingElement;
var enclosingElement = element.enclosingElement3;
var container =
enclosingElement != null ? _getContainer(enclosingElement) : null;
containerName = container != null ? _getDisplayName(container) : null;
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/computer/computer_color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ColorComputer {

var constructor = expression.constructorName;
var staticElement = constructor.staticElement;
var classElement = staticElement?.enclosingElement;
var classElement = staticElement?.enclosingElement3;
var className = classElement?.name;
var constructorName = constructor.name?.name;
var constructorArgs = expression.argumentList.arguments
Expand Down
4 changes: 2 additions & 2 deletions pkg/analysis_server/lib/src/computer/computer_highlights.dart
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class DartUnitHighlightsComputer {
var isInvocation =
parent is MethodInvocation && parent.methodName.token == nameToken;
HighlightRegionType type;
var isTopLevel = element.enclosingElement is CompilationUnitElement;
var isTopLevel = element.enclosingElement3 is CompilationUnitElement;
type = isTopLevel
? isInvocation
? HighlightRegionType.TOP_LEVEL_FUNCTION_REFERENCE
Expand All @@ -357,7 +357,7 @@ class DartUnitHighlightsComputer {
return false;
}
// getter or setter
var isTopLevel = element.enclosingElement is CompilationUnitElement;
var isTopLevel = element.enclosingElement3 is CompilationUnitElement;
HighlightRegionType type;
if (element.isGetter) {
if (isTopLevel) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/analysis_server/lib/src/computer/computer_hover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class DartUnitHoverComputer {
hover.elementKind = element.kind.displayName;
hover.isDeprecated = element.hasDeprecated;
// not local element
if (element.enclosingElement is! ExecutableElement) {
if (element.enclosingElement3 is! ExecutableElement) {
// containing class
hover.containingClassDescription = _containingClass(element);
// containing library
Expand Down Expand Up @@ -267,7 +267,7 @@ class DartUnitHoverComputer {
/// incorrect types to be shown and so we stick with the synthetic getter.
bool _useNonSyntheticElement(Element element) {
return element is PropertyAccessorElement &&
!(element.enclosingElement is EnumElement &&
!(element.enclosingElement3 is EnumElement &&
element.name == 'values' &&
element.isSynthetic);
}
Expand All @@ -282,7 +282,7 @@ class DartUnitHoverComputer {
element = element.field;
}
if (element is ParameterElement) {
element = element.enclosingElement;
element = element.enclosingElement3;
}
if (element == null) {
// This can happen when the code is invalid, such as having a field formal
Expand Down Expand Up @@ -330,9 +330,9 @@ class DartUnitHoverComputer {
var result =
dartdocInfo.processDartdoc(rawDoc, includeSummary: includeSummary);

var documentedElementClass = documentedElement.enclosingElement;
var documentedElementClass = documentedElement.enclosingElement3;
if (documentedElementClass != null &&
documentedElementClass != element.enclosingElement) {
documentedElementClass != element.enclosingElement3) {
var documentedClass = documentedElementClass.displayName;
result.full = '${result.full}\n\nCopied from `$documentedClass`.';
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/computer/computer_outline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class _FunctionBodyOutlinesVisitor extends RecursiveAstVisitor<void> {
/// Return `true` if the given [element] is a top-level member of the test
/// package.
bool _isInsideTestPackage(engine.FunctionElement element) {
var parent = element.enclosingElement;
var parent = element.enclosingElement3;
return parent is engine.CompilationUnitElement &&
parent.source.fullName.endsWith('test.dart');
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/analysis_server/lib/src/computer/computer_overrides.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:analyzer/dart/element/element.dart';

/// Return the elements that the given [element] overrides.
OverriddenElements findOverriddenElements(Element element) {
if (element.enclosingElement is InterfaceElement) {
if (element.enclosingElement3 is InterfaceElement) {
return _OverriddenElementsFinder(element).find();
}
return OverriddenElements(element, <Element>[], <Element>[]);
Expand Down Expand Up @@ -110,7 +110,7 @@ class _OverriddenElementsFinder {
final Set<InterfaceElement> _visited = {};

factory _OverriddenElementsFinder(Element seed) {
var class_ = seed.enclosingElement as InterfaceElement;
var class_ = seed.enclosingElement3 as InterfaceElement;
var library = class_.library;
var name = seed.displayName;
List<ElementKind> kinds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ class _Visitor extends UnifyingAstVisitor<void> {
if (element == null) {
return;
}
if (element.enclosingElement is! CompilationUnitElement) {
if (element is PrefixElement) {
return;
}
if (element.enclosingElement3 is! CompilationUnitElement) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class DefinitionHandler extends LspMessageHandler<TextDocumentPositionParams,
// the parameters / representation type but we want the whole declaration
// for the code range because otherwise previews will just show `(int a)`
// which is not what the user expects.
if (codeElement.enclosingElement case ExtensionTypeElement enclosingElement
if (codeElement.enclosingElement3 case ExtensionTypeElement enclosingElement
when enclosingElement.primaryConstructor == codeElement) {
codeElement = enclosingElement;
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/analysis_server/lib/src/protocol_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Location newLocation_fromUnit(
/// Construct based on an element from the analyzer engine.
OverriddenMember newOverriddenMember_fromEngine(engine.Element member) {
var element = convertElement(member);
var className = member.enclosingElement!.displayName;
var className = member.enclosingElement3!.displayName;
return OverriddenMember(element, className);
}

Expand Down Expand Up @@ -305,9 +305,8 @@ engine.CompilationUnitElement _getUnitElement(engine.Element element) {
return element;
}

var enclosingElement = element.enclosingElement;
if (enclosingElement is engine.LibraryElement) {
element = enclosingElement;
if (element.enclosingElement3 case engine.LibraryElement enclosing) {
return enclosing.definingCompilationUnit;
}

if (element is engine.LibraryElement) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/search/element_references.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ class ElementReferencesComputer {
if (element is ConstructorElement) {
return false;
}
return element.enclosingElement is InterfaceElement;
return element.enclosingElement3 is InterfaceElement;
}
}
4 changes: 2 additions & 2 deletions pkg/analysis_server/lib/src/search/type_hierarchy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ class TypeHierarchyComputerHelper {
bool pivotFieldFinal = false;
if (pivotElement is FieldElement) {
pivotFieldFinal = pivotElement.isFinal;
element = pivotElement.enclosingElement;
element = pivotElement.enclosingElement3;
}
if (pivotElement is ExecutableElement) {
element = pivotElement.enclosingElement;
element = pivotElement.enclosingElement3;
}
InterfaceElement? pivotClass;
if (element is InterfaceElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ final class ConstructorSuggestion extends ImportableSuggestion

@override
String get completion {
var enclosingClass = element.enclosingElement.augmented.declaration;
var enclosingClass = element.enclosingElement3.augmented.declaration;

var className = enclosingClass.name;

Expand Down Expand Up @@ -234,7 +234,7 @@ final class EnumConstantSuggestion extends ImportableSuggestion
@override
String get completion {
if (includeEnumName) {
var enclosingElement = element.enclosingElement;
var enclosingElement = element.enclosingElement3;
return '$completionPrefix${enclosingElement.name}.${element.name}';
} else {
return element.name;
Expand Down Expand Up @@ -596,7 +596,7 @@ mixin MemberSuggestion implements ElementBasedSuggestion {
var inheritanceDistance = 0.0;
var element = this.element;
if (!(element is FieldElement && element.isEnumConstant)) {
var declaringClass = element.enclosingElement;
var declaringClass = element.enclosingElement3;
var referencingInterface = this.referencingInterface;
if (referencingInterface != null && declaringClass is InterfaceElement) {
inheritanceDistance = featureComputer.inheritanceDistanceFeature(
Expand Down Expand Up @@ -754,7 +754,7 @@ final class PropertyAccessSuggestion extends ImportableSuggestion
/// The enclosing element must be either a class, or extension; otherwise
/// we either fail with assertion, or return `null`.
String? get _enclosingClassOrExtensionName {
var enclosing = element.enclosingElement;
var enclosing = element.enclosingElement3;
if (enclosing is InterfaceElement) {
return enclosing.name;
} else if (enclosing is ExtensionElement) {
Expand Down Expand Up @@ -900,7 +900,7 @@ final class StaticFieldSuggestion extends ImportableSuggestion

@override
String get completion {
var enclosingElement = element.enclosingElement;
var enclosingElement = element.enclosingElement3;
return '$completionPrefix${enclosingElement.name}.${element.name}';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class DeclarationHelper {
/// be skipped because the cursor is inside that field's name.
void addFieldsForInitializers(
ConstructorDeclaration constructor, FieldElement? fieldToInclude) {
var containingElement = constructor.declaredElement?.enclosingElement;
var containingElement = constructor.declaredElement?.enclosingElement3;
if (containingElement == null) {
return;
}
Expand Down Expand Up @@ -554,7 +554,7 @@ class DeclarationHelper {
void addPossibleRedirectionsInLibrary(
ConstructorElement redirectingConstructor, LibraryElement library) {
var classElement =
redirectingConstructor.enclosingElement.augmented.declaration;
redirectingConstructor.enclosingElement3.augmented.declaration;
var classType = classElement.thisType;
var typeSystem = library.typeSystem;
for (var unit in library.units) {
Expand Down Expand Up @@ -1273,7 +1273,7 @@ class DeclarationHelper {
(containingElement is EnumElement && field.name == 'values')) &&
field.isVisibleIn(request.libraryElement)) {
if (field.isEnumConstant) {
var enumElement = field.enclosingElement;
var enumElement = field.enclosingElement3;
var matcherScore =
state.matcher.score('${enumElement.name}.${field.name}');
if (matcherScore != -1) {
Expand Down Expand Up @@ -1379,7 +1379,7 @@ class DeclarationHelper {
}

if (element.isProtected) {
var elementInterface = element.enclosingElement;
var elementInterface = element.enclosingElement3;
if (elementInterface is! InterfaceElement) {
return false;
}
Expand Down Expand Up @@ -1486,7 +1486,7 @@ class DeclarationHelper {
}
if (importData?.isNotImported ?? false) {
if (!visibilityTracker.isVisible(
element: element.enclosingElement, importData: importData)) {
element: element.enclosingElement3, importData: importData)) {
// If the constructor is on a class from a not-yet-imported library and
// the class isn't visible, then we shouldn't suggest it.
//
Expand All @@ -1500,7 +1500,7 @@ class DeclarationHelper {
// Add the class to the visibility tracker so that we will know later that
// any non-imported elements with the same name are not visible.
visibilityTracker.isVisible(
element: element.enclosingElement, importData: importData);
element: element.enclosingElement3, importData: importData);
}

// TODO(keertip): Compute the completion string.
Expand Down Expand Up @@ -1715,7 +1715,7 @@ class DeclarationHelper {
}
var matcherScore = state.matcher.score(method.displayName);
if (matcherScore != -1) {
var enclosingElement = method.enclosingElement;
var enclosingElement = method.enclosingElement3;
if (method.name == 'setState' &&
enclosingElement is ClassElement &&
enclosingElement.isExactState) {
Expand Down Expand Up @@ -1857,7 +1857,7 @@ class DeclarationHelper {
request.libraryElement.typeSystem
.isSubtypeOf(element.type, contextType)) {
if (element.isEnumConstant) {
var enumElement = element.enclosingElement;
var enumElement = element.enclosingElement3;
var matcherScore = state.matcher
.score('${enumElement.displayName}.${element.displayName}');
if (matcherScore != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class RelevanceComputer {
/// Compute the relevance for [ConstructorElement].
int _computeConstructorRelevance(ConstructorElement element,
NeverType neverType, bool isNotImportedLibrary) {
var enclosingClass = element.enclosingElement.augmented.declaration;
var enclosingClass = element.enclosingElement3.augmented.declaration;
var returnType = instantiateInstanceElement(enclosingClass, neverType);
return computeTopLevelRelevance(element,
elementType: returnType, isNotImportedLibrary: isNotImportedLibrary);
Expand Down
Loading

0 comments on commit f412b5e

Please sign in to comment.