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

Side by Side Diff: site/try/poi/poi.dart

Issue 1056133008: Fix other tests in 'try' after elementvisitor changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | site/try/poi/scope_information_visitor.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 trydart.poi; 5 library trydart.poi;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Completer, 8 Completer,
9 Future; 9 Future;
10 10
(...skipping 16 matching lines...) Expand all
27 import 'package:compiler/compiler.dart' as api; 27 import 'package:compiler/compiler.dart' as api;
28 28
29 import 'package:compiler/src/dart2jslib.dart' show 29 import 'package:compiler/src/dart2jslib.dart' show
30 Compiler, 30 Compiler,
31 CompilerTask, 31 CompilerTask,
32 Enqueuer, 32 Enqueuer,
33 QueueFilter, 33 QueueFilter,
34 WorkItem; 34 WorkItem;
35 35
36 import 'package:compiler/src/elements/visitor.dart' show 36 import 'package:compiler/src/elements/visitor.dart' show
37 ElementVisitor; 37 BaseElementVisitor;
38 38
39 import 'package:compiler/src/elements/elements.dart' show 39 import 'package:compiler/src/elements/elements.dart' show
40 AbstractFieldElement, 40 AbstractFieldElement,
41 ClassElement, 41 ClassElement,
42 CompilationUnitElement, 42 CompilationUnitElement,
43 Element, 43 Element,
44 ElementCategory, 44 ElementCategory,
45 FunctionElement, 45 FunctionElement,
46 LibraryElement, 46 LibraryElement,
47 ScopeContainerElement; 47 ScopeContainerElement;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if (poiCount != null) poiCount++; 485 if (poiCount != null) poiCount++;
486 if (success != true) { 486 if (success != true) {
487 throw 'Compilation failed'; 487 throw 'Compilation failed';
488 } 488 }
489 return findPosition(position, cachedCompiler.mainApp); 489 return findPosition(position, cachedCompiler.mainApp);
490 }); 490 });
491 } 491 }
492 492
493 Element findPosition(int position, Element element) { 493 Element findPosition(int position, Element element) {
494 FindPositionVisitor visitor = new FindPositionVisitor(position, element); 494 FindPositionVisitor visitor = new FindPositionVisitor(position, element);
495 element.accept(visitor); 495 element.accept(visitor, null);
496 return visitor.element; 496 return visitor.element;
497 } 497 }
498 498
499 String scopeInformation(Element element, int position) { 499 String scopeInformation(Element element, int position) {
500 ScopeInformationVisitor visitor = 500 ScopeInformationVisitor visitor =
501 new ScopeInformationVisitor(cachedCompiler, element, position); 501 new ScopeInformationVisitor(cachedCompiler, element, position);
502 element.accept(visitor); 502 element.accept(visitor, null);
503 return '${visitor.buffer}'; 503 return '${visitor.buffer}';
504 } 504 }
505 505
506 class FindPositionVisitor extends ElementVisitor { 506 class FindPositionVisitor extends BaseElementVisitor {
507 final int position; 507 final int position;
508 Element element; 508 Element element;
509 509
510 FindPositionVisitor(this.position, this.element); 510 FindPositionVisitor(this.position, this.element);
511 511
512 visitElement(modelx.ElementX e) { 512 visitElement(modelx.ElementX e, _) {
513 DeclarationSite site = e.declarationSite; 513 DeclarationSite site = e.declarationSite;
514 if (site is PartialElement) { 514 if (site is PartialElement) {
515 if (site.beginToken.charOffset <= position && 515 if (site.beginToken.charOffset <= position &&
516 position < site.endToken.next.charOffset) { 516 position < site.endToken.next.charOffset) {
517 element = e; 517 element = e;
518 } 518 }
519 } 519 }
520 } 520 }
521 521
522 visitClassElement(ClassElement e) { 522 visitClassElement(ClassElement e, _) {
523 if (e is PartialClassElement) { 523 if (e is PartialClassElement) {
524 if (e.beginToken.charOffset <= position && 524 if (e.beginToken.charOffset <= position &&
525 position < e.endToken.next.charOffset) { 525 position < e.endToken.next.charOffset) {
526 element = e; 526 element = e;
527 visitScopeContainerElement(e); 527 visitScopeContainerElement(e, _);
528 } 528 }
529 } 529 }
530 } 530 }
531 531
532 visitScopeContainerElement(ScopeContainerElement e) { 532 visitScopeContainerElement(ScopeContainerElement e, _) {
533 e.forEachLocalMember((Element element) => element.accept(this)); 533 e.forEachLocalMember((Element element) => element.accept(this, _));
534 } 534 }
535 } 535 }
536 536
537 class ScriptOnlyFilter implements QueueFilter { 537 class ScriptOnlyFilter implements QueueFilter {
538 final Uri script; 538 final Uri script;
539 539
540 ScriptOnlyFilter(this.script); 540 ScriptOnlyFilter(this.script);
541 541
542 bool checkNoEnqueuedInvokedInstanceMethods(Enqueuer enqueuer) => true; 542 bool checkNoEnqueuedInvokedInstanceMethods(Enqueuer enqueuer) => true;
543 543
544 void processWorkItem(void f(WorkItem work), WorkItem work) { 544 void processWorkItem(void f(WorkItem work), WorkItem work) {
545 if (work.element.library.canonicalUri != script) { 545 if (work.element.library.canonicalUri != script) {
546 // TODO(ahe): Rather nasty hack to work around another nasty hack in 546 // TODO(ahe): Rather nasty hack to work around another nasty hack in
547 // backend.dart. Find better solution. 547 // backend.dart. Find better solution.
548 if (work.element.name != 'closureFromTearOff') { 548 if (work.element.name != 'closureFromTearOff') {
549 printWallClock('Skipped ${work.element}.'); 549 printWallClock('Skipped ${work.element}.');
550 return; 550 return;
551 } 551 }
552 } 552 }
553 f(work); 553 f(work);
554 printWallClock('Processed ${work.element}.'); 554 printWallClock('Processed ${work.element}.');
555 } 555 }
556 } 556 }
557 557
558 class PoiTask extends CompilerTask { 558 class PoiTask extends CompilerTask {
559 PoiTask(Compiler compiler) : super(compiler); 559 PoiTask(Compiler compiler) : super(compiler);
560 560
561 String get name => 'POI'; 561 String get name => 'POI';
562 } 562 }
OLDNEW
« no previous file with comments | « no previous file | site/try/poi/scope_information_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698