Skip to content

Commit cc681ff

Browse files
author
Dart CI
committed
Version 3.1.0-279.0.dev
Merge 28ea45c into dev
2 parents fa1a34a + 28ea45c commit cc681ff

19 files changed

+445
-331
lines changed

pkg/analysis_server/lib/src/computer/computer_hover.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class DartUnitHoverComputer {
5252
locationEntity = node.name2;
5353
} else if (node is ConstructorDeclaration) {
5454
locationEntity = node.name ?? node.returnType;
55+
} else if (node is DeclaredIdentifier) {
56+
locationEntity = node.name;
5557
} else if (node is VariableDeclaration) {
5658
locationEntity = node.name;
5759
} else if (node is VariablePattern) {
@@ -84,6 +86,7 @@ class DartUnitHoverComputer {
8486
node is MethodDeclaration ||
8587
node is NamedType ||
8688
node is ConstructorDeclaration ||
89+
node is DeclaredIdentifier ||
8790
node is VariableDeclaration ||
8891
node is VariablePattern ||
8992
node is PatternFieldName)) {

pkg/analysis_server/test/lsp/hover_test.dart

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,36 @@ class HoverTest extends AbstractLspAnalysisServerTest {
159159
Future<void> test_dartDocPreference_unset() =>
160160
assertDocumentation(null, includesSummary: true, includesFull: true);
161161

162+
Future<void> test_forLoop_declaredVariable() async {
163+
final content = '''
164+
void f() {
165+
for (var [!ii^i!] in <String>[]) {}
166+
}
167+
''';
168+
final expected = '''
169+
```dart
170+
String iii
171+
```
172+
Type: `String`''';
173+
await assertStringContents(content, equals(expected));
174+
}
175+
176+
Future<void> test_forLoop_variableReference() async {
177+
final content = '''
178+
void f() {
179+
for (var iii in <String>[]) {
180+
print([!ii^i!]);
181+
}
182+
}
183+
''';
184+
final expected = '''
185+
```dart
186+
String iii
187+
```
188+
Type: `String`''';
189+
await assertStringContents(content, equals(expected));
190+
}
191+
162192
Future<void> test_function_startOfParameterList() => assertStringContents(
163193
'''
164194
/// This is a function.
@@ -596,22 +626,41 @@ Type: `String`
596626
expect(contents, contains('Updated'));
597627
}
598628

599-
Future<void> test_string_simple() => assertStringContents(
600-
'''
601-
/// This is a string.
602-
String [!a^bc!];
603-
''',
604-
contains('This is a string.'),
605-
);
629+
Future<void> test_string_simple() async {
630+
final content = '''
631+
/// This is a string.
632+
String [!a^bc!];
633+
''';
634+
final expected = '''
635+
```dart
636+
String abc
637+
```
638+
Type: `String`
606639
607-
Future<void> test_unopenFile() => assertStringContents(
608-
withOpenFile: false,
609-
'''
610-
/// This is a string.
611-
String [!a^bc!];
612-
''',
613-
contains('This is a string.'),
614-
);
640+
*package:test/main.dart*
641+
642+
---
643+
This is a string.''';
644+
await assertStringContents(content, equals(expected));
645+
}
646+
647+
Future<void> test_unopenFile() async {
648+
final content = '''
649+
/// This is a string.
650+
String [!a^bc!];
651+
''';
652+
final expected = '''
653+
```dart
654+
String abc
655+
```
656+
Type: `String`
657+
658+
*package:test/main.dart*
659+
660+
---
661+
This is a string.''';
662+
await assertStringContents(withOpenFile: false, content, equals(expected));
663+
}
615664

616665
MarkupContent _getMarkupContents(Hover hover) {
617666
return hover.contents.map(

pkg/analyzer/lib/src/dart/ast/ast.dart

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ abstract final class AsExpression implements Expression {
554554
/// An as expression.
555555
///
556556
/// asExpression ::=
557-
/// [Expression] 'as' [TypeName]
557+
/// [Expression] 'as' [NamedType]
558558
final class AsExpressionImpl extends ExpressionImpl implements AsExpression {
559559
/// The expression used to compute the value being cast.
560560
ExpressionImpl _expression;
@@ -3049,7 +3049,7 @@ abstract final class ClassOrAugmentationDeclaration
30493049
/// | 'abstract'? 'base'? 'mixin'
30503050
///
30513051
/// mixinApplication ::=
3052-
/// [TypeName] [WithClause] [ImplementsClause]? ';'
3052+
/// [NamedType] [WithClause] [ImplementsClause]? ';'
30533053
abstract final class ClassTypeAlias implements TypeAlias {
30543054
/// Return the token for the 'abstract' keyword, or `null` if this is not
30553055
/// defining an abstract class.
@@ -3101,7 +3101,7 @@ abstract final class ClassTypeAlias implements TypeAlias {
31013101
/// | 'abstract'? 'base'? 'mixin'
31023102
///
31033103
/// mixinApplication ::=
3104-
/// [TypeName] [WithClause] [ImplementsClause]? ';'
3104+
/// [NamedType] [WithClause] [ImplementsClause]? ';'
31053105
final class ClassTypeAliasImpl extends TypeAliasImpl implements ClassTypeAlias {
31063106
/// The type parameters for the class, or `null` if the class does not have
31073107
/// any type parameters.
@@ -6473,7 +6473,7 @@ final class ExpressionStatementImpl extends StatementImpl
64736473
/// The "extends" clause in a class declaration.
64746474
///
64756475
/// extendsClause ::=
6476-
/// 'extends' [TypeName]
6476+
/// 'extends' [NamedType]
64776477
abstract final class ExtendsClause implements AstNode {
64786478
/// Return the token representing the 'extends' keyword.
64796479
Token get extendsKeyword;
@@ -6485,7 +6485,7 @@ abstract final class ExtendsClause implements AstNode {
64856485
/// The "extends" clause in a class declaration.
64866486
///
64876487
/// extendsClause ::=
6488-
/// 'extends' [TypeName]
6488+
/// 'extends' [NamedType]
64896489
final class ExtendsClauseImpl extends AstNodeImpl implements ExtendsClause {
64906490
/// The token representing the 'extends' keyword.
64916491
@override
@@ -6990,7 +6990,7 @@ abstract final class FieldFormalParameter implements NormalFormalParameter {
69906990
/// A field formal parameter.
69916991
///
69926992
/// fieldFormalParameter ::=
6993-
/// ('final' [TypeName] | 'const' [TypeName] | 'var' | [TypeName])?
6993+
/// ('final' [NamedType] | 'const' [NamedType] | 'var' | [NamedType])?
69946994
/// 'this' '.' [SimpleIdentifier]
69956995
/// ([TypeParameterList]? [FormalParameterList])?
69966996
final class FieldFormalParameterImpl extends NormalFormalParameterImpl
@@ -8839,7 +8839,7 @@ abstract final class FunctionTypedFormalParameter
88398839
/// A function-typed formal parameter.
88408840
///
88418841
/// functionSignature ::=
8842-
/// [TypeName]? [SimpleIdentifier] [TypeParameterList]?
8842+
/// [NamedType]? [SimpleIdentifier] [TypeParameterList]?
88438843
/// [FormalParameterList] '?'?
88448844
final class FunctionTypedFormalParameterImpl extends NormalFormalParameterImpl
88458845
implements FunctionTypedFormalParameter {
@@ -9693,7 +9693,7 @@ final class IfStatementImpl extends StatementImpl
96939693
/// The "implements" clause in an class declaration.
96949694
///
96959695
/// implementsClause ::=
9696-
/// 'implements' [TypeName] (',' [TypeName])*
9696+
/// 'implements' [NamedType] (',' [NamedType])*
96979697
abstract final class ImplementsClause implements AstNode {
96989698
/// Return the token representing the 'implements' keyword.
96999699
Token get implementsKeyword;
@@ -9705,7 +9705,7 @@ abstract final class ImplementsClause implements AstNode {
97059705
/// The "implements" clause in an class declaration.
97069706
///
97079707
/// implementsClause ::=
9708-
/// 'implements' [TypeName] (',' [TypeName])*
9708+
/// 'implements' [NamedType] (',' [NamedType])*
97099709
final class ImplementsClauseImpl extends AstNodeImpl
97109710
implements ImplementsClause {
97119711
/// The token representing the 'implements' keyword.
@@ -10330,7 +10330,7 @@ final class IndexExpressionImpl extends ExpressionImpl
1033010330
/// An instance creation expression.
1033110331
///
1033210332
/// newExpression ::=
10333-
/// ('new' | 'const')? [TypeName] ('.' [SimpleIdentifier])? [ArgumentList]
10333+
/// ('new' | 'const')? [NamedType] ('.' [SimpleIdentifier])? [ArgumentList]
1033410334
abstract final class InstanceCreationExpression implements Expression {
1033510335
/// Return the list of arguments to the constructor.
1033610336
ArgumentList get argumentList;
@@ -10352,7 +10352,7 @@ abstract final class InstanceCreationExpression implements Expression {
1035210352
/// An instance creation expression.
1035310353
///
1035410354
/// newExpression ::=
10355-
/// ('new' | 'const')? [TypeName] ('.' [SimpleIdentifier])?
10355+
/// ('new' | 'const')? [NamedType] ('.' [SimpleIdentifier])?
1035610356
/// [ArgumentList]
1035710357
final class InstanceCreationExpressionImpl extends ExpressionImpl
1035810358
implements InstanceCreationExpression {
@@ -10870,7 +10870,7 @@ abstract final class IsExpression implements Expression {
1087010870
/// An is expression.
1087110871
///
1087210872
/// isExpression ::=
10873-
/// [Expression] 'is' '!'? [TypeName]
10873+
/// [Expression] 'is' '!'? [NamedType]
1087410874
final class IsExpressionImpl extends ExpressionImpl implements IsExpression {
1087510875
/// The expression used to compute the value whose type is being tested.
1087610876
ExpressionImpl _expression;
@@ -13645,7 +13645,7 @@ final class ObjectPatternImpl extends DartPatternImpl implements ObjectPattern {
1364513645
/// The "on" clause in a mixin declaration.
1364613646
///
1364713647
/// onClause ::=
13648-
/// 'on' [TypeName] (',' [TypeName])*
13648+
/// 'on' [NamedType] (',' [NamedType])*
1364913649
abstract final class OnClause implements AstNode {
1365013650
/// Return the token representing the 'on' keyword.
1365113651
Token get onKeyword;
@@ -13657,7 +13657,7 @@ abstract final class OnClause implements AstNode {
1365713657
/// The "on" clause in a mixin declaration.
1365813658
///
1365913659
/// onClause ::=
13660-
/// 'on' [TypeName] (',' [TypeName])*
13660+
/// 'on' [NamedType] (',' [NamedType])*
1366113661
final class OnClauseImpl extends AstNodeImpl implements OnClause {
1366213662
@override
1366313663
final Token onKeyword;
@@ -15921,7 +15921,7 @@ abstract final class SimpleFormalParameter implements NormalFormalParameter {
1592115921
/// A simple formal parameter.
1592215922
///
1592315923
/// simpleFormalParameter ::=
15924-
/// ('final' [TypeName] | 'var' | [TypeName])? [SimpleIdentifier]
15924+
/// ('final' [NamedType] | 'var' | [NamedType])? [SimpleIdentifier]
1592515925
final class SimpleFormalParameterImpl extends NormalFormalParameterImpl
1592615926
implements SimpleFormalParameter {
1592715927
/// The token representing either the 'final', 'const' or 'var' keyword, or
@@ -16974,7 +16974,7 @@ abstract final class SuperFormalParameter implements NormalFormalParameter {
1697416974
/// A super-initializer formal parameter.
1697516975
///
1697616976
/// fieldFormalParameter ::=
16977-
/// ('final' [TypeName] | 'const' [TypeName] | 'var' | [TypeName])?
16977+
/// ('final' [NamedType] | 'const' [NamedType] | 'var' | [NamedType])?
1697816978
/// 'super' '.' [SimpleIdentifier]
1697916979
/// ([TypeParameterList]? [FormalParameterList])?
1698016980
final class SuperFormalParameterImpl extends NormalFormalParameterImpl
@@ -18381,7 +18381,7 @@ abstract final class TypeParameter implements Declaration {
1838118381
/// A type parameter.
1838218382
///
1838318383
/// typeParameter ::=
18384-
/// typeParameterVariance? [SimpleIdentifier] ('extends' [TypeName])?
18384+
/// typeParameterVariance? [SimpleIdentifier] ('extends' [NamedType])?
1838518385
///
1838618386
/// typeParameterVariance ::= 'out' | 'inout' | 'in'
1838718387
final class TypeParameterImpl extends DeclarationImpl implements TypeParameter {
@@ -19237,7 +19237,7 @@ final class WildcardPatternImpl extends DartPatternImpl
1923719237
/// The with clause in a class declaration.
1923819238
///
1923919239
/// withClause ::=
19240-
/// 'with' [TypeName] (',' [TypeName])*
19240+
/// 'with' [NamedType] (',' [NamedType])*
1924119241
abstract final class WithClause implements AstNode {
1924219242
/// Return the names of the mixins that were specified.
1924319243
NodeList<NamedType> get mixinTypes;
@@ -19249,7 +19249,7 @@ abstract final class WithClause implements AstNode {
1924919249
/// The with clause in a class declaration.
1925019250
///
1925119251
/// withClause ::=
19252-
/// 'with' [TypeName] (',' [TypeName])*
19252+
/// 'with' [NamedType] (',' [NamedType])*
1925319253
final class WithClauseImpl extends AstNodeImpl implements WithClause {
1925419254
/// The token representing the 'with' keyword.
1925519255
@override

0 commit comments

Comments
 (0)