Skip to content

Commit 560bb8e

Browse files
kallentuCommit Queue
authored andcommitted
[analysis_server] Dot shorthands: Go to definition tests.
Tests with dot shorthand invocations, constructor invocations and property accesses for the go to definition feature. Bug: #59836 Change-Id: If8f7d85d273299d7a5c6c7cddaffc59cd41eb2fb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431780 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Kallen Tu <[email protected]>
1 parent 676df8b commit 560bb8e

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

pkg/analysis_server/test/lsp/definition_test.dart

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,90 @@ class [!A!] {
363363
);
364364
}
365365

366+
Future<void> test_dotShorthand_constructor_named() async {
367+
var contents = '''
368+
f() {
369+
A a = .nam^ed();
370+
}
371+
372+
class A {
373+
A.[!named!]();
374+
}
375+
''';
376+
377+
await testContents(contents);
378+
}
379+
380+
Future<void> test_dotShorthand_constructor_unnamed() async {
381+
var contents = '''
382+
f() {
383+
A a = .ne^w();
384+
}
385+
386+
class A {
387+
[!A!]();
388+
}
389+
''';
390+
391+
await testContents(contents);
392+
}
393+
394+
Future<void> test_dotShorthand_enum() async {
395+
var contents = '''
396+
enum A {
397+
[!one!],
398+
}
399+
400+
f() {
401+
A a = .on^e;
402+
}
403+
''';
404+
405+
await testContents(contents);
406+
}
407+
408+
Future<void> test_dotShorthand_extensionType() async {
409+
var contents = '''
410+
f() {
411+
A a = .fie^ld;
412+
}
413+
414+
extension type A(int x) {
415+
static A get [!field!] => A(1);
416+
}
417+
''';
418+
419+
await testContents(contents);
420+
}
421+
422+
Future<void> test_dotShorthand_field() async {
423+
var contents = '''
424+
f() {
425+
A a = .fie^ld;
426+
}
427+
428+
class A {
429+
static A [!field!] = A();
430+
}
431+
''';
432+
433+
await testContents(contents);
434+
}
435+
436+
Future<void> test_dotShorthand_method() async {
437+
var contents = '''
438+
f() {
439+
A a = .meth^od();
440+
}
441+
442+
class A {
443+
static A [!method!]() => A();
444+
}
445+
''';
446+
447+
await testContents(contents);
448+
}
449+
366450
Future<void> test_field_underscore() async {
367451
var contents = '''
368452
class A {

0 commit comments

Comments
 (0)