Class JSDocInfo
- All Implemented Interfaces:
Serializable
Constructing JSDocInfo
objects is simplified by JSDocInfo.Builder
which
provides early incompatibility detection.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A builder forJSDocInfo
objects.static final class
Defines a class for containing the parsing information for this JSDocInfo.static class
A piece of information (found in a marker) which contains a position with a name node.static class
A piece of information (found in a marker) which contains a position with a string.static class
A piece of information (found in a marker) which contains a position with a type expression syntax tree.static enum
Visibility categories. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
areEquivalent
(JSDocInfo jsDoc1, JSDocInfo jsDoc2) static JSDocInfo.Builder
builder()
Create a new JSDocInfo.Builder object.clone()
clone
(boolean cloneTypeNodes) cloneAndReplaceTypeNames
(Set<String> names) Clones this JSDoc but replaces the given names in any type related annotation with unknown type.boolean
Returns whether there is a declaration present on thisJSDocInfo
, including a typeless @const like/** @const * / a.b.c = 0
boolean
Returns whether there is a declaration present on thisJSDocInfo
.boolean
Deprecated.This method is quite heuristic, looking for @type annotations that start with "function".boolean
Returns whether this JSDoc contains a type declaration such as/** @type {string}
boolean
Gets the alternate message ID specified by the@alternateMessageId
annotation.Returns the list of authors or null if none.Gets the base type specified by the@extends
annotation.Returns the block-level description or null if none specified.Returns the@closurePrimitive {id}
identifierReturns the deprecation reason or null if none specified.Gets the description specified by the@desc
annotation.@Nullable String
Returns the description for the parameter with the given name, if its exists.Returns the enhanced namespace or null if none is specified.Gets the enum parameter type specified by the@enum
annotation.Returns the interfaces extended by an interfaceint
Gets the number of extended interfaces specifiedReturns the file overview or null if none specified.int
Gets the number of interfaces specified by the@implements
annotation.Returns the types specified by the@implements
annotation.Gets the name we're lending to in a@lends
annotation.Gets the description specified by the@license
annotation.boolean
Returns whether we should log the type of values passed to this function.Gets the list of all markers for the documentation in this JSDoc.Gets the meaning specified by the@meaning
annotation.Returns the set of sideeffect notations.getMods()
Returns the modded namespace or null if none is specified.int
Returns the original JSDoc comment string.int
Gets the number of parameters defined.@Nullable String
getParameterNameAt
(int index) Returns the nth name in the defined parameters.Returns the set of names of the defined parameters.@Nullable JSTypeExpression
getParameterType
(String parameter) Gets the type of a given named parameter.protected Object
getPropertyValueByIndex
(int index) Returns the list of references or null if none.Returns the description of the returned object or null if none specified.Gets the return type specified by the@return
annotation.Returns the set of suppressed warnings.Returns a map containing key=set of suppressions, and value=the corresponding description for the set.com.google.common.collect.ImmutableList
<String> Gets the @template type names.com.google.common.collect.ImmutableMap
<String, JSTypeExpression> Gets the type specified by the@this
annotation.Returns the list of thrown types and descriptions as text.com.google.common.collect.ImmutableList
<String> Gets the ts type declarations specified by the@tsType
annotations.getType()
Gets the type specified by the@type
annotation.Gets the typedef type specified by the@type
annotation.Returns a collection of all JSTypeExpressions that are a part of this JSDocInfo.Returns a collection of all type nodes that are a part of this JSDocInfo.Gets the type transformations.Gets the visibility specified by@private
,@protected
or@public
annotation.boolean
Returns whether thisJSDocInfo
contains a type for@extends
annotation.boolean
Whether this JSDoc is annotated with@closurePrimitive
boolean
Returns whether the@const
annotation is present on thisJSDocInfo
.boolean
Returns whether a description exists for the parameter with the specified name.boolean
Returns whether this has an enhanced namespace.boolean
Returns whether an enum parameter type, specified using the@enum
annotation, is present on this JSDoc.boolean
Returns whether this has a fileoverview flag.boolean
boolean
boolean
hasMods()
Returns whether this has a modded namespace.boolean
hasParameter
(String parameter) Returns whether the parameter is defined.boolean
hasParameterType
(String parameter) Returns whether the parameter has an attached type.boolean
Returns whether thisJSDocInfo
contains a type for@return
annotation.boolean
Returns whether the @modifies annotation includes "arguments" or any named parameters.boolean
Returns whether thisJSDocInfo
contains a type for@this
annotation.boolean
hasType()
Returns whether a type, specified using the@type
annotation, is present on this JSDoc.boolean
Returns whether a typedef parameter type, specified using the@typedef
annotation, is present on this JSDoc.boolean
boolean
Returns whether the@abstract
annotation is present on thisJSDocInfo
.boolean
Returns whether any@idGenerator
oridGenerator {?}
annotation is present.boolean
Returns whether the@code
is present within thisJSDocInfo
.boolean
Returns whether JSDoc is annotated with the@closureUnawareCode
annotation.boolean
Returns whether the@collapsibleOrBreakMyCode
annotation is present on thisJSDocInfo
.boolean
Returns whether the@idGenerator {consistent}
is present on thisJSDocInfo
.boolean
Returns whether thisJSDocInfo
implies that annotated value is constant.boolean
Returns whether the@constructor
annotation is present on thisJSDocInfo
.boolean
boolean
Returns whether JSDoc is annotated with@customElement
annotation.boolean
isDefine()
Returns whether the@define
annotation is present on thisJSDocInfo
.boolean
Returns whether the@deprecated
annotation is present on thisJSDocInfo
.boolean
isExport()
Returns whether the@export
annotation is present on thisJSDocInfo
.boolean
Returns whether the@externs
annotation is present on thisJSDocInfo
.boolean
isFinal()
Returns whether the@final
annotation is present on thisJSDocInfo
.boolean
Returns whether the@idGenerator
is present on thisJSDocInfo
.boolean
Returns whether the@implicitCast
annotation is present on thisJSDocInfo
.boolean
Returns whether the type annotation was inlined.boolean
Returns whether the@interface
annotation is present on thisJSDocInfo
.boolean
Returns whether the@idGenerator {mapped}
is present on thisJSDocInfo
.boolean
Returns whether JSDoc is annotated with@mixinClass
annotation.boolean
Returns whether JSDoc is annotated with@mixinFunction
annotation.boolean
Returns whether JSDoc is annotated with@ngInject
annotation.boolean
Returns whether the@nocollapse
annotation is present on thisJSDocInfo
.boolean
Returns whether the@nocompile
annotation is present on thisJSDocInfo
.boolean
Returns whether the@nocoverage
annotation is present on thisJSDocInfo
.boolean
isNoDts()
Returns whether the@nodts
annotation is present on thisJSDocInfo
.boolean
Returns whether the@noinline
annotation is present on thisJSDocInfo
.boolean
Returns whether the@nosideeffects
annotation is present on thisJSDocInfo
.boolean
Returns whether the@override
annotation is present on thisJSDocInfo
.boolean
Returns whether JSDoc is annotated with@polymer
annotation.boolean
Returns whether JSDoc is annotated with@polymerBehavior
annotation.boolean
Returns whether the@provideAlreadyProvided
annotation is present on thisJSDocInfo
.boolean
Returns whether the@provideGoog
annotation is present on thisJSDocInfo
.boolean
Returns whether the@pureOrBreakMyCode
annotation is present on thisJSDocInfo
.boolean
Returns whether the@requireInlining
annotation is present on thisJSDocInfo
.boolean
boolean
Returns whether the@idGenerator {stable}
is present on thisJSDocInfo
.boolean
Returns whether the@typeSummary
annotation is present on thisJSDocInfo
.boolean
Returns whether JSDoc is annotated with the@usedViaDotConstructor
annotation.boolean
Returns whether JSDoc is annotated with@wizaction
annotation.boolean
Returns if JSDoc is annotated with@wizcallback
annotation.boolean
Returns whether the@idGenerator {xid}
is present on thisJSDocInfo
.boolean
Returns whether the@dict
annotation is present on thisJSDocInfo
.boolean
Returns whether the@struct
annotation is present on thisJSDocInfo
.boolean
Returns whether the@unrestricted
annotation is present on thisJSDocInfo
.boolean
Get the value of the @modifies{this} annotation stored in the doc info.toString()
boolean
Returns whether the@record
annotation is present on thisJSDocInfo
.
-
Method Details
-
builder
Create a new JSDocInfo.Builder object. -
toBuilder
-
clone
-
cloneAndReplaceTypeNames
Clones this JSDoc but replaces the given names in any type related annotation with unknown type.- Returns:
- returns the the cloned JSDocInfo
-
clone
-
areEquivalent
-
isAnyIdGenerator
public boolean isAnyIdGenerator()Returns whether any@idGenerator
oridGenerator {?}
annotation is present. -
isConsistentIdGenerator
public boolean isConsistentIdGenerator()Returns whether the@idGenerator {consistent}
is present on thisJSDocInfo
. -
isStableIdGenerator
public boolean isStableIdGenerator()Returns whether the@idGenerator {stable}
is present on thisJSDocInfo
. -
isXidGenerator
public boolean isXidGenerator()Returns whether the@idGenerator {xid}
is present on thisJSDocInfo
. -
isMappedIdGenerator
public boolean isMappedIdGenerator()Returns whether the@idGenerator {mapped}
is present on thisJSDocInfo
. -
isIdGenerator
public boolean isIdGenerator()Returns whether the@idGenerator
is present on thisJSDocInfo
. -
isConstant
public boolean isConstant()Returns whether thisJSDocInfo
implies that annotated value is constant. -
hasConstAnnotation
public boolean hasConstAnnotation()Returns whether the@const
annotation is present on thisJSDocInfo
. -
isFinal
public boolean isFinal()Returns whether the@final
annotation is present on thisJSDocInfo
. -
isConstructor
public boolean isConstructor()Returns whether the@constructor
annotation is present on thisJSDocInfo
. -
isAbstract
public boolean isAbstract()Returns whether the@abstract
annotation is present on thisJSDocInfo
. -
usesImplicitMatch
public boolean usesImplicitMatch()Returns whether the@record
annotation is present on thisJSDocInfo
. -
makesUnrestricted
public boolean makesUnrestricted()Returns whether the@unrestricted
annotation is present on thisJSDocInfo
. -
makesStructs
public boolean makesStructs()Returns whether the@struct
annotation is present on thisJSDocInfo
. -
makesDicts
public boolean makesDicts()Returns whether the@dict
annotation is present on thisJSDocInfo
. -
isDefine
public boolean isDefine() -
isOverride
public boolean isOverride()Returns whether the@override
annotation is present on thisJSDocInfo
. -
isDeprecated
public boolean isDeprecated()Returns whether the@deprecated
annotation is present on thisJSDocInfo
. -
isInterface
public boolean isInterface()Returns whether the@interface
annotation is present on thisJSDocInfo
. -
isConstructorOrInterface
public boolean isConstructorOrInterface() -
isExport
public boolean isExport()Returns whether the@export
annotation is present on thisJSDocInfo
. -
isImplicitCast
public boolean isImplicitCast()Returns whether the@implicitCast
annotation is present on thisJSDocInfo
. -
isNoSideEffects
public boolean isNoSideEffects()Returns whether the@nosideeffects
annotation is present on thisJSDocInfo
. -
isExterns
public boolean isExterns()Returns whether the@externs
annotation is present on thisJSDocInfo
. -
isNoCoverage
public boolean isNoCoverage()Returns whether the@nocoverage
annotation is present on thisJSDocInfo
. -
isTypeSummary
public boolean isTypeSummary()Returns whether the@typeSummary
annotation is present on thisJSDocInfo
. -
isNoCompile
public boolean isNoCompile()Returns whether the@nocompile
annotation is present on thisJSDocInfo
. -
isNoDts
public boolean isNoDts()Returns whether the@nodts
annotation is present on thisJSDocInfo
. -
isNoCollapse
public boolean isNoCollapse()Returns whether the@nocollapse
annotation is present on thisJSDocInfo
. -
isNoInline
public boolean isNoInline()Returns whether the@noinline
annotation is present on thisJSDocInfo
. -
isRequireInlining
public boolean isRequireInlining()Returns whether the@requireInlining
annotation is present on thisJSDocInfo
. -
isCollapsibleOrBreakMyCode
public boolean isCollapsibleOrBreakMyCode()Returns whether the@collapsibleOrBreakMyCode
annotation is present on thisJSDocInfo
. -
isPureOrBreakMyCode
public boolean isPureOrBreakMyCode()Returns whether the@pureOrBreakMyCode
annotation is present on thisJSDocInfo
. -
isProvideGoog
public boolean isProvideGoog()Returns whether the@provideGoog
annotation is present on thisJSDocInfo
. -
isProvideAlreadyProvided
public boolean isProvideAlreadyProvided()Returns whether the@provideAlreadyProvided
annotation is present on thisJSDocInfo
. -
containsDeclarationExcludingTypelessConst
public boolean containsDeclarationExcludingTypelessConst()Returns whether there is a declaration present on thisJSDocInfo
.Does not consider `@const` (without a following type) to indicate a declaration. Whether you want this method, or the`containsDeclaration` that includes const, depends on whether you want to consider
/** @const * / a.b.c = 0
a declaration or not. -
containsTypeDeclaration
public boolean containsTypeDeclaration()Returns whether this JSDoc contains a type declaration such as/** @type {string}
-
containsDeclaration
public boolean containsDeclaration()Returns whether there is a declaration present on thisJSDocInfo
, including a typeless @const like/** @const * / a.b.c = 0
-
containsFunctionDeclaration
Deprecated.This method is quite heuristic, looking for @type annotations that start with "function". Other methods like containsDeclaration() and containsTypeDefinition are generally preferred.- Returns:
- Whether there is a declaration of a callable type.
-
containsTypeDefinition
public boolean containsTypeDefinition() -
isAtSignCodePresent
public boolean isAtSignCodePresent()Returns whether the@code
is present within thisJSDocInfo
. -
getVisibility
Gets the visibility specified by@private
,@protected
or@public
annotation. If no visibility is specified, visibility is inherited from the base class. -
getParameterType
Gets the type of a given named parameter.- Parameters:
parameter
- the parameter's name- Returns:
- the parameter's type or
null
if this parameter is not defined or has anull
type
-
hasParameter
Returns whether the parameter is defined. -
hasParameterType
Returns whether the parameter has an attached type.- Returns:
true
if the parameter has an attached type,false
if the parameter has no attached type or does not exist.
-
getParameterNames
Returns the set of names of the defined parameters. The iteration order of the returned set is the order in which parameters are defined in the JSDoc, rather than the order in which the function declares them.- Returns:
- the set of names of the defined parameters. The returned set is immutable.
-
getParameterNameAt
Returns the nth name in the defined parameters. The iteration order is the order in which parameters are defined in the JSDoc, rather than the order in which the function declares them. -
getParameterCount
public int getParameterCount()Gets the number of parameters defined. -
getThrowsAnnotations
Returns the list of thrown types and descriptions as text. -
hasEnumParameterType
public boolean hasEnumParameterType()Returns whether an enum parameter type, specified using the@enum
annotation, is present on this JSDoc. -
hasTypedefType
public boolean hasTypedefType()Returns whether a typedef parameter type, specified using the@typedef
annotation, is present on this JSDoc. -
hasReturnType
public boolean hasReturnType()Returns whether thisJSDocInfo
contains a type for@return
annotation. -
hasType
public boolean hasType()Returns whether a type, specified using the@type
annotation, is present on this JSDoc. -
hasTypeInformation
public boolean hasTypeInformation() -
isInlineType
public boolean isInlineType()Returns whether the type annotation was inlined. -
getReturnType
Gets the return type specified by the@return
annotation. -
getEnumParameterType
Gets the enum parameter type specified by the@enum
annotation. -
getTypedefType
Gets the typedef type specified by the@type
annotation. -
getType
Gets the type specified by the@type
annotation. -
getThisType
Gets the type specified by the@this
annotation. -
hasThisType
public boolean hasThisType()Returns whether thisJSDocInfo
contains a type for@this
annotation. -
getBaseType
Gets the base type specified by the@extends
annotation. -
getDescription
Gets the description specified by the@desc
annotation. -
getTsTypes
Gets the ts type declarations specified by the@tsType
annotations. -
getMeaning
Gets the meaning specified by the@meaning
annotation.In localization systems, two messages with the same content but different "meanings" may be translated differently. By default, we use the name of the variable that the message is initialized to as the "meaning" of the message.
But some code generators (like Closure Templates) inject their own meaning with the jsdoc
@meaning
annotation. -
getAlternateMessageId
Gets the alternate message ID specified by the@alternateMessageId
annotation.In localization systems, if we migrate from one message ID algorithm to another, we can specify the old one via
@alternateMessageId
. This allows the product to use the previous translation while waiting for the new one to be translated.Some code generators (like Closure Templates) inject this.
-
getLendsName
Gets the name we're lending to in a@lends
annotation.In many reflection APIs, you pass an anonymous object to a function, and that function mixes the anonymous object into another object. The
@lends
annotation allows the type system to track those property assignments. -
hasLendsName
public boolean hasLendsName() -
getClosurePrimitiveId
Returns the@closurePrimitive {id}
identifier -
hasClosurePrimitiveId
public boolean hasClosurePrimitiveId()Whether this JSDoc is annotated with@closurePrimitive
-
isNgInject
public boolean isNgInject()Returns whether JSDoc is annotated with@ngInject
annotation. -
isWizaction
public boolean isWizaction()Returns whether JSDoc is annotated with@wizaction
annotation. -
isWizcallback
public boolean isWizcallback()Returns if JSDoc is annotated with@wizcallback
annotation. -
isPolymerBehavior
public boolean isPolymerBehavior()Returns whether JSDoc is annotated with@polymerBehavior
annotation. -
isPolymer
public boolean isPolymer()Returns whether JSDoc is annotated with@polymer
annotation. -
isCustomElement
public boolean isCustomElement()Returns whether JSDoc is annotated with@customElement
annotation. -
isMixinClass
public boolean isMixinClass()Returns whether JSDoc is annotated with@mixinClass
annotation. -
isMixinFunction
public boolean isMixinFunction()Returns whether JSDoc is annotated with@mixinFunction
annotation. -
isSassGeneratedCssTs
public boolean isSassGeneratedCssTs() -
isClosureUnawareCode
public boolean isClosureUnawareCode()Returns whether JSDoc is annotated with the@closureUnawareCode
annotation. -
isUsedViaDotConstructor
public boolean isUsedViaDotConstructor()Returns whether JSDoc is annotated with the@usedViaDotConstructor
annotation. -
getLicense
Gets the description specified by the@license
annotation. -
toString
-
toStringVerbose
-
hasBaseType
public boolean hasBaseType()Returns whether thisJSDocInfo
contains a type for@extends
annotation. -
getImplementedInterfaces
Returns the types specified by the@implements
annotation.- Returns:
- An immutable list of JSTypeExpression objects that can be resolved to types.
-
getImplementedInterfaceCount
public int getImplementedInterfaceCount()Gets the number of interfaces specified by the@implements
annotation. -
getExtendedInterfaces
Returns the interfaces extended by an interface- Returns:
- An immutable list of JSTypeExpression objects that can be resolved to types.
-
getExtendedInterfacesCount
public int getExtendedInterfacesCount()Gets the number of extended interfaces specified -
getDeprecationReason
Returns the deprecation reason or null if none specified. -
getSuppressions
Returns the set of suppressed warnings. -
getSuppressionsAndTheirDescription
public com.google.common.collect.ImmutableMap<com.google.common.collect.ImmutableSet<String>,String> getSuppressionsAndTheirDescription()Returns a map containing key=set of suppressions, and value=the corresponding description for the set. -
getModifies
Returns the set of sideeffect notations. -
hasDescriptionForParameter
Returns whether a description exists for the parameter with the specified name. -
getDescriptionForParameter
Returns the description for the parameter with the given name, if its exists. -
getAuthors
Returns the list of authors or null if none. -
getReferences
Returns the list of references or null if none. -
getReturnDescription
Returns the description of the returned object or null if none specified. -
getBlockDescription
Returns the block-level description or null if none specified. -
hasFileOverview
public boolean hasFileOverview()Returns whether this has a fileoverview flag. -
getFileOverview
Returns the file overview or null if none specified. -
hasEnhance
public boolean hasEnhance()Returns whether this has an enhanced namespace. -
getEnhance
Returns the enhanced namespace or null if none is specified. -
hasMods
public boolean hasMods()Returns whether this has a modded namespace. -
getMods
Returns the modded namespace or null if none is specified. -
getMarkers
Gets the list of all markers for the documentation in this JSDoc. -
getTemplateTypeNames
Gets the @template type names.Excludes @template types from TTL; get those with
getTypeTransformations()
-
getTemplateTypes
-
getTypeTransformations
Gets the type transformations. -
getTypeExpressions
Returns a collection of all JSTypeExpressions that are a part of this JSDocInfo.This includes:
- base type
- @extends
- @implements
- @lend
- @param
- @return
- @template
- @this
- @throws
- @type
- Returns:
- collection of all type nodes
-
getTypeNodes
Returns a collection of all type nodes that are a part of this JSDocInfo.This includes:
- @extends
- @implements
- @lend
- @param
- @return
- @template
- @this
- @throws
- @type
- Returns:
- collection of all type nodes
-
hasModifies
public boolean hasModifies() -
getOriginalCommentString
Returns the original JSDoc comment string. Returns null unless parseJsDocDocumentation is enabled via the ParserConfig. -
getOriginalCommentPosition
public int getOriginalCommentPosition() -
modifiesThis
public boolean modifiesThis()Get the value of the @modifies{this} annotation stored in the doc info. -
hasSideEffectsArgumentsAnnotation
public boolean hasSideEffectsArgumentsAnnotation()Returns whether the @modifies annotation includes "arguments" or any named parameters. -
getLogTypeInCompiler
public boolean getLogTypeInCompiler()Returns whether we should log the type of values passed to this function. -
getPropertyValueByIndex
-