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

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

Issue 2293143003: Revert "Remove 'Element.docRange'." (Closed)
Patch Set: Created 4 years, 4 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 | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/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/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index d2fbf23d50c8f09a742073a1c4b293d2759a109b..491025e0bee8683f54745eb1ed23c5af73d74749 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -584,6 +584,18 @@ class ClassElementImpl extends AbstractClassElementImpl
}
@override
+ SourceRange get docRange {
+ if (_unlinkedClass != null) {
+ UnlinkedDocumentationComment comment =
+ _unlinkedClass.documentationComment;
+ return comment != null
+ ? new SourceRange(comment.offset, comment.length)
+ : null;
+ }
+ return super.docRange;
+ }
+
+ @override
String get documentationComment {
if (_unlinkedClass != null) {
return _unlinkedClass?.documentationComment?.text;
@@ -1802,6 +1814,18 @@ class ConstFieldElementImpl_EnumValue extends ConstFieldElementImpl_ofEnum {
: super(enumElement);
@override
+ SourceRange get docRange {
+ if (_unlinkedEnumValue != null) {
+ UnlinkedDocumentationComment comment =
+ _unlinkedEnumValue.documentationComment;
+ return comment != null
+ ? new SourceRange(comment.offset, comment.length)
+ : null;
+ }
+ return super.docRange;
+ }
+
+ @override
String get documentationComment {
if (_unlinkedEnumValue != null) {
return _unlinkedEnumValue?.documentationComment?.text;
@@ -2669,6 +2693,17 @@ abstract class ElementImpl implements Element {
String _docComment;
/**
+ * The offset to the beginning of the documentation comment,
+ * or `null` if this element does not have a documentation comment.
+ */
+ int _docRangeOffset;
+
+ /**
+ * The length of the documentation comment range for this element.
+ */
+ int _docRangeLength;
+
+ /**
* The offset of the beginning of the element's code in the file that contains
* the element, or `null` if the element is synthetic.
*/
@@ -2721,6 +2756,14 @@ abstract class ElementImpl implements Element {
String get displayName => _name;
@override
+ SourceRange get docRange {
+ if (_docRangeOffset != null && _docRangeLength != null) {
+ return new SourceRange(_docRangeOffset, _docRangeLength);
+ }
+ return null;
+ }
+
+ @override
String get documentationComment => _docComment;
/**
@@ -3065,6 +3108,15 @@ abstract class ElementImpl implements Element {
}
/**
+ * Set the documentation comment source range for this element.
+ */
+ void setDocRange(int offset, int length) {
+ assert(!isResynthesized);
+ _docRangeOffset = offset;
+ _docRangeLength = length;
+ }
+
+ /**
* Set whether the given [modifier] is associated with this element to
* correspond to the given [value].
*/
@@ -3350,6 +3402,17 @@ class EnumElementImpl extends AbstractClassElementImpl {
}
@override
+ SourceRange get docRange {
+ if (_unlinkedEnum != null) {
+ UnlinkedDocumentationComment comment = _unlinkedEnum.documentationComment;
+ return comment != null
+ ? new SourceRange(comment.offset, comment.length)
+ : null;
+ }
+ return super.docRange;
+ }
+
+ @override
String get documentationComment {
if (_unlinkedEnum != null) {
return _unlinkedEnum?.documentationComment?.text;
@@ -3603,6 +3666,18 @@ abstract class ExecutableElementImpl extends ElementImpl
}
@override
+ SourceRange get docRange {
+ if (serializedExecutable != null) {
+ UnlinkedDocumentationComment comment =
+ serializedExecutable.documentationComment;
+ return comment != null
+ ? new SourceRange(comment.offset, comment.length)
+ : null;
+ }
+ return super.docRange;
+ }
+
+ @override
String get documentationComment {
if (serializedExecutable != null) {
return serializedExecutable?.documentationComment?.text;
@@ -4569,6 +4644,18 @@ class FunctionTypeAliasElementImpl extends ElementImpl
String get displayName => name;
@override
+ SourceRange get docRange {
+ if (_unlinkedTypedef != null) {
+ UnlinkedDocumentationComment comment =
+ _unlinkedTypedef.documentationComment;
+ return comment != null
+ ? new SourceRange(comment.offset, comment.length)
+ : null;
+ }
+ return super.docRange;
+ }
+
+ @override
String get documentationComment {
if (_unlinkedTypedef != null) {
return _unlinkedTypedef?.documentationComment?.text;
@@ -5326,6 +5413,18 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
}
@override
+ SourceRange get docRange {
+ if (_unlinkedDefiningUnit != null) {
+ UnlinkedDocumentationComment comment =
+ _unlinkedDefiningUnit.libraryDocumentationComment;
+ return comment != null
+ ? new SourceRange(comment.offset, comment.length)
+ : null;
+ }
+ return super.docRange;
+ }
+
+ @override
String get documentationComment {
if (_unlinkedDefiningUnit != null) {
return _unlinkedDefiningUnit?.libraryDocumentationComment?.text;
@@ -6359,6 +6458,9 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
String get displayName => _name;
@override
+ SourceRange get docRange => null;
+
+ @override
String get documentationComment => null;
@override
@@ -6642,6 +6744,18 @@ abstract class NonParameterVariableElementImpl extends VariableElementImpl {
}
@override
+ SourceRange get docRange {
+ if (_unlinkedVariable != null) {
+ UnlinkedDocumentationComment comment =
+ _unlinkedVariable.documentationComment;
+ return comment != null
+ ? new SourceRange(comment.offset, comment.length)
+ : null;
+ }
+ return super.docRange;
+ }
+
+ @override
String get documentationComment {
if (_unlinkedVariable != null) {
return _unlinkedVariable?.documentationComment?.text;
« no previous file with comments | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/element/handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698