@@ -59,6 +59,130 @@ foo(String str) {}
5959 expect (result.path.first.name, 'f' );
6060 }
6161
62+ Future <void > test_findReferences_dotShorthand_invocation_class () async {
63+ var text = r'''
64+ class A {
65+ A.foo /* target */();
66+ }
67+
68+ void f() {
69+ A a = .foo();
70+ }
71+ ''' ;
72+
73+ pathname = sourcePath ('foo.dart' );
74+ writeFile (pathname, text);
75+ await standardAnalysisSetup ();
76+ await analysisFinished;
77+
78+ var results = (await _findElementReferences (text))! ;
79+ expect (results, hasLength (1 ));
80+ var result = results.first;
81+ expect (result.location.file, pathname);
82+ expect (result.isPotential, isFalse);
83+ expect (result.kind.name, SearchResultKind .INVOCATION .name);
84+ expect (result.path.first.name, 'f' );
85+ }
86+
87+ Future <void >
88+ test_findReferences_dotShorthand_invocation_extensionType () async {
89+ var text = r'''
90+ extension type A(int x) {
91+ static A foo /* target */() => A(1);
92+ }
93+
94+ void f() {
95+ A a = .foo();
96+ }
97+ ''' ;
98+
99+ pathname = sourcePath ('foo.dart' );
100+ writeFile (pathname, text);
101+ await standardAnalysisSetup ();
102+ await analysisFinished;
103+
104+ var results = (await _findElementReferences (text))! ;
105+ expect (results, hasLength (1 ));
106+ var result = results.first;
107+ expect (result.location.file, pathname);
108+ expect (result.isPotential, isFalse);
109+ expect (result.kind.name, SearchResultKind .INVOCATION .name);
110+ expect (result.path.first.name, 'f' );
111+ }
112+
113+ Future <void > test_findReferences_dotShorthand_read_class () async {
114+ var text = r'''
115+ class A {
116+ static A get getter /* target */ => A();
117+ }
118+
119+ void f() {
120+ A a = .getter;
121+ }
122+ ''' ;
123+
124+ pathname = sourcePath ('foo.dart' );
125+ writeFile (pathname, text);
126+ await standardAnalysisSetup ();
127+ await analysisFinished;
128+
129+ var results = (await _findElementReferences (text))! ;
130+ expect (results, hasLength (1 ));
131+ var result = results.first;
132+ expect (result.location.file, pathname);
133+ expect (result.isPotential, isFalse);
134+ expect (result.kind.name, SearchResultKind .READ .name);
135+ expect (result.path.first.name, 'f' );
136+ }
137+
138+ Future <void > test_findReferences_dotShorthand_read_enum () async {
139+ var text = r'''
140+ enum A { a /* target */ }
141+
142+ void f() {
143+ A a = .a;
144+ }
145+ ''' ;
146+
147+ pathname = sourcePath ('foo.dart' );
148+ writeFile (pathname, text);
149+ await standardAnalysisSetup ();
150+ await analysisFinished;
151+
152+ var results = (await _findElementReferences (text))! ;
153+ expect (results, hasLength (1 ));
154+ var result = results.first;
155+ expect (result.location.file, pathname);
156+ expect (result.isPotential, isFalse);
157+ expect (result.kind.name, SearchResultKind .READ .name);
158+ expect (result.path.first.name, 'f' );
159+ }
160+
161+ Future <void > test_findReferences_dotShorthand_read_extensionType () async {
162+ var text = r'''
163+ extension type A(int x) {
164+ static A get getter /* target */ => A(1);
165+ }
166+
167+ void f() {
168+ A a = .getter;
169+ }
170+ ''' ;
171+
172+ pathname = sourcePath ('foo.dart' );
173+ writeFile (pathname, text);
174+ await standardAnalysisSetup ();
175+ await analysisFinished;
176+
177+ var results = (await _findElementReferences (text))! ;
178+ expect (results, hasLength (1 ));
179+ var result = results.first;
180+ expect (result.location.file, pathname);
181+ expect (result.isPotential, isFalse);
182+ expect (result.kind.name, SearchResultKind .READ .name);
183+ expect (result.path.first.name, 'f' );
184+ }
185+
62186 Future <void > test_findReferences_inNullAware_listElement () async {
63187 var text = r'''
64188List<int> f(int? foo) {
0 commit comments