Skip to content

Commit

Permalink
Version 2.19.0-81.0.dev
Browse files Browse the repository at this point in the history
Merge commit '709b878c075911ef84e63185b58ac993f6cd66a9' into 'dev'
  • Loading branch information
Dart CI committed Aug 9, 2022
2 parents 7f93725 + 709b878 commit f06ac84
Show file tree
Hide file tree
Showing 144 changed files with 1,126 additions and 874 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ vars = {
"html_rev": "8243e967caad9932c13971af3b2a7c8f028383d5",
"http_multi_server_rev": "20bf079c8955d1250a45afb9cb096472a724a551",
"http_parser_rev": "b968f7ddde0588273a6cbd1d2eb6569f418606ac",
"http_rev": "5055b684ae45fb141a106ef6ced988aa37ed0ea6", # b/241795598
"http_rev": "45f91f23847d51df53bb704bd25a7f64fb117081",
"icu_rev": "81d656878ec611cb0b42d52c82e9dae93920d9ba",
"intl_rev": "7e3a1bbdeff241323f56295d8991c004bef815e6",
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
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 @@ -414,7 +414,7 @@ class DartUnitOutlineComputer {

/// Returns `true` if the given [element] is not `null` and deprecated.
static bool _isDeprecated(Declaration declaration) {
var element = declaration.declaredElement;
var element = declaration.declaredElement2;
return element != null && element.hasDeprecated;
}

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 @@ -68,15 +68,15 @@ class DartUnitOverridesComputer {
if (classMember.isStatic) {
continue;
}
_addOverride(classMember.name2, classMember.declaredElement);
_addOverride(classMember.name2, classMember.declaredElement2);
}
if (classMember is FieldDeclaration) {
if (classMember.isStatic) {
continue;
}
List<VariableDeclaration> fields = classMember.fields.variables;
for (var field in fields) {
_addOverride(field.name2, field.declaredElement);
_addOverride(field.name2, field.declaredElement2);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> {

@override
void visitEnumConstantDeclaration(EnumConstantDeclaration node) {
_addOccurrence(node.declaredElement!, node.name2.offset);
_addOccurrence(node.declaredElement2!, node.name2.offset);

super.visitEnumConstantDeclaration(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';

/// A contributor that produces suggestions for constructors to be invoked
/// in enum constants.
Expand Down Expand Up @@ -46,7 +45,7 @@ class EnumConstantConstructorContributor extends DartCompletionContributor {
return;
}

var enumElement = enumDeclaration.declaredElement as ClassElement;
var enumElement = enumDeclaration.declaredElement2!;
for (var constructor in enumElement.constructors) {
builder.suggestConstructor(
constructor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ class FeatureComputer {
: (node as ForElement).forLoopParts;
if (loopParts is ForPartsWithDeclarations) {
for (var declaredVariable in loopParts.variables.variables.reversed) {
if (declaredVariable.declaredElement == variable) {
if (declaredVariable.declaredElement2 == variable) {
return distance;
}
distance++;
}
} else if (loopParts is ForEachPartsWithDeclaration) {
if (loopParts.loopVariable.declaredElement == variable) {
if (loopParts.loopVariable.declaredElement2 == variable) {
return distance;
}
distance++;
Expand All @@ -384,7 +384,7 @@ class FeatureComputer {
var index = variables.indexOf(node);
for (var i = index - 1; i >= 0; i--) {
var declaredVariable = variables[i];
if (declaredVariable.declaredElement == variable) {
if (declaredVariable.declaredElement2 == variable) {
return distance;
}
distance++;
Expand Down Expand Up @@ -412,7 +412,7 @@ class FeatureComputer {
if (statement is VariableDeclarationStatement) {
for (var declaredVariable
in statement.variables.variables.reversed) {
if (declaredVariable.declaredElement == variable) {
if (declaredVariable.declaredElement2 == variable) {
return distance;
}
distance++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class FieldFormalContributor extends DartCompletionContributor {
}
}

ClassElement? enclosingClass;
InterfaceElement? enclosingClass;
var constructorParent = constructor.parent;
if (constructorParent is ClassDeclaration) {
enclosingClass = constructorParent.declaredElement;
enclosingClass = constructorParent.declaredElement2;
} else if (constructorParent is EnumDeclaration) {
enclosingClass = constructorParent.declaredElement;
enclosingClass = constructorParent.declaredElement2;
} else {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor {
@override
void visitClassElement(ClassElement element) {
if (opType.includeTypeNameSuggestions) {
builder.suggestClass(element, prefix: prefix);
builder.suggestInterface(element, prefix: prefix);
}
if (opType.includeConstructorSuggestions) {
_addConstructorSuggestions(element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class LocalReferenceContributor extends DartCompletionContributor {
if (member != null) {
var enclosingNode = member.parent;
if (enclosingNode is ClassDeclaration) {
_addForInterface(enclosingNode.declaredElement!);
_addForInterface(enclosingNode.declaredElement2!);
} else if (enclosingNode is MixinDeclaration) {
_addForInterface(enclosingNode.declaredElement!);
_addForInterface(enclosingNode.declaredElement2!);
}
}
}
Expand Down Expand Up @@ -217,14 +217,14 @@ class _LocalVisitor extends LocalDeclarationVisitor {

@override
void declaredClass(ClassDeclaration declaration) {
_declaredClassElement(declaration.declaredElement);
_declaredInterfaceElement(declaration.declaredElement2);
}

@override
void declaredClassTypeAlias(ClassTypeAlias declaration) {
var declaredElement = declaration.declaredElement;
var declaredElement = declaration.declaredElement2;
if (declaredElement != null && opType.includeTypeNameSuggestions) {
builder.suggestClass(declaredElement);
builder.suggestInterface(declaredElement);
}
}

Expand All @@ -235,12 +235,12 @@ class _LocalVisitor extends LocalDeclarationVisitor {

@override
void declaredEnum(EnumDeclaration declaration) {
_declaredClassElement(declaration.declaredElement);
_declaredInterfaceElement(declaration.declaredElement2);
}

@override
void declaredExtension(ExtensionDeclaration declaration) {
var declaredElement = declaration.declaredElement;
var declaredElement = declaration.declaredElement2;
if (declaredElement != null &&
visibilityTracker._isVisible(declaredElement) &&
opType.includeReturnValueSuggestions &&
Expand All @@ -251,7 +251,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {

@override
void declaredField(FieldDeclaration fieldDecl, VariableDeclaration varDecl) {
var field = varDecl.declaredElement;
var field = varDecl.declaredElement2;
if (field is FieldElement &&
((visibilityTracker._isVisible(field) &&
opType.includeReturnValueSuggestions &&
Expand All @@ -260,7 +260,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
var inheritanceDistance = 0.0;
var enclosingClass = request.target.containingNode
.thisOrAncestorOfType<ClassDeclaration>();
var enclosingElement = enclosingClass?.declaredElement;
var enclosingElement = enclosingClass?.declaredElement2;
if (enclosingElement != null) {
var enclosingElement = field.enclosingElement3;
if (enclosingElement is ClassElement) {
Expand All @@ -274,7 +274,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {

@override
void declaredFunction(FunctionDeclaration declaration) {
if (visibilityTracker._isVisible(declaration.declaredElement) &&
if (visibilityTracker._isVisible(declaration.declaredElement2) &&
(opType.includeReturnValueSuggestions ||
opType.includeVoidReturnSuggestions)) {
if (declaration.isSetter) {
Expand All @@ -287,7 +287,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
return;
}
}
var declaredElement = declaration.declaredElement;
var declaredElement = declaration.declaredElement2;
if (declaredElement is FunctionElement) {
builder.suggestTopLevelFunction(declaredElement, kind: _defaultKind);
} else if (declaredElement is PropertyAccessorElement) {
Expand All @@ -298,15 +298,15 @@ class _LocalVisitor extends LocalDeclarationVisitor {

@override
void declaredFunctionTypeAlias(FunctionTypeAlias declaration) {
var declaredElement = declaration.declaredElement;
var declaredElement = declaration.declaredElement2;
if (declaredElement != null && opType.includeTypeNameSuggestions) {
builder.suggestTypeAlias(declaredElement);
}
}

@override
void declaredGenericTypeAlias(GenericTypeAlias declaration) {
var declaredElement = declaration.declaredElement;
var declaredElement = declaration.declaredElement2;
if (declaredElement is TypeAliasElement &&
opType.includeTypeNameSuggestions) {
builder.suggestTypeAlias(declaredElement);
Expand All @@ -332,7 +332,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {

@override
void declaredMethod(MethodDeclaration declaration) {
var element = declaration.declaredElement;
var element = declaration.declaredElement2;
if (visibilityTracker._isVisible(element) &&
(opType.includeReturnValueSuggestions ||
opType.includeVoidReturnSuggestions) &&
Expand All @@ -345,7 +345,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
if (enclosingElement is ClassElement) {
inheritanceDistance = request.featureComputer
.inheritanceDistanceFeature(
enclosingClass.declaredElement!, enclosingElement);
enclosingClass.declaredElement2!, enclosingElement);
}
}
if (element is MethodElement) {
Expand All @@ -360,12 +360,12 @@ class _LocalVisitor extends LocalDeclarationVisitor {

@override
void declaredMixin(MixinDeclaration declaration) {
var declaredElement = declaration.declaredElement;
var declaredElement = declaration.declaredElement2;
if (!inExtendsClause &&
declaredElement != null &&
visibilityTracker._isVisible(declaredElement) &&
opType.includeTypeNameSuggestions) {
builder.suggestClass(declaredElement);
builder.suggestInterface(declaredElement);
}
}

Expand All @@ -387,7 +387,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
@override
void declaredTopLevelVar(
VariableDeclarationList varList, VariableDeclaration varDecl) {
var variableElement = varDecl.declaredElement;
var variableElement = varDecl.declaredElement2;
if (variableElement is TopLevelVariableElement &&
visibilityTracker._isVisible(variableElement) &&
opType.includeReturnValueSuggestions) {
Expand All @@ -400,7 +400,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {

@override
void declaredTypeParameter(TypeParameter node) {
var declaredElement = node.declaredElement;
var declaredElement = node.declaredElement2;
if (declaredElement != null &&
visibilityTracker._isVisible(declaredElement) &&
opType.includeTypeNameSuggestions) {
Expand All @@ -414,17 +414,19 @@ class _LocalVisitor extends LocalDeclarationVisitor {
super.visitExtendsClause(node);
}

void _declaredClassElement(ClassElement? class_) {
if (class_ != null && visibilityTracker._isVisible(class_)) {
void _declaredInterfaceElement(InterfaceElement? element) {
if (element != null && visibilityTracker._isVisible(element)) {
if (opType.includeTypeNameSuggestions) {
builder.suggestClass(class_);
builder.suggestInterface(element);
}

if (!opType.isPrefixed &&
opType.includeConstructorSuggestions &&
class_ is! EnumElement) {
for (final constructor in class_.constructors) {
if (!class_.isAbstract || constructor.isFactory) {
element is ClassElement &&
// TODO(scheglov) Remove when separated EnumElement from ClassElement
element is! EnumElement) {
for (final constructor in element.constructors) {
if (!element.isAbstract || constructor.isFactory) {
builder.suggestConstructor(constructor);
}
}
Expand All @@ -435,7 +437,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
final contextType = request.contextType;
if (contextType is InterfaceType) {
// TODO(scheglov) This looks not ideal - we should suggest getters.
for (final field in class_.fields) {
for (final field in element.fields) {
if (field.isStatic &&
typeSystem.isSubtypeOf(field.type, contextType)) {
builder.suggestStaticField(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RedirectingContributor extends DartCompletionContributor {
// C() : this.^
var containingConstructor =
parent.thisOrAncestorOfType<ConstructorDeclaration>();
var constructorElement = containingConstructor?.declaredElement;
var constructorElement = containingConstructor?.declaredElement2;
var classElement = constructorElement?.enclosingElement3;
if (classElement != null) {
for (var constructor in classElement.constructors) {
Expand Down Expand Up @@ -51,7 +51,7 @@ class RedirectingContributor extends DartCompletionContributor {
// factory C() = ^
var containingConstructor =
parent.thisOrAncestorOfType<ConstructorDeclaration>();
var constructorElement = containingConstructor?.declaredElement;
var constructorElement = containingConstructor?.declaredElement2;
var classElement = constructorElement?.enclosingElement3;
var libraryElement = request.libraryElement;
if (classElement == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,22 +322,6 @@ class SuggestionBuilder {
);
}

/// Add a suggestion for a [classElement]. If the class can only be
/// referenced using a prefix, then the [prefix] should be provided.
void suggestClass(ClassElement classElement, {String? prefix}) {
var relevance = _computeTopLevelRelevance(classElement,
elementType: _instantiateInterfaceElement(classElement));
_addBuilder(
_createCompletionSuggestionBuilder(
classElement,
kind: CompletionSuggestionKind.IDENTIFIER,
prefix: prefix,
relevance: relevance,
isNotImported: isNotImportedLibrary,
),
);
}

/// Add a suggestion to insert a closure matching the given function [type].
/// If [includeTrailingComma] is `true` then the completion text will include
/// a trailing comma, such as when the closure is part of an argument list.
Expand Down Expand Up @@ -452,7 +436,7 @@ class SuggestionBuilder {
void suggestElement(Element element,
{CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION}) {
if (element is ClassElement) {
suggestClass(element);
suggestInterface(element);
} else if (element is ConstructorElement) {
suggestConstructor(element, kind: kind);
} else if (element is ExtensionElement) {
Expand Down Expand Up @@ -588,6 +572,22 @@ class SuggestionBuilder {
);
}

/// Add a suggestion for a [element]. If the class can only be
/// referenced using a prefix, then the [prefix] should be provided.
void suggestInterface(InterfaceElement element, {String? prefix}) {
var relevance = _computeTopLevelRelevance(element,
elementType: _instantiateInterfaceElement(element));
_addBuilder(
_createCompletionSuggestionBuilder(
element,
kind: CompletionSuggestionKind.IDENTIFIER,
prefix: prefix,
relevance: relevance,
isNotImported: isNotImportedLibrary,
),
);
}

/// Add a suggestion for a [keyword]. The [offset] is the offset from the
/// beginning of the keyword where the cursor will be left.
void suggestKeyword(String keyword, {int? offset}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SuperFormalContributor extends DartCompletionContributor {
return;
}

var constructorElement = constructor.declaredElement;
var constructorElement = constructor.declaredElement2;
constructorElement as ConstructorElementImpl;

var superConstructor = constructorElement.superConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ abstract class CorrectionProducer extends SingleCorrectionProducer {
if (parent is VariableDeclaration) {
var variableDeclaration = parent;
if (variableDeclaration.initializer == expression) {
var variableElement = variableDeclaration.declaredElement;
var variableElement = variableDeclaration.declaredElement2;
if (variableElement != null) {
return variableElement.type;
}
Expand Down
Loading

0 comments on commit f06ac84

Please sign in to comment.