OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library test.services.completion.util; | 5 library test.services.completion.util; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol |
10 show Element, ElementKind; | 10 show Element, ElementKind; |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 assertNotSuggested('partBoo'); | 1283 assertNotSuggested('partBoo'); |
1284 // hidden element suggested as low relevance | 1284 // hidden element suggested as low relevance |
1285 // but imported results are partially filtered | 1285 // but imported results are partially filtered |
1286 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); | 1286 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); |
1287 //assertSuggestImportedFunction( | 1287 //assertSuggestImportedFunction( |
1288 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); | 1288 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); |
1289 assertSuggestLocalFunction('D2', 'Z'); | 1289 assertSuggestLocalFunction('D2', 'Z'); |
1290 assertSuggestImportedClass('EE'); | 1290 assertSuggestImportedClass('EE'); |
1291 // hidden element suggested as low relevance | 1291 // hidden element suggested as low relevance |
1292 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | 1292 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); |
1293 assertSuggestLibraryPrefix('g'); | 1293 // Suggested by LibraryPrefixContributor |
| 1294 assertNotSuggested('g'); |
1294 assertNotSuggested('G'); | 1295 assertNotSuggested('G'); |
1295 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | 1296 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); |
1296 assertSuggestImportedClass('Object'); | 1297 assertSuggestImportedClass('Object'); |
1297 assertSuggestImportedFunction('min', 'num'); | 1298 assertSuggestImportedFunction('min', 'num'); |
1298 //assertSuggestImportedFunction( | 1299 //assertSuggestImportedFunction( |
1299 // 'max', | 1300 // 'max', |
1300 // 'num', | 1301 // 'num', |
1301 // false, | 1302 // false, |
1302 // COMPLETION_RELEVANCE_LOW); | 1303 // COMPLETION_RELEVANCE_LOW); |
1303 if (contributor is ImportedReferenceContributor) { | 1304 if (contributor is ImportedReferenceContributor) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 assertNotSuggested('partBoo'); | 1395 assertNotSuggested('partBoo'); |
1395 // hidden element suggested as low relevance | 1396 // hidden element suggested as low relevance |
1396 // but imported results are partially filtered | 1397 // but imported results are partially filtered |
1397 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); | 1398 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); |
1398 //assertSuggestImportedFunction( | 1399 //assertSuggestImportedFunction( |
1399 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); | 1400 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); |
1400 assertNotSuggested('D2'); | 1401 assertNotSuggested('D2'); |
1401 assertSuggestImportedClass('EE'); | 1402 assertSuggestImportedClass('EE'); |
1402 // hidden element suggested as low relevance | 1403 // hidden element suggested as low relevance |
1403 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | 1404 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); |
1404 assertSuggestLibraryPrefix('g'); | 1405 // Suggested by LibraryPrefixContributor |
| 1406 assertNotSuggested('g'); |
1405 assertNotSuggested('G'); | 1407 assertNotSuggested('G'); |
1406 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | 1408 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); |
1407 assertSuggestImportedClass('Object'); | 1409 assertSuggestImportedClass('Object'); |
1408 assertNotSuggested('min'); | 1410 assertNotSuggested('min'); |
1409 //assertSuggestImportedFunction( | 1411 //assertSuggestImportedFunction( |
1410 // 'max', | 1412 // 'max', |
1411 // 'num', | 1413 // 'num', |
1412 // false, | 1414 // false, |
1413 // COMPLETION_RELEVANCE_LOW); | 1415 // COMPLETION_RELEVANCE_LOW); |
1414 assertNotSuggested('T1'); | 1416 assertNotSuggested('T1'); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 assertNotSuggested('partBoo'); | 1519 assertNotSuggested('partBoo'); |
1518 // hidden element suggested as low relevance | 1520 // hidden element suggested as low relevance |
1519 // but imported results are partially filtered | 1521 // but imported results are partially filtered |
1520 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); | 1522 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); |
1521 //assertSuggestImportedFunction( | 1523 //assertSuggestImportedFunction( |
1522 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); | 1524 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); |
1523 assertNotSuggested('D2'); | 1525 assertNotSuggested('D2'); |
1524 assertSuggestImportedClass('EE'); | 1526 assertSuggestImportedClass('EE'); |
1525 // hidden element suggested as low relevance | 1527 // hidden element suggested as low relevance |
1526 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | 1528 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); |
1527 assertSuggestLibraryPrefix('g'); | 1529 // Suggested by LibraryPrefixContributor |
| 1530 assertNotSuggested('g'); |
1528 assertNotSuggested('G'); | 1531 assertNotSuggested('G'); |
1529 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | 1532 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); |
1530 assertSuggestImportedClass('Object'); | 1533 assertSuggestImportedClass('Object'); |
1531 assertNotSuggested('min'); | 1534 assertNotSuggested('min'); |
1532 //assertSuggestImportedFunction( | 1535 //assertSuggestImportedFunction( |
1533 // 'max', | 1536 // 'max', |
1534 // 'num', | 1537 // 'num', |
1535 // false, | 1538 // false, |
1536 // COMPLETION_RELEVANCE_LOW); | 1539 // COMPLETION_RELEVANCE_LOW); |
1537 assertNotSuggested('T1'); | 1540 assertNotSuggested('T1'); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 assertNotSuggested('partBoo'); | 1627 assertNotSuggested('partBoo'); |
1625 // hidden element suggested as low relevance | 1628 // hidden element suggested as low relevance |
1626 // but imported results are partially filtered | 1629 // but imported results are partially filtered |
1627 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); | 1630 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); |
1628 //assertSuggestImportedFunction( | 1631 //assertSuggestImportedFunction( |
1629 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); | 1632 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); |
1630 assertNotSuggested('D2'); | 1633 assertNotSuggested('D2'); |
1631 assertSuggestImportedClass('EE'); | 1634 assertSuggestImportedClass('EE'); |
1632 // hidden element suggested as low relevance | 1635 // hidden element suggested as low relevance |
1633 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | 1636 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); |
1634 assertSuggestLibraryPrefix('g'); | 1637 // Suggested by LibraryPrefixContributor |
| 1638 assertNotSuggested('g'); |
1635 assertNotSuggested('G'); | 1639 assertNotSuggested('G'); |
1636 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | 1640 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); |
1637 assertSuggestImportedClass('Object'); | 1641 assertSuggestImportedClass('Object'); |
1638 assertNotSuggested('min'); | 1642 assertNotSuggested('min'); |
1639 //assertSuggestImportedFunction( | 1643 //assertSuggestImportedFunction( |
1640 // 'max', | 1644 // 'max', |
1641 // 'num', | 1645 // 'num', |
1642 // false, | 1646 // false, |
1643 // COMPLETION_RELEVANCE_LOW); | 1647 // COMPLETION_RELEVANCE_LOW); |
1644 assertNotSuggested('T1'); | 1648 assertNotSuggested('T1'); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 if (suggestionB != null) { | 2075 if (suggestionB != null) { |
2072 expect(suggestionB.element.isDeprecated, isFalse); | 2076 expect(suggestionB.element.isDeprecated, isFalse); |
2073 expect(suggestionB.element.isPrivate, isTrue); | 2077 expect(suggestionB.element.isPrivate, isTrue); |
2074 } | 2078 } |
2075 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object'); | 2079 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object'); |
2076 if (suggestionO != null) { | 2080 if (suggestionO != null) { |
2077 expect(suggestionO.element.isDeprecated, isFalse); | 2081 expect(suggestionO.element.isDeprecated, isFalse); |
2078 expect(suggestionO.element.isPrivate, isFalse); | 2082 expect(suggestionO.element.isPrivate, isFalse); |
2079 } | 2083 } |
2080 assertNotSuggested('T'); | 2084 assertNotSuggested('T'); |
2081 assertSuggestLibraryPrefix('x'); | 2085 // Suggested by LibraryPrefixContributor |
| 2086 assertNotSuggested('x'); |
2082 }); | 2087 }); |
2083 } | 2088 } |
2084 | 2089 |
2085 test_ClassDeclaration_body_final() { | 2090 test_ClassDeclaration_body_final() { |
2086 // ClassDeclaration CompilationUnit | 2091 // ClassDeclaration CompilationUnit |
2087 addSource( | 2092 addSource( |
2088 '/testB.dart', | 2093 '/testB.dart', |
2089 ''' | 2094 ''' |
2090 class B { }'''); | 2095 class B { }'''); |
2091 addTestSource(''' | 2096 addTestSource(''' |
2092 import "testB.dart" as x; | 2097 import "testB.dart" as x; |
2093 class A {final ^} | 2098 class A {final ^} |
2094 class _B {} | 2099 class _B {} |
2095 A T;'''); | 2100 A T;'''); |
2096 computeFast(); | 2101 computeFast(); |
2097 return computeFull((bool result) { | 2102 return computeFull((bool result) { |
2098 expect(request.replacementOffset, completionOffset); | 2103 expect(request.replacementOffset, completionOffset); |
2099 expect(request.replacementLength, 0); | 2104 expect(request.replacementLength, 0); |
2100 assertSuggestLocalClass('A'); | 2105 assertSuggestLocalClass('A'); |
2101 assertSuggestLocalClass('_B'); | 2106 assertSuggestLocalClass('_B'); |
2102 assertSuggestImportedClass('Object'); | 2107 assertSuggestImportedClass('Object'); |
2103 assertNotSuggested('T'); | 2108 assertNotSuggested('T'); |
2104 assertSuggestLibraryPrefix('x'); | 2109 // Suggested by LibraryPrefixContributor |
| 2110 assertNotSuggested('x'); |
2105 }); | 2111 }); |
2106 } | 2112 } |
2107 | 2113 |
2108 test_ClassDeclaration_body_final_field() { | 2114 test_ClassDeclaration_body_final_field() { |
2109 // ClassDeclaration CompilationUnit | 2115 // ClassDeclaration CompilationUnit |
2110 addSource( | 2116 addSource( |
2111 '/testB.dart', | 2117 '/testB.dart', |
2112 ''' | 2118 ''' |
2113 class B { }'''); | 2119 class B { }'''); |
2114 addTestSource(''' | 2120 addTestSource(''' |
2115 import "testB.dart" as x; | 2121 import "testB.dart" as x; |
2116 class A {final ^ A(){}} | 2122 class A {final ^ A(){}} |
2117 class _B {} | 2123 class _B {} |
2118 A T;'''); | 2124 A T;'''); |
2119 computeFast(); | 2125 computeFast(); |
2120 return computeFull((bool result) { | 2126 return computeFull((bool result) { |
2121 expect(request.replacementOffset, completionOffset); | 2127 expect(request.replacementOffset, completionOffset); |
2122 expect(request.replacementLength, 0); | 2128 expect(request.replacementLength, 0); |
2123 assertSuggestLocalClass('A'); | 2129 assertSuggestLocalClass('A'); |
2124 assertSuggestLocalClass('_B'); | 2130 assertSuggestLocalClass('_B'); |
2125 assertSuggestImportedClass('String'); | 2131 assertSuggestImportedClass('String'); |
2126 assertNotSuggested('T'); | 2132 assertNotSuggested('T'); |
2127 assertSuggestLibraryPrefix('x'); | 2133 // Suggested by LibraryPrefixContributor |
| 2134 assertNotSuggested('x'); |
2128 }); | 2135 }); |
2129 } | 2136 } |
2130 | 2137 |
2131 test_ClassDeclaration_body_final_field2() { | 2138 test_ClassDeclaration_body_final_field2() { |
2132 // ClassDeclaration CompilationUnit | 2139 // ClassDeclaration CompilationUnit |
2133 addSource( | 2140 addSource( |
2134 '/testB.dart', | 2141 '/testB.dart', |
2135 ''' | 2142 ''' |
2136 class B { }'''); | 2143 class B { }'''); |
2137 addTestSource(''' | 2144 addTestSource(''' |
2138 import "testB.dart" as Soo; | 2145 import "testB.dart" as Soo; |
2139 class A {final S^ A();} | 2146 class A {final S^ A();} |
2140 class _B {} | 2147 class _B {} |
2141 A Sew;'''); | 2148 A Sew;'''); |
2142 computeFast(); | 2149 computeFast(); |
2143 return computeFull((bool result) { | 2150 return computeFull((bool result) { |
2144 expect(request.replacementOffset, completionOffset - 1); | 2151 expect(request.replacementOffset, completionOffset - 1); |
2145 expect(request.replacementLength, 1); | 2152 expect(request.replacementLength, 1); |
2146 assertSuggestLocalClass('A'); | 2153 assertSuggestLocalClass('A'); |
2147 assertSuggestLocalClass('_B'); | 2154 assertSuggestLocalClass('_B'); |
2148 assertSuggestImportedClass('String'); | 2155 assertSuggestImportedClass('String'); |
2149 assertNotSuggested('Sew'); | 2156 assertNotSuggested('Sew'); |
2150 assertSuggestLibraryPrefix('Soo'); | 2157 // Suggested by LibraryPrefixContributor |
| 2158 assertNotSuggested('Soo'); |
2151 }); | 2159 }); |
2152 } | 2160 } |
2153 | 2161 |
2154 test_ClassDeclaration_body_final_final() { | 2162 test_ClassDeclaration_body_final_final() { |
2155 // ClassDeclaration CompilationUnit | 2163 // ClassDeclaration CompilationUnit |
2156 addSource( | 2164 addSource( |
2157 '/testB.dart', | 2165 '/testB.dart', |
2158 ''' | 2166 ''' |
2159 class B { }'''); | 2167 class B { }'''); |
2160 addTestSource(''' | 2168 addTestSource(''' |
2161 import "testB.dart" as x; | 2169 import "testB.dart" as x; |
2162 class A {final ^ final foo;} | 2170 class A {final ^ final foo;} |
2163 class _B {} | 2171 class _B {} |
2164 A T;'''); | 2172 A T;'''); |
2165 computeFast(); | 2173 computeFast(); |
2166 return computeFull((bool result) { | 2174 return computeFull((bool result) { |
2167 expect(request.replacementOffset, completionOffset); | 2175 expect(request.replacementOffset, completionOffset); |
2168 expect(request.replacementLength, 0); | 2176 expect(request.replacementLength, 0); |
2169 assertSuggestLocalClass('A'); | 2177 assertSuggestLocalClass('A'); |
2170 assertSuggestLocalClass('_B'); | 2178 assertSuggestLocalClass('_B'); |
2171 assertSuggestImportedClass('Object'); | 2179 assertSuggestImportedClass('Object'); |
2172 assertNotSuggested('T'); | 2180 assertNotSuggested('T'); |
2173 assertSuggestLibraryPrefix('x'); | 2181 // Suggested by LibraryPrefixContributor |
| 2182 assertNotSuggested('x'); |
2174 }); | 2183 }); |
2175 } | 2184 } |
2176 | 2185 |
2177 test_ClassDeclaration_body_final_var() { | 2186 test_ClassDeclaration_body_final_var() { |
2178 // ClassDeclaration CompilationUnit | 2187 // ClassDeclaration CompilationUnit |
2179 addSource( | 2188 addSource( |
2180 '/testB.dart', | 2189 '/testB.dart', |
2181 ''' | 2190 ''' |
2182 class B { }'''); | 2191 class B { }'''); |
2183 addTestSource(''' | 2192 addTestSource(''' |
2184 import "testB.dart" as x; | 2193 import "testB.dart" as x; |
2185 class A {final ^ var foo;} | 2194 class A {final ^ var foo;} |
2186 class _B {} | 2195 class _B {} |
2187 A T;'''); | 2196 A T;'''); |
2188 computeFast(); | 2197 computeFast(); |
2189 return computeFull((bool result) { | 2198 return computeFull((bool result) { |
2190 expect(request.replacementOffset, completionOffset); | 2199 expect(request.replacementOffset, completionOffset); |
2191 expect(request.replacementLength, 0); | 2200 expect(request.replacementLength, 0); |
2192 assertSuggestLocalClass('A'); | 2201 assertSuggestLocalClass('A'); |
2193 assertSuggestLocalClass('_B'); | 2202 assertSuggestLocalClass('_B'); |
2194 assertSuggestImportedClass('Object'); | 2203 assertSuggestImportedClass('Object'); |
2195 assertNotSuggested('T'); | 2204 assertNotSuggested('T'); |
2196 assertSuggestLibraryPrefix('x'); | 2205 // Suggested by LibraryPrefixContributor |
| 2206 assertNotSuggested('x'); |
2197 }); | 2207 }); |
2198 } | 2208 } |
2199 | 2209 |
2200 test_Combinator_hide() { | 2210 test_Combinator_hide() { |
2201 // SimpleIdentifier HideCombinator ImportDirective | 2211 // SimpleIdentifier HideCombinator ImportDirective |
2202 addSource( | 2212 addSource( |
2203 '/testAB.dart', | 2213 '/testAB.dart', |
2204 ''' | 2214 ''' |
2205 library libAB; | 2215 library libAB; |
2206 part '/partAB.dart'; | 2216 part '/partAB.dart'; |
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4676 assertNotSuggested('bar2'); | 4686 assertNotSuggested('bar2'); |
4677 assertNotSuggested('_B'); | 4687 assertNotSuggested('_B'); |
4678 assertSuggestLocalClass('Y'); | 4688 assertSuggestLocalClass('Y'); |
4679 assertSuggestLocalClass('C'); | 4689 assertSuggestLocalClass('C'); |
4680 assertSuggestLocalVariable('f', null); | 4690 assertSuggestLocalVariable('f', null); |
4681 assertNotSuggested('x'); | 4691 assertNotSuggested('x'); |
4682 assertNotSuggested('e'); | 4692 assertNotSuggested('e'); |
4683 }); | 4693 }); |
4684 } | 4694 } |
4685 } | 4695 } |
OLD | NEW |