Skip to content

Commit

Permalink
Version 3.6.0-178.0.dev
Browse files Browse the repository at this point in the history
Merge ee0b971 into dev
  • Loading branch information
Dart CI committed Aug 24, 2024
2 parents ce23f79 + ee0b971 commit c7eb323
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 1 deletion.
30 changes: 30 additions & 0 deletions pkg/analysis_server/test/lsp/document_highlights_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ void main() {

@reflectiveTest
class DocumentHighlightsTest extends AbstractLspAnalysisServerTest {
Future<void> test_bound_topLevelVariable_wildcard() => _testMarkedContent('''
var /*[0*/^_/*0]*/ = 1;
void f() {
var _ = 2;
print(/*[1*/_/*1]*/);
}
''');

Future<void> test_forInLoop() => _testMarkedContent('''
void f() {
for (final /*[0*/x^/*0]*/ in []) {
Expand Down Expand Up @@ -96,6 +104,14 @@ class A {}
expect(highlights[1].range.start, functionCallOffsetPosition);
}

Future<void> test_method_underscore() => _testMarkedContent('''
class C {
/*[0*/_/*0]*/() {
/*[1*/^_/*1]*/();
}
}
''');

Future<void> test_nonDartFile() async {
await initialize();
await openFile(pubspecFileUri, simplePubspecContent);
Expand All @@ -116,6 +132,12 @@ void f() {
void f() {
/*[0*/prin^t/*0]*/('');
}
''');

Future<void> test_onlySelf_wildcard() => _testMarkedContent('''
void f() {
var /*[0*/^_/*0]*/ = '';
}
''');

Future<void> test_pattern_object_destructure() => _testMarkedContent('''
Expand Down Expand Up @@ -155,6 +177,14 @@ void f() {
print(/*[1*/foo/*1]*/);
/*[2*/fo^o/*2]*/ = '';
}
''');

Future<void> test_topLevelVariable_underscore() => _testMarkedContent('''
String /*[0*/_/*0]*/ = 'bar';
void f() {
print(/*[1*/_/*1]*/);
/*[2*/^_/*2]*/ = '';
}
''');

/// Tests highlights in a Dart file using the provided content.
Expand Down
123 changes: 123 additions & 0 deletions pkg/analysis_server/test/lsp/hover_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ class HoverTest extends AbstractLspAnalysisServerTest {
expect(markup.value, matcher);
}

Future<void> assertNullHover(
String content, {
bool waitForAnalysis = false,
bool withOpenFile = true,
}) async {
var code = TestCode.parse(content);

var initialAnalysis = waitForAnalysis ? waitForAnalysisComplete() : null;
await initialize();
if (withOpenFile) {
await openFile(mainFileUri, code.code);
} else {
newFile(mainFilePath, code.code);
}
await initialAnalysis;
var hover = await getHover(mainFileUri, code.position.position);
expect(hover, isNull);
}

Future<void> assertPlainTextContents(String content, Matcher matcher) async {
setHoverContentFormat([MarkupKind.PlainText]);
var code = TestCode.parse(content);
Expand Down Expand Up @@ -181,6 +200,23 @@ List<MyEnum> get values
```
Type: `List<MyEnum>`
*package:test/main.dart*''';
await assertStringContents(content, equals(expected));
}

Future<void> test_field_underscore() async {
var content = '''
class A {
int _ = 1;
int f() => [!^_!];
}
''';
var expected = '''
```dart
int _
```
Type: `int`
*package:test/main.dart*''';
await assertStringContents(content, equals(expected));
}
Expand Down Expand Up @@ -240,6 +276,20 @@ Type: `String`''';
);
}

Future<void> test_localVariable_wildcard() async {
var content = '''
f() {
int [!^_!] = 0;
}
''';
var expected = '''
```dart
int _
```
Type: `int`''';
await assertStringContents(content, equals(expected));
}

Future<void> test_markdown_isFormattedForDisplay() async {
var content = '''
/// This is a string.
Expand Down Expand Up @@ -306,6 +356,23 @@ print();
contains('This is a method.'),
);

Future<void> test_method_underscore() async {
var content = '''
class A {
int _() => 1;
int f() => [!^_!]();
}
''';
var expected = '''
```dart
int _()
```
Type: `int Function()`
*package:test/main.dart*''';
await assertStringContents(content, equals(expected));
}

Future<void> test_noElement() async {
var code = TestCode.parse('''
String? abc;
Expand Down Expand Up @@ -346,6 +413,18 @@ Type: `String?`
await assertStringContents(content, equals(expectedHoverContent));
}

Future<void> test_parameter_wildcard() async {
var content = '''
f(int [!^_!]) { }
''';
var expected = '''
```dart
int _
```
Type: `int`''';
await assertStringContents(content, equals(expected));
}

Future<void> test_pattern_assignment_left() => assertStringContents(
'''
void f(String a, String b) {
Expand Down Expand Up @@ -807,6 +886,50 @@ This is a string.''';
await assertStringContents(content, equals(expected));
}

Future<void> test_topLevelFunction_underscore() async {
var content = '''
int _() => 1;
int f() => [!^_!]();
''';
var expected = '''
```dart
int _()
```
Type: `int Function()`
*package:test/main.dart*''';
await assertStringContents(content, equals(expected));
}

Future<void> test_topLevelVariable_underscore() async {
var content = '''
int _ = 1;
int f() => [!^_!];
''';
var expected = '''
```dart
int _
```
Type: `int`
*package:test/main.dart*''';
await assertStringContents(content, equals(expected));
}

Future<void> test_typeParameter() async {
var content = '''
class C<[!^T!]> {}
''';
await assertNullHover(content);
}

Future<void> test_typeParameter_wildcard() async {
var content = '''
class C<[!^_!]> {}
''';
await assertNullHover(content);
}

Future<void> test_unnamed_library_directive() async {
var content = '''
/// This is a string.
Expand Down
31 changes: 31 additions & 0 deletions pkg/analysis_server/test/lsp/implementation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class ImplementationTest extends AbstractLspAnalysisServerTest {
class /*[1*/C/*1]*/ extends A {}
''');

Future<void> test_class_sub_underscore() => _testMarkedContent('''
abstract class ^_ {}
class /*[0*/B/*0]*/ extends _ {}
class /*[1*/C/*1]*/ extends _ {}
''');

Future<void> test_class_subSub() => _testMarkedContent('''
abstract class ^A {}
class /*[0*/B/*0]*/ extends A {}
Expand Down Expand Up @@ -68,6 +74,17 @@ class ImplementationTest extends AbstractLspAnalysisServerTest {
}
''');

Future<void> test_getter_overriddenByField_underscore() =>
_testMarkedContent('''
class B extends A {
final String? [!_!] = null;
}
abstract class A {
String? get _^;
}
''');

Future<void> test_method_excludesClassesWithoutImplementations() =>
_testMarkedContent('''
abstract class A {
Expand Down Expand Up @@ -162,6 +179,20 @@ class ImplementationTest extends AbstractLspAnalysisServerTest {
}
''');

Future<void> test_method_sub_underscore() => _testMarkedContent('''
abstract class A {
void ^_();
}
class B extends A {
void /*[0*/_/*0]*/() {}
}
class C extends A {
void /*[1*/_/*1]*/() {}
}
''');

Future<void> test_method_subSub() => _testMarkedContent('''
abstract class A {
void ^b();
Expand Down
55 changes: 55 additions & 0 deletions pkg/analysis_server/test/lsp/super_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ class C^ extends B {}
'''));
}

Future<void> test_className_underscore() async {
await verifyGoToSuper(TestCode.parse('''
class A {}
class [!_!] extends A {}
class C^ extends _ {}
'''));
}

Future<void> test_constructor_named_callsSuperNamed() async {
await verifyGoToSuper(TestCode.parse('''
class A {
Expand Down Expand Up @@ -157,6 +167,21 @@ class C extends B {
'''));
}

Future<void> test_getter_underscore() async {
await verifyGoToSuper(TestCode.parse('''
class A {
String get [!_!] => '';
}
class B extends A {}
class C extends B {
@override
String get ^_ => '';
}
'''));
}

Future<void> test_insideClass() async {
await verifyGoToSuper(TestCode.parse('''
class A {}
Expand Down Expand Up @@ -231,6 +256,21 @@ class C extends B {
'''));
}

Future<void> test_methodName_underscore() async {
await verifyGoToSuper(TestCode.parse('''
class A {
void [!_!]() {}
}
class B extends A {}
class C extends B {
@override
void ^_() {}
}
'''));
}

Future<void> test_methodReturnType() async {
await verifyGoToSuper(TestCode.parse('''
class A {
Expand Down Expand Up @@ -261,6 +301,21 @@ class C extends B {
'''));
}

Future<void> test_setter_underscore() async {
await verifyGoToSuper(TestCode.parse('''
class A {
set [!_!](String value) {}
}
class B extends A {}
class C extends B {
@override
set ^_(String value) {}
}
'''));
}

Future<void> verifyGoToSuper(TestCode code) async {
await initialize();
await openFile(mainFileUri, code.code);
Expand Down
Loading

0 comments on commit c7eb323

Please sign in to comment.