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

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

Issue 1689303002: Issue 25385. Set documentation comment for enum constants. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/resolver.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/builder.dart
diff --git a/pkg/analyzer/lib/src/dart/element/builder.dart b/pkg/analyzer/lib/src/dart/element/builder.dart
index ac051b984a1e07ab85da83e46c0e06dc336adfc5..7f68a66a8940c431e95b08f2c46edc8f9efdfadc 100644
--- a/pkg/analyzer/lib/src/dart/element/builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/builder.dart
@@ -176,7 +176,7 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
exportElement.uri = node.uriContent;
exportElement.combinators = _buildCombinators(node);
exportElement.exportedLibrary = exportedLibrary;
- _setDoc(exportElement, node);
+ setElementDocumentationComment(exportElement, node);
node.element = exportElement;
exports.add(exportElement);
if (exportSourceKindMap[exportedSource] != SourceKind.LIBRARY) {
@@ -218,7 +218,7 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
importElement.deferred = node.deferredKeyword != null;
importElement.combinators = _buildCombinators(node);
importElement.importedLibrary = importedLibrary;
- _setDoc(importElement, node);
+ setElementDocumentationComment(importElement, node);
SimpleIdentifier prefixNode = node.prefix;
if (prefixNode != null) {
importElement.prefixOffset = prefixNode.offset;
@@ -272,19 +272,6 @@ class DirectiveElementBuilder extends SimpleAstVisitor<Object> {
}
/**
- * If the given [node] has a documentation comment, remember its content
- * and range into the given [element].
- */
- void _setDoc(ElementImpl element, AnnotatedNode node) {
- Comment comment = node.documentationComment;
- if (comment != null && comment.isDocumentation) {
- element.documentationComment =
- comment.tokens.map((Token t) => t.lexeme).join('\n');
- element.setDocRange(comment.offset, comment.length);
- }
- }
-
- /**
* Build the element model representing the combinators declared by
* the given [directive].
*/
@@ -415,7 +402,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
interfaceType.typeArguments = typeArguments;
element.type = interfaceType;
element.typeParameters = typeParameters;
- _setDoc(element, node);
+ setElementDocumentationComment(element, node);
element.abstract = node.isAbstract;
element.accessors = holder.accessors;
List<ConstructorElement> constructors = holder.constructors;
@@ -466,7 +453,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
InterfaceTypeImpl interfaceType = new InterfaceTypeImpl(element);
interfaceType.typeArguments = typeArguments;
element.type = interfaceType;
- _setDoc(element, node);
+ setElementDocumentationComment(element, node);
_currentHolder.addType(element);
className.staticElement = element;
holder.validate();
@@ -488,7 +475,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
ConstructorElementImpl element =
new ConstructorElementImpl.forNode(constructorName);
element.metadata = _createElementAnnotations(node.metadata);
- _setDoc(element, node);
+ setElementDocumentationComment(element, node);
if (node.externalKeyword != null) {
element.external = true;
}
@@ -596,7 +583,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
ClassElementImpl enumElement = new ClassElementImpl.forNode(enumName);
enumElement.metadata = _createElementAnnotations(node.metadata);
enumElement.enum2 = true;
- _setDoc(enumElement, node);
+ setElementDocumentationComment(enumElement, node);
InterfaceTypeImpl enumType = new InterfaceTypeImpl(enumElement);
enumElement.type = enumType;
// The equivalent code for enums in the spec shows a single constructor,
@@ -677,7 +664,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
FunctionElementImpl element =
new FunctionElementImpl.forNode(functionName);
element.metadata = _createElementAnnotations(node.metadata);
- _setDoc(element, node);
+ setElementDocumentationComment(element, node);
if (node.externalKeyword != null) {
element.external = true;
}
@@ -723,7 +710,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
PropertyAccessorElementImpl getter =
new PropertyAccessorElementImpl.forNode(propertyNameNode);
getter.metadata = _createElementAnnotations(node.metadata);
- _setDoc(getter, node);
+ setElementDocumentationComment(getter, node);
if (node.externalKeyword != null) {
getter.external = true;
}
@@ -750,7 +737,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
PropertyAccessorElementImpl setter =
new PropertyAccessorElementImpl.forNode(propertyNameNode);
setter.metadata = _createElementAnnotations(node.metadata);
- _setDoc(setter, node);
+ setElementDocumentationComment(setter, node);
if (node.externalKeyword != null) {
setter.external = true;
}
@@ -839,7 +826,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
FunctionTypeAliasElementImpl element =
new FunctionTypeAliasElementImpl.forNode(aliasName);
element.metadata = _createElementAnnotations(node.metadata);
- _setDoc(element, node);
+ setElementDocumentationComment(element, node);
element.parameters = parameters;
element.typeParameters = typeParameters;
_createTypeParameterTypes(typeParameters);
@@ -924,7 +911,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
MethodElementImpl element =
new MethodElementImpl(nameOfMethod, methodName.offset);
element.metadata = _createElementAnnotations(node.metadata);
- _setDoc(element, node);
+ setElementDocumentationComment(element, node);
element.abstract = node.isAbstract;
if (node.externalKeyword != null) {
element.external = true;
@@ -962,7 +949,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
PropertyAccessorElementImpl getter =
new PropertyAccessorElementImpl.forNode(propertyNameNode);
getter.metadata = _createElementAnnotations(node.metadata);
- _setDoc(getter, node);
+ setElementDocumentationComment(getter, node);
if (node.externalKeyword != null) {
getter.external = true;
}
@@ -989,7 +976,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
PropertyAccessorElementImpl setter =
new PropertyAccessorElementImpl.forNode(propertyNameNode);
setter.metadata = _createElementAnnotations(node.metadata);
- _setDoc(setter, node);
+ setElementDocumentationComment(setter, node);
if (node.externalKeyword != null) {
setter.external = true;
}
@@ -1134,7 +1121,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
}
element = field;
if (node.parent.parent is FieldDeclaration) {
- _setDoc(element, node.parent.parent);
+ setElementDocumentationComment(element, node.parent.parent);
}
if ((node.parent as VariableDeclarationList).type == null) {
field.hasImplicitType = true;
@@ -1169,7 +1156,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
}
element = variable;
if (node.parent.parent is TopLevelVariableDeclaration) {
- _setDoc(element, node.parent.parent);
+ setElementDocumentationComment(element, node.parent.parent);
}
if ((node.parent as VariableDeclarationList).type == null) {
variable.hasImplicitType = true;
@@ -1340,19 +1327,6 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
}
/**
- * If the given [node] has a documentation comment, remember its content
- * and range into the given [element].
- */
- void _setDoc(ElementImpl element, AnnotatedNode node) {
- Comment comment = node.documentationComment;
- if (comment != null && comment.isDocumentation) {
- element.documentationComment =
- comment.tokens.map((Token t) => t.lexeme).join('\n');
- element.setDocRange(comment.offset, comment.length);
- }
- }
-
- /**
* Sets the visible source range for formal parameter.
*/
void _setParameterVisibleRange(
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698