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

Side by Side Diff: pkg/analysis_server/lib/src/computer/computer_outline.dart

Issue 482573004: Change analysis server protocol to omit empty lists when optional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Simplify constructor invocations. Created 6 years, 4 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/computer/computer_overrides.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 computer.outline; 5 library computer.outline;
6 6
7 import 'package:analysis_server/src/protocol2.dart'; 7 import 'package:analysis_server/src/protocol2.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/element.dart' as engine; 9 import 'package:analyzer/src/generated/element.dart' as engine;
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 List<Outline> classContents) { 157 List<Outline> classContents) {
158 SimpleIdentifier nameNode = classDeclaration.name; 158 SimpleIdentifier nameNode = classDeclaration.name;
159 String name = nameNode.name; 159 String name = nameNode.name;
160 _SourceRegion sourceRegion = _getSourceRegion(classDeclaration); 160 _SourceRegion sourceRegion = _getSourceRegion(classDeclaration);
161 Element element = new Element(ElementKind.CLASS, name, 161 Element element = new Element(ElementKind.CLASS, name,
162 Element.makeFlags(isPrivate: Identifier.isPrivateName(name), 162 Element.makeFlags(isPrivate: Identifier.isPrivateName(name),
163 isDeprecated: _isDeprecated(classDeclaration), 163 isDeprecated: _isDeprecated(classDeclaration),
164 isAbstract: classDeclaration.isAbstract), 164 isAbstract: classDeclaration.isAbstract),
165 location: _getLocationNode(nameNode)); 165 location: _getLocationNode(nameNode));
166 return new Outline(element, sourceRegion.offset, 166 return new Outline(element, sourceRegion.offset,
167 sourceRegion.length, 167 sourceRegion.length, children: classContents);
168 children: classContents.isNotEmpty ? classContents : null);
169 } 168 }
170 169
171 Outline _newClassTypeAlias(ClassTypeAlias alias) { 170 Outline _newClassTypeAlias(ClassTypeAlias alias) {
172 SimpleIdentifier nameNode = alias.name; 171 SimpleIdentifier nameNode = alias.name;
173 String name = nameNode.name; 172 String name = nameNode.name;
174 _SourceRegion sourceRegion = _getSourceRegion(alias); 173 _SourceRegion sourceRegion = _getSourceRegion(alias);
175 Element element = new Element(ElementKind.CLASS_TYPE_ALIAS, name, 174 Element element = new Element(ElementKind.CLASS_TYPE_ALIAS, name,
176 Element.makeFlags(isPrivate: Identifier.isPrivateName(name), 175 Element.makeFlags(isPrivate: Identifier.isPrivateName(name),
177 isDeprecated: _isDeprecated(alias), isAbstract: alias.isAbstract), 176 isDeprecated: _isDeprecated(alias), isAbstract: alias.isAbstract),
178 location: _getLocationNode(nameNode)); 177 location: _getLocationNode(nameNode));
(...skipping 18 matching lines...) Expand all
197 _SourceRegion sourceRegion = _getSourceRegion(constructor); 196 _SourceRegion sourceRegion = _getSourceRegion(constructor);
198 FormalParameterList parameters = constructor.parameters; 197 FormalParameterList parameters = constructor.parameters;
199 String parametersStr = parameters != null ? parameters.toSource() : ''; 198 String parametersStr = parameters != null ? parameters.toSource() : '';
200 Element element = new Element(ElementKind.CONSTRUCTOR, name, 199 Element element = new Element(ElementKind.CONSTRUCTOR, name,
201 Element.makeFlags(isPrivate: isPrivate, 200 Element.makeFlags(isPrivate: isPrivate,
202 isDeprecated: _isDeprecated(constructor)), 201 isDeprecated: _isDeprecated(constructor)),
203 location: _getLocationOffsetLength(offset, length), 202 location: _getLocationOffsetLength(offset, length),
204 parameters: parametersStr); 203 parameters: parametersStr);
205 List<Outline> contents = _addLocalFunctionOutlines(constructor.body); 204 List<Outline> contents = _addLocalFunctionOutlines(constructor.body);
206 Outline outline = new Outline(element, sourceRegion.offset, 205 Outline outline = new Outline(element, sourceRegion.offset,
207 sourceRegion.length, children: contents.isNotEmpty ? contents : null); 206 sourceRegion.length, children: contents);
208 return outline; 207 return outline;
209 } 208 }
210 209
211 Outline _newFunctionOutline(FunctionDeclaration function, bool isStatic) { 210 Outline _newFunctionOutline(FunctionDeclaration function, bool isStatic) {
212 TypeName returnType = function.returnType; 211 TypeName returnType = function.returnType;
213 SimpleIdentifier nameNode = function.name; 212 SimpleIdentifier nameNode = function.name;
214 String name = nameNode.name; 213 String name = nameNode.name;
215 FunctionExpression functionExpression = function.functionExpression; 214 FunctionExpression functionExpression = function.functionExpression;
216 FormalParameterList parameters = functionExpression.parameters; 215 FormalParameterList parameters = functionExpression.parameters;
217 ElementKind kind; 216 ElementKind kind;
218 if (function.isGetter) { 217 if (function.isGetter) {
219 kind = ElementKind.GETTER; 218 kind = ElementKind.GETTER;
220 } else if (function.isSetter) { 219 } else if (function.isSetter) {
221 kind = ElementKind.SETTER; 220 kind = ElementKind.SETTER;
222 } else { 221 } else {
223 kind = ElementKind.FUNCTION; 222 kind = ElementKind.FUNCTION;
224 } 223 }
225 _SourceRegion sourceRegion = _getSourceRegion(function); 224 _SourceRegion sourceRegion = _getSourceRegion(function);
226 String parametersStr = parameters != null ? parameters.toSource() : ''; 225 String parametersStr = parameters != null ? parameters.toSource() : '';
227 String returnTypeStr = returnType != null ? returnType.toSource() : ''; 226 String returnTypeStr = returnType != null ? returnType.toSource() : '';
228 Element element = new Element(kind, name, 227 Element element = new Element(kind, name,
229 Element.makeFlags(isPrivate: Identifier.isPrivateName(name), 228 Element.makeFlags(isPrivate: Identifier.isPrivateName(name),
230 isDeprecated: _isDeprecated(function), isStatic: isStatic), 229 isDeprecated: _isDeprecated(function), isStatic: isStatic),
231 location: _getLocationNode(nameNode), parameters: parametersStr, 230 location: _getLocationNode(nameNode), parameters: parametersStr,
232 returnType: returnTypeStr); 231 returnType: returnTypeStr);
233 List<Outline> contents = _addLocalFunctionOutlines(functionExpression.body); 232 List<Outline> contents = _addLocalFunctionOutlines(functionExpression.body);
234 Outline outline = new Outline(element, sourceRegion.offset, 233 Outline outline = new Outline(element, sourceRegion.offset,
235 sourceRegion.length, children: contents.isNotEmpty ? contents : null); 234 sourceRegion.length, children: contents);
236 return outline; 235 return outline;
237 } 236 }
238 237
239 Outline _newFunctionTypeAliasOutline(FunctionTypeAlias alias) { 238 Outline _newFunctionTypeAliasOutline(FunctionTypeAlias alias) {
240 TypeName returnType = alias.returnType; 239 TypeName returnType = alias.returnType;
241 SimpleIdentifier nameNode = alias.name; 240 SimpleIdentifier nameNode = alias.name;
242 String name = nameNode.name; 241 String name = nameNode.name;
243 _SourceRegion sourceRegion = _getSourceRegion(alias); 242 _SourceRegion sourceRegion = _getSourceRegion(alias);
244 FormalParameterList parameters = alias.parameters; 243 FormalParameterList parameters = alias.parameters;
245 String parametersStr = parameters != null ? parameters.toSource() : ''; 244 String parametersStr = parameters != null ? parameters.toSource() : '';
(...skipping 23 matching lines...) Expand all
269 _SourceRegion sourceRegion = _getSourceRegion(method); 268 _SourceRegion sourceRegion = _getSourceRegion(method);
270 String parametersStr = parameters != null ? parameters.toSource() : ''; 269 String parametersStr = parameters != null ? parameters.toSource() : '';
271 String returnTypeStr = returnType != null ? returnType.toSource() : ''; 270 String returnTypeStr = returnType != null ? returnType.toSource() : '';
272 Element element = new Element(kind, name, 271 Element element = new Element(kind, name,
273 Element.makeFlags(isPrivate: Identifier.isPrivateName(name), 272 Element.makeFlags(isPrivate: Identifier.isPrivateName(name),
274 isDeprecated: _isDeprecated(method), isAbstract: method.isAbstract, 273 isDeprecated: _isDeprecated(method), isAbstract: method.isAbstract,
275 isStatic: method.isStatic), location: _getLocationNode(nameNode), 274 isStatic: method.isStatic), location: _getLocationNode(nameNode),
276 parameters: parametersStr, returnType: returnTypeStr); 275 parameters: parametersStr, returnType: returnTypeStr);
277 List<Outline> contents = _addLocalFunctionOutlines(method.body); 276 List<Outline> contents = _addLocalFunctionOutlines(method.body);
278 Outline outline = new Outline(element, sourceRegion.offset, 277 Outline outline = new Outline(element, sourceRegion.offset,
279 sourceRegion.length, children: contents.isNotEmpty ? contents : null); 278 sourceRegion.length, children: contents);
280 return outline; 279 return outline;
281 } 280 }
282 281
283 Outline _newUnitOutline(List<Outline> unitContents) { 282 Outline _newUnitOutline(List<Outline> unitContents) {
284 Element element = new Element(ElementKind.COMPILATION_UNIT, '<unit>', 283 Element element = new Element(ElementKind.COMPILATION_UNIT, '<unit>',
285 Element.makeFlags(), location: _getLocationNode(_unit)); 284 Element.makeFlags(), location: _getLocationNode(_unit));
286 return new Outline(element, _unit.offset, _unit.length, 285 return new Outline(element, _unit.offset, _unit.length,
287 children: unitContents.isNotEmpty ? unitContents : null); 286 children: unitContents);
288 } 287 }
289 288
290 Outline _newVariableOutline(String typeName, ElementKind kind, 289 Outline _newVariableOutline(String typeName, ElementKind kind,
291 VariableDeclaration variable, bool isStatic) { 290 VariableDeclaration variable, bool isStatic) {
292 SimpleIdentifier nameNode = variable.name; 291 SimpleIdentifier nameNode = variable.name;
293 String name = nameNode.name; 292 String name = nameNode.name;
294 _SourceRegion sourceRegion = _getSourceRegion(variable); 293 _SourceRegion sourceRegion = _getSourceRegion(variable);
295 Element element = new Element(kind, name, 294 Element element = new Element(kind, name,
296 Element.makeFlags(isPrivate: Identifier.isPrivateName(name), 295 Element.makeFlags(isPrivate: Identifier.isPrivateName(name),
297 isDeprecated: _isDeprecated(variable), 296 isDeprecated: _isDeprecated(variable),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 329
331 330
332 /** 331 /**
333 * A range of characters. 332 * A range of characters.
334 */ 333 */
335 class _SourceRegion { 334 class _SourceRegion {
336 final int length; 335 final int length;
337 final int offset; 336 final int offset;
338 _SourceRegion(this.offset, this.length); 337 _SourceRegion(this.offset, this.length);
339 } 338 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/computer/computer_overrides.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698