Skip to content

Commit 74f74d7

Browse files
kallentuCommit Queue
authored andcommitted
[analysis_server] Dot shorthands: Document highlights tests.
Tests for documenting highlighting for dot shorthands. Tested with enums, classes, and extension types. Bug: #59836 Change-Id: I9b13dd8594ff8113ec9dbe97089688d893d2853d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431983 Commit-Queue: Kallen Tu <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent e724547 commit 74f74d7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

pkg/analysis_server/test/lsp/document_highlights_test.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,43 @@ var a; // Not a reference
6464
_testMarkedContent('''
6565
var /*[0*/^a/*0]*/ = [''].where((_) => true).toList();
6666
var b = /*[1*/a/*1]*/;
67+
''');
68+
69+
Future<void> test_dotShorthand_class() => _testMarkedContent('''
70+
A topA = ./*[0*/^a/*0]*/;
71+
class A {
72+
static A get /*[1*/a/*1]*/ => A();
73+
}
74+
void fn(A a) => print(a);
75+
void f() {
76+
A a = ./*[2*/a/*2]*/;
77+
fn(./*[3*/a/*3]*/);
78+
A aa = A./*[4*/a/*4]*/;
79+
}
80+
''');
81+
82+
Future<void> test_dotShorthand_enum() => _testMarkedContent('''
83+
const A constA = ./*[0*/^a/*0]*/;
84+
enum A { /*[1*/a/*1]*/ }
85+
void fn(A a) => print(a);
86+
void f() {
87+
A a = ./*[2*/a/*2]*/;
88+
fn(./*[3*/a/*3]*/);
89+
A aa = A./*[4*/a/*4]*/;
90+
}
91+
''');
92+
93+
Future<void> test_dotShorthand_extensionType() => _testMarkedContent('''
94+
A topA = ./*[0*/^a/*0]*/;
95+
extension type A(int x) {
96+
static A get /*[1*/a/*1]*/ => A(1);
97+
}
98+
void fn(A a) => print(a);
99+
void f() {
100+
A a = ./*[2*/a/*2]*/;
101+
fn(./*[3*/a/*3]*/);
102+
A aa = A./*[4*/a/*4]*/;
103+
}
67104
''');
68105

69106
Future<void> test_forInLoop() => _testMarkedContent('''

0 commit comments

Comments
 (0)