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

Unified Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 738673002: Use shorter DartElementLocation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
Index: pkg/analyzer/lib/src/generated/engine.dart
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index 62c2d0b8d001b83e82fe88aa54d5f299cd36f8ca..18dd254abb776c01935ce94e29da84012107dc92 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -1713,22 +1713,16 @@ class AnalysisContextImpl implements InternalAnalysisContext {
Element getElement(ElementLocation location) {
// TODO(brianwilkerson) This should not be a "get" method.
try {
- List<String> components = location.components;
- Source source = _computeSourceFromEncoding(components[0]);
- String sourceName = source.shortName;
- if (AnalysisEngine.isDartFileName(sourceName)) {
- ElementImpl element = computeLibraryElement(source) as ElementImpl;
- for (int i = 1; i < components.length; i++) {
- if (element == null) {
- return null;
- }
- element = element.getChild(components[i]);
- }
- return element;
- }
- if (AnalysisEngine.isHtmlFileName(sourceName)) {
- return computeHtmlElement(source);
- }
+ if (location is DartElementLocation) {
+ String libSourceEncoding = location.librarySourceEncoding;
+ Source libSource = _computeSourceFromEncoding(libSourceEncoding);
+ LibraryElementImpl libElement = computeLibraryElement(libSource);
+ return libElement.getChildElement(
+ location.unitSourceEncoding,
+ location.nameOffset,
+ location.kind);
+ }
+ // TODO(scheglov) add HtmlElementLocation
} on AnalysisException catch (exception) {
}
return null;

Powered by Google App Engine
This is Rietveld 408576698