## com.google.javascript.rhino
Class JSDocInfo

    java.lang.Object
      com.google.javascript.rhino.JSDocInfo

All Implemented Interfaces:
  Serializable

    public class JSDocInfo

extends Object
implements 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:
  Serialized Form

Nested Class Summary
`static class` | `JSDocInfo.Marker` Defines a class for containing the parsing information for this JSDocInfo.
`static class` | `JSDocInfo.NamePosition` A piece of information (found in a marker) which contains a position with a name node.
`static class` | `JSDocInfo.StringPosition` A piece of information (found in a marker) which contains a position with a string.
`static class` | `JSDocInfo.TypePosition` A piece of information (found in a marker) which contains a position with a type expression syntax tree.
`static class` | `JSDocInfo.Visibility` Visibility categories.

Constructor Summary
`JSDocInfo()`

Method Summary
`void` | `addSuppression(String suppression)` Add a suppressed warning.
`boolean` | `containsDeclaration()`
`Node` | `getAssociatedNode()`
`Collection<String>` | `getAuthors()` Returns the list of authors or null if none.
`JSTypeExpression` | `getBaseType()` Gets the base type specified by the `@extends` annotation.
`String` | `getBlockDescription()` Returns the block-level description or null if none specified.
`String` | `getDeprecationReason()` Returns the deprecation reason or null if none specified.
`String` | `getDescription()` Gets the description specified by the `@desc` annotation.
`String` | `getDescriptionForParameter(String name)` Returns the description for the parameter with the given name, if its exists.
`JSTypeExpression` | `getEnumParameterType()` Gets the enum parameter type specified by the `@enum` annotation.
`List<JSTypeExpression>` | `getExtendedInterfaces()` Returns the interfaces extended by an interface
`int` | `getExtendedInterfacesCount()` Gets the number of extended interfaces specified
`String` | `getFileOverview()` Returns the file overview or null if none specified.
`int` | `getImplementedInterfaceCount()` Gets the number of interfaces specified by the `@implements` annotation.
`List<JSTypeExpression>` | `getImplementedInterfaces()` Returns the types specified by the `@implements` annotation.
`String` | `getLendsName()` Gets the name we're lending to in a `@lends` annotation.
`String` | `getLicense()` Gets the description specified by the `@license` annotation.
`Collection<JSDocInfo.Marker>` | `getMarkers()` Gets the list of all markers for the documentation in this JSDoc.
`String` | `getMeaning()` Gets the meaning specified by the `@meaning` annotation.
`Set<String>` | `getModifies()` Returns the set of sideeffect notations.
`String` | `getOriginalCommentString()` Returns the original JSDoc comment string.
`int` | `getParameterCount()` Gets the number of parameters defined.
`Set<String>` | `getParameterNames()` Returns the set of names of the defined parameters.
`JSTypeExpression` | `getParameterType(String parameter)` Gets the parameter type.
`Collection<String>` | `getReferences()` Returns the list of references or null if none.
`String` | `getReturnDescription()` Returns the description of the returned object or null if none specified.
`JSTypeExpression` | `getReturnType()` Gets the return type specified by the `@return` annotation.
`String` | `getSourceName()` Gets the name of the source file that contains this JSDoc.
`Set<String>` | `getSuppressions()` Returns the set of suppressed warnings.
`String` | `getTemplateTypeName()` Gets the template type name.
`JSTypeExpression` | `getThisType()` Gets the type specified by the `@this` annotation.
`List<JSTypeExpression>` | `getThrownTypes()` Returns the list of thrown types.
`JSTypeExpression` | `getType()` Gets the type specified by the `@type` annotation.
`JSTypeExpression` | `getTypedefType()` Gets the typedef type specified by the `@type` annotation.
`Collection<Node>` | `getTypeNodes()` Returns a collection of all type nodes that are a part of this JSDocInfo.
`String` | `getVersion()` Returns the version or null if none.
`JSDocInfo.Visibility` | `getVisibility()` Gets the visibility specified by `@private`, `@protected` or `@public` annotation.
`boolean` | `hasBaseType()` Returns whether this `JSDocInfo` contains a type for `@extends` annotation.
`boolean` | `hasDescriptionForParameter(String name)` Returns whether a description exists for the parameter with the specified name.
`boolean` | `hasEnumParameterType()` Returns whether an enum parameter type, specified using the `@enum` annotation, is present on this JSDoc.
`boolean` | `hasFileOverview()` Returns whether this has a fileoverview flag.
`boolean` | `hasModifies()`
`boolean` | `hasParameter(String parameter)` Returns whether the parameter is defined.
`boolean` | `hasParameterType(String parameter)` Returns whether the parameter has an attached type.
`boolean` | `hasReturnType()` Returns whether this `JSDocInfo` contains a type for `@return` annotation.
`boolean` | `hasThisType()` Returns whether this `JSDocInfo` contains a type for `@this` annotation.
`boolean` | `hasType()` Returns whether a type, specified using the `@type` annotation, is present on this JSDoc.
`boolean` | `hasTypedefType()` Returns whether a typedef parameter type, specified using the `@typedef` annotation, is present on this JSDoc.
`boolean` | `isConsistentIdGenerator()`
`boolean` | `isConstant()` Returns whether the `@const` annotation is present on this `JSDocInfo`.
`boolean` | `isConstructor()` Returns whether the `@constructor` annotation is present on this `JSDocInfo`.
`boolean` | `isDefine()` Returns whether the `@define` annotation is present on this `JSDocInfo`.
`boolean` | `isDeprecated()` Returns whether the `@deprecated` annotation is present on this `JSDocInfo`.
`boolean` | `isExport()` Returns whether the `@export` annotation is present on this `JSDocInfo`.
`boolean` | `isExpose()` Returns whether the `@expose` annotation is present on this `JSDocInfo`.
`boolean` | `isExterns()` Returns whether the `@externs` annotation is present on this `JSDocInfo`.
`boolean` | `isHidden()` Returns whether the `@hidden` annotation is present on this `JSDocInfo`.
`boolean` | `isIdGenerator()`
`boolean` | `isImplicitCast()` Returns whether the `@implicitCast` annotation is present on this `JSDocInfo`.
`boolean` | `isInterface()` Returns whether the `@interface` annotation is present on this `JSDocInfo`.
`boolean` | `isJavaDispatch()` Returns whether the `@javadispath` annotation is present on this `JSDocInfo`.
`boolean` | `isNoAlias()` Returns whether the `@noalias` annotation is present on this `JSDocInfo`.
`boolean` | `isNoCompile()` Returns whether the `@nocompile` annotation is present on this `JSDocInfo`.
`boolean` | `isNoShadow()` Returns whether the `@noshadow` annotation is present on this `JSDocInfo`.
`boolean` | `isNoSideEffects()` Returns whether the `@nosideeffects` annotation is present on this `JSDocInfo`.
`boolean` | `isNoTypeCheck()` Returns whether the `@nocheck` annotation is present on this `JSDocInfo`.
`boolean` | `isOverride()` Returns whether the `@override` annotation is present on this `JSDocInfo`.
`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` | `shouldPreserveTry()` Returns whether the `@preserveTry` annotation is present on this `JSDocInfo`.
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### JSDocInfo

    public JSDocInfo()

Method Detail

### setDeprecated

    public void setDeprecated(boolean value)

### isConsistentIdGenerator

    public boolean isConsistentIdGenerator()

  Returns:
    whether the `@consistentIdGenerator` is present on this `JSDocInfo`

### isConstant

    public boolean isConstant()

  Returns whether the `@const` annotation is present on this `JSDocInfo`.

### isConstructor

    public boolean isConstructor()

  Returns whether the `@constructor` annotation is present on this `JSDocInfo`.

### isDefine

    public boolean isDefine()

  Returns whether the `@define` annotation is present on this `JSDocInfo`. If this annotation is present, then the `getType()` method will retrieve the define type.

### isHidden

    public boolean isHidden()

  Returns whether the `@hidden` annotation is present on this `JSDocInfo`.

### isNoTypeCheck

    public boolean isNoTypeCheck()

  Returns whether the `@nocheck` annotation is present on this `JSDocInfo`.

### shouldPreserveTry

    public boolean shouldPreserveTry()

  Returns whether the `@preserveTry` annotation is present on this `JSDocInfo`.

### isOverride

    public boolean isOverride()

  Returns whether the `@override` annotation is present on this `JSDocInfo`.

### isNoAlias

    public boolean isNoAlias()

  Returns whether the `@noalias` annotation is present on this `JSDocInfo`.

### isDeprecated

    public boolean isDeprecated()

  Returns whether the `@deprecated` annotation is present on this `JSDocInfo`.

### isInterface

    public boolean isInterface()

  Returns whether the `@interface` annotation is present on this `JSDocInfo`.

### isExport

    public boolean isExport()

  Returns whether the `@export` annotation is present on this `JSDocInfo`.

### isExpose

    public boolean isExpose()

  Returns whether the `@expose` annotation is present on this `JSDocInfo`.

### isNoShadow

    public boolean isNoShadow()

  Returns whether the `@noshadow` annotation is present on this `JSDocInfo`.

### isIdGenerator

    public boolean isIdGenerator()

  Returns:
    whether the `@idGenerator` is present on this `JSDocInfo`

### isImplicitCast

    public boolean isImplicitCast()

  Returns whether the `@implicitCast` annotation is present on this `JSDocInfo`.

### isNoSideEffects

    public boolean isNoSideEffects()

  Returns whether the `@nosideeffects` annotation is present on this `JSDocInfo`.

### isExterns

    public boolean isExterns()

  Returns whether the `@externs` annotation is present on this `JSDocInfo`.

### isJavaDispatch

    public boolean isJavaDispatch()

  Returns whether the `@javadispath` annotation is present on this `JSDocInfo`.

### isNoCompile

    public boolean isNoCompile()

  Returns whether the `@nocompile` annotation is present on this `JSDocInfo`.

### containsDeclaration

    public boolean containsDeclaration()

  Returns:
    Whether there is declaration present on this `JSDocInfo`.

### setVisibility

    public void setVisibility(JSDocInfo.Visibility visibility)

### addSuppression

    public void addSuppression(String suppression)

  Add a suppressed warning.

### getVisibility

    public JSDocInfo.Visibility getVisibility()

  Gets the visibility specified by `@private`, `@protected` or `@public` annotation. If no visibility is specified, visibility is inherited from the base class.

### getParameterType

    public JSTypeExpression getParameterType(String parameter)

  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 a `null` type

### hasParameter

    public boolean hasParameter(String parameter)

  Returns whether the parameter is defined.

### hasParameterType

    public boolean hasParameterType(String parameter)

  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

    public Set<String> 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

    public List<JSTypeExpression> 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 this `JSDocInfo` contains a type for `@return` annotation.

### getType

    public JSTypeExpression getType()

  Gets the type specified by the `@type` annotation.

### getReturnType

    public JSTypeExpression getReturnType()

  Gets the return type specified by the `@return` annotation.

### getEnumParameterType

    public JSTypeExpression getEnumParameterType()

  Gets the enum parameter type specified by the `@enum` annotation.

### getTypedefType

    public JSTypeExpression getTypedefType()

  Gets the typedef type specified by the `@type` annotation.

### getThisType

    public JSTypeExpression getThisType()

  Gets the type specified by the `@this` annotation.

### hasThisType

    public boolean hasThisType()

  Returns whether this `JSDocInfo` contains a type for `@this` annotation.

### getBaseType

    public JSTypeExpression getBaseType()

  Gets the base type specified by the `@extends` annotation.

### getDescription

    public String getDescription()

  Gets the description specified by the `@desc` annotation.

### getMeaning

    public String 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

    public String 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.

### getLicense

    public String getLicense()

  Gets the description specified by the `@license` annotation.

### setLicense

    public void setLicense(String license)

  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

    public String toString()

  Overrides:
    `toString` in class `Object`

### hasBaseType

    public boolean hasBaseType()

  Returns whether this `JSDocInfo` contains a type for `@extends` annotation.

### getImplementedInterfaces

    public List<JSTypeExpression> 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

    public List<JSTypeExpression> 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

    public String getDeprecationReason()

  Returns the deprecation reason or null if none specified.

### getSuppressions

    public Set<String> getSuppressions()

  Returns the set of suppressed warnings.

### getModifies

    public Set<String> getModifies()

  Returns the set of sideeffect notations.

### hasDescriptionForParameter

    public boolean hasDescriptionForParameter(String name)

  Returns whether a description exists for the parameter with the specified name.

### getDescriptionForParameter

    public String getDescriptionForParameter(String name)

  Returns the description for the parameter with the given name, if its exists.

### getAuthors

    public Collection<String> getAuthors()

  Returns the list of authors or null if none.

### getReferences

    public Collection<String> getReferences()

  Returns the list of references or null if none.

### getVersion

    public String getVersion()

  Returns the version or null if none.

### getReturnDescription

    public String getReturnDescription()

  Returns the description of the returned object or null if none specified.

### getBlockDescription

    public String getBlockDescription()

  Returns the block-level description or null if none specified.

### hasFileOverview

    public boolean hasFileOverview()

  Returns whether this has a fileoverview flag.

### getFileOverview

    public String getFileOverview()

  Returns the file overview or null if none specified.

### getAssociatedNode

    public Node getAssociatedNode()

### setAssociatedNode

    public void setAssociatedNode(Node node)

  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

    public String getSourceName()

  Gets the name of the source file that contains this JSDoc.

### getMarkers

    public Collection<JSDocInfo.Marker> getMarkers()

  Gets the list of all markers for the documentation in this JSDoc.

### getTemplateTypeName

    public String getTemplateTypeName()

  Gets the template type name.

### getTypeNodes

    public Collection<Node> 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

    public String getOriginalCommentString()

  Returns the original JSDoc comment string. Returns null unless parseJsDocDocumentation is enabled via the ParserConfig.