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

Side by Side Diff: pkg/dartdoc/mirrors/dart2js_mirror.dart

Issue 10829361: 'Find-as-you-type'-search in dartdoc/apidoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 8 years, 3 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 | « pkg/dartdoc/dropdown.dart ('k') | pkg/dartdoc/nav.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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('mirrors.dart2js'); 5 #library('mirrors.dart2js');
6 6
7 #import('../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); 7 #import('../../../lib/compiler/compiler.dart', prefix: 'diagnostics');
8 #import('../../../lib/compiler/implementation/elements/elements.dart'); 8 #import('../../../lib/compiler/implementation/elements/elements.dart');
9 #import('../../../lib/compiler/implementation/apiimpl.dart', prefix: 'api'); 9 #import('../../../lib/compiler/implementation/apiimpl.dart', prefix: 'api');
10 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart'); 10 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart');
11 #import('../../../lib/compiler/implementation/leg.dart'); 11 #import('../../../lib/compiler/implementation/leg.dart');
12 #import('../../../lib/compiler/implementation/filenames.dart'); 12 #import('../../../lib/compiler/implementation/filenames.dart');
13 #import('../../../lib/compiler/implementation/source_file.dart'); 13 #import('../../../lib/compiler/implementation/source_file.dart');
14 #import('../../../lib/compiler/implementation/tree/tree.dart'); 14 #import('../../../lib/compiler/implementation/tree/tree.dart');
15 #import('../../../lib/compiler/implementation/util/util.dart'); 15 #import('../../../lib/compiler/implementation/util/util.dart');
16 #import('../../../lib/compiler/implementation/util/uri_extras.dart'); 16 #import('../../../lib/compiler/implementation/util/uri_extras.dart');
17 #import('../../../lib/compiler/implementation/dart2js.dart'); 17 #import('../../../lib/compiler/implementation/dart2js.dart');
18 #import('../../../lib/compiler/implementation/ssa/ssa.dart');
18 #import('mirrors.dart'); 19 #import('mirrors.dart');
19 #import('util.dart'); 20 #import('util.dart');
20 #import('dart:io'); 21 #import('dart:io');
21 #import('dart:uri'); 22 #import('dart:uri');
22 23
23 24
24 //------------------------------------------------------------------------------ 25 //------------------------------------------------------------------------------
25 // Utility types and functions for the dart2js mirror system 26 // Utility types and functions for the dart2js mirror system
26 //------------------------------------------------------------------------------ 27 //------------------------------------------------------------------------------
27 28
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 Dart2JsObjectMirror library, Element element) { 75 Dart2JsObjectMirror library, Element element) {
75 if (element is SynthesizedConstructorElement) { 76 if (element is SynthesizedConstructorElement) {
76 return const <Dart2JsMemberMirror>[]; 77 return const <Dart2JsMemberMirror>[];
77 } else if (element is VariableElement) { 78 } else if (element is VariableElement) {
78 return <Dart2JsMemberMirror>[new Dart2JsFieldMirror(library, element)]; 79 return <Dart2JsMemberMirror>[new Dart2JsFieldMirror(library, element)];
79 } else if (element is FunctionElement) { 80 } else if (element is FunctionElement) {
80 return <Dart2JsMemberMirror>[new Dart2JsMethodMirror(library, element)]; 81 return <Dart2JsMemberMirror>[new Dart2JsMethodMirror(library, element)];
81 } else if (element is AbstractFieldElement) { 82 } else if (element is AbstractFieldElement) {
82 var members = <Dart2JsMemberMirror>[]; 83 var members = <Dart2JsMemberMirror>[];
83 if (element.getter !== null) { 84 if (element.getter !== null) {
84 members.add(new Dart2JsMethodMirror(library, element.getter, 85 members.add(new Dart2JsMethodMirror(library, element.getter));
85 Dart2JsMethodKind.GETTER));
86 } 86 }
87 if (element.setter !== null) { 87 if (element.setter !== null) {
88 members.add(new Dart2JsMethodMirror(library, element.setter, 88 members.add(new Dart2JsMethodMirror(library, element.setter));
89 Dart2JsMethodKind.SETTER));
90 } 89 }
91 return members; 90 return members;
92 } 91 }
93 throw new IllegalArgumentException( 92 throw new IllegalArgumentException(
94 "Unexpected member type $element ${element.kind}"); 93 "Unexpected member type $element ${element.kind}");
95 } 94 }
96 95
97 MethodMirror _convertElementMethodToMethodMirror(Dart2JsObjectMirror library, 96 MethodMirror _convertElementMethodToMethodMirror(Dart2JsObjectMirror library,
98 Element element) { 97 Element element) {
99 if (element is FunctionElement) { 98 if (element is FunctionElement) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 class Dart2JsDiagnosticListener implements DiagnosticListener { 156 class Dart2JsDiagnosticListener implements DiagnosticListener {
158 const Dart2JsDiagnosticListener(); 157 const Dart2JsDiagnosticListener();
159 158
160 void cancel([String reason, node, token, instruction, element]) { 159 void cancel([String reason, node, token, instruction, element]) {
161 print(reason); 160 print(reason);
162 } 161 }
163 162
164 void log(message) { 163 void log(message) {
165 print(message); 164 print(message);
166 } 165 }
166
167 void internalError(String message,
168 [Node node, Token token, HInstruction instruction,
169 Element element]) {
170 cancel('Internal error: $message', node, token, instruction, element);
171 }
172
173 void internalErrorOnElement(Element element, String message) {
174 internalError(message, element: element);
175 }
167 } 176 }
168 177
169 //------------------------------------------------------------------------------ 178 //------------------------------------------------------------------------------
170 // Compiler extension for apidoc. 179 // Compiler extension for apidoc.
171 //------------------------------------------------------------------------------ 180 //------------------------------------------------------------------------------
172 181
173 /** 182 /**
174 * Extension of the compiler that enables the analysis of several libraries with 183 * Extension of the compiler that enables the analysis of several libraries with
175 * no particular entry point. 184 * no particular entry point.
176 */ 185 */
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 class Dart2JsMethodMirror extends Dart2JsElementMirror 1210 class Dart2JsMethodMirror extends Dart2JsElementMirror
1202 implements Dart2JsMemberMirror, MethodMirror { 1211 implements Dart2JsMemberMirror, MethodMirror {
1203 final Dart2JsObjectMirror _objectMirror; 1212 final Dart2JsObjectMirror _objectMirror;
1204 String _name; 1213 String _name;
1205 String _constructorName; 1214 String _constructorName;
1206 String _operatorName; 1215 String _operatorName;
1207 Dart2JsMethodKind _kind; 1216 Dart2JsMethodKind _kind;
1208 String _canonicalName; 1217 String _canonicalName;
1209 1218
1210 Dart2JsMethodMirror(Dart2JsObjectMirror objectMirror, 1219 Dart2JsMethodMirror(Dart2JsObjectMirror objectMirror,
1211 FunctionElement function, 1220 FunctionElement function)
1212 [Dart2JsMethodKind kind = null])
1213 : this._objectMirror = objectMirror, 1221 : this._objectMirror = objectMirror,
1214 this._kind = kind,
1215 super(objectMirror.system, function) { 1222 super(objectMirror.system, function) {
1216 _name = _element.name.slowToString(); 1223 _name = _element.name.slowToString();
1217 if (kind == null) { 1224 if (_function.kind == ElementKind.GETTER) {
1218 if (_function.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { 1225 _kind = Dart2JsMethodKind.GETTER;
1219 _constructorName = ''; 1226 _canonicalName = _name;
1220 int dollarPos = _name.indexOf('\$'); 1227 } else if (_function.kind == ElementKind.SETTER) {
1221 if (dollarPos != -1) { 1228 _kind = Dart2JsMethodKind.SETTER;
1222 _constructorName = _name.substring(dollarPos+1); 1229 _canonicalName = '$_name=';
1223 _name = _name.substring(0, dollarPos); 1230 } else if (_function.kind == ElementKind.GENERATIVE_CONSTRUCTOR) {
1224 // canonical name is TypeName.constructorName 1231 _constructorName = '';
1225 _canonicalName = '$_name.$_constructorName'; 1232 int dollarPos = _name.indexOf('\$');
1226 } else { 1233 if (dollarPos != -1) {
1227 // canonical name is TypeName 1234 _constructorName = _name.substring(dollarPos + 1);
1228 _canonicalName = _name; 1235 _name = _name.substring(0, dollarPos);
1229 }
1230 if (_function.modifiers !== null && _function.modifiers.isConst()) {
1231 _kind = Dart2JsMethodKind.CONST;
1232 } else {
1233 _kind = Dart2JsMethodKind.CONSTRUCTOR;
1234 }
1235 } else if (_function.modifiers !== null
1236 && _function.modifiers.isFactory()) {
1237 _constructorName = '';
1238 int dollarPos = _name.indexOf('\$');
1239 if (dollarPos != -1) {
1240 _constructorName = _name.substring(dollarPos+1);
1241 _name = _name.substring(0, dollarPos);
1242 }
1243 _kind = Dart2JsMethodKind.FACTORY;
1244 // canonical name is TypeName.constructorName 1236 // canonical name is TypeName.constructorName
1245 _canonicalName = '$_name.$_constructorName'; 1237 _canonicalName = '$_name.$_constructorName';
1246 } else if (_name == 'negate') { 1238 } else if (_name == 'negate') {
1247 _operatorName = _name; 1239 _operatorName = _name;
1248 _name = 'operator'; 1240 _name = 'operator';
1249 _kind = Dart2JsMethodKind.OPERATOR; 1241 _kind = Dart2JsMethodKind.OPERATOR;
1250 // canonical name is 'operator operatorName' 1242 // canonical name is 'operator operatorName'
1251 _canonicalName = 'operator $_operatorName'; 1243 _canonicalName = 'operator $_operatorName';
1252 } else if (_name.startsWith('operator\$')) { 1244 } else if (_name.startsWith('operator\$')) {
1253 String str = _name.substring(9); 1245 String str = _name.substring(9);
1254 _name = 'operator'; 1246 _name = 'operator';
1255 _kind = Dart2JsMethodKind.OPERATOR; 1247 _kind = Dart2JsMethodKind.OPERATOR;
1256 _operatorName = _getOperatorFromOperatorName(str); 1248 _operatorName = _getOperatorFromOperatorName(str);
1257 // canonical name is 'operator operatorName' 1249 // canonical name is 'operator operatorName'
1258 _canonicalName = 'operator $_operatorName'; 1250 _canonicalName = 'operator $_operatorName';
1259 } else { 1251 } else {
1260 _kind = Dart2JsMethodKind.NORMAL; 1252 // canonical name is TypeName
1261 _canonicalName = _name; 1253 _canonicalName = _name;
1262 } 1254 }
1263 } else if (kind == Dart2JsMethodKind.GETTER) { 1255 if (_function.modifiers !== null && _function.modifiers.isConst()) {
1256 _kind = Dart2JsMethodKind.CONST;
1257 } else {
1258 _kind = Dart2JsMethodKind.CONSTRUCTOR;
1259 }
1260 } else if (_function.modifiers !== null &&
1261 _function.modifiers.isFactory()) {
1262 _kind = Dart2JsMethodKind.FACTORY;
1263 _constructorName = '';
1264 int dollarPos = _name.indexOf('\$');
1265 if (dollarPos != -1) {
1266 _constructorName = _name.substring(dollarPos+1);
1267 _name = _name.substring(0, dollarPos);
1268 }
1269 // canonical name is TypeName.constructorName
1270 _canonicalName = '$_name.$_constructorName';
1271 } else if (_name.startsWith('operator\$')) {
1272 String str = _name.substring(9);
1273 _name = 'operator';
1274 _kind = Dart2JsMethodKind.OPERATOR;
1275 _operatorName = _getOperatorFromOperatorName(str);
1276 // canonical name is 'operator operatorName'
1277 _canonicalName = 'operator $_operatorName';
1278 } else {
1279 _kind = Dart2JsMethodKind.NORMAL;
1264 _canonicalName = _name; 1280 _canonicalName = _name;
1265 } else if (kind == Dart2JsMethodKind.SETTER) {
1266 _canonicalName = '$_name=';
1267 } else {
1268 assert(false);
1269 } 1281 }
1270 } 1282 }
1271 1283
1272 FunctionElement get _function() => _element; 1284 FunctionElement get _function() => _element;
1273 1285
1274 String get simpleName() => _name; 1286 String get simpleName() => _name;
1275 1287
1276 String get qualifiedName() 1288 String get qualifiedName()
1277 => '${surroundingDeclaration.qualifiedName}.$canonicalName'; 1289 => '${surroundingDeclaration.qualifiedName}.$canonicalName';
1278 1290
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 if (node !== null) { 1389 if (node !== null) {
1378 var span = system.compiler.spanFromNode(node, script.uri); 1390 var span = system.compiler.spanFromNode(node, script.uri);
1379 return new Dart2JsLocation(script, span); 1391 return new Dart2JsLocation(script, span);
1380 } else { 1392 } else {
1381 var span = system.compiler.spanFromElement(_variable); 1393 var span = system.compiler.spanFromElement(_variable);
1382 return new Dart2JsLocation(script, span); 1394 return new Dart2JsLocation(script, span);
1383 } 1395 }
1384 } 1396 }
1385 } 1397 }
1386 1398
OLDNEW
« no previous file with comments | « pkg/dartdoc/dropdown.dart ('k') | pkg/dartdoc/nav.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698