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

Side by Side Diff: pkg/analysis_server/lib/src/protocol_server.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 protocol.server; 5 library protocol.server;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/search/search_engine.dart' 8 import 'package:analysis_server/src/services/search/search_engine.dart'
9 as engine; 9 as engine;
10 import 'package:analyzer/src/generated/ast.dart' as engine; 10 import 'package:analyzer/src/generated/ast.dart' as engine;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 String correction = error.correction; 77 String correction = error.correction;
78 return new AnalysisError(severity, type, location, message, 78 return new AnalysisError(severity, type, location, message,
79 correction: correction); 79 correction: correction);
80 } 80 }
81 81
82 /** 82 /**
83 * Construct based on a value from the analyzer engine. 83 * Construct based on a value from the analyzer engine.
84 */ 84 */
85 Element newElement_fromEngine(engine.Element element) { 85 Element newElement_fromEngine(engine.Element element) {
86 String name = element.displayName; 86 String name = element.displayName;
87 String elementTypeParameters = _getTypeParametersString(element);
87 String elementParameters = _getParametersString(element); 88 String elementParameters = _getParametersString(element);
88 String elementReturnType = _getReturnTypeString(element); 89 String elementReturnType = _getReturnTypeString(element);
89 return new Element(newElementKind_fromEngine(element.kind), name, Element 90 return new Element(newElementKind_fromEngine(element.kind), name, Element
90 .makeFlags( 91 .makeFlags(
91 isPrivate: element.isPrivate, 92 isPrivate: element.isPrivate,
92 isDeprecated: element.isDeprecated, 93 isDeprecated: element.isDeprecated,
93 isAbstract: _isAbstract(element), 94 isAbstract: _isAbstract(element),
94 isConst: _isConst(element), 95 isConst: _isConst(element),
95 isFinal: _isFinal(element), 96 isFinal: _isFinal(element),
96 isStatic: _isStatic(element)), 97 isStatic: _isStatic(element)),
97 location: newLocation_fromElement(element), 98 location: newLocation_fromElement(element),
99 typeParameters: elementTypeParameters,
98 parameters: elementParameters, 100 parameters: elementParameters,
99 returnType: elementReturnType); 101 returnType: elementReturnType);
100 } 102 }
101 103
102 /** 104 /**
103 * Construct based on a value from the analyzer engine. 105 * Construct based on a value from the analyzer engine.
104 */ 106 */
105 ElementKind newElementKind_fromEngine(engine.ElementKind kind) { 107 ElementKind newElementKind_fromEngine(engine.ElementKind kind) {
106 if (kind == engine.ElementKind.CLASS) { 108 if (kind == engine.ElementKind.CLASS) {
107 return ElementKind.CLASS; 109 return ElementKind.CLASS;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } else if (element is engine.VariableElement) { 346 } else if (element is engine.VariableElement) {
345 engine.DartType type = element.type; 347 engine.DartType type = element.type;
346 return type != null ? type.displayName : 'dynamic'; 348 return type != null ? type.displayName : 'dynamic';
347 } else if (element is engine.FunctionTypeAliasElement) { 349 } else if (element is engine.FunctionTypeAliasElement) {
348 return element.returnType.toString(); 350 return element.returnType.toString();
349 } else { 351 } else {
350 return null; 352 return null;
351 } 353 }
352 } 354 }
353 355
356 String _getTypeParametersString(engine.Element element) {
357 List<engine.TypeParameterElement> typeParameters;
358 if (element is engine.ClassElement) {
359 typeParameters = element.typeParameters;
360 } else if (element is engine.FunctionTypeAliasElement) {
361 typeParameters = element.typeParameters;
362 }
363 if (typeParameters == null || typeParameters.isEmpty) {
364 return null;
365 }
366 return '<${typeParameters.join(', ')}>';
367 }
368
354 bool _isAbstract(engine.Element element) { 369 bool _isAbstract(engine.Element element) {
355 // TODO(scheglov) add isAbstract to Element API 370 // TODO(scheglov) add isAbstract to Element API
356 if (element is engine.ClassElement) { 371 if (element is engine.ClassElement) {
357 return element.isAbstract; 372 return element.isAbstract;
358 } 373 }
359 if (element is engine.MethodElement) { 374 if (element is engine.MethodElement) {
360 return element.isAbstract; 375 return element.isAbstract;
361 } 376 }
362 if (element is engine.PropertyAccessorElement) { 377 if (element is engine.PropertyAccessorElement) {
363 return element.isAbstract; 378 return element.isAbstract;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (lineInfo != null) { 422 if (lineInfo != null) {
408 engine.LineInfo_Location offsetLocation = 423 engine.LineInfo_Location offsetLocation =
409 lineInfo.getLocation(range.offset); 424 lineInfo.getLocation(range.offset);
410 startLine = offsetLocation.lineNumber; 425 startLine = offsetLocation.lineNumber;
411 startColumn = offsetLocation.columnNumber; 426 startColumn = offsetLocation.columnNumber;
412 } 427 }
413 } 428 }
414 return new Location( 429 return new Location(
415 source.fullName, range.offset, range.length, startLine, startColumn); 430 source.fullName, range.offset, range.length, startLine, startColumn);
416 } 431 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/generated_protocol.dart ('k') | pkg/analysis_server/test/analysis/notification_outline_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698