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

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

Issue 969113002: Reformat (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 computer.overrides; 5 library computer.overrides;
6 6
7 import 'package:analysis_server/src/collections.dart'; 7 import 'package:analysis_server/src/collections.dart';
8 import 'package:analysis_server/src/protocol_server.dart'; 8 import 'package:analysis_server/src/protocol_server.dart';
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart' as engine; 10 import 'package:analyzer/src/generated/element.dart' as engine;
11 11
12
13 /** 12 /**
14 * A computer for class member overrides in a Dart [CompilationUnit]. 13 * A computer for class member overrides in a Dart [CompilationUnit].
15 */ 14 */
16 class DartUnitOverridesComputer { 15 class DartUnitOverridesComputer {
17 final CompilationUnit _unit; 16 final CompilationUnit _unit;
18 17
19 final List<Override> _overrides = <Override>[]; 18 final List<Override> _overrides = <Override>[];
20 engine.ClassElement _currentClass; 19 engine.ClassElement _currentClass;
21 20
22 DartUnitOverridesComputer(this._unit); 21 DartUnitOverridesComputer(this._unit);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 List<engine.Element> interfaceEngineElements = <engine.Element>[]; 58 List<engine.Element> interfaceEngineElements = <engine.Element>[];
60 for (engine.InterfaceType interfaceType in _currentClass.interfaces) { 59 for (engine.InterfaceType interfaceType in _currentClass.interfaces) {
61 engine.ClassElement interfaceElement = interfaceType.element; 60 engine.ClassElement interfaceElement = interfaceType.element;
62 engine.Element interfaceMember = _lookupMember(interfaceElement, name); 61 engine.Element interfaceMember = _lookupMember(interfaceElement, name);
63 if (interfaceMember != null) { 62 if (interfaceMember != null) {
64 interfaceEngineElements.add(interfaceMember); 63 interfaceEngineElements.add(interfaceMember);
65 } 64 }
66 } 65 }
67 // is there any override? 66 // is there any override?
68 if (superEngineElement != null || interfaceEngineElements.isNotEmpty) { 67 if (superEngineElement != null || interfaceEngineElements.isNotEmpty) {
69 OverriddenMember superMember = superEngineElement != null ? 68 OverriddenMember superMember = superEngineElement != null
70 newOverriddenMember_fromEngine(superEngineElement) : 69 ? newOverriddenMember_fromEngine(superEngineElement)
71 null; 70 : null;
72 List<OverriddenMember> interfaceMembers = interfaceEngineElements.map( 71 List<OverriddenMember> interfaceMembers = interfaceEngineElements
73 (engine.Element member) => newOverriddenMember_fromEngine(member)).toL ist(); 72 .map(
74 _overrides.add( 73 (engine.Element member) => newOverriddenMember_fromEngine(member))
75 new Override( 74 .toList();
76 offset, 75 _overrides.add(new Override(offset, length,
77 length, 76 superclassMember: superMember,
78 superclassMember: superMember, 77 interfaceMembers: nullIfEmpty(interfaceMembers)));
79 interfaceMembers: nullIfEmpty(interfaceMembers)));
80 } 78 }
81 } 79 }
82 80
83 static engine.Element _lookupMember(engine.ClassElement classElement, 81 static engine.Element _lookupMember(
84 String name) { 82 engine.ClassElement classElement, String name) {
85 if (classElement == null) { 83 if (classElement == null) {
86 return null; 84 return null;
87 } 85 }
88 engine.LibraryElement library = classElement.library; 86 engine.LibraryElement library = classElement.library;
89 // method 87 // method
90 engine.Element member = classElement.lookUpMethod(name, library); 88 engine.Element member = classElement.lookUpMethod(name, library);
91 if (member != null) { 89 if (member != null) {
92 return member; 90 return member;
93 } 91 }
94 // getter 92 // getter
95 member = classElement.lookUpGetter(name, library); 93 member = classElement.lookUpGetter(name, library);
96 if (member != null) { 94 if (member != null) {
97 return member; 95 return member;
98 } 96 }
99 // setter 97 // setter
100 member = classElement.lookUpSetter(name + '=', library); 98 member = classElement.lookUpSetter(name + '=', library);
101 if (member != null) { 99 if (member != null) {
102 return member; 100 return member;
103 } 101 }
104 // not found 102 // not found
105 return null; 103 return null;
106 } 104 }
107 } 105 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/computer/computer_outline.dart ('k') | pkg/analysis_server/lib/src/context_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698