| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino 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.md file. | |
| 4 | |
| 5 import 'package:compiler/src/elements/visitor.dart'; | |
| 6 import 'package:compiler/src/parser/partial_elements.dart'; | |
| 7 import 'package:compiler/src/elements/elements.dart'; | |
| 8 import 'package:compiler/src/elements/modelx.dart'; | |
| 9 | |
| 10 class FindPositionVisitor extends BaseElementVisitor { | |
| 11 final int position; | |
| 12 Element element; | |
| 13 | |
| 14 FindPositionVisitor(this.position, this.element); | |
| 15 | |
| 16 visit(Element e, [arg]) => e.accept(this, arg); | |
| 17 | |
| 18 visitElement(ElementX e, _) { | |
| 19 DeclarationSite site = e.declarationSite; | |
| 20 if (site is PartialElement) { | |
| 21 if (site.beginToken.charOffset <= position && | |
| 22 position < site.endToken.next.charOffset) { | |
| 23 element = e; | |
| 24 } | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 visitClassElement(ClassElement e, _) { | |
| 29 if (e is PartialClassElement) { | |
| 30 if (e.beginToken.charOffset <= position && | |
| 31 position < e.endToken.next.charOffset) { | |
| 32 element = e; | |
| 33 visitScopeContainerElement(e, null); | |
| 34 } | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 visitScopeContainerElement(ScopeContainerElement e, _) { | |
| 39 e.forEachLocalMember((Element element) => visit(element)); | |
| 40 } | |
| 41 | |
| 42 visitCompilationUnitElement(CompilationUnitElement e, _) { | |
| 43 e.forEachLocalMember((Element element) => visit(element)); | |
| 44 } | |
| 45 } | |
| OLD | NEW |