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

Side by Side Diff: pkg/analysis_server/lib/src/generated/service_computers.dart

Issue 361713005: Remove server/generated folder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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/generated/service_interfaces.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information.
7
8 library service.computers;
9
10 import 'package:analyzer/src/generated/java_core.dart' show JavaStringBuilder, S tringUtils;
11 import 'package:analyzer/src/generated/java_engine.dart';
12 import 'package:analyzer/src/generated/source.dart' show Source;
13 import 'package:analyzer/src/generated/scanner.dart' show Token;
14 import 'package:analyzer/src/generated/ast.dart';
15 import 'package:analyzer/src/generated/element.dart' as pae;
16 import 'package:analyzer/src/generated/element.dart' show DartType;
17 import 'package:analyzer/src/generated/source.dart';
18 import 'service_interfaces.dart' as psi;
19
20 /**
21 * A concrete implementation of [CompletionSuggestion].
22 */
23 class CompletionSuggestionImpl implements psi.CompletionSuggestion {
24 final String completion;
25
26 final String declaringType;
27
28 final String elementDocSummary;
29
30 final String elementDocDetails;
31
32 final psi.CompletionSuggestionKind kind;
33
34 final int location;
35
36 final String parameterName;
37
38 final List<String> parameterNames;
39
40 final String parameterType;
41
42 final List<String> parameterTypes;
43
44 final int positionalParameterCount;
45
46 final int relevance;
47
48 final int replacementLength;
49
50 final int replacementLengthIdentifier;
51
52 final String returnType;
53
54 final bool hasNamed;
55
56 final bool hasPositional;
57
58 final bool isDeprecated;
59
60 final bool isPotentialMatch;
61
62 CompletionSuggestionImpl(this.elementDocSummary, this.elementDocDetails, this. completion, this.declaringType, this.kind, this.location, this.parameterName, th is.parameterNames, this.parameterType, this.parameterTypes, this.positionalParam eterCount, this.relevance, this.replacementLength, this.replacementLengthIdentif ier, this.returnType, this.hasNamed, this.hasPositional, this.isDeprecated, this .isPotentialMatch);
63 }
64
65 /**
66 * A computer for [HighlightRegion]s in a Dart [CompilationUnit].
67 */
68 class DartUnitHighlightsComputer {
69 final CompilationUnit _unit;
70
71 List<psi.HighlightRegion> _regions = [];
72
73 DartUnitHighlightsComputer(this._unit);
74
75 /**
76 * Returns the computed [HighlightRegion]s, not `null`.
77 */
78 List<psi.HighlightRegion> compute() {
79 _unit.accept(new RecursiveAstVisitor_DartUnitHighlightsComputer_compute(this ));
80 return new List.from(_regions);
81 }
82
83 void _addIdentifierRegion(SimpleIdentifier node) {
84 if (_addIdentifierRegion_keyword(node)) {
85 return;
86 }
87 if (_addIdentifierRegion_class(node)) {
88 return;
89 }
90 if (_addIdentifierRegion_constructor(node)) {
91 return;
92 }
93 if (_addIdentifierRegion_dynamicType(node)) {
94 return;
95 }
96 if (_addIdentifierRegion_getterSetterDeclaration(node)) {
97 return;
98 }
99 if (_addIdentifierRegion_field(node)) {
100 return;
101 }
102 if (_addIdentifierRegion_function(node)) {
103 return;
104 }
105 if (_addIdentifierRegion_functionTypeAlias(node)) {
106 return;
107 }
108 if (_addIdentifierRegion_importPrefix(node)) {
109 return;
110 }
111 if (_addIdentifierRegion_localVariable(node)) {
112 return;
113 }
114 if (_addIdentifierRegion_method(node)) {
115 return;
116 }
117 if (_addIdentifierRegion_parameter(node)) {
118 return;
119 }
120 if (_addIdentifierRegion_topLevelVariable(node)) {
121 return;
122 }
123 if (_addIdentifierRegion_typeParameter(node)) {
124 return;
125 }
126 _addRegion_node(node, psi.HighlightType.IDENTIFIER_DEFAULT);
127 }
128
129 void _addIdentifierRegion_annotation(Annotation node) {
130 ArgumentList arguments = node.arguments;
131 if (arguments == null) {
132 _addRegion_node(node, psi.HighlightType.ANNOTATION);
133 } else {
134 _addRegion_nodeStart_tokenEnd(node, arguments.beginToken, psi.HighlightTyp e.ANNOTATION);
135 _addRegion_token(arguments.endToken, psi.HighlightType.ANNOTATION);
136 }
137 }
138
139 bool _addIdentifierRegion_class(SimpleIdentifier node) {
140 pae.Element element = node.staticElement;
141 if (element is! pae.ClassElement) {
142 return false;
143 }
144 return _addRegion_node(node, psi.HighlightType.CLASS);
145 }
146
147 bool _addIdentifierRegion_constructor(SimpleIdentifier node) {
148 pae.Element element = node.staticElement;
149 if (element is! pae.ConstructorElement) {
150 return false;
151 }
152 return _addRegion_node(node, psi.HighlightType.CONSTRUCTOR);
153 }
154
155 bool _addIdentifierRegion_dynamicType(SimpleIdentifier node) {
156 // should be variable
157 pae.Element element = node.staticElement;
158 if (element is! pae.VariableElement) {
159 return false;
160 }
161 // has propagated type
162 if (node.propagatedType != null) {
163 return false;
164 }
165 // has dynamic static type
166 DartType staticType = node.staticType;
167 if (staticType == null || !staticType.isDynamic) {
168 return false;
169 }
170 // OK
171 return _addRegion_node(node, psi.HighlightType.DYNAMIC_TYPE);
172 }
173
174 bool _addIdentifierRegion_field(SimpleIdentifier node) {
175 pae.Element element = node.bestElement;
176 if (element is pae.FieldFormalParameterElement) {
177 element = (element as pae.FieldFormalParameterElement).field;
178 }
179 if (element is pae.FieldElement) {
180 if ((element as pae.FieldElement).isStatic) {
181 return _addRegion_node(node, psi.HighlightType.FIELD_STATIC);
182 } else {
183 return _addRegion_node(node, psi.HighlightType.FIELD);
184 }
185 }
186 if (element is pae.PropertyAccessorElement) {
187 if ((element as pae.PropertyAccessorElement).isStatic) {
188 return _addRegion_node(node, psi.HighlightType.FIELD_STATIC);
189 } else {
190 return _addRegion_node(node, psi.HighlightType.FIELD);
191 }
192 }
193 return false;
194 }
195
196 bool _addIdentifierRegion_function(SimpleIdentifier node) {
197 pae.Element element = node.staticElement;
198 if (element is! pae.FunctionElement) {
199 return false;
200 }
201 psi.HighlightType type;
202 if (node.inDeclarationContext()) {
203 type = psi.HighlightType.FUNCTION_DECLARATION;
204 } else {
205 type = psi.HighlightType.FUNCTION;
206 }
207 return _addRegion_node(node, type);
208 }
209
210 bool _addIdentifierRegion_functionTypeAlias(SimpleIdentifier node) {
211 pae.Element element = node.staticElement;
212 if (element is! pae.FunctionTypeAliasElement) {
213 return false;
214 }
215 return _addRegion_node(node, psi.HighlightType.FUNCTION_TYPE_ALIAS);
216 }
217
218 bool _addIdentifierRegion_getterSetterDeclaration(SimpleIdentifier node) {
219 // should be declaration
220 AstNode parent = node.parent;
221 if (!(parent is MethodDeclaration || parent is FunctionDeclaration)) {
222 return false;
223 }
224 // should be property accessor
225 pae.Element element = node.staticElement;
226 if (element is! pae.PropertyAccessorElement) {
227 return false;
228 }
229 // getter or setter
230 pae.PropertyAccessorElement propertyAccessorElement = element as pae.Propert yAccessorElement;
231 if (propertyAccessorElement.isGetter) {
232 return _addRegion_node(node, psi.HighlightType.GETTER_DECLARATION);
233 } else {
234 return _addRegion_node(node, psi.HighlightType.SETTER_DECLARATION);
235 }
236 }
237
238 bool _addIdentifierRegion_importPrefix(SimpleIdentifier node) {
239 pae.Element element = node.staticElement;
240 if (element is! pae.PrefixElement) {
241 return false;
242 }
243 return _addRegion_node(node, psi.HighlightType.IMPORT_PREFIX);
244 }
245
246 bool _addIdentifierRegion_keyword(SimpleIdentifier node) {
247 String name = node.name;
248 if (name == "void") {
249 return _addRegion_node(node, psi.HighlightType.KEYWORD);
250 }
251 return false;
252 }
253
254 bool _addIdentifierRegion_localVariable(SimpleIdentifier node) {
255 pae.Element element = node.staticElement;
256 if (element is! pae.LocalVariableElement) {
257 return false;
258 }
259 // OK
260 psi.HighlightType type;
261 if (node.inDeclarationContext()) {
262 type = psi.HighlightType.LOCAL_VARIABLE_DECLARATION;
263 } else {
264 type = psi.HighlightType.LOCAL_VARIABLE;
265 }
266 return _addRegion_node(node, type);
267 }
268
269 bool _addIdentifierRegion_method(SimpleIdentifier node) {
270 pae.Element element = node.bestElement;
271 if (element is! pae.MethodElement) {
272 return false;
273 }
274 pae.MethodElement methodElement = element as pae.MethodElement;
275 bool isStatic = methodElement.isStatic;
276 // OK
277 psi.HighlightType type;
278 if (node.inDeclarationContext()) {
279 if (isStatic) {
280 type = psi.HighlightType.METHOD_DECLARATION_STATIC;
281 } else {
282 type = psi.HighlightType.METHOD_DECLARATION;
283 }
284 } else {
285 if (isStatic) {
286 type = psi.HighlightType.METHOD_STATIC;
287 } else {
288 type = psi.HighlightType.METHOD;
289 }
290 }
291 return _addRegion_node(node, type);
292 }
293
294 bool _addIdentifierRegion_parameter(SimpleIdentifier node) {
295 pae.Element element = node.staticElement;
296 if (element is! pae.ParameterElement) {
297 return false;
298 }
299 return _addRegion_node(node, psi.HighlightType.PARAMETER);
300 }
301
302 bool _addIdentifierRegion_topLevelVariable(SimpleIdentifier node) {
303 pae.Element element = node.staticElement;
304 if (element is! pae.TopLevelVariableElement) {
305 return false;
306 }
307 return _addRegion_node(node, psi.HighlightType.TOP_LEVEL_VARIABLE);
308 }
309
310 bool _addIdentifierRegion_typeParameter(SimpleIdentifier node) {
311 pae.Element element = node.staticElement;
312 if (element is! pae.TypeParameterElement) {
313 return false;
314 }
315 return _addRegion_node(node, psi.HighlightType.TYPE_PARAMETER);
316 }
317
318 void _addRegion(int offset, int length, psi.HighlightType type) {
319 _regions.add(new HighlightRegionImpl(offset, length, type));
320 }
321
322 bool _addRegion_node(AstNode node, psi.HighlightType type) {
323 int offset = node.offset;
324 int length = node.length;
325 _addRegion(offset, length, type);
326 return true;
327 }
328
329 void _addRegion_nodeStart_tokenEnd(AstNode a, Token b, psi.HighlightType type) {
330 int offset = a.offset;
331 int end = b.end;
332 _addRegion(offset, end - offset, type);
333 }
334
335 void _addRegion_token(Token token, psi.HighlightType type) {
336 if (token != null) {
337 int offset = token.offset;
338 int length = token.length;
339 _addRegion(offset, length, type);
340 }
341 }
342
343 void _addRegion_tokenStart_tokenEnd(Token a, Token b, psi.HighlightType type) {
344 int offset = a.offset;
345 int end = b.end;
346 _addRegion(offset, end - offset, type);
347 }
348 }
349
350 /**
351 * A computer for [NavigationRegion]s in a Dart [CompilationUnit].
352 */
353 class DartUnitNavigationComputer {
354 final String _contextId;
355
356 final CompilationUnit _unit;
357
358 List<psi.NavigationRegion> _regions = [];
359
360 DartUnitNavigationComputer(this._contextId, this._unit);
361
362 /**
363 * Returns the computed [NavigationRegion]s, not `null`.
364 */
365 List<psi.NavigationRegion> compute() {
366 _unit.accept(new RecursiveAstVisitor_DartUnitNavigationComputer_compute(this ));
367 return new List.from(_regions);
368 }
369
370 /**
371 * If the given [Element] is not `null`, then creates a corresponding
372 * [NavigationRegion].
373 */
374 void _addRegion(int offset, int length, pae.Element element) {
375 psi.Element target = _createTarget(element);
376 if (target == null) {
377 return;
378 }
379 _regions.add(new NavigationRegionImpl(offset, length, <psi.Element> [target] ));
380 }
381
382 void _addRegion_nodeStart_nodeEnd(AstNode a, AstNode b, pae.Element element) {
383 int offset = a.offset;
384 int length = b.end - offset;
385 _addRegion(offset, length, element);
386 }
387
388 void _addRegion_nodeStart_nodeStart(AstNode a, AstNode b, pae.Element element) {
389 int offset = a.offset;
390 int length = b.offset - offset;
391 _addRegion(offset, length, element);
392 }
393
394 void _addRegion_tokenStart_nodeEnd(Token a, AstNode b, pae.Element element) {
395 int offset = a.offset;
396 int length = b.end - offset;
397 _addRegion(offset, length, element);
398 }
399
400 /**
401 * If the given [Element] is not `null`, then creates a corresponding
402 * [NavigationRegion].
403 */
404 void _addRegionForNode(AstNode node, pae.Element element) {
405 int offset = node.offset;
406 int length = node.length;
407 _addRegion(offset, length, element);
408 }
409
410 /**
411 * If the given [Element] is not `null`, then creates a corresponding
412 * [NavigationRegion].
413 */
414 void _addRegionForToken(Token token, pae.Element element) {
415 int offset = token.offset;
416 int length = token.length;
417 _addRegion(offset, length, element);
418 }
419
420 /**
421 * Returns the [com.google.dart.server.Element] for the given [Element], maybe
422 * `null` if `null` was given.
423 */
424 psi.Element _createTarget(pae.Element element) {
425 if (element == null) {
426 return null;
427 }
428 if (element is pae.FieldFormalParameterElement) {
429 element = (element as pae.FieldFormalParameterElement).field;
430 }
431 return ElementImpl.create(_contextId, element);
432 }
433 }
434
435 /**
436 * A computer for [Outline]s in a Dart [CompilationUnit].
437 */
438 class DartUnitOutlineComputer {
439 static String _UNITTEST_LIBRARY = "unittest";
440
441 final String _contextId;
442
443 final Source _source;
444
445 final CompilationUnit _unit;
446
447 DartUnitOutlineComputer(this._contextId, this._source, this._unit);
448
449 /**
450 * Returns the computed [Outline]s, not `null`.
451 */
452 psi.Outline compute() {
453 OutlineImpl unitOutline = _newUnitOutline();
454 List<psi.Outline> unitChildren = [];
455 for (CompilationUnitMember unitMember in _unit.declarations) {
456 if (unitMember is ClassDeclaration) {
457 ClassDeclaration classDeclartion = unitMember;
458 OutlineImpl classOutline = _newClassOutline(unitOutline, unitChildren, c lassDeclartion);
459 List<psi.Outline> classChildren = [];
460 for (ClassMember classMember in classDeclartion.members) {
461 if (classMember is ConstructorDeclaration) {
462 ConstructorDeclaration constructorDeclaration = classMember;
463 _newConstructorOutline(classOutline, classChildren, constructorDecla ration);
464 }
465 if (classMember is FieldDeclaration) {
466 FieldDeclaration fieldDeclaration = classMember;
467 VariableDeclarationList fields = fieldDeclaration.fields;
468 if (fields != null) {
469 TypeName fieldType = fields.type;
470 String fieldTypeName = fieldType != null ? fieldType.toSource() : "";
471 for (VariableDeclaration field in fields.variables) {
472 _newVariableOutline(classOutline, classChildren, fieldTypeName, psi.ElementKind.FIELD, field, fieldDeclaration.isStatic);
473 }
474 }
475 }
476 if (classMember is MethodDeclaration) {
477 MethodDeclaration methodDeclaration = classMember;
478 _newMethodOutline(classOutline, classChildren, methodDeclaration);
479 }
480 }
481 classOutline.children = new List.from(classChildren);
482 }
483 if (unitMember is TopLevelVariableDeclaration) {
484 TopLevelVariableDeclaration fieldDeclaration = unitMember;
485 VariableDeclarationList fields = fieldDeclaration.variables;
486 if (fields != null) {
487 TypeName fieldType = fields.type;
488 String fieldTypeName = fieldType != null ? fieldType.toSource() : "";
489 for (VariableDeclaration field in fields.variables) {
490 _newVariableOutline(unitOutline, unitChildren, fieldTypeName, psi.El ementKind.TOP_LEVEL_VARIABLE, field, false);
491 }
492 }
493 }
494 if (unitMember is FunctionDeclaration) {
495 FunctionDeclaration functionDeclaration = unitMember;
496 _newFunctionOutline(unitOutline, unitChildren, functionDeclaration);
497 }
498 if (unitMember is ClassTypeAlias) {
499 ClassTypeAlias alias = unitMember;
500 _newClassTypeAlias(unitOutline, unitChildren, alias);
501 }
502 if (unitMember is FunctionTypeAlias) {
503 FunctionTypeAlias alias = unitMember;
504 _newFunctionTypeAliasOutline(unitOutline, unitChildren, alias);
505 }
506 }
507 unitOutline.children = new List.from(unitChildren);
508 return unitOutline;
509 }
510
511 void _addLocalFunctionOutlines(OutlineImpl parent, FunctionBody body) {
512 List<psi.Outline> localOutlines = [];
513 body.accept(new RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunction Outlines(this, parent, localOutlines));
514 parent.children = new List.from(localOutlines);
515 }
516
517 bool _addUnitTestOutlines(OutlineImpl parent, List<psi.Outline> children, Meth odInvocation node) {
518 psi.ElementKind unitTestKind = null;
519 if (_isUnitTestFunctionInvocation(node, "group")) {
520 unitTestKind = psi.ElementKind.UNIT_TEST_GROUP;
521 } else if (_isUnitTestFunctionInvocation(node, "test")) {
522 unitTestKind = psi.ElementKind.UNIT_TEST_CASE;
523 } else {
524 return false;
525 }
526 ArgumentList argumentList = node.argumentList;
527 if (argumentList != null) {
528 List<Expression> arguments = argumentList.arguments;
529 if (arguments.length == 2 && arguments[1] is FunctionExpression) {
530 // prepare name
531 String name;
532 int nameOffset;
533 int nameLength;
534 {
535 Expression nameNode = arguments[0];
536 if (nameNode is SimpleStringLiteral) {
537 SimpleStringLiteral nameLiteral = arguments[0] as SimpleStringLitera l;
538 name = nameLiteral.value;
539 nameOffset = nameLiteral.valueOffset;
540 nameLength = name.length;
541 } else {
542 name = "??????????";
543 nameOffset = nameNode.offset;
544 nameLength = nameNode.length;
545 }
546 }
547 // add a new outline
548 FunctionExpression functionExpression = arguments[1] as FunctionExpressi on;
549 SourceRegionImpl sourceRegion = new SourceRegionImpl(node.offset, node.l ength);
550 ElementImpl element = new ElementImpl(_contextId, null, _source, unitTes tKind, name, nameOffset, nameLength, null, null, false, false, false);
551 OutlineImpl outline = new OutlineImpl(parent, element, sourceRegion);
552 children.add(outline);
553 _addLocalFunctionOutlines(outline, functionExpression.body);
554 return true;
555 }
556 }
557 return false;
558 }
559
560 /**
561 * Returns the [AstNode]'s source region.
562 */
563 psi.SourceRegion _getSourceRegion(AstNode node) {
564 int endOffset = node.end;
565 // prepare position of the node among its siblings
566 int firstOffset;
567 List<AstNode> siblings;
568 AstNode parent = node.parent;
569 // field
570 if (parent is VariableDeclarationList) {
571 VariableDeclarationList variableList = parent as VariableDeclarationList;
572 List<VariableDeclaration> variables = variableList.variables;
573 int variableIndex = variables.indexOf(node);
574 if (variableIndex == variables.length - 1) {
575 endOffset = variableList.parent.end;
576 }
577 if (variableIndex == 0) {
578 node = parent.parent;
579 parent = node.parent;
580 } else if (variableIndex >= 1) {
581 firstOffset = variables[variableIndex - 1].end;
582 return new SourceRegionImpl(firstOffset, endOffset - firstOffset);
583 }
584 }
585 // unit or class member
586 if (parent is CompilationUnit) {
587 firstOffset = 0;
588 siblings = (parent as CompilationUnit).declarations;
589 } else if (parent is ClassDeclaration) {
590 ClassDeclaration classDeclaration = parent as ClassDeclaration;
591 firstOffset = classDeclaration.leftBracket.end;
592 siblings = classDeclaration.members;
593 } else {
594 int offset = node.offset;
595 return new SourceRegionImpl(offset, endOffset - offset);
596 }
597 // first child: [endOfParent, endOfNode]
598 int index = siblings.indexOf(node);
599 if (index == 0) {
600 return new SourceRegionImpl(firstOffset, endOffset - firstOffset);
601 }
602 // not first child: [endOfPreviousSibling, endOfNode]
603 int prevSiblingEnd = siblings[index - 1].end;
604 return new SourceRegionImpl(prevSiblingEnd, endOffset - prevSiblingEnd);
605 }
606
607 /**
608 * Returns `true` if the given [MethodInvocation] is invocation of the functio n with
609 * the given name from the "unittest" library.
610 */
611 bool _isUnitTestFunctionInvocation(MethodInvocation node, String name) {
612 SimpleIdentifier methodName = node.methodName;
613 if (methodName != null) {
614 pae.Element element = methodName.staticElement;
615 if (element is pae.FunctionElement) {
616 pae.FunctionElement functionElement = element;
617 if (name == functionElement.name) {
618 pae.LibraryElement libraryElement = functionElement.library;
619 return libraryElement != null && _UNITTEST_LIBRARY == libraryElement.n ame;
620 }
621 }
622 }
623 return false;
624 }
625
626 OutlineImpl _newClassOutline(psi.Outline unitOutline, List<psi.Outline> unitCh ildren, ClassDeclaration classDeclaration) {
627 SimpleIdentifier nameNode = classDeclaration.name;
628 String name = nameNode.name;
629 ElementImpl element = new ElementImpl(_contextId, ElementImpl.createId(class Declaration.element), _source, psi.ElementKind.CLASS, name, nameNode.offset, nam e.length, null, null, classDeclaration.isAbstract, false, StringUtilities.starts WithChar(name, 0x5F));
630 psi.SourceRegion sourceRegion = _getSourceRegion(classDeclaration);
631 OutlineImpl outline = new OutlineImpl(unitOutline, element, sourceRegion);
632 unitChildren.add(outline);
633 return outline;
634 }
635
636 void _newClassTypeAlias(psi.Outline unitOutline, List<psi.Outline> unitChildre n, ClassTypeAlias alias) {
637 SimpleIdentifier nameNode = alias.name;
638 String name = nameNode.name;
639 ElementImpl element = new ElementImpl(_contextId, ElementImpl.createId(alias .element), _source, psi.ElementKind.CLASS_TYPE_ALIAS, name, nameNode.offset, nam eNode.length, null, null, alias.isAbstract, false, StringUtilities.startsWithCha r(name, 0x5F));
640 psi.SourceRegion sourceRegion = _getSourceRegion(alias);
641 OutlineImpl outline = new OutlineImpl(unitOutline, element, sourceRegion);
642 unitChildren.add(outline);
643 }
644
645 void _newConstructorOutline(OutlineImpl classOutline, List<psi.Outline> childr en, ConstructorDeclaration constructorDeclaration) {
646 Identifier returnType = constructorDeclaration.returnType;
647 String name = returnType.name;
648 int offset = returnType.offset;
649 int length = returnType.length;
650 bool isPrivate = false;
651 SimpleIdentifier constructorNameNode = constructorDeclaration.name;
652 if (constructorNameNode != null) {
653 String constructorName = constructorNameNode.name;
654 isPrivate = StringUtilities.startsWithChar(constructorName, 0x5F);
655 name += ".${constructorName}";
656 offset = constructorNameNode.offset;
657 length = constructorNameNode.length;
658 }
659 FormalParameterList parameters = constructorDeclaration.parameters;
660 ElementImpl element = new ElementImpl(_contextId, ElementImpl.createId(const ructorDeclaration.element), _source, psi.ElementKind.CONSTRUCTOR, name, offset, length, parameters != null ? parameters.toSource() : "", null, false, false, isP rivate);
661 psi.SourceRegion sourceRegion = _getSourceRegion(constructorDeclaration);
662 OutlineImpl outline = new OutlineImpl(classOutline, element, sourceRegion);
663 children.add(outline);
664 _addLocalFunctionOutlines(outline, constructorDeclaration.body);
665 }
666
667 void _newFunctionOutline(psi.Outline parent, List<psi.Outline> children, Funct ionDeclaration functionDeclaration) {
668 TypeName returnType = functionDeclaration.returnType;
669 SimpleIdentifier nameNode = functionDeclaration.name;
670 String name = nameNode.name;
671 FunctionExpression functionExpression = functionDeclaration.functionExpressi on;
672 FormalParameterList parameters = functionExpression.parameters;
673 psi.ElementKind kind;
674 if (functionDeclaration.isGetter) {
675 kind = psi.ElementKind.GETTER;
676 } else if (functionDeclaration.isSetter) {
677 kind = psi.ElementKind.SETTER;
678 } else {
679 kind = psi.ElementKind.FUNCTION;
680 }
681 ElementImpl element = new ElementImpl(_contextId, ElementImpl.createId(funct ionDeclaration.element), _source, kind, name, nameNode.offset, nameNode.length, parameters != null ? parameters.toSource() : "", returnType != null ? returnType .toSource() : "", false, false, StringUtilities.startsWithChar(name, 0x5F));
682 psi.SourceRegion sourceRegion = _getSourceRegion(functionDeclaration);
683 OutlineImpl outline = new OutlineImpl(parent, element, sourceRegion);
684 children.add(outline);
685 _addLocalFunctionOutlines(outline, functionExpression.body);
686 }
687
688 void _newFunctionTypeAliasOutline(psi.Outline unitOutline, List<psi.Outline> u nitChildren, FunctionTypeAlias alias) {
689 TypeName returnType = alias.returnType;
690 SimpleIdentifier nameNode = alias.name;
691 String name = nameNode.name;
692 FormalParameterList parameters = alias.parameters;
693 ElementImpl element = new ElementImpl(_contextId, ElementImpl.createId(alias .element), _source, psi.ElementKind.FUNCTION_TYPE_ALIAS, name, nameNode.offset, nameNode.length, parameters != null ? parameters.toSource() : "", returnType != null ? returnType.toSource() : "", false, false, StringUtilities.startsWithChar( name, 0x5F));
694 psi.SourceRegion sourceRegion = _getSourceRegion(alias);
695 OutlineImpl outline = new OutlineImpl(unitOutline, element, sourceRegion);
696 unitChildren.add(outline);
697 }
698
699 void _newMethodOutline(OutlineImpl classOutline, List<psi.Outline> children, M ethodDeclaration methodDeclaration) {
700 TypeName returnType = methodDeclaration.returnType;
701 SimpleIdentifier nameNode = methodDeclaration.name;
702 String name = nameNode.name;
703 FormalParameterList parameters = methodDeclaration.parameters;
704 psi.ElementKind kind;
705 if (methodDeclaration.isGetter) {
706 kind = psi.ElementKind.GETTER;
707 } else if (methodDeclaration.isSetter) {
708 kind = psi.ElementKind.SETTER;
709 } else {
710 kind = psi.ElementKind.METHOD;
711 }
712 ElementImpl element = new ElementImpl(_contextId, ElementImpl.createId(metho dDeclaration.element), _source, kind, name, nameNode.offset, nameNode.length, pa rameters != null ? parameters.toSource() : "", returnType != null ? returnType.t oSource() : "", methodDeclaration.isAbstract, methodDeclaration.isStatic, String Utilities.startsWithChar(name, 0x5F));
713 psi.SourceRegion sourceRegion = _getSourceRegion(methodDeclaration);
714 OutlineImpl outline = new OutlineImpl(classOutline, element, sourceRegion);
715 children.add(outline);
716 _addLocalFunctionOutlines(outline, methodDeclaration.body);
717 }
718
719 OutlineImpl _newUnitOutline() {
720 ElementImpl element = new ElementImpl(_contextId, ElementImpl.createId(_unit .element), _source, psi.ElementKind.COMPILATION_UNIT, null, 0, 0, null, null, fa lse, false, false);
721 return new OutlineImpl(null, element, new SourceRegionImpl(_unit.offset, _un it.length));
722 }
723
724 void _newVariableOutline(OutlineImpl classOutline, List<psi.Outline> children, String typeName, psi.ElementKind kind, VariableDeclaration variable, bool isSta tic) {
725 SimpleIdentifier nameNode = variable.name;
726 String name = nameNode.name;
727 ElementImpl element = new ElementImpl(_contextId, ElementImpl.createId(varia ble.element), _source, kind, name, nameNode.offset, nameNode.length, null, typeN ame, false, isStatic, StringUtilities.startsWithChar(name, 0x5F));
728 psi.SourceRegion sourceRegion = _getSourceRegion(variable);
729 OutlineImpl outline = new OutlineImpl(classOutline, element, sourceRegion);
730 children.add(outline);
731 }
732 }
733
734 /**
735 * A concrete implementation of [Element].
736 */
737 class ElementImpl implements psi.Element {
738 /**
739 * Creates an [ElementImpl] instance for the given
740 * [com.google.dart.engine.element.Element].
741 */
742 static ElementImpl create(String contextId, pae.Element element) {
743 if (element == null) {
744 return null;
745 }
746 // prepare name
747 String name = element.displayName;
748 int nameOffset = element.nameOffset;
749 int nameLength = name != null ? name.length : 0;
750 // prepare element kind specific information
751 psi.ElementKind outlineKind;
752 bool isAbstract = false;
753 bool isStatic = false;
754 bool isPrivate = element.isPrivate;
755 while (true) {
756 if (element.kind == pae.ElementKind.CLASS) {
757 outlineKind = psi.ElementKind.CLASS;
758 isAbstract = (element as pae.ClassElement).isAbstract;
759 } else if (element.kind == pae.ElementKind.COMPILATION_UNIT) {
760 outlineKind = psi.ElementKind.COMPILATION_UNIT;
761 nameOffset = -1;
762 nameLength = 0;
763 } else if (element.kind == pae.ElementKind.CONSTRUCTOR) {
764 outlineKind = psi.ElementKind.CONSTRUCTOR;
765 String className = element.enclosingElement.name;
766 if (name.length != 0) {
767 name = "${className}.${name}";
768 } else {
769 name = className;
770 }
771 } else if (element.kind == pae.ElementKind.FUNCTION) {
772 outlineKind = psi.ElementKind.FUNCTION;
773 } else if (element.kind == pae.ElementKind.GETTER) {
774 outlineKind = psi.ElementKind.GETTER;
775 } else if (element.kind == pae.ElementKind.FUNCTION_TYPE_ALIAS) {
776 outlineKind = psi.ElementKind.FUNCTION_TYPE_ALIAS;
777 } else if (element.kind == pae.ElementKind.LIBRARY) {
778 outlineKind = psi.ElementKind.LIBRARY;
779 } else if (element.kind == pae.ElementKind.METHOD) {
780 outlineKind = psi.ElementKind.METHOD;
781 isAbstract = (element as pae.MethodElement).isAbstract;
782 } else if (element.kind == pae.ElementKind.SETTER) {
783 outlineKind = psi.ElementKind.SETTER;
784 } else {
785 outlineKind = psi.ElementKind.UNKNOWN;
786 }
787 break;
788 }
789 // extract return type and parameters from toString()
790 // TODO(scheglov) we need a way to get this information directly from an Ele ment
791 String parameters;
792 String returnType;
793 {
794 String str = element.toString();
795 // return type
796 String rightArrow = pae.Element.RIGHT_ARROW;
797 int returnIndex = str.lastIndexOf(rightArrow);
798 if (returnIndex != -1) {
799 returnType = str.substring(returnIndex + rightArrow.length);
800 str = str.substring(0, returnIndex);
801 } else {
802 returnType = null;
803 }
804 // parameters
805 int parametersIndex = str.indexOf("(");
806 if (parametersIndex != -1) {
807 parameters = str.substring(parametersIndex);
808 } else {
809 parameters = null;
810 }
811 }
812 // new element
813 return new ElementImpl(contextId, createId(element), element.source, outline Kind, name, nameOffset, nameLength, parameters, returnType, isAbstract, isStatic , isPrivate);
814 }
815
816 /**
817 * Returns an identifier of the given [Element], maybe `null` if `null` given.
818 */
819 static String createId(pae.Element element) {
820 if (element == null) {
821 return null;
822 }
823 return element.location.encoding;
824 }
825
826 final String contextId;
827
828 final String id;
829
830 final Source source;
831
832 final psi.ElementKind kind;
833
834 final String name;
835
836 final int offset;
837
838 final int length;
839
840 final String parameters;
841
842 final String returnType;
843
844 final bool isAbstract;
845
846 final bool isPrivate;
847
848 final bool isStatic;
849
850 ElementImpl(this.contextId, this.id, this.source, this.kind, this.name, this.o ffset, this.length, this.parameters, this.returnType, this.isAbstract, this.isSt atic, this.isPrivate);
851
852 @override
853 bool operator ==(Object obj) {
854 if (identical(obj, this)) {
855 return true;
856 }
857 if (obj is! ElementImpl) {
858 return false;
859 }
860 ElementImpl other = obj as ElementImpl;
861 return other.kind == kind && (other.source == source) && (name == other.name );
862 }
863
864 @override
865 int get hashCode {
866 if (name == null) {
867 return source.hashCode;
868 }
869 return ObjectUtilities.combineHashCodes(source.hashCode, name.hashCode);
870 }
871
872 @override
873 String toString() {
874 JavaStringBuilder builder = new JavaStringBuilder();
875 builder.append("[name=");
876 builder.append(name);
877 builder.append(", kind=");
878 builder.append(kind);
879 builder.append(", offset=");
880 builder.append(offset);
881 builder.append(", length=");
882 builder.append(length);
883 builder.append(", parameters=");
884 builder.append(parameters);
885 builder.append(", return=");
886 builder.append(returnType);
887 builder.append("]");
888 return builder.toString();
889 }
890 }
891
892 class GeneralizingElementVisitor_TypeHierarchyComputer_findEngineElement extends pae.GeneralizingElementVisitor<Object> {
893 int nameOffset = 0;
894
895 List<pae.Element> result;
896
897 GeneralizingElementVisitor_TypeHierarchyComputer_findEngineElement(this.nameOf fset, this.result) : super();
898
899 @override
900 Object visitElement(pae.Element element) {
901 if (element.nameOffset == nameOffset) {
902 result[0] = element;
903 }
904 return super.visitElement(element);
905 }
906 }
907
908 /**
909 * A concrete implementation of [HighlightRegion].
910 */
911 class HighlightRegionImpl extends SourceRegionImpl implements psi.HighlightRegio n {
912 final psi.HighlightType type;
913
914 HighlightRegionImpl(int offset, int length, this.type) : super(offset, length) ;
915
916 @override
917 String toString() {
918 JavaStringBuilder builder = new JavaStringBuilder();
919 builder.append("[offset=");
920 builder.append(offset);
921 builder.append(", length=");
922 builder.append(length);
923 builder.append(", type=");
924 builder.append(type);
925 builder.append("]");
926 return builder.toString();
927 }
928 }
929
930 /**
931 * A concrete implementation of [NavigationRegion].
932 */
933 class NavigationRegionImpl extends SourceRegionImpl implements psi.NavigationReg ion {
934 final List<psi.Element> targets;
935
936 NavigationRegionImpl(int offset, int length, this.targets) : super(offset, len gth);
937
938 @override
939 String toString() {
940 JavaStringBuilder builder = new JavaStringBuilder();
941 builder.append(super.toString());
942 builder.append(" -> [");
943 builder.append(StringUtils.join(targets, ", "));
944 builder.append("]");
945 return builder.toString();
946 }
947 }
948
949 /**
950 * A concrete implementation of [Outline].
951 */
952 class OutlineImpl implements psi.Outline {
953 final psi.Outline parent;
954
955 final psi.Element element;
956
957 final psi.SourceRegion sourceRegion;
958
959 List<psi.Outline> children = psi.Outline.EMPTY_ARRAY;
960
961 OutlineImpl(this.parent, this.element, this.sourceRegion);
962
963 @override
964 bool operator ==(Object obj) {
965 if (identical(obj, this)) {
966 return true;
967 }
968 if (obj is! OutlineImpl) {
969 return false;
970 }
971 OutlineImpl other = obj as OutlineImpl;
972 return (other.element == element) && (other.parent == parent);
973 }
974
975 @override
976 int get hashCode {
977 if (parent == null) {
978 return element.hashCode;
979 }
980 return ObjectUtilities.combineHashCodes(parent.hashCode, element.hashCode);
981 }
982
983 @override
984 String toString() {
985 JavaStringBuilder builder = new JavaStringBuilder();
986 builder.append("[element=");
987 builder.append(element);
988 builder.append(", children=[");
989 builder.append(StringUtils.join(children, ", "));
990 builder.append("]]");
991 return builder.toString();
992 }
993 }
994
995 class RecursiveAstVisitor_DartUnitHighlightsComputer_compute extends RecursiveAs tVisitor<Object> {
996 final DartUnitHighlightsComputer DartUnitHighlightsComputer_this;
997
998 RecursiveAstVisitor_DartUnitHighlightsComputer_compute(this.DartUnitHighlights Computer_this) : super();
999
1000 @override
1001 Object visitAnnotation(Annotation node) {
1002 DartUnitHighlightsComputer_this._addIdentifierRegion_annotation(node);
1003 return super.visitAnnotation(node);
1004 }
1005
1006 @override
1007 Object visitAsExpression(AsExpression node) {
1008 DartUnitHighlightsComputer_this._addRegion_token(node.asOperator, psi.Highli ghtType.BUILT_IN);
1009 return super.visitAsExpression(node);
1010 }
1011
1012 @override
1013 Object visitBooleanLiteral(BooleanLiteral node) {
1014 DartUnitHighlightsComputer_this._addRegion_node(node, psi.HighlightType.LITE RAL_BOOLEAN);
1015 return super.visitBooleanLiteral(node);
1016 }
1017
1018 @override
1019 Object visitCatchClause(CatchClause node) {
1020 DartUnitHighlightsComputer_this._addRegion_token(node.onKeyword, psi.Highlig htType.BUILT_IN);
1021 return super.visitCatchClause(node);
1022 }
1023
1024 @override
1025 Object visitClassDeclaration(ClassDeclaration node) {
1026 DartUnitHighlightsComputer_this._addRegion_token(node.abstractKeyword, psi.H ighlightType.BUILT_IN);
1027 return super.visitClassDeclaration(node);
1028 }
1029
1030 @override
1031 Object visitConstructorDeclaration(ConstructorDeclaration node) {
1032 DartUnitHighlightsComputer_this._addRegion_token(node.externalKeyword, psi.H ighlightType.BUILT_IN);
1033 DartUnitHighlightsComputer_this._addRegion_token(node.factoryKeyword, psi.Hi ghlightType.BUILT_IN);
1034 return super.visitConstructorDeclaration(node);
1035 }
1036
1037 @override
1038 Object visitDoubleLiteral(DoubleLiteral node) {
1039 DartUnitHighlightsComputer_this._addRegion_node(node, psi.HighlightType.LITE RAL_DOUBLE);
1040 return super.visitDoubleLiteral(node);
1041 }
1042
1043 @override
1044 Object visitExportDirective(ExportDirective node) {
1045 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1046 return super.visitExportDirective(node);
1047 }
1048
1049 @override
1050 Object visitFieldDeclaration(FieldDeclaration node) {
1051 DartUnitHighlightsComputer_this._addRegion_token(node.staticKeyword, psi.Hig hlightType.BUILT_IN);
1052 return super.visitFieldDeclaration(node);
1053 }
1054
1055 @override
1056 Object visitFunctionDeclaration(FunctionDeclaration node) {
1057 DartUnitHighlightsComputer_this._addRegion_token(node.externalKeyword, psi.H ighlightType.BUILT_IN);
1058 DartUnitHighlightsComputer_this._addRegion_token(node.propertyKeyword, psi.H ighlightType.BUILT_IN);
1059 return super.visitFunctionDeclaration(node);
1060 }
1061
1062 @override
1063 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
1064 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1065 return super.visitFunctionTypeAlias(node);
1066 }
1067
1068 @override
1069 Object visitHideCombinator(HideCombinator node) {
1070 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1071 return super.visitHideCombinator(node);
1072 }
1073
1074 @override
1075 Object visitImplementsClause(ImplementsClause node) {
1076 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1077 return super.visitImplementsClause(node);
1078 }
1079
1080 @override
1081 Object visitImportDirective(ImportDirective node) {
1082 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1083 DartUnitHighlightsComputer_this._addRegion_token(node.deferredToken, psi.Hig hlightType.BUILT_IN);
1084 DartUnitHighlightsComputer_this._addRegion_token(node.asToken, psi.Highlight Type.BUILT_IN);
1085 return super.visitImportDirective(node);
1086 }
1087
1088 @override
1089 Object visitIntegerLiteral(IntegerLiteral node) {
1090 DartUnitHighlightsComputer_this._addRegion_node(node, psi.HighlightType.LITE RAL_INTEGER);
1091 return super.visitIntegerLiteral(node);
1092 }
1093
1094 @override
1095 Object visitLibraryDirective(LibraryDirective node) {
1096 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1097 return super.visitLibraryDirective(node);
1098 }
1099
1100 @override
1101 Object visitMethodDeclaration(MethodDeclaration node) {
1102 DartUnitHighlightsComputer_this._addRegion_token(node.externalKeyword, psi.H ighlightType.BUILT_IN);
1103 DartUnitHighlightsComputer_this._addRegion_token(node.modifierKeyword, psi.H ighlightType.BUILT_IN);
1104 DartUnitHighlightsComputer_this._addRegion_token(node.operatorKeyword, psi.H ighlightType.BUILT_IN);
1105 DartUnitHighlightsComputer_this._addRegion_token(node.propertyKeyword, psi.H ighlightType.BUILT_IN);
1106 return super.visitMethodDeclaration(node);
1107 }
1108
1109 @override
1110 Object visitNativeClause(NativeClause node) {
1111 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1112 return super.visitNativeClause(node);
1113 }
1114
1115 @override
1116 Object visitNativeFunctionBody(NativeFunctionBody node) {
1117 DartUnitHighlightsComputer_this._addRegion_token(node.nativeToken, psi.Highl ightType.BUILT_IN);
1118 return super.visitNativeFunctionBody(node);
1119 }
1120
1121 @override
1122 Object visitPartDirective(PartDirective node) {
1123 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1124 return super.visitPartDirective(node);
1125 }
1126
1127 @override
1128 Object visitPartOfDirective(PartOfDirective node) {
1129 DartUnitHighlightsComputer_this._addRegion_tokenStart_tokenEnd(node.partToke n, node.ofToken, psi.HighlightType.BUILT_IN);
1130 return super.visitPartOfDirective(node);
1131 }
1132
1133 @override
1134 Object visitShowCombinator(ShowCombinator node) {
1135 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, psi.Highlight Type.BUILT_IN);
1136 return super.visitShowCombinator(node);
1137 }
1138
1139 @override
1140 Object visitSimpleIdentifier(SimpleIdentifier node) {
1141 DartUnitHighlightsComputer_this._addIdentifierRegion(node);
1142 return super.visitSimpleIdentifier(node);
1143 }
1144
1145 @override
1146 Object visitSimpleStringLiteral(SimpleStringLiteral node) {
1147 DartUnitHighlightsComputer_this._addRegion_node(node, psi.HighlightType.LITE RAL_STRING);
1148 return super.visitSimpleStringLiteral(node);
1149 }
1150
1151 @override
1152 Object visitTypeName(TypeName node) {
1153 DartType type = node.type;
1154 if (type != null) {
1155 if (type.isDynamic && node.name.name == "dynamic") {
1156 DartUnitHighlightsComputer_this._addRegion_node(node, psi.HighlightType. TYPE_NAME_DYNAMIC);
1157 return null;
1158 }
1159 }
1160 return super.visitTypeName(node);
1161 }
1162 }
1163
1164 class RecursiveAstVisitor_DartUnitNavigationComputer_compute extends RecursiveAs tVisitor<Object> {
1165 final DartUnitNavigationComputer DartUnitNavigationComputer_this;
1166
1167 RecursiveAstVisitor_DartUnitNavigationComputer_compute(this.DartUnitNavigation Computer_this) : super();
1168
1169 @override
1170 Object visitAssignmentExpression(AssignmentExpression node) {
1171 DartUnitNavigationComputer_this._addRegionForToken(node.operator, node.bestE lement);
1172 return super.visitAssignmentExpression(node);
1173 }
1174
1175 @override
1176 Object visitBinaryExpression(BinaryExpression node) {
1177 DartUnitNavigationComputer_this._addRegionForToken(node.operator, node.bestE lement);
1178 return super.visitBinaryExpression(node);
1179 }
1180
1181 @override
1182 Object visitConstructorDeclaration(ConstructorDeclaration node) {
1183 // associate constructor with "T" or "T.name"
1184 {
1185 AstNode firstNode = node.returnType;
1186 AstNode lastNode = node.name;
1187 if (lastNode == null) {
1188 lastNode = firstNode;
1189 }
1190 if (firstNode != null && lastNode != null) {
1191 DartUnitNavigationComputer_this._addRegion_nodeStart_nodeEnd(firstNode, lastNode, node.element);
1192 }
1193 }
1194 return super.visitConstructorDeclaration(node);
1195 }
1196
1197 @override
1198 Object visitExportDirective(ExportDirective node) {
1199 pae.ExportElement exportElement = node.element;
1200 if (exportElement != null) {
1201 pae.Element element = exportElement.exportedLibrary;
1202 DartUnitNavigationComputer_this._addRegion_tokenStart_nodeEnd(node.keyword , node.uri, element);
1203 }
1204 return super.visitExportDirective(node);
1205 }
1206
1207 @override
1208 Object visitImportDirective(ImportDirective node) {
1209 pae.ImportElement importElement = node.element;
1210 if (importElement != null) {
1211 pae.Element element = importElement.importedLibrary;
1212 DartUnitNavigationComputer_this._addRegion_tokenStart_nodeEnd(node.keyword , node.uri, element);
1213 }
1214 return super.visitImportDirective(node);
1215 }
1216
1217 @override
1218 Object visitIndexExpression(IndexExpression node) {
1219 DartUnitNavigationComputer_this._addRegionForToken(node.rightBracket, node.b estElement);
1220 return super.visitIndexExpression(node);
1221 }
1222
1223 @override
1224 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
1225 DartUnitNavigationComputer_this._addRegion_nodeStart_nodeStart(node, node.ar gumentList, node.staticElement);
1226 return super.visitInstanceCreationExpression(node);
1227 }
1228
1229 @override
1230 Object visitPartDirective(PartDirective node) {
1231 DartUnitNavigationComputer_this._addRegion_tokenStart_nodeEnd(node.keyword, node.uri, node.element);
1232 return super.visitPartDirective(node);
1233 }
1234
1235 @override
1236 Object visitPartOfDirective(PartOfDirective node) {
1237 DartUnitNavigationComputer_this._addRegion_tokenStart_nodeEnd(node.keyword, node.libraryName, node.element);
1238 return super.visitPartOfDirective(node);
1239 }
1240
1241 @override
1242 Object visitPostfixExpression(PostfixExpression node) {
1243 DartUnitNavigationComputer_this._addRegionForToken(node.operator, node.bestE lement);
1244 return super.visitPostfixExpression(node);
1245 }
1246
1247 @override
1248 Object visitPrefixExpression(PrefixExpression node) {
1249 DartUnitNavigationComputer_this._addRegionForToken(node.operator, node.bestE lement);
1250 return super.visitPrefixExpression(node);
1251 }
1252
1253 @override
1254 Object visitSimpleIdentifier(SimpleIdentifier node) {
1255 if (node.parent is ConstructorDeclaration) {
1256 } else {
1257 DartUnitNavigationComputer_this._addRegionForNode(node, node.bestElement);
1258 }
1259 return super.visitSimpleIdentifier(node);
1260 }
1261 }
1262
1263 class RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunctionOutlines exten ds RecursiveAstVisitor<Object> {
1264 final DartUnitOutlineComputer DartUnitOutlineComputer_this;
1265
1266 OutlineImpl parent;
1267
1268 List<psi.Outline> localOutlines;
1269
1270 RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunctionOutlines(this.Dart UnitOutlineComputer_this, this.parent, this.localOutlines) : super();
1271
1272 @override
1273 Object visitFunctionDeclaration(FunctionDeclaration node) {
1274 DartUnitOutlineComputer_this._newFunctionOutline(parent, localOutlines, node );
1275 return null;
1276 }
1277
1278 @override
1279 Object visitMethodInvocation(MethodInvocation node) {
1280 bool handled = DartUnitOutlineComputer_this._addUnitTestOutlines(parent, loc alOutlines, node);
1281 if (handled) {
1282 return null;
1283 }
1284 return super.visitMethodInvocation(node);
1285 }
1286 }
1287
1288 /**
1289 * A concrete implementation of [SearchResult].
1290 */
1291 class SearchResultImpl implements psi.SearchResult {
1292 final List<psi.Element> path;
1293
1294 final Source source;
1295
1296 final psi.SearchResultKind kind;
1297
1298 final int offset;
1299
1300 final int length;
1301
1302 final bool isPotential;
1303
1304 SearchResultImpl(this.path, this.source, this.kind, this.offset, this.length, this.isPotential);
1305
1306 @override
1307 String toString() {
1308 JavaStringBuilder builder = new JavaStringBuilder();
1309 builder.append("[source=");
1310 builder.append(source);
1311 builder.append(", kind=");
1312 builder.append(kind);
1313 builder.append(", offset=");
1314 builder.append(offset);
1315 builder.append(", length=");
1316 builder.append(length);
1317 builder.append(", potential=");
1318 builder.append(isPotential);
1319 builder.append(", path=");
1320 builder.append(path);
1321 builder.append("]");
1322 return builder.toString();
1323 }
1324 }
1325
1326 /**
1327 * A concrete implementation of [SourceRegion].
1328 */
1329 class SourceRegionImpl implements psi.SourceRegion {
1330 final int offset;
1331
1332 final int length;
1333
1334 SourceRegionImpl(this.offset, this.length);
1335
1336 @override
1337 bool containsInclusive(int x) => offset <= x && x <= offset + length;
1338
1339 @override
1340 bool operator ==(Object obj) {
1341 if (identical(obj, this)) {
1342 return true;
1343 }
1344 if (obj is! psi.SourceRegion) {
1345 return false;
1346 }
1347 psi.SourceRegion other = obj as psi.SourceRegion;
1348 return other.offset == offset && other.length == length;
1349 }
1350
1351 @override
1352 int get hashCode => ObjectUtilities.combineHashCodes(offset, length);
1353
1354 @override
1355 String toString() {
1356 JavaStringBuilder builder = new JavaStringBuilder();
1357 builder.append("[offset=");
1358 builder.append(offset);
1359 builder.append(", length=");
1360 builder.append(length);
1361 builder.append("]");
1362 return builder.toString();
1363 }
1364 }
1365
1366 /**
1367 * A concrete implementation of [TypeHierarchyItem].
1368 */
1369 class TypeHierarchyItemImpl implements psi.TypeHierarchyItem {
1370 final String name;
1371
1372 final psi.Element classElement;
1373
1374 final psi.Element memberElement;
1375
1376 final psi.TypeHierarchyItem extendedType;
1377
1378 final List<psi.TypeHierarchyItem> mixedTypes;
1379
1380 final List<psi.TypeHierarchyItem> implementedTypes;
1381
1382 List<psi.TypeHierarchyItem> subTypes = psi.TypeHierarchyItem.EMPTY_ARRAY;
1383
1384 TypeHierarchyItemImpl(this.name, this.classElement, this.memberElement, this.e xtendedType, this.mixedTypes, this.implementedTypes);
1385
1386 @override
1387 String toString() {
1388 JavaStringBuilder builder = new JavaStringBuilder();
1389 builder.append("[name=");
1390 builder.append(name);
1391 builder.append(", classElement=");
1392 builder.append(classElement);
1393 builder.append(", memberElement=");
1394 builder.append(memberElement);
1395 builder.append(", extendedType=");
1396 builder.append(extendedType);
1397 builder.append(", mixedTypes=[");
1398 builder.append(StringUtils.join(mixedTypes, ", "));
1399 builder.append("], implementedTypes=[");
1400 builder.append(StringUtils.join(implementedTypes, ", "));
1401 builder.append("], subTypes=[");
1402 builder.append(StringUtils.join(subTypes, ", "));
1403 builder.append("]]");
1404 return builder.toString();
1405 }
1406 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/generated/service_interfaces.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698