Package com.google.javascript.rhino
Class JSDocInfo
java.lang.Object
com.google.javascript.rhino.JSDocInfo
- All Implemented Interfaces:
Serializable
JSDoc information describing JavaScript code. JSDoc is represented as a unified object with fields for each JSDoc annotation, even though some combinations are incorrect. For instance, if a JSDoc describes an enum, it cannot have information about a return type. This implementation takes advantage of such incompatibilities to reuse fields for multiple purposes, reducing memory consumption.
Constructing JSDocInfo
objects is simplified by
JSDocInfoBuilder
which provides early incompatibility detection.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic 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. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSuppression
(String suppression) Add a suppressed warning.boolean
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.com.google.common.collect.ImmutableList<String>
Returns the deprecation reason or null if none specified.Gets the description specified by the@desc
annotation.Returns the description for the parameter with the given name, if its exists.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.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.Returns the original JSDoc comment string.int
Gets the number of parameters defined.Returns the set of names of the defined parameters.getParameterType
(String parameter) Gets the parameter type.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.Gets the name of the source file that contains this JSDoc.Returns the set of suppressed warnings.com.google.common.collect.ImmutableList<String>
Gets the template type name.Gets the type specified by the@this
annotation.Returns the list of thrown types.getType()
Gets the type specified by the@type
annotation.Gets the typedef type specified by the@type
annotation.Returns a collection of all type nodes that are a part of this JSDocInfo.Returns the version or null if none.Gets the visibility specified by@private
,@protected
or@public
annotation.boolean
Returns whether thisJSDocInfo
contains a type for@extends
annotation.boolean
Returns whether a description exists for the parameter with the specified name.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
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 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@const
annotation is present on thisJSDocInfo
.boolean
Returns whether the@constructor
annotation is present on thisJSDocInfo
.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
isExpose()
Returns whether the@expose
annotation is present on thisJSDocInfo
.boolean
Returns whether the@externs
annotation is present on thisJSDocInfo
.boolean
isHidden()
Returns whether the@hidden
annotation is present on thisJSDocInfo
.boolean
boolean
Returns whether the@implicitCast
annotation is present on thisJSDocInfo
.boolean
Returns whether the@interface
annotation is present on thisJSDocInfo
.boolean
Returns whether the@javadispatch
annotation is present on thisJSDocInfo
.boolean
Returns whether JSDoc is annotated with@ngInject
annotation.boolean
Returns whether the@noalias
annotation is present on thisJSDocInfo
.boolean
Returns whether the@nocompile
annotation is present on thisJSDocInfo
.boolean
Returns whether the@noshadow
annotation is present on thisJSDocInfo
.boolean
Returns whether the@nosideeffects
annotation is present on thisJSDocInfo
.boolean
Returns whether the@nocheck
annotation is present on thisJSDocInfo
.boolean
Returns whether the@override
annotation is present on thisJSDocInfo
.boolean
boolean
Returns whether the@dict
annotation is present on thisJSDocInfo
.boolean
Returns whether the@struct
annotation is present on thisJSDocInfo
.void
setAssociatedNode
(Node node) Sets the node associated with this JSDoc.void
setDeprecated
(boolean value) void
setLicense
(String license) License directives can appear in multiple comments, and always apply to the entire file.void
setVisibility
(JSDocInfo.Visibility visibility) boolean
Returns whether the@preserveTry
annotation is present on thisJSDocInfo
.toString()
-
Constructor Details
-
JSDocInfo
public JSDocInfo()
-
-
Method Details
-
setDeprecated
public void setDeprecated(boolean value) -
isConsistentIdGenerator
public boolean isConsistentIdGenerator()- Returns:
- whether the
@consistentIdGenerator
is present on thisJSDocInfo
-
isStableIdGenerator
public boolean isStableIdGenerator()- Returns:
- whether the
@stableIdGenerator
is present on thisJSDocInfo
.
-
isConstant
public boolean isConstant()Returns whether the@const
annotation is present on thisJSDocInfo
. -
isConstructor
public boolean isConstructor()Returns whether the@constructor
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() -
isHidden
public boolean isHidden()Returns whether the@hidden
annotation is present on thisJSDocInfo
. -
isNoTypeCheck
public boolean isNoTypeCheck()Returns whether the@nocheck
annotation is present on thisJSDocInfo
. -
shouldPreserveTry
public boolean shouldPreserveTry()Returns whether the@preserveTry
annotation is present on thisJSDocInfo
. -
isOverride
public boolean isOverride()Returns whether the@override
annotation is present on thisJSDocInfo
. -
isNoAlias
public boolean isNoAlias()Returns whether the@noalias
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
. -
isExport
public boolean isExport()Returns whether the@export
annotation is present on thisJSDocInfo
. -
isExpose
public boolean isExpose()Returns whether the@expose
annotation is present on thisJSDocInfo
. -
isNoShadow
public boolean isNoShadow()Returns whether the@noshadow
annotation is present on thisJSDocInfo
. -
isIdGenerator
public boolean isIdGenerator()- Returns:
- whether the
@idGenerator
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
. -
isJavaDispatch
public boolean isJavaDispatch()Returns whether the@javadispatch
annotation is present on thisJSDocInfo
. -
isNoCompile
public boolean isNoCompile()Returns whether the@nocompile
annotation is present on thisJSDocInfo
. -
containsDeclaration
public boolean containsDeclaration()- Returns:
- Whether there is declaration present on this
JSDocInfo
.
-
setVisibility
-
addSuppression
Add a suppressed warning. -
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 parameter type.- 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 not the order in which parameters are defined.- Returns:
- the set of names of the defined parameters. The returned set is immutable.
-
getParameterCount
public int getParameterCount()Gets the number of parameters defined. -
getThrownTypes
Returns the list of thrown types. -
hasType
public boolean hasType()Returns whether a type, specified using the@type
annotation, is present on this JSDoc. -
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. -
getType
Gets the type specified by the@type
annotation. -
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. -
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. -
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. -
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. -
isNgInject
public boolean isNgInject()Returns whether JSDoc is annotated with@ngInject
annotation. -
getLicense
Gets the description specified by the@license
annotation. -
setLicense
License directives can appear in multiple comments, and always apply to the entire file. Break protection and allow outsiders to update the license string so that we can attach the license text even when the JSDocInfo has been created and tagged with other information.- Parameters:
license
- String containing new license text.
-
toString
-
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. -
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. -
getVersion
Returns the version 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. -
getAssociatedNode
-
setAssociatedNode
Sets the node associated with this JSDoc. Notice that many nodes may have pointer to the same JSDocInfo object (because we propagate it across the type graph). But there is only one canonical "owner" node of the JSDocInfo, which corresponds to its original place in the syntax tree. -
getSourceName
Gets the name of the source file that contains this JSDoc. -
getMarkers
Gets the list of all markers for the documentation in this JSDoc. -
getTemplateTypeNames
Gets the template type name. -
getClassTemplateTypeNames
-
getTypeNodes
Returns a collection of all type nodes that are a part of this JSDocInfo. This includes @type, @this, @extends, @implements, @param, @throws, and @return. Any future type specific JSDoc should make sure to add the appropriate nodes here.- 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.
-