@@ -245,9 +245,9 @@ class Accessor extends ModelElement
245245
246246 /// Call exactly once to set the enclosing combo for this Accessor.
247247 set enclosingCombo (GetterSetterCombo combo) {
248- assert (_enclosingCombo == null || combo == _enclosingCombo);
249- assert (combo != null );
250- _enclosingCombo = combo;
248+ assert (_enclosingCombo == null || combo == _enclosingCombo);
249+ assert (combo != null );
250+ _enclosingCombo = combo;
251251 }
252252
253253 bool get isSynthetic => element.isSynthetic;
@@ -274,7 +274,8 @@ class Accessor extends ModelElement
274274 @override
275275 String get computeDocumentationComment {
276276 if (isSynthetic) {
277- String docComment = (element as PropertyAccessorElement ).variable.documentationComment;
277+ String docComment =
278+ (element as PropertyAccessorElement ).variable.documentationComment;
278279 // If we're a setter, only display something if we have something different than the getter.
279280 // TODO(jcollins-g): modify analyzer to do this itself?
280281 if (isGetter ||
@@ -1204,7 +1205,7 @@ class EnumField extends Field {
12041205 : super (element, library, getter, null );
12051206
12061207 @override
1207- String get constantValue {
1208+ String get constantValueBase {
12081209 if (name == 'values' ) {
12091210 return 'const List<${_field .enclosingElement .name }>' ;
12101211 } else {
@@ -1260,7 +1261,6 @@ class EnumField extends Field {
12601261class Field extends ModelElement
12611262 with GetterSetterCombo , Inheritable , SourceCodeMixin
12621263 implements EnclosedElement {
1263- String _constantValue;
12641264 bool _isInherited = false ;
12651265 Class _enclosingClass;
12661266 @override
@@ -1296,20 +1296,6 @@ class Field extends ModelElement
12961296 return super .documentation;
12971297 }
12981298
1299- String get constantValue {
1300- if (_constantValue != null ) return _constantValue;
1301-
1302- if (_field.computeNode () == null ) return null ;
1303- var v = _field.computeNode ().toSource ();
1304- if (v == null ) return null ;
1305- var string = v.substring (v.indexOf ('=' ) + 1 , v.length).trim ();
1306- _constantValue = string.replaceAll ("${modelType .name }" , "${modelType .linkedName }" );
1307-
1308- return _constantValue;
1309- }
1310-
1311- String get constantValueTruncated => truncateString (constantValue, 200 );
1312-
13131299 @override
13141300 ModelElement get enclosingElement {
13151301 if (_enclosingClass == null ) {
@@ -1441,11 +1427,34 @@ abstract class GetterSetterCombo implements ModelElement {
14411427 return allFeatures;
14421428 }
14431429
1444-
14451430 @override
14461431 ModelElement enclosingElement;
14471432 bool get isInherited;
14481433
1434+ String _constantValueBase;
1435+ String get constantValueBase {
1436+ if (_constantValueBase == null ) {
1437+ if (element.computeNode () != null ) {
1438+ var v = element.computeNode ().toSource ();
1439+ if (v == null ) return null ;
1440+ var string = v.substring (v.indexOf ('=' ) + 1 , v.length).trim ();
1441+ _constantValueBase =
1442+ const HtmlEscape (HtmlEscapeMode .UNKNOWN ).convert (string);
1443+ }
1444+ }
1445+ return _constantValueBase;
1446+ }
1447+
1448+ String linkifyWithModelType (String text) {
1449+ RegExp r = new RegExp ("\\ b${modelType .name }\\ b" );
1450+ return text? .replaceAll (r, modelType.linkedName);
1451+ }
1452+
1453+ String get constantValue => linkifyWithModelType (constantValueBase);
1454+
1455+ String get constantValueTruncated =>
1456+ linkifyWithModelType (truncateString (constantValueBase, 200 ));
1457+
14491458 /// Returns true if both accessors are synthetic.
14501459 bool get hasSyntheticAccessors {
14511460 if ((hasPublicGetter && getter.element.isSynthetic) ||
@@ -2868,16 +2877,16 @@ abstract class ModelElement extends Nameable
28682877 Library lib;
28692878 // TODO(jcollins-g): get rid of dynamic special casing
28702879 if (element.kind != ElementKind .DYNAMIC ) {
2871- lib = _findOrCreateEnclosingLibraryFor ((element as dynamic ).type.element);
2880+ lib = _findOrCreateEnclosingLibraryFor (
2881+ (element as dynamic ).type.element);
28722882 }
2873- _modelType = new ElementType (
2874- (element as dynamic ).type, new ModelElement .from ((element as dynamic ).type.element, lib));
2883+ _modelType = new ElementType ((element as dynamic ).type,
2884+ new ModelElement .from ((element as dynamic ).type.element, lib));
28752885 }
28762886 }
28772887 return _modelType;
28782888 }
28792889
2880-
28812890 @override
28822891 String get name => element.name;
28832892
@@ -4402,16 +4411,6 @@ class TopLevelVariable extends ModelElement
44024411 @override
44034412 bool get isInherited => false ;
44044413
4405- String get constantValue {
4406- var v = _variable.computeNode ().toSource ();
4407- if (v == null ) return '' ;
4408- var string = v.substring (v.indexOf ('=' ) + 1 , v.length).trim ();
4409- string = HTML_ESCAPE .convert (string);
4410- return string.replaceAll (modelType.name, modelType.linkedName);
4411- }
4412-
4413- String get constantValueTruncated => truncateString (constantValue, 200 );
4414-
44154414 @override
44164415 String get documentation {
44174416 // Verify that hasSetter and hasGetterNoSetter are mutually exclusive,
0 commit comments