Package com.google.javascript.rhino
Class JSDocInfo.Builder
java.lang.Object
com.google.javascript.rhino.JSDocInfo.Builder
- Enclosing class:
JSDocInfo
A builder for
JSDocInfo
objects. This builder is required because JSDocInfo instances
have immutable structure. It provides early incompatibility detection among properties stored
on the JSDocInfo
object being created.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addLicense
(String license) build()
Builds aJSDocInfo
object based on the populated information and returns it.@Nullable JSDocInfo
build
(boolean always) Builds aJSDocInfo
object based on the populated information and returns it.Builds aJSDocInfo
object based on the populated information and returns it.boolean
Changes a base type, even if one has already been set on currentInfo.static JSDocInfo.Builder
static JSDocInfo.Builder
copyFromWithNewType
(JSDocInfo info, JSTypeExpression typeExpression) boolean
hasParameter
(String name) Returns whether a parameter of the given name has already been recorded.boolean
Returns whether JSDoc is annotated with the@closureUnaware
annotation.boolean
boolean
Returns whether current JSDoc is annotated with@customElement
.boolean
Returns whether a deprecation reason has been recorded.boolean
Returns whether this builder recorded a description.boolean
boolean
boolean
Returns whether current JSDoc is annotated with@mixinClass
.boolean
Returns whether current JSDoc is annotated with@mixinFunction
.boolean
Returns whether this builder recorded a modded namespace.boolean
Returns whether current JSDoc is annotated with@ngInject
.boolean
Returns whether the@noinline
annotation is present on thisJSDocInfo
.boolean
Returns whether current JSDoc is annotated with@polymerBehavior
.boolean
Returns whether current JSDoc is annotated with@polymer
.boolean
boolean
Returns whether the@requireInlining
annotation is present on thisJSDocInfo
.boolean
Returns whether current JSDoc is annotated with@sassGeneratedCssTs
.boolean
boolean
boolean
Returns whether current JSDoc is annotated with@wizaction
.boolean
Returns if current JSDoc is annotated with@wizcallback
.boolean
Returns whether we should log the type of values passed to this function.void
markAnnotation
(String annotation, int lineno, int charno) Adds a marker to the current JSDocInfo and populates the marker with the annotation information.void
Adds a name declaration to the current marker.void
Adds a textual block to the current marker.void
markTypeNode
(Node typeNode, int lineno, int startCharno, int endLineno, int endCharno, boolean hasLC) Adds a type declaration to the current marker.static JSDocInfo.Builder
maybeCopyFrom
(@Nullable JSDocInfo info) static JSDocInfo.Builder
maybeCopyFromAndReplaceNames
(JSDocInfo info, Set<String> moduleLocalNamesToReplace) Returns a JSDocInfo.Builder that contains a JSDoc in which all module local types (which may be inside@param
,@type
or@returns
are replaced with unknown.static JSDocInfo.Builder
maybeCopyFromWithNewType
(JSDocInfo info, JSTypeExpression typeExpression) Returns a JSDocInfo.Builder that contains a copy of the given JSDocInfo in which only the@type
field of the JSDocInfo is replaced with the given typeExpression.void
overwriteVisibility
(JSDocInfo.Visibility visibility) Configures the builder to parse documentation.boolean
boolean
recordAlternateMessageId
(String alternateMessageId) Records an ID for an alternate message to be used if this message is not yet translated.boolean
recordAuthor
(String author) Adds an author to the current information.boolean
Records a base type.boolean
recordBlockDescription
(String description) Records a block-level description.boolean
recordClosurePrimitiveId
(String closurePrimitiveId) Records an identifier for a Closure Primitive.boolean
Records that this JSDoc was annotated with the@closureUnaware
annotation.boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.isCollapsibleOrBreakMyCode()
flag set totrue
.boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.isConsistentIdGenerator()
flag set totrue
.boolean
boolean
boolean
Records that this method is to be exposed as a customElement.boolean
Records the type of a define.boolean
boolean
recordDeprecationReason
(String reason) Records the deprecation reason.boolean
recordDescription
(String description) Records a description giving context for translation (i18n).boolean
boolean
recordEnhance
(String namespace) Records enhanced namespace.boolean
Records a parameter type to an enum.boolean
boolean
recordExtendedInterface
(JSTypeExpression interfaceType) Records an extended interface type.boolean
boolean
recordFileOverview
(String description) Records a fileoverview description.boolean
boolean
boolean
recordImplementedInterface
(JSTypeExpression interfaceType) Records an implemented interface.boolean
boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.usesImplicitMatch()
flag set totrue
.void
boolean
boolean
recordLends
(JSTypeExpression name) Records that we're lending to another name.boolean
recordLicense
(String license) boolean
Records that the types of values passed to this method should be logged in the compiler.boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.isStableIdGenerator()
flag set totrue
.boolean
recordMeaning
(String meaning) Records a meaning giving context for translation (i18n).boolean
Records that this method is to be exposed as a mixinClass.boolean
Records that this method is to be exposed as a mixinFunction.boolean
recordModifies
(Set<String> modifies) Records the list of modifies warnings.boolean
recordMods
(String namespace) Records modded namespace.boolean
boolean
recordNgInject
(boolean ngInject) Records that we'd like to add$inject
property inferred from parameters.boolean
boolean
boolean
boolean
Records that theJSDocInfo
being built should have itsinvalid reference
JSDocInfo#isNoDtsOutput()
true
.boolean
boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.isNoSideEffects()
flag set totrue
.void
recordOriginalCommentPosition
(int position) Sets the position of original JSDoc comment.void
recordOriginalCommentString
(String sourceComment) Sets the original JSDoc comment string.boolean
boolean
recordParameter
(String parameterName, JSTypeExpression type) Records a typed parameter.boolean
recordParameterDescription
(String parameterName, String description) Records a parameter's description.boolean
Records that this method is to be exposed as a polymer element.boolean
Records that this method is to be exposed as a polymerBehavior.boolean
boolean
boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.isPureOrBreakMyCode()
flag set totrue
.boolean
recordReference
(String reference) Adds a reference ("@see") to the current information.boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.isRequireInlining()
flag set totrue
.boolean
recordReturnDescription
(String description) Records a return descriptionboolean
Records a return type.void
Records that this script was generated by Sass from a.css.ts file.boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.isStableIdGenerator()
flag set totrue
.boolean
void
recordSuppression
(String suppression) void
recordSuppressions
(com.google.common.collect.ImmutableSet<String> suppressions, String description) void
recordSuppressions
(Set<String> suppressions) Records the list of suppressed warnings, possibly adding to the set of already configured warnings.boolean
recordTemplateTypeName
(String name) Records a template type name.boolean
recordTemplateTypeName
(String name, @Nullable JSTypeExpression bound) boolean
Records a type for@this
annotation.boolean
recordThrowsAnnotation
(String annotation) Records a throw annotation description.void
recordTsType
(String tsType) Records a tsType giving context for .d.ts generationboolean
recordType
(JSTypeExpression type) Records a type.boolean
Records that theJSDocInfo
being built should be populated with atypedef
'd type.boolean
boolean
recordTypeTransformation
(String name, Node expr) Records a type transformation expression together with its template type name.boolean
Records that theJSDocInfo
being built should have itsJSDocInfo.makesUnrestricted()
flag set totrue
.boolean
Records that this JSDoc was annotated with the@usedViaDotConstructor
annotation.boolean
recordVisibility
(JSDocInfo.Visibility visibility) Records a visibility.boolean
Records that this method is to be exposed as a wizaction.boolean
Records that this method is to be exposed as a wizcallback.boolean
boolean
Removes the@closureUnaware
annotation from this JSDoc, returning true the annotation was present before removal.boolean
boolean
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
copyFrom
-
maybeCopyFrom
-
maybeCopyFromWithNewType
public static JSDocInfo.Builder maybeCopyFromWithNewType(JSDocInfo info, JSTypeExpression typeExpression) Returns a JSDocInfo.Builder that contains a copy of the given JSDocInfo in which only the@type
field of the JSDocInfo is replaced with the given typeExpression. This is done to prevent generating code in the client module which references local variables from another module. -
copyFromWithNewType
public static JSDocInfo.Builder copyFromWithNewType(JSDocInfo info, JSTypeExpression typeExpression) -
maybeCopyFromAndReplaceNames
public static JSDocInfo.Builder maybeCopyFromAndReplaceNames(JSDocInfo info, Set<String> moduleLocalNamesToReplace) Returns a JSDocInfo.Builder that contains a JSDoc in which all module local types (which may be inside@param
,@type
or@returns
are replaced with unknown. This is done to prevent generating code in the client module which references local variables from another module. -
parseDocumentation
Configures the builder to parse documentation. This should be called immediately after instantiating the builder if documentation should be included, since it enables various operations to do work that would otherwise be no-ops. -
shouldParseDocumentation
public boolean shouldParseDocumentation() -
recordOriginalCommentString
Sets the original JSDoc comment string. This is a no-op if the builder isn't configured to record documentation. -
recordOriginalCommentPosition
public void recordOriginalCommentPosition(int position) Sets the position of original JSDoc comment. -
isPopulatedWithFileOverview
public boolean isPopulatedWithFileOverview() -
isDescriptionRecorded
public boolean isDescriptionRecorded()Returns whether this builder recorded a description. -
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
. -
build
Builds aJSDocInfo
object based on the populated information and returns it.- Returns:
- a
JSDocInfo
object populated with the values given to this builder. If no value was populated, this method simply returnsnull
-
build
Builds aJSDocInfo
object based on the populated information and returns it.- Parameters:
always
- Return an default JSDoc object.- Returns:
- a
JSDocInfo
object populated with the values given to this builder. If no value was populated andalways
is false, returnsnull
. Ifalways
is true, returns a default JSDocInfo.
-
buildAndReset
Builds aJSDocInfo
object based on the populated information and returns it. Once this method is called, the builder can be reused to build anotherJSDocInfo
object.- Returns:
- a
JSDocInfo
object populated with the values given to this builder. If no value was populated, this method simply returnsnull
-
markAnnotation
Adds a marker to the current JSDocInfo and populates the marker with the annotation information. -
markText
Adds a textual block to the current marker. -
markTypeNode
public void markTypeNode(Node typeNode, int lineno, int startCharno, int endLineno, int endCharno, boolean hasLC) Adds a type declaration to the current marker. -
markName
Adds a name declaration to the current marker. -
recordBlockDescription
Records a block-level description.- Returns:
true
if the description was recorded.
-
recordVisibility
Records a visibility.- Returns:
true
if the visibility was recorded andfalse
if it was already defined
-
overwriteVisibility
-
recordParameter
Records a typed parameter.- Returns:
true
if the typed parameter was recorded andfalse
if a parameter with the same name was already defined
-
recordParameterDescription
Records a parameter's description.- Returns:
true
if the parameter's description was recorded andfalse
if a parameter with the same name was already defined
-
recordTemplateTypeName
Records a template type name.- Returns:
true
if the template type name was recorded andfalse
if the input template type name was already defined.
-
recordTemplateTypeName
-
recordTypeTransformation
Records a type transformation expression together with its template type name. -
recordThrowsAnnotation
Records a throw annotation description.- Returns:
true
if the type's description was recorded. The description of a throw annotation is the text including the type.
-
recordAuthor
Adds an author to the current information. -
recordReference
Adds a reference ("@see") to the current information. -
recordConsistentIdGenerator
public boolean recordConsistentIdGenerator()Records that theJSDocInfo
being built should have itsJSDocInfo.isConsistentIdGenerator()
flag set totrue
.- Returns:
true
if the consistentIdGenerator flag was recorded andfalse
if it was already recorded
-
recordStableIdGenerator
public boolean recordStableIdGenerator()Records that theJSDocInfo
being built should have itsJSDocInfo.isStableIdGenerator()
flag set totrue
.- Returns:
true
if the stableIdGenerator flag was recorded andfalse
if it was already recorded.
-
recordXidGenerator
public boolean recordXidGenerator()- Returns:
true
if the isXidGenerator flag was recorded andfalse
if it was already recorded.
-
recordMappedIdGenerator
public boolean recordMappedIdGenerator()Records that theJSDocInfo
being built should have itsJSDocInfo.isStableIdGenerator()
flag set totrue
.- Returns:
true
if the stableIdGenerator flag was recorded andfalse
if it was already recorded.
-
recordIdGenerator
public boolean recordIdGenerator()- Returns:
true
if the idGenerator flag was recorded andfalse
if it was already recorded
-
recordDeprecationReason
Records the deprecation reason. -
isDeprecationReasonRecorded
public boolean isDeprecationReasonRecorded()Returns whether a deprecation reason has been recorded. -
recordSuppressions
-
recordSuppressions
Records the list of suppressed warnings, possibly adding to the set of already configured warnings. -
recordSuppression
-
recordModifies
Records the list of modifies warnings. -
recordType
Records a type.- Returns:
true
if the type was recorded andfalse
if it is invalid or was already defined
-
recordInlineType
public void recordInlineType() -
recordTypedef
Records that theJSDocInfo
being built should be populated with atypedef
'd type. -
recordReturnType
Records a return type.- Returns:
true
if the return type was recorded andfalse
if it is invalid or was already defined
-
recordReturnDescription
Records a return description- Returns:
true
if the return description was recorded andfalse
if it is invalid or was already defined
-
recordDefineType
Records the type of a define.'Define' values are special constants that may be manipulated by the compiler. They are designed to mimic the #define command in the C preprocessor.
-
recordEnumParameterType
Records a parameter type to an enum.- Returns:
true
if the enum's parameter type was recorded andfalse
if it was invalid or already defined
-
recordThisType
Records a type for@this
annotation.- Returns:
true
if the type was recorded andfalse
if it is invalid or if it collided with@enum
or@type
annotations
-
recordBaseType
Records a base type.- Returns:
true
if the base type was recorded andfalse
if it was already defined
-
changeBaseType
Changes a base type, even if one has already been set on currentInfo.- Returns:
true
if the base type was changed successfully.
-
recordConstancy
public boolean recordConstancy()- Returns:
true
if the constancy was recorded andfalse
if it was already defined
-
recordMutable
public boolean recordMutable()- Returns:
true
if the mutability was recorded andfalse
if it was already defined
-
recordFinality
public boolean recordFinality()- Returns:
true
if the finality was recorded andfalse
if it was already defined
-
recordDescription
Records a description giving context for translation (i18n).- Returns:
true
if the description was recorded andfalse
if the description was invalid or was already defined
-
recordTsType
Records a tsType giving context for .d.ts generation -
recordMeaning
Records a meaning giving context for translation (i18n). Different meanings will result in different translations.- Returns:
true
If the meaning was successfully updated.
-
recordAlternateMessageId
Records an ID for an alternate message to be used if this message is not yet translated.- Returns:
true
If the alternate message ID was successfully updated.
-
recordClosurePrimitiveId
Records an identifier for a Closure Primitive. function.- Returns:
true
If the id was successfully updated.
-
recordFileOverview
Records a fileoverview description.- Returns:
true
if the description was recorded andfalse
if the description was invalid or was already defined.
-
recordEnhance
Records enhanced namespace.- Returns:
true
If the enhanced namespace was recorded.
-
isModsRecorded
public boolean isModsRecorded()Returns whether this builder recorded a modded namespace. -
recordMods
Records modded namespace.- Returns:
true
If the modded namespace was recorded.
-
recordLicense
-
addLicense
-
recordNoCompile
public boolean recordNoCompile()- Returns:
true
if the no compile flag was recorded andfalse
if it was already recorded
-
recordNoDts
public boolean recordNoDts()Records that theJSDocInfo
being built should have itsinvalid reference
JSDocInfo#isNoDtsOutput()
true
.- Returns:
true
if the no compile flag was recorded andfalse
if it was already recorded
-
recordNoCollapse
public boolean recordNoCollapse()- Returns:
true
if the no collapse flag was recorded andfalse
if it was already recorded
-
recordNoInline
public boolean recordNoInline()- Returns:
true
if the no inline flag was recorded andfalse
if it was already recorded
-
recordRequireInlining
@CanIgnoreReturnValue public boolean recordRequireInlining()Records that theJSDocInfo
being built should have itsJSDocInfo.isRequireInlining()
flag set totrue
.- Returns:
true
if the requireInlining flag was recorded andfalse
if it was already recorded
-
recordPureOrBreakMyCode
public boolean recordPureOrBreakMyCode()Records that theJSDocInfo
being built should have itsJSDocInfo.isPureOrBreakMyCode()
flag set totrue
.- Returns:
true
if the no pureOrBreakMyCode flag was recorded andfalse
if it was already recorded
-
recordCollapsibleOrBreakMyCode
public boolean recordCollapsibleOrBreakMyCode()Records that theJSDocInfo
being built should have itsJSDocInfo.isCollapsibleOrBreakMyCode()
flag set totrue
.- Returns:
true
if the no collapsibleOrBreakMyCode flag was recorded andfalse
if it was already recorded
-
recordConstructor
public boolean recordConstructor()- Returns:
true
if the constructor was recorded andfalse
if it was already defined or it was incompatible with the existing flags
-
recordImplicitMatch
public boolean recordImplicitMatch()Records that theJSDocInfo
being built should have itsJSDocInfo.usesImplicitMatch()
flag set totrue
.- Returns:
true
if the@record
tag was recorded andfalse
if it was already defined or it was incompatible with the existing flags
-
recordProvideGoog
public boolean recordProvideGoog() -
recordProvideAlreadyProvided
public boolean recordProvideAlreadyProvided() -
isConstructorRecorded
public boolean isConstructorRecorded() -
recordUnrestricted
public boolean recordUnrestricted()Records that theJSDocInfo
being built should have itsJSDocInfo.makesUnrestricted()
flag set totrue
.- Returns:
true
if annotation was recorded andfalse
if it was already defined or it was incompatible with the existing flags
-
isUnrestrictedRecorded
public boolean isUnrestrictedRecorded() -
recordAbstract
public boolean recordAbstract()- Returns:
true
if the flag was recorded andfalse
if it was already defined or it was incompatible with the existing flags
-
recordStruct
public boolean recordStruct()- Returns:
true
if the struct was recorded andfalse
if it was already defined or it was incompatible with the existing flags
-
isStructRecorded
public boolean isStructRecorded() -
recordDict
public boolean recordDict()- Returns:
true
if the dict was recorded andfalse
if it was already defined or it was incompatible with the existing flags
-
isDictRecorded
public boolean isDictRecorded() -
recordOverride
public boolean recordOverride() -
recordDeprecated
public boolean recordDeprecated() -
recordInterface
public boolean recordInterface()- Returns:
true
if the flag was recorded andfalse
if it was already defined or it was incompatible with the existing flags
-
recordExport
public boolean recordExport() -
removeExport
public boolean removeExport() -
recordImplicitCast
public boolean recordImplicitCast() -
recordNoSideEffects
public boolean recordNoSideEffects()Records that theJSDocInfo
being built should have itsJSDocInfo.isNoSideEffects()
flag set totrue
. -
recordExterns
public boolean recordExterns() -
recordNoCoverage
@CanIgnoreReturnValue public boolean recordNoCoverage() -
recordTypeSummary
public boolean recordTypeSummary() -
isInterfaceRecorded
public boolean isInterfaceRecorded() -
hasParameter
Returns whether a parameter of the given name has already been recorded. -
recordImplementedInterface
Records an implemented interface. -
recordExtendedInterface
Records an extended interface type. -
recordLends
Records that we're lending to another name. -
isNgInjectRecorded
public boolean isNgInjectRecorded()Returns whether current JSDoc is annotated with@ngInject
. -
recordNgInject
public boolean recordNgInject(boolean ngInject) Records that we'd like to add$inject
property inferred from parameters. -
isWizactionRecorded
public boolean isWizactionRecorded()Returns whether current JSDoc is annotated with@wizaction
. -
recordWizaction
public boolean recordWizaction()Records that this method is to be exposed as a wizaction. -
isWizcallbackRecorded
public boolean isWizcallbackRecorded()Returns if current JSDoc is annotated with@wizcallback
. -
recordWizcallback
public boolean recordWizcallback()Records that this method is to be exposed as a wizcallback. -
isPolymerBehaviorRecorded
public boolean isPolymerBehaviorRecorded()Returns whether current JSDoc is annotated with@polymerBehavior
. -
recordPolymerBehavior
public boolean recordPolymerBehavior()Records that this method is to be exposed as a polymerBehavior. -
isPolymerRecorded
public boolean isPolymerRecorded()Returns whether current JSDoc is annotated with@polymer
. -
recordPolymer
public boolean recordPolymer()Records that this method is to be exposed as a polymer element. -
isCustomElementRecorded
public boolean isCustomElementRecorded()Returns whether current JSDoc is annotated with@customElement
. -
recordCustomElement
public boolean recordCustomElement()Records that this method is to be exposed as a customElement. -
isMixinClassRecorded
public boolean isMixinClassRecorded()Returns whether current JSDoc is annotated with@mixinClass
. -
recordMixinClass
public boolean recordMixinClass()Records that this method is to be exposed as a mixinClass. -
isMixinFunctionRecorded
public boolean isMixinFunctionRecorded()Returns whether current JSDoc is annotated with@mixinFunction
. -
recordMixinFunction
public boolean recordMixinFunction()Records that this method is to be exposed as a mixinFunction. -
isSassGeneratedCssTsRecorded
public boolean isSassGeneratedCssTsRecorded()Returns whether current JSDoc is annotated with@sassGeneratedCssTs
. -
recordSassGeneratedCssTs
public void recordSassGeneratedCssTs()Records that this script was generated by Sass from a.css.ts file. -
logTypeInCompiler
public boolean logTypeInCompiler()Returns whether we should log the type of values passed to this function. -
recordLogTypeInCompiler
public boolean recordLogTypeInCompiler()Records that the types of values passed to this method should be logged in the compiler. -
isClosureUnawareCode
public boolean isClosureUnawareCode()Returns whether JSDoc is annotated with the@closureUnaware
annotation. -
recordClosureUnawareCode
public boolean recordClosureUnawareCode()Records that this JSDoc was annotated with the@closureUnaware
annotation. -
removeClosureUnawareCode
@CanIgnoreReturnValue public boolean removeClosureUnawareCode()Removes the@closureUnaware
annotation from this JSDoc, returning true the annotation was present before removal. -
recordUsedViaDotConstructor
public boolean recordUsedViaDotConstructor()Records that this JSDoc was annotated with the@usedViaDotConstructor
annotation.
-