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

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

Issue 1364583006: Add Element.nameLength getter and specialize it for LibraryElement. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 | « no previous file | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 45f52bfa1cc5fbd537049f85c1edbe93cbc82fd2..1df7206c5191f577a7706423010780f55bf0c07c 100644
--- a/pkg/analyzer/lib/src/generated/element.dart
+++ b/pkg/analyzer/lib/src/generated/element.dart
@@ -2536,6 +2536,12 @@ abstract class Element implements AnalysisTarget {
String get name;
/**
+ * Return the length of the name of this element in the file that contains the
+ * declaration of this element, or `0` if this element does not have a name.
+ */
+ int get nameLength;
+
+ /**
* Return the offset of the name of this element in the file that contains the
* declaration of this element, or `-1` if this element is synthetic, does not
* have a name, or otherwise does not have an offset.
@@ -2936,10 +2942,10 @@ abstract class ElementImpl implements Element {
_cachedHashCode = null;
}
- /**
- * The offset of the name of this element in the file that contains the
- * declaration of this element.
- */
+ @override
+ int get nameLength => name != null ? name.length : 0;
+
+ @override
int get nameOffset => _nameOffset;
/**
@@ -7312,6 +7318,9 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
*/
FunctionElement _loadLibraryFunction;
+ @override
+ final int nameLength;
+
/**
* The export [Namespace] of this library, `null` if it has not been
* computed yet.
@@ -7330,7 +7339,7 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
* Initialize a newly created library element in the given [context] to have
* the given [name] and [offset].
*/
- LibraryElementImpl(this.context, String name, int offset)
+ LibraryElementImpl(this.context, String name, int offset, this.nameLength)
: super(name, offset);
/**
@@ -7338,7 +7347,7 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
* the given [name].
*/
LibraryElementImpl.forNode(this.context, LibraryIdentifier name)
- : super.forNode(name);
+ : super.forNode(name), nameLength = name != null ? name.length : 0;
Brian Wilkerson 2015/09/25 20:32:14 nit: Should the call to 'super' be last?
@override
CompilationUnitElement get definingCompilationUnit =>
@@ -7940,6 +7949,9 @@ abstract class Member implements Element {
String get name => _baseElement.name;
@override
+ int get nameLength => _baseElement.nameLength;
+
+ @override
int get nameOffset => _baseElement.nameOffset;
@deprecated
@@ -8453,6 +8465,9 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
String get name => _name;
@override
+ int get nameLength => name != null ? name.length : 0;
+
+ @override
int get nameOffset => -1;
@deprecated
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698