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

Side by Side Diff: pkg/analysis_server/test/protocol_server_test.dart

Issue 990343002: Add an optional 'typeParameters' to Element. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update version. 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.computer.element; 5 library test.computer.element;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 8
9 import 'package:analysis_server/src/constants.dart'; 9 import 'package:analysis_server/src/constants.dart';
10 import 'package:analysis_server/src/protocol_server.dart'; 10 import 'package:analysis_server/src/protocol_server.dart';
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 @reflectiveTest 188 @reflectiveTest
189 class ElementTest extends AbstractContextTest { 189 class ElementTest extends AbstractContextTest {
190 engine.Element findElementInUnit(engine.CompilationUnit unit, String name, 190 engine.Element findElementInUnit(engine.CompilationUnit unit, String name,
191 [engine.ElementKind kind]) { 191 [engine.ElementKind kind]) {
192 return findChildElement(unit.element, name, kind); 192 return findChildElement(unit.element, name, kind);
193 } 193 }
194 194
195 void test_fromElement_CLASS() { 195 void test_fromElement_CLASS() {
196 engine.Source source = addSource('/test.dart', ''' 196 engine.Source source = addSource('/test.dart', '''
197 @deprecated 197 @deprecated
198 abstract class _MyClass {}'''); 198 abstract class _A {}
199 class B<K, V> {}''');
199 engine.CompilationUnit unit = resolveLibraryUnit(source); 200 engine.CompilationUnit unit = resolveLibraryUnit(source);
200 engine.ClassElement engineElement = findElementInUnit(unit, '_MyClass');
201 // create notification Element
202 Element element = newElement_fromEngine(engineElement);
203 expect(element.kind, ElementKind.CLASS);
204 expect(element.name, '_MyClass');
205 { 201 {
206 Location location = element.location; 202 engine.ClassElement engineElement = findElementInUnit(unit, '_A');
207 expect(location.file, '/test.dart'); 203 // create notification Element
208 expect(location.offset, 27); 204 Element element = newElement_fromEngine(engineElement);
209 expect(location.length, '_MyClass'.length); 205 expect(element.kind, ElementKind.CLASS);
210 expect(location.startLine, 2); 206 expect(element.name, '_A');
211 expect(location.startColumn, 16); 207 expect(element.typeParameters, isNull);
208 {
209 Location location = element.location;
210 expect(location.file, '/test.dart');
211 expect(location.offset, 27);
212 expect(location.length, '_A'.length);
213 expect(location.startLine, 2);
214 expect(location.startColumn, 16);
215 }
216 expect(element.parameters, isNull);
217 expect(element.flags, Element.FLAG_ABSTRACT |
218 Element.FLAG_DEPRECATED |
219 Element.FLAG_PRIVATE);
212 } 220 }
213 expect(element.parameters, isNull); 221 {
214 expect(element.flags, 222 engine.ClassElement engineElement = findElementInUnit(unit, 'B');
215 Element.FLAG_ABSTRACT | Element.FLAG_DEPRECATED | Element.FLAG_PRIVATE); 223 // create notification Element
224 Element element = newElement_fromEngine(engineElement);
225 expect(element.kind, ElementKind.CLASS);
226 expect(element.name, 'B');
227 expect(element.typeParameters, '<K, V>');
228 expect(element.flags, 0);
229 }
216 } 230 }
217 231
218 void test_fromElement_CONSTRUCTOR() { 232 void test_fromElement_CONSTRUCTOR() {
219 engine.Source source = addSource('/test.dart', ''' 233 engine.Source source = addSource('/test.dart', '''
220 class A { 234 class A {
221 const A.myConstructor(int a, [String b]); 235 const A.myConstructor(int a, [String b]);
222 }'''); 236 }''');
223 engine.CompilationUnit unit = resolveLibraryUnit(source); 237 engine.CompilationUnit unit = resolveLibraryUnit(source);
224 engine.ConstructorElement engineElement = 238 engine.ConstructorElement engineElement =
225 findElementInUnit(unit, 'myConstructor'); 239 findElementInUnit(unit, 'myConstructor');
226 // create notification Element 240 // create notification Element
227 Element element = newElement_fromEngine(engineElement); 241 Element element = newElement_fromEngine(engineElement);
228 expect(element.kind, ElementKind.CONSTRUCTOR); 242 expect(element.kind, ElementKind.CONSTRUCTOR);
229 expect(element.name, 'myConstructor'); 243 expect(element.name, 'myConstructor');
244 expect(element.typeParameters, isNull);
230 { 245 {
231 Location location = element.location; 246 Location location = element.location;
232 expect(location.file, '/test.dart'); 247 expect(location.file, '/test.dart');
233 expect(location.offset, 20); 248 expect(location.offset, 20);
234 expect(location.length, 'myConstructor'.length); 249 expect(location.length, 'myConstructor'.length);
235 expect(location.startLine, 2); 250 expect(location.startLine, 2);
236 expect(location.startColumn, 11); 251 expect(location.startColumn, 11);
237 } 252 }
238 expect(element.parameters, '(int a, [String b])'); 253 expect(element.parameters, '(int a, [String b])');
239 expect(element.returnType, 'A'); 254 expect(element.returnType, 'A');
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 expect(location.startLine, 2); 286 expect(location.startLine, 2);
272 expect(location.startColumn, 16); 287 expect(location.startColumn, 16);
273 } 288 }
274 expect(element.parameters, isNull); 289 expect(element.parameters, isNull);
275 expect(element.returnType, 'dynamic'); 290 expect(element.returnType, 'dynamic');
276 expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC); 291 expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC);
277 } 292 }
278 293
279 void test_fromElement_FUNCTION_TYPE_ALIAS() { 294 void test_fromElement_FUNCTION_TYPE_ALIAS() {
280 engine.Source source = addSource('/test.dart', ''' 295 engine.Source source = addSource('/test.dart', '''
281 typedef int f(String x); 296 typedef int F<T>(String x);
282 '''); 297 ''');
283 engine.CompilationUnit unit = resolveLibraryUnit(source); 298 engine.CompilationUnit unit = resolveLibraryUnit(source);
284 engine.FunctionTypeAliasElement engineElement = 299 engine.FunctionTypeAliasElement engineElement =
285 findElementInUnit(unit, 'f'); 300 findElementInUnit(unit, 'F');
286 // create notification Element 301 // create notification Element
287 Element element = newElement_fromEngine(engineElement); 302 Element element = newElement_fromEngine(engineElement);
288 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); 303 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS);
289 expect(element.name, 'f'); 304 expect(element.name, 'F');
305 expect(element.typeParameters, '<T>');
290 { 306 {
291 Location location = element.location; 307 Location location = element.location;
292 expect(location.file, '/test.dart'); 308 expect(location.file, '/test.dart');
293 expect(location.offset, 12); 309 expect(location.offset, 12);
294 expect(location.length, 'f'.length); 310 expect(location.length, 'F'.length);
295 expect(location.startLine, 1); 311 expect(location.startLine, 1);
296 expect(location.startColumn, 13); 312 expect(location.startColumn, 13);
297 } 313 }
298 expect(element.parameters, '(String x)'); 314 expect(element.parameters, '(String x)');
299 expect(element.returnType, 'int'); 315 expect(element.returnType, 'int');
300 expect(element.flags, 0); 316 expect(element.flags, 0);
301 } 317 }
302 318
303 void test_fromElement_GETTER() { 319 void test_fromElement_GETTER() {
304 engine.Source source = addSource('/test.dart', ''' 320 engine.Source source = addSource('/test.dart', '''
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 ApiEnum apiValue = convert(engineValue); 496 ApiEnum apiValue = convert(engineValue);
481 expect(apiValue, equals(expectedResult)); 497 expect(apiValue, equals(expectedResult));
482 } 498 }
483 } else { 499 } else {
484 ApiEnum apiValue = convert(engineValue); 500 ApiEnum apiValue = convert(engineValue);
485 expect(apiValue.name, equals(enumName)); 501 expect(apiValue.name, equals(enumName));
486 } 502 }
487 }); 503 });
488 } 504 }
489 } 505 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/integration/protocol_matchers.dart ('k') | pkg/analysis_server/tool/spec/spec_input.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698