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

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

Issue 1080503003: Move getElementAt() to CompilationUnitElement. (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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/generated/element.dart
diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart
index 9c94c92840167ee8cf6464d46ddd0b74c3cecaa2..861b1ea2f5e6e2cf7c48623ad2283c9c5d5a0981 100644
--- a/pkg/analyzer/lib/src/generated/element.dart
+++ b/pkg/analyzer/lib/src/generated/element.dart
@@ -1213,6 +1213,11 @@ abstract class CompilationUnitElement implements Element, UriReferencedElement {
List<ClassElement> get types;
/**
+ * Return the element at the given [offset], maybe `null` if no such element.
+ */
+ Element getElementAt(int offset);
+
+ /**
* Return the enum defined in this compilation unit that has the given [name],
* or `null` if this compilation unit does not define an enum with the given
* name.
@@ -1280,6 +1285,11 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
TopLevelVariableElementImpl.EMPTY_ARRAY;
/**
+ * A map from offsets to elements of this unit at these offsets.
+ */
+ final Map<int, Element> _offsetToElementMap = new HashMap<int, Element>();
+
+ /**
* Initialize a newly created compilation unit element to have the given
* [name].
*/
@@ -1400,6 +1410,13 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
@override
accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this);
+ /**
+ * This method is invoked after this unit was incrementally resolved.
+ */
+ void afterIncrementalResolution() {
+ _offsetToElementMap.clear();
+ }
+
@override
void appendTo(StringBuffer buffer) {
if (source == null) {
@@ -1451,6 +1468,14 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
}
@override
+ Element getElementAt(int offset) {
+ if (_offsetToElementMap.isEmpty) {
+ accept(new _BuildOffsetToElementMap(_offsetToElementMap));
+ }
+ return _offsetToElementMap[offset];
+ }
+
+ @override
ClassElement getEnum(String enumName) {
for (ClassElement enumDeclaration in _enums) {
if (enumDeclaration.name == enumName) {
@@ -6766,11 +6791,6 @@ abstract class LibraryElement implements Element {
List<LibraryElement> get visibleLibraries;
/**
- * Return the element at the given [offset], maybe `null` if no such element.
- */
- Element getElementAt(int offset);
-
- /**
* Return a list containing all of the imports that share the given [prefix],
* or an empty array if there are no such imports.
*/
@@ -6840,11 +6860,6 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
FunctionElement _loadLibraryFunction;
/**
- * A map from offsets to elements of this library at these offsets.
- */
- final Map<int, Element> _offsetToElementMap = new HashMap<int, Element>();
-
- /**
* The export [Namespace] of this library, `null` if it has not been
* computed yet.
*/
@@ -7119,13 +7134,6 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
@override
accept(ElementVisitor visitor) => visitor.visitLibraryElement(this);
- /**
- * This method is invoked after this library was incrementally resolved.
- */
- void afterIncrementalResolution() {
- _offsetToElementMap.clear();
- }
-
@override
ElementImpl getChild(String identifier) {
if ((_definingCompilationUnit as CompilationUnitElementImpl).identifier ==
@@ -7151,14 +7159,6 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
}
@override
- Element getElementAt(int offset) {
- if (_offsetToElementMap.isEmpty) {
- accept(new _BuildOffsetToElementMap(_offsetToElementMap));
- }
- return _offsetToElementMap[offset];
- }
-
- @override
List<ImportElement> getImportsWithPrefix(PrefixElement prefixElement) {
int count = _imports.length;
List<ImportElement> importList = new List<ImportElement>();
« no previous file with comments | « pkg/analysis_server/lib/src/services/index/store/codec.dart ('k') | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698