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

Side by Side Diff: pkg/analysis_server/lib/src/protocol_server.dart

Issue 1157113004: add enum suggestions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 elementTypeParameters = _getTypeParametersString(element);
88 String elementParameters = _getParametersString(element); 88 String elementParameters = _getParametersString(element);
89 String elementReturnType = _getReturnTypeString(element); 89 String elementReturnType = _getReturnTypeString(element);
90 return new Element(newElementKind_fromEngine(element.kind), name, Element 90 ElementKind kind = newElementKind_fromEngine(element.kind);
91 // TODO(danrubel) this check should be in newElementKind_fromEngine
92 if (element is engine.ClassElement && element.isEnum) {
93 kind = ElementKind.ENUM;
94 }
95 return new Element(kind, name, Element
91 .makeFlags( 96 .makeFlags(
92 isPrivate: element.isPrivate, 97 isPrivate: element.isPrivate,
93 isDeprecated: element.isDeprecated, 98 isDeprecated: element.isDeprecated,
94 isAbstract: _isAbstract(element), 99 isAbstract: _isAbstract(element),
95 isConst: _isConst(element), 100 isConst: _isConst(element),
96 isFinal: _isFinal(element), 101 isFinal: _isFinal(element),
97 isStatic: _isStatic(element)), 102 isStatic: _isStatic(element)),
98 location: newLocation_fromElement(element), 103 location: newLocation_fromElement(element),
99 typeParameters: elementTypeParameters, 104 typeParameters: elementTypeParameters,
100 parameters: elementParameters, 105 parameters: elementParameters,
101 returnType: elementReturnType); 106 returnType: elementReturnType);
102 } 107 }
103 108
104 /** 109 /**
105 * Construct based on a value from the analyzer engine. 110 * Construct based on a value from the analyzer engine.
106 */ 111 */
107 ElementKind newElementKind_fromEngine(engine.ElementKind kind) { 112 ElementKind newElementKind_fromEngine(engine.ElementKind kind) {
108 if (kind == engine.ElementKind.CLASS) { 113 if (kind == engine.ElementKind.CLASS) {
114 // TODO(danrubel) check if element.isEnum and return ElementKind.ENUM
109 return ElementKind.CLASS; 115 return ElementKind.CLASS;
110 } 116 }
111 if (kind == engine.ElementKind.COMPILATION_UNIT) { 117 if (kind == engine.ElementKind.COMPILATION_UNIT) {
112 return ElementKind.COMPILATION_UNIT; 118 return ElementKind.COMPILATION_UNIT;
113 } 119 }
114 if (kind == engine.ElementKind.CONSTRUCTOR) { 120 if (kind == engine.ElementKind.CONSTRUCTOR) {
115 return ElementKind.CONSTRUCTOR; 121 return ElementKind.CONSTRUCTOR;
116 } 122 }
117 if (kind == engine.ElementKind.FIELD) { 123 if (kind == engine.ElementKind.FIELD) {
118 return ElementKind.FIELD; 124 return ElementKind.FIELD;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (lineInfo != null) { 416 if (lineInfo != null) {
411 engine.LineInfo_Location offsetLocation = 417 engine.LineInfo_Location offsetLocation =
412 lineInfo.getLocation(range.offset); 418 lineInfo.getLocation(range.offset);
413 startLine = offsetLocation.lineNumber; 419 startLine = offsetLocation.lineNumber;
414 startColumn = offsetLocation.columnNumber; 420 startColumn = offsetLocation.columnNumber;
415 } 421 }
416 } 422 }
417 return new Location( 423 return new Location(
418 source.fullName, range.offset, range.length, startLine, startColumn); 424 source.fullName, range.offset, range.length, startLine, startColumn);
419 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698