This class is the foundation of Dartdoc's model for source code. All ModelElements are contained within a Package, and laid out in a structure that mirrors the availability of identifiers in the various namespaces within that package. For example, multiple Class objects for a particular identifier (ModelElement.element) may show up in different Librarys as the identifier is reexported.
However, ModelElements have an additional concept vital to generating documentation: canonicalization.
A ModelElement is canonical if it is the element in the namespace where that element 'comes from' in the public interface to this Package. That often means the ModelElement.library is contained in Package.libraries, but there are many exceptions and ambiguities the code tries to address here.
Non-canonical elements should refer to their canonical counterparts, making it easy to calculate links via ModelElement.href without having to know in a particular namespace which elements are canonical or not. A number of Package methods, such as Package.findCanonicalModelElementFor can help with this.
When documenting, Dartdoc should only write out files corresponding to canonical instances of ModelElement (ModelElement.isCanonical). This helps prevent subtle bugs as generated output for a non-canonical ModelElement will reference itself as part of the "wrong" Library from the public interface perspective.
- Implements
-
- Comparable
- Nameable
- Documentable
- Implemented by
Constructors
- ModelElement(Element _element, Library _library)
- ModelElement.from(Element e, Library library, { Class enclosingClass, int index, ModelElement enclosingCombo })
-
Do not construct any ModelElements unless they are from this constructor.
TODO(jcollins-g): enforce this.
Specify enclosingClass only if this is to be an inherited object.
Specify index only if this is to be an EnumField.forConstant.
Specify enclosingCombo (a GetterSetterCombo) only if this is to be an
Accessor.
TODO(jcollins-g): this way of using the optional parameter is messy,
clean that up.
factory
Properties
- allParameters → List<Parameter>
-
read-only
- annotations → List<String>
-
read-only
- canHaveParameters → bool
-
read-only
- canonicalLibrary → Library
-
read-only
- definingLibrary → Library
-
read-only
- documentation → String
-
Returns the docs, stripped of their leading comments syntax.
@override, read-only
- documentationAsHtml → String
-
@override, read-only
- documentationFrom → ModelElement
-
Returns the ModelElement from which we will get documentation.
@override, read-only
- element → Element
-
@override, read-only
- elementLocation → String
-
@override, read-only
- exportedInLibraries → Set<Library>
-
read-only
- features → Set<String>
-
read-only
- featuresAsString → String
-
read-only
- fullyQualifiedName → String
-
Returns the fully qualified name.
@override, read-only
- fullyQualifiedNameWithoutLibrary → String
-
read-only
- genericParameters → String
-
read-only
- hasAnnotations → bool
-
read-only
- hasDocumentation → bool
-
@override, read-only
- hasExtendedDocumentation → bool
-
@override, read-only
- hasParameters → bool
-
read-only
- href → String
-
If canonicalLibrary (or canonicalEnclosingElement, for Inheritable
subclasses) is null, href should be null.
@override, read-only
- htmlId → String
-
read-only
- isAsynchronous → bool
-
read-only
- isCanonical → bool
-
@override, read-only
- isConst → bool
-
read-only
- isDeprecated → bool
-
read-only
- isExecutable → bool
-
read-only
- isFinal → bool
-
read-only
- isLocalElement → bool
-
read-only
- isPropertyAccessor → bool
-
read-only
- isPropertyInducer → bool
-
read-only
- isStatic → bool
-
read-only
- kind → String
-
A human-friendly name for the kind of element this is.
read-only
- library → Library
-
read-only
- lineAndColumn → Tuple2<int, int>
-
@override, read-only
- linkedName → String
-
read-only
- linkedParamsLines → String
-
read-only
- linkedParamsNoMetadata → String
-
read-only
- linkedParamsNoMetadataOrNames → String
-
read-only
- modelType → ElementType
-
read-only
- name → String
-
@override, read-only
- nameWithGenerics → String
-
read-only
- oneLineDoc → String
-
@override, read-only
- overriddenDepth → int
-
read-only
- overriddenDocumentedElement → ModelElement
-
@override, read-only
- overriddenElement → ModelElement
-
read-only
- package → Package
-
@override, read-only
- parameters → List<Parameter>
-
read-only
- sourceFileName → String
-
read-only
- usedElements → Iterable<ModelElement>
-
Gather all the used elements, from the parameters and return type, for example
E.g. method
Iterable
will returnblah(List foo) Iterable, String, List, int
read-only - hashCode → int
-
The hash code for this object.
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
annotationsFromMetadata(
List md) → List<String> - Returns annotations from a given metadata set, with escaping. md is a dynamic parameter since ElementAnnotation and Annotation have no common class for calling toSource() and element.
-
canOverride(
) → bool -
compareTo(
other) → int -
Compares this object to another
Comparable
-
linkedParams(
{bool showMetadata: true, bool showNames: true, String separator: ', ' }) → String -
toString(
) → String - Returns a string representation of this object.
-
warn(
PackageWarning kind, { String message, Locatable referredFrom }) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited