Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1029)

Side by Side Diff: pkg/analysis_server/test/services/completion/completion_test_util.dart

Issue 999923002: completions for function return type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/src/protocol.dart' as protocol 9 import 'package:analysis_server/src/protocol.dart' as protocol
10 show Element, ElementKind; 10 show Element, ElementKind;
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 computeFast(); 2104 computeFast();
2105 return computeFull((bool result) { 2105 return computeFull((bool result) {
2106 expect(request.replacementOffset, completionOffset - 1); 2106 expect(request.replacementOffset, completionOffset - 1);
2107 expect(request.replacementLength, 1); 2107 expect(request.replacementLength, 1);
2108 assertSuggestLocalVariable('index', 'int'); 2108 assertSuggestLocalVariable('index', 'int');
2109 assertSuggestLocalFunction('main', null); 2109 assertSuggestLocalFunction('main', null);
2110 assertNotSuggested('bar'); 2110 assertNotSuggested('bar');
2111 }); 2111 });
2112 } 2112 }
2113 2113
2114 test_FunctionDeclaration_returnType_afterComment() {
2115 // ClassDeclaration CompilationUnit
2116 addSource('/testA.dart', '''
2117 int T1;
2118 F1() { }
2119 typedef D1();
2120 class C1 {C1(this.x) { } int x;}''');
2121 addTestSource('''
2122 import "/testA.dart";
2123 int T2;
2124 F2() { }
2125 typedef D2();
2126 class C2 { }
2127 /* */ ^ zoo(z) { } String name;''');
2128 computeFast();
2129 return computeFull((bool result) {
2130 expect(request.replacementOffset, completionOffset);
2131 expect(request.replacementLength, 0);
2132 assertSuggestImportedClass('Object');
2133 assertNotSuggested('T1');
2134 assertNotSuggested('F1');
2135 assertSuggestImportedFunctionTypeAlias('D1', null);
2136 assertSuggestImportedClass('C1');
2137 assertNotSuggested('T2');
2138 assertNotSuggested('F2');
2139 assertSuggestLocalFunctionTypeAlias('D2', null);
2140 assertSuggestLocalClass('C2');
2141 assertNotSuggested('name');
2142 });
2143 }
2144
2145 test_FunctionDeclaration_returnType_afterComment2() {
2146 // FunctionDeclaration ClassDeclaration CompilationUnit
2147 addSource('/testA.dart', '''
2148 int T1;
2149 F1() { }
2150 typedef D1();
2151 class C1 {C1(this.x) { } int x;}''');
2152 addTestSource('''
2153 import "/testA.dart";
2154 int T2;
2155 F2() { }
2156 typedef D2();
2157 class C2 { }
2158 /** */ ^ zoo(z) { } String name;''');
2159 computeFast();
2160 return computeFull((bool result) {
2161 expect(request.replacementOffset, completionOffset);
2162 expect(request.replacementLength, 0);
2163 assertSuggestImportedClass('Object');
2164 assertNotSuggested('T1');
2165 assertNotSuggested('F1');
2166 assertSuggestImportedFunctionTypeAlias('D1', null);
2167 assertSuggestImportedClass('C1');
2168 assertNotSuggested('T2');
2169 assertNotSuggested('F2');
2170 assertSuggestLocalFunctionTypeAlias('D2', null);
2171 assertSuggestLocalClass('C2');
2172 assertNotSuggested('name');
2173 });
2174 }
2175
2176 test_FunctionDeclaration_returnType_afterComment3() {
2177 // FunctionDeclaration ClassDeclaration CompilationUnit
2178 addSource('/testA.dart', '''
2179 int T1;
2180 F1() { }
2181 typedef D1();
2182 class C1 {C1(this.x) { } int x;}''');
2183 addTestSource('''
2184 import "/testA.dart";
2185 int T2;
2186 F2() { }
2187 typedef D2();
2188 /// some dartdoc
2189 class C2 { }
2190 ^ zoo(z) { } String name;''');
2191 computeFast();
2192 return computeFull((bool result) {
2193 expect(request.replacementOffset, completionOffset);
2194 expect(request.replacementLength, 0);
2195 assertSuggestImportedClass('Object');
2196 assertNotSuggested('T1');
2197 assertNotSuggested('F1');
2198 assertSuggestImportedFunctionTypeAlias('D1', null);
2199 assertSuggestImportedClass('C1');
2200 assertNotSuggested('T2');
2201 assertNotSuggested('F2');
2202 assertSuggestLocalFunctionTypeAlias('D2', null);
2203 assertSuggestLocalClass('C2');
2204 assertNotSuggested('name');
2205 });
2206 }
2207
2114 test_FunctionExpression_body_function() { 2208 test_FunctionExpression_body_function() {
2115 // Block BlockFunctionBody FunctionExpression 2209 // Block BlockFunctionBody FunctionExpression
2116 addTestSource(''' 2210 addTestSource('''
2117 void bar() { } 2211 void bar() { }
2118 String foo(List args) {x.then((R b) {^});}'''); 2212 String foo(List args) {x.then((R b) {^});}''');
2119 computeFast(); 2213 computeFast();
2120 return computeFull((bool result) { 2214 return computeFull((bool result) {
2121 expect(request.replacementOffset, completionOffset); 2215 expect(request.replacementOffset, completionOffset);
2122 expect(request.replacementLength, 0); 2216 expect(request.replacementLength, 0);
2123 var f = assertSuggestLocalFunction('foo', 'String', deprecated: false); 2217 var f = assertSuggestLocalFunction('foo', 'String', deprecated: false);
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 assertNotSuggested('bar2'); 3481 assertNotSuggested('bar2');
3388 assertNotSuggested('_B'); 3482 assertNotSuggested('_B');
3389 assertSuggestLocalClass('Y'); 3483 assertSuggestLocalClass('Y');
3390 assertSuggestLocalClass('C'); 3484 assertSuggestLocalClass('C');
3391 assertSuggestLocalVariable('f', null); 3485 assertSuggestLocalVariable('f', null);
3392 assertNotSuggested('x'); 3486 assertNotSuggested('x');
3393 assertNotSuggested('e'); 3487 assertNotSuggested('e');
3394 }); 3488 });
3395 } 3489 }
3396 } 3490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698