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

Unified Diff: dart/site/try/poi/poi.dart

Issue 561233005: Add ElementX.declarationSite. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r40311. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/site/try/poi/diff.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/poi/poi.dart
diff --git a/dart/site/try/poi/poi.dart b/dart/site/try/poi/poi.dart
index f4e049804ee150ed1670d3e23e207cb3d17422a4..9b218324f4631972f2e1b7c01cbc78b8376cde6f 100644
--- a/dart/site/try/poi/poi.dart
+++ b/dart/site/try/poi/poi.dart
@@ -53,6 +53,9 @@ import 'package:compiler/implementation/elements/elements.dart' show
import 'package:compiler/implementation/elements/modelx.dart' as modelx;
+import 'package:compiler/implementation/elements/modelx.dart' show
+ DeclarationSite;
+
import 'package:compiler/implementation/dart_types.dart' show
DartType;
@@ -330,10 +333,9 @@ Future parseUserInput(
/// [LibraryElement] is currently limited, and works only for named libraries.
Token findToken(modelx.ElementX element, int position) {
Token beginToken;
- if (element is PartialElement) {
- beginToken = (element as PartialElement).beginToken;
- } else if (element is PartialClassElement) {
- beginToken = element.beginToken;
+ DeclarationSite site = element.declarationSite;
+ if (site is PartialElement) {
+ beginToken = site.beginToken;
} else if (element.isLibrary) {
// TODO(ahe): Generalize support for library elements (and update above
// documentation).
@@ -420,10 +422,11 @@ class FindPositionVisitor extends ElementVisitor {
FindPositionVisitor(this.position, this.element);
- visitElement(Element e) {
- if (e is PartialElement) {
- if ((e as PartialElement).beginToken.charOffset <= position &&
- position < (e as PartialElement).endToken.next.charOffset) {
+ visitElement(modelx.ElementX e) {
+ DeclarationSite site = e.declarationSite;
+ if (site is PartialElement) {
+ if (site.beginToken.charOffset <= position &&
+ position < site.endToken.next.charOffset) {
element = e;
}
}
« no previous file with comments | « dart/site/try/poi/diff.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698