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 classA builder forJSDocInfoobjects.static final classDefines a class for containing the parsing information for this JSDocInfo.static classA piece of information (found in a marker) which contains a position with a name node.static classA piece of information (found in a marker) which contains a position with a string.static classA piece of information (found in a marker) which contains a position with a type expression syntax tree.static enumVisibility categories. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareEquivalent(JSDocInfo jsDoc1, JSDocInfo jsDoc2) static JSDocInfo.Builderbuilder()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.booleanReturns whether there is a declaration present on thisJSDocInfo, including a typeless @const like/** @const * / a.b.c = 0booleanReturns whether there is a declaration present on thisJSDocInfo.booleanDeprecated.This method is quite heuristic, looking for @type annotations that start with "function".booleanReturns whether this JSDoc contains a type declaration such as/** @type {string}booleanGets the alternate message ID specified by the@alternateMessageIdannotation.Returns the list of authors or null if none.Gets the base type specified by the@extendsannotation.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@descannotation.@Nullable StringReturns 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@enumannotation.Returns the interfaces extended by an interfaceintGets the number of extended interfaces specifiedReturns the file overview or null if none specified.intGets the number of interfaces specified by the@implementsannotation.Returns the types specified by the@implementsannotation.Gets the name we're lending to in a@lendsannotation.Gets the description specified by the@licenseannotation.booleanReturns 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@meaningannotation.Returns the set of sideeffect notations.getMods()Returns the modded namespace or null if none is specified.intReturns the original JSDoc comment string.intGets the number of parameters defined.@Nullable StringgetParameterNameAt(int index) Returns the nth name in the defined parameters.Returns the set of names of the defined parameters.@Nullable JSTypeExpressiongetParameterType(String parameter) Gets the type of a given named parameter.protected ObjectgetPropertyValueByIndex(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@returnannotation.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@thisannotation.Returns the list of thrown types and descriptions as text.com.google.common.collect.ImmutableList<String> Gets the ts type declarations specified by the@tsTypeannotations.getType()Gets the type specified by the@typeannotation.Gets the typedef type specified by the@typeannotation.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,@protectedor@publicannotation.booleanReturns whether thisJSDocInfocontains a type for@extendsannotation.booleanWhether this JSDoc is annotated with@closurePrimitivebooleanReturns whether the@constannotation is present on thisJSDocInfo.booleanReturns whether a description exists for the parameter with the specified name.booleanReturns whether this has an enhanced namespace.booleanReturns whether an enum parameter type, specified using the@enumannotation, is present on this JSDoc.booleanReturns whether this has a fileoverview flag.booleanbooleanbooleanhasMods()Returns whether this has a modded namespace.booleanhasParameter(String parameter) Returns whether the parameter is defined.booleanhasParameterType(String parameter) Returns whether the parameter has an attached type.booleanReturns whether thisJSDocInfocontains a type for@returnannotation.booleanReturns whether the @modifies annotation includes "arguments" or any named parameters.booleanReturns whether thisJSDocInfocontains a type for@thisannotation.booleanhasType()Returns whether a type, specified using the@typeannotation, is present on this JSDoc.booleanReturns whether a typedef parameter type, specified using the@typedefannotation, is present on this JSDoc.booleanbooleanReturns whether the@abstractannotation is present on thisJSDocInfo.booleanReturns whether any@idGeneratororidGenerator {?}annotation is present.booleanReturns whether the@codeis present within thisJSDocInfo.booleanReturns whether JSDoc is annotated with the@closureUnawareCodeannotation.booleanReturns whether the@collapsibleOrBreakMyCodeannotation is present on thisJSDocInfo.booleanReturns whether the@idGenerator {consistent}is present on thisJSDocInfo.booleanReturns whether thisJSDocInfoimplies that annotated value is constant.booleanReturns whether the@constructorannotation is present on thisJSDocInfo.booleanbooleanReturns whether JSDoc is annotated with@customElementannotation.booleanisDefine()Returns whether the@defineannotation is present on thisJSDocInfo.booleanReturns whether the@deprecatedannotation is present on thisJSDocInfo.booleanisExport()Returns whether the@exportannotation is present on thisJSDocInfo.booleanReturns whether the@externsannotation is present on thisJSDocInfo.booleanisFinal()Returns whether the@finalannotation is present on thisJSDocInfo.booleanReturns whether the@idGeneratoris present on thisJSDocInfo.booleanReturns whether the@implicitCastannotation is present on thisJSDocInfo.booleanReturns whether the type annotation was inlined.booleanReturns whether the@interfaceannotation is present on thisJSDocInfo.booleanReturns whether the@idGenerator {mapped}is present on thisJSDocInfo.booleanReturns whether JSDoc is annotated with@mixinClassannotation.booleanReturns whether JSDoc is annotated with@mixinFunctionannotation.booleanReturns whether JSDoc is annotated with@ngInjectannotation.booleanReturns whether the@nocollapseannotation is present on thisJSDocInfo.booleanReturns whether the@nocompileannotation is present on thisJSDocInfo.booleanReturns whether the@nocoverageannotation is present on thisJSDocInfo.booleanisNoDts()Returns whether the@nodtsannotation is present on thisJSDocInfo.booleanReturns whether the@noinlineannotation is present on thisJSDocInfo.booleanReturns whether the@nosideeffectsannotation is present on thisJSDocInfo.booleanReturns whether the@overrideannotation is present on thisJSDocInfo.booleanReturns whether JSDoc is annotated with@polymerannotation.booleanReturns whether JSDoc is annotated with@polymerBehaviorannotation.booleanReturns whether the@provideAlreadyProvidedannotation is present on thisJSDocInfo.booleanReturns whether the@provideGoogannotation is present on thisJSDocInfo.booleanReturns whether the@pureOrBreakMyCodeannotation is present on thisJSDocInfo.booleanReturns whether the@requireInliningannotation is present on thisJSDocInfo.booleanbooleanReturns whether the@idGenerator {stable}is present on thisJSDocInfo.booleanReturns whether the@typeSummaryannotation is present on thisJSDocInfo.booleanReturns whether JSDoc is annotated with the@usedViaDotConstructorannotation.booleanReturns whether JSDoc is annotated with@wizactionannotation.booleanReturns if JSDoc is annotated with@wizcallbackannotation.booleanReturns whether the@idGenerator {xid}is present on thisJSDocInfo.booleanReturns whether the@dictannotation is present on thisJSDocInfo.booleanReturns whether the@structannotation is present on thisJSDocInfo.booleanReturns whether the@unrestrictedannotation is present on thisJSDocInfo.booleanGet the value of the @modifies{this} annotation stored in the doc info.toString()booleanReturns whether the@recordannotation 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@idGeneratororidGenerator {?}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@idGeneratoris present on thisJSDocInfo. -
isConstant
public boolean isConstant()Returns whether thisJSDocInfoimplies that annotated value is constant. -
hasConstAnnotation
public boolean hasConstAnnotation()Returns whether the@constannotation is present on thisJSDocInfo. -
isFinal
public boolean isFinal()Returns whether the@finalannotation is present on thisJSDocInfo. -
isConstructor
public boolean isConstructor()Returns whether the@constructorannotation is present on thisJSDocInfo. -
isAbstract
public boolean isAbstract()Returns whether the@abstractannotation is present on thisJSDocInfo. -
usesImplicitMatch
public boolean usesImplicitMatch()Returns whether the@recordannotation is present on thisJSDocInfo. -
makesUnrestricted
public boolean makesUnrestricted()Returns whether the@unrestrictedannotation is present on thisJSDocInfo. -
makesStructs
public boolean makesStructs()Returns whether the@structannotation is present on thisJSDocInfo. -
makesDicts
public boolean makesDicts()Returns whether the@dictannotation is present on thisJSDocInfo. -
isDefine
public boolean isDefine() -
isOverride
public boolean isOverride()Returns whether the@overrideannotation is present on thisJSDocInfo. -
isDeprecated
public boolean isDeprecated()Returns whether the@deprecatedannotation is present on thisJSDocInfo. -
isInterface
public boolean isInterface()Returns whether the@interfaceannotation is present on thisJSDocInfo. -
isConstructorOrInterface
public boolean isConstructorOrInterface() -
isExport
public boolean isExport()Returns whether the@exportannotation is present on thisJSDocInfo. -
isImplicitCast
public boolean isImplicitCast()Returns whether the@implicitCastannotation is present on thisJSDocInfo. -
isNoSideEffects
public boolean isNoSideEffects()Returns whether the@nosideeffectsannotation is present on thisJSDocInfo. -
isExterns
public boolean isExterns()Returns whether the@externsannotation is present on thisJSDocInfo. -
isNoCoverage
public boolean isNoCoverage()Returns whether the@nocoverageannotation is present on thisJSDocInfo. -
isTypeSummary
public boolean isTypeSummary()Returns whether the@typeSummaryannotation is present on thisJSDocInfo. -
isNoCompile
public boolean isNoCompile()Returns whether the@nocompileannotation is present on thisJSDocInfo. -
isNoDts
public boolean isNoDts()Returns whether the@nodtsannotation is present on thisJSDocInfo. -
isNoCollapse
public boolean isNoCollapse()Returns whether the@nocollapseannotation is present on thisJSDocInfo. -
isNoInline
public boolean isNoInline()Returns whether the@noinlineannotation is present on thisJSDocInfo. -
isRequireInlining
public boolean isRequireInlining()Returns whether the@requireInliningannotation is present on thisJSDocInfo. -
isCollapsibleOrBreakMyCode
public boolean isCollapsibleOrBreakMyCode()Returns whether the@collapsibleOrBreakMyCodeannotation is present on thisJSDocInfo. -
isPureOrBreakMyCode
public boolean isPureOrBreakMyCode()Returns whether the@pureOrBreakMyCodeannotation is present on thisJSDocInfo. -
isProvideGoog
public boolean isProvideGoog()Returns whether the@provideGoogannotation is present on thisJSDocInfo. -
isProvideAlreadyProvided
public boolean isProvideAlreadyProvided()Returns whether the@provideAlreadyProvidedannotation 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 = 0a 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@codeis present within thisJSDocInfo. -
getVisibility
Gets the visibility specified by@private,@protectedor@publicannotation. 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
nullif this parameter is not defined or has anulltype
-
hasParameter
Returns whether the parameter is defined. -
hasParameterType
Returns whether the parameter has an attached type.- Returns:
trueif the parameter has an attached type,falseif 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@enumannotation, is present on this JSDoc. -
hasTypedefType
public boolean hasTypedefType()Returns whether a typedef parameter type, specified using the@typedefannotation, is present on this JSDoc. -
hasReturnType
public boolean hasReturnType()Returns whether thisJSDocInfocontains a type for@returnannotation. -
hasType
public boolean hasType()Returns whether a type, specified using the@typeannotation, 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@returnannotation. -
getEnumParameterType
Gets the enum parameter type specified by the@enumannotation. -
getTypedefType
Gets the typedef type specified by the@typeannotation. -
getType
Gets the type specified by the@typeannotation. -
getThisType
Gets the type specified by the@thisannotation. -
hasThisType
public boolean hasThisType()Returns whether thisJSDocInfocontains a type for@thisannotation. -
getBaseType
Gets the base type specified by the@extendsannotation. -
getDescription
Gets the description specified by the@descannotation. -
getTsTypes
Gets the ts type declarations specified by the@tsTypeannotations. -
getMeaning
Gets the meaning specified by the@meaningannotation.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
@meaningannotation. -
getAlternateMessageId
Gets the alternate message ID specified by the@alternateMessageIdannotation.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@lendsannotation.In many reflection APIs, you pass an anonymous object to a function, and that function mixes the anonymous object into another object. The
@lendsannotation 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@ngInjectannotation. -
isWizaction
public boolean isWizaction()Returns whether JSDoc is annotated with@wizactionannotation. -
isWizcallback
public boolean isWizcallback()Returns if JSDoc is annotated with@wizcallbackannotation. -
isPolymerBehavior
public boolean isPolymerBehavior()Returns whether JSDoc is annotated with@polymerBehaviorannotation. -
isPolymer
public boolean isPolymer()Returns whether JSDoc is annotated with@polymerannotation. -
isCustomElement
public boolean isCustomElement()Returns whether JSDoc is annotated with@customElementannotation. -
isMixinClass
public boolean isMixinClass()Returns whether JSDoc is annotated with@mixinClassannotation. -
isMixinFunction
public boolean isMixinFunction()Returns whether JSDoc is annotated with@mixinFunctionannotation. -
isSassGeneratedCssTs
public boolean isSassGeneratedCssTs() -
isClosureUnawareCode
public boolean isClosureUnawareCode()Returns whether JSDoc is annotated with the@closureUnawareCodeannotation. -
isUsedViaDotConstructor
public boolean isUsedViaDotConstructor()Returns whether JSDoc is annotated with the@usedViaDotConstructorannotation. -
getLicense
Gets the description specified by the@licenseannotation. -
toString
-
toStringVerbose
-
hasBaseType
public boolean hasBaseType()Returns whether thisJSDocInfocontains a type for@extendsannotation. -
getImplementedInterfaces
Returns the types specified by the@implementsannotation.- 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@implementsannotation. -
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
-