Package com.google.javascript.rhino
Class JSDocInfoBuilder
- java.lang.Object
-
- com.google.javascript.rhino.JSDocInfoBuilder
-
public final class JSDocInfoBuilder extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddAuthor(java.lang.String author)Adds an author to the current information.booleanaddLicense(java.lang.String license)booleanaddReference(java.lang.String reference)Adds a reference ("@see") to the current information.voidaddSuppression(java.lang.String suppression)JSDocInfobuild()Builds aJSDocInfoobject based on the populated information and returns it.JSDocInfobuild(boolean always)Builds aJSDocInfoobject based on the populated information and returns it.JSDocInfobuildAndReset()Builds aJSDocInfoobject based on the populated information and returns it.booleanchangeBaseType(JSTypeExpression jsType)Changes a base type, even if one has already been set on currentInfo.static JSDocInfoBuildercopyFrom(JSDocInfo info)static JSDocInfoBuildercopyFromWithNewType(JSDocInfo info, JSTypeExpression typeExpression)booleanhasParameter(java.lang.String name)booleanisConstructorRecorded()booleanisCustomElementRecorded()Returns whether current JSDoc is annotated with@customElement.booleanisDeprecationReasonRecorded()Returns whether a deprecation reason has been recorded.booleanisDescriptionRecorded()Returns whether this builder recorded a description.booleanisDictRecorded()booleanisInterfaceRecorded()booleanisMixinClassRecorded()Returns whether current JSDoc is annotated with@mixinClass.booleanisMixinFunctionRecorded()Returns whether current JSDoc is annotated with@mixinFunction.booleanisNgInjectRecorded()Returns whether current JSDoc is annotated with@ngInject.booleanisPolymerBehaviorRecorded()Returns whether current JSDoc is annotated with@polymerBehavior.booleanisPolymerRecorded()Returns whether current JSDoc is annotated with@polymer.booleanisPopulated()booleanisPopulatedWithFileOverview()booleanisStructRecorded()booleanisUnrestrictedRecorded()booleanisWizactionRecorded()Returns whether current JSDoc is annotated with@wizaction.voidmarkAnnotation(java.lang.String annotation, int lineno, int charno)Adds a marker to the current JSDocInfo and populates the marker with the annotation information.voidmarkName(java.lang.String name, Node templateNode, int lineno, int charno)Adds a name declaration to the current marker.voidmarkText(java.lang.String text, int startLineno, int startCharno, int endLineno, int endCharno)Adds a textual block to the current marker.voidmarkTypeNode(Node typeNode, int lineno, int startCharno, int endLineno, int endCharno, boolean hasLC)Adds a type declaration to the current marker.static JSDocInfoBuildermaybeCopyFrom(JSDocInfo info)static JSDocInfoBuildermaybeCopyFromAndReplaceNames(JSDocInfo info, java.util.Set<java.lang.String> moduleLocalNamesToReplace)Returns a JSDocInfoBuilder that contains a JSDoc in which all module local types (which may be inside@param,@typeor@returnsare replaced with unknown.static JSDocInfoBuildermaybeCopyFromWithNewType(JSDocInfo info, JSTypeExpression typeExpression)Returns a JSDocInfoBuilder that contains a copy of the given JSDocInfo in which only the@typefield of the JSDocInfo is replaced with the given typeExpression.voidmergePropertyBitfieldFrom(JSDocInfo other)voidoverwriteVisibility(JSDocInfo.Visibility visibility)JSDocInfoBuilderparseDocumentation()Configures the builder to parse documentation.booleanrecordAbstract()booleanrecordAlternateMessageId(java.lang.String alternateMessageId)Records an ID for an alternate message to be used if this message is not yet translated.booleanrecordBaseType(JSTypeExpression jsType)Records a base type.booleanrecordBlockDescription(java.lang.String description)Records a block-level description.booleanrecordClosurePrimitiveId(java.lang.String closurePrimitiveId)Records an identifier for a Closure Primitive.booleanrecordConsistentIdGenerator()Records that theJSDocInfobeing built should have itsJSDocInfo.isConsistentIdGenerator()flag set totrue.booleanrecordConstancy()booleanrecordConstructor()booleanrecordCustomElement()Records that this method is to be exposed as a customElement.booleanrecordDefineType(JSTypeExpression type)Records the type of a define.booleanrecordDeprecated()booleanrecordDeprecationReason(java.lang.String reason)Records the deprecation reason.booleanrecordDescription(java.lang.String description)Records a description giving context for translation (i18n).booleanrecordDict()booleanrecordEnumParameterType(JSTypeExpression type)Records a parameter type to an enum.booleanrecordExport()booleanrecordExpose()booleanrecordExtendedInterface(JSTypeExpression interfaceType)Records an extended interface type.booleanrecordExterns()booleanrecordFileOverview(java.lang.String description)Records a fileoverview description.booleanrecordFinality()booleanrecordHiddenness()booleanrecordIdGenerator()booleanrecordImplementedInterface(JSTypeExpression interfaceName)Records an implemented interface.booleanrecordImplicitCast()booleanrecordImplicitMatch()Records that theJSDocInfobeing built should have itsJSDocInfo.usesImplicitMatch()flag set totrue.voidrecordInlineType()booleanrecordInterface()booleanrecordLends(JSTypeExpression name)Records that we're lending to another name.booleanrecordLicense(java.lang.String license)booleanrecordMappedIdGenerator()Records that theJSDocInfobeing built should have itsJSDocInfo.isStableIdGenerator()flag set totrue.booleanrecordMeaning(java.lang.String meaning)Records a meaning giving context for translation (i18n).booleanrecordMixinClass()Records that this method is to be exposed as a mixinClass.booleanrecordMixinFunction()Records that this method is to be exposed as a mixinFunction.booleanrecordModifies(java.util.Set<java.lang.String> modifies)Records the list of modifies warnings.booleanrecordMutable()booleanrecordNgInject(boolean ngInject)Records that we'd like to add$injectproperty inferred from parameters.booleanrecordNoCollapse()booleanrecordNoCompile()booleanrecordNoInline()booleanrecordNoSideEffects()Records that theJSDocInfobeing built should have itsJSDocInfo.isNoSideEffects()flag set totrue.voidrecordOriginalCommentPosition(int position)Sets the position of original JSDoc comment.voidrecordOriginalCommentString(java.lang.String sourceComment)Sets the original JSDoc comment string.booleanrecordOverride()booleanrecordParameter(java.lang.String parameterName, JSTypeExpression type)Records a typed parameter.booleanrecordParameterDescription(java.lang.String parameterName, java.lang.String description)Records a parameter's description.booleanrecordPolymer()Records that this method is to be exposed as a polymer element.booleanrecordPolymerBehavior()Records that this method is to be exposed as a polymerBehavior.booleanrecordReturnDescription(java.lang.String description)Records a return descriptionbooleanrecordReturnType(JSTypeExpression jsType)Records a return type.booleanrecordStableIdGenerator()Records that theJSDocInfobeing built should have itsJSDocInfo.isStableIdGenerator()flag set totrue.booleanrecordStruct()voidrecordSuppressions(java.util.Set<java.lang.String> suppressions)Records the list of suppressed warnings, possibly adding to the set of already configured warnings.booleanrecordTemplateTypeName(java.lang.String name)Records a template type name.booleanrecordTemplateTypeName(java.lang.String name, JSTypeExpression bound)booleanrecordThisType(JSTypeExpression type)Records a type for@thisannotation.booleanrecordThrowDescription(JSTypeExpression type, java.lang.String description)Records a throw type's description.booleanrecordThrowType(JSTypeExpression type)Records a thrown type.booleanrecordType(JSTypeExpression type)Records a type.booleanrecordTypedef(JSTypeExpression type)Records that theJSDocInfobeing built should be populated with atypedef'd type.booleanrecordTypeSummary()booleanrecordTypeTransformation(java.lang.String name, Node expr)Records a type transformation expression together with its template type name.booleanrecordUnrestricted()Records that theJSDocInfobeing built should have itsJSDocInfo.makesUnrestricted()flag set totrue.booleanrecordVersion(java.lang.String version)Records the version.booleanrecordVisibility(JSDocInfo.Visibility visibility)Records a visibility.booleanrecordWizaction()Records that this method is to be exposed as a wizaction.booleanrecordXidGenerator()booleanremoveExport()booleanshouldParseDocumentation()
-
-
-
Method Detail
-
copyFrom
public static JSDocInfoBuilder copyFrom(JSDocInfo info)
-
maybeCopyFrom
public static JSDocInfoBuilder maybeCopyFrom(@Nullable JSDocInfo info)
-
maybeCopyFromWithNewType
public static JSDocInfoBuilder maybeCopyFromWithNewType(JSDocInfo info, JSTypeExpression typeExpression)
Returns a JSDocInfoBuilder that contains a copy of the given JSDocInfo in which only the@typefield 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 JSDocInfoBuilder copyFromWithNewType(JSDocInfo info, JSTypeExpression typeExpression)
-
maybeCopyFromAndReplaceNames
public static JSDocInfoBuilder maybeCopyFromAndReplaceNames(JSDocInfo info, java.util.Set<java.lang.String> moduleLocalNamesToReplace)
Returns a JSDocInfoBuilder that contains a JSDoc in which all module local types (which may be inside@param,@typeor@returnsare replaced with unknown. This is done to prevent generating code in the client module which references local variables from another module.
-
parseDocumentation
public JSDocInfoBuilder 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.
-
recordOriginalCommentString
public void recordOriginalCommentString(java.lang.String sourceComment)
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.
-
shouldParseDocumentation
public boolean shouldParseDocumentation()
-
isPopulated
public boolean isPopulated()
-
isPopulatedWithFileOverview
public boolean isPopulatedWithFileOverview()
-
isDescriptionRecorded
public boolean isDescriptionRecorded()
Returns whether this builder recorded a description.
-
build
public JSDocInfo build()
Builds aJSDocInfoobject based on the populated information and returns it.- Returns:
- a
JSDocInfoobject populated with the values given to this builder. If no value was populated, this method simply returnsnull
-
build
public JSDocInfo build(boolean always)
Builds aJSDocInfoobject based on the populated information and returns it.- Parameters:
always- Return an default JSDoc object.- Returns:
- a
JSDocInfoobject populated with the values given to this builder. If no value was populated andalwaysis false, returnsnull. Ifalwaysis true, returns a default JSDocInfo.
-
buildAndReset
public JSDocInfo buildAndReset()
Builds aJSDocInfoobject based on the populated information and returns it. Once this method is called, the builder can be reused to build anotherJSDocInfoobject.- Returns:
- a
JSDocInfoobject populated with the values given to this builder. If no value was populated, this method simply returnsnull
-
markAnnotation
public void markAnnotation(java.lang.String annotation, int lineno, int charno)Adds a marker to the current JSDocInfo and populates the marker with the annotation information.
-
markText
public void markText(java.lang.String text, int startLineno, int startCharno, int endLineno, int endCharno)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
public void markName(java.lang.String name, Node templateNode, int lineno, int charno)Adds a name declaration to the current marker.
-
recordBlockDescription
public boolean recordBlockDescription(java.lang.String description)
Records a block-level description.- Returns:
trueif the description was recorded.
-
recordVisibility
public boolean recordVisibility(JSDocInfo.Visibility visibility)
Records a visibility.- Returns:
trueif the visibility was recorded andfalseif it was already defined
-
overwriteVisibility
public void overwriteVisibility(JSDocInfo.Visibility visibility)
-
recordParameter
public boolean recordParameter(java.lang.String parameterName, JSTypeExpression type)Records a typed parameter.- Returns:
trueif the typed parameter was recorded andfalseif a parameter with the same name was already defined
-
recordParameterDescription
public boolean recordParameterDescription(java.lang.String parameterName, java.lang.String description)Records a parameter's description.- Returns:
trueif the parameter's description was recorded andfalseif a parameter with the same name was already defined
-
recordTemplateTypeName
public boolean recordTemplateTypeName(java.lang.String name)
Records a template type name.- Returns:
trueif the template type name was recorded andfalseif the input template type name was already defined.
-
recordTemplateTypeName
public boolean recordTemplateTypeName(java.lang.String name, JSTypeExpression bound)
-
recordTypeTransformation
public boolean recordTypeTransformation(java.lang.String name, Node expr)Records a type transformation expression together with its template type name.
-
recordThrowType
public boolean recordThrowType(JSTypeExpression type)
Records a thrown type.
-
recordThrowDescription
public boolean recordThrowDescription(JSTypeExpression type, java.lang.String description)
Records a throw type's description.- Returns:
trueif the type's description was recorded andfalseif a description with the same type was already defined
-
addAuthor
public boolean addAuthor(java.lang.String author)
Adds an author to the current information.
-
addReference
public boolean addReference(java.lang.String reference)
Adds a reference ("@see") to the current information.
-
recordConsistentIdGenerator
public boolean recordConsistentIdGenerator()
Records that theJSDocInfobeing built should have itsJSDocInfo.isConsistentIdGenerator()flag set totrue.- Returns:
trueif the consistentIdGenerator flag was recorded andfalseif it was already recorded
-
recordStableIdGenerator
public boolean recordStableIdGenerator()
Records that theJSDocInfobeing built should have itsJSDocInfo.isStableIdGenerator()flag set totrue.- Returns:
trueif the stableIdGenerator flag was recorded andfalseif it was already recorded.
-
recordXidGenerator
public boolean recordXidGenerator()
- Returns:
trueif the isXidGenerator flag was recorded andfalseif it was already recorded.
-
recordMappedIdGenerator
public boolean recordMappedIdGenerator()
Records that theJSDocInfobeing built should have itsJSDocInfo.isStableIdGenerator()flag set totrue.- Returns:
trueif the stableIdGenerator flag was recorded andfalseif it was already recorded.
-
recordVersion
public boolean recordVersion(java.lang.String version)
Records the version.
-
recordDeprecationReason
public boolean recordDeprecationReason(java.lang.String reason)
Records the deprecation reason.
-
isDeprecationReasonRecorded
public boolean isDeprecationReasonRecorded()
Returns whether a deprecation reason has been recorded.
-
recordSuppressions
public void recordSuppressions(java.util.Set<java.lang.String> suppressions)
Records the list of suppressed warnings, possibly adding to the set of already configured warnings.
-
addSuppression
public void addSuppression(java.lang.String suppression)
-
recordModifies
public boolean recordModifies(java.util.Set<java.lang.String> modifies)
Records the list of modifies warnings.
-
recordType
public boolean recordType(JSTypeExpression type)
Records a type.- Returns:
trueif the type was recorded andfalseif it is invalid or was already defined
-
recordInlineType
public void recordInlineType()
-
recordTypedef
public boolean recordTypedef(JSTypeExpression type)
Records that theJSDocInfobeing built should be populated with atypedef'd type.
-
recordIdGenerator
public boolean recordIdGenerator()
- Returns:
trueif the idGenerator flag was recorded andfalseif it was already recorded
-
recordReturnType
public boolean recordReturnType(JSTypeExpression jsType)
Records a return type.- Returns:
trueif the return type was recorded andfalseif it is invalid or was already defined
-
recordReturnDescription
public boolean recordReturnDescription(java.lang.String description)
Records a return description- Returns:
trueif the return description was recorded andfalseif it is invalid or was already defined
-
recordDefineType
public boolean recordDefineType(JSTypeExpression type)
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
public boolean recordEnumParameterType(JSTypeExpression type)
Records a parameter type to an enum.- Returns:
trueif the enum's parameter type was recorded andfalseif it was invalid or already defined
-
recordThisType
public boolean recordThisType(JSTypeExpression type)
Records a type for@thisannotation.- Returns:
trueif the type was recorded andfalseif it is invalid or if it collided with@enumor@typeannotations
-
recordBaseType
public boolean recordBaseType(JSTypeExpression jsType)
Records a base type.- Returns:
trueif the base type was recorded andfalseif it was already defined
-
changeBaseType
public boolean changeBaseType(JSTypeExpression jsType)
Changes a base type, even if one has already been set on currentInfo.- Returns:
trueif the base type was changed successfully.
-
recordConstancy
public boolean recordConstancy()
- Returns:
trueif the constancy was recorded andfalseif it was already defined
-
recordMutable
public boolean recordMutable()
- Returns:
trueif the mutability was recorded andfalseif it was already defined
-
recordFinality
public boolean recordFinality()
- Returns:
trueif the finality was recorded andfalseif it was already defined
-
recordDescription
public boolean recordDescription(java.lang.String description)
Records a description giving context for translation (i18n).- Returns:
trueif the description was recorded andfalseif the description was invalid or was already defined
-
recordMeaning
public boolean recordMeaning(java.lang.String meaning)
Records a meaning giving context for translation (i18n). Different meanings will result in different translations.- Returns:
trueIf the meaning was successfully updated.
-
recordAlternateMessageId
public boolean recordAlternateMessageId(java.lang.String alternateMessageId)
Records an ID for an alternate message to be used if this message is not yet translated.- Returns:
trueIf the alternate message ID was successfully updated.
-
recordClosurePrimitiveId
public boolean recordClosurePrimitiveId(java.lang.String closurePrimitiveId)
Records an identifier for a Closure Primitive. function.- Returns:
trueIf the id was successfully updated.
-
recordFileOverview
public boolean recordFileOverview(java.lang.String description)
Records a fileoverview description.- Returns:
trueif the description was recorded andfalseif the description was invalid or was already defined.
-
recordLicense
public boolean recordLicense(java.lang.String license)
-
addLicense
public boolean addLicense(java.lang.String license)
-
recordHiddenness
public boolean recordHiddenness()
- Returns:
trueif the hiddenness was recorded andfalseif it was already defined
-
recordNoCompile
public boolean recordNoCompile()
- Returns:
trueif the no compile flag was recorded andfalseif it was already recorded
-
recordNoCollapse
public boolean recordNoCollapse()
- Returns:
trueif the no collapse flag was recorded andfalseif it was already recorded
-
recordNoInline
public boolean recordNoInline()
- Returns:
trueif the no inline flag was recorded andfalseif it was already recorded
-
recordConstructor
public boolean recordConstructor()
- Returns:
trueif the constructor was recorded andfalseif it was already defined or it was incompatible with the existing flags
-
recordImplicitMatch
public boolean recordImplicitMatch()
Records that theJSDocInfobeing built should have itsJSDocInfo.usesImplicitMatch()flag set totrue.- Returns:
trueif the@recordtag was recorded andfalseif it was already defined or it was incompatible with the existing flags
-
isConstructorRecorded
public boolean isConstructorRecorded()
-
recordUnrestricted
public boolean recordUnrestricted()
Records that theJSDocInfobeing built should have itsJSDocInfo.makesUnrestricted()flag set totrue.- Returns:
trueif annotation was recorded andfalseif it was already defined or it was incompatible with the existing flags
-
isUnrestrictedRecorded
public boolean isUnrestrictedRecorded()
-
recordAbstract
public boolean recordAbstract()
- Returns:
trueif the flag was recorded andfalseif it was already defined or it was incompatible with the existing flags
-
recordStruct
public boolean recordStruct()
- Returns:
trueif the struct was recorded andfalseif it was already defined or it was incompatible with the existing flags
-
isStructRecorded
public boolean isStructRecorded()
-
recordDict
public boolean recordDict()
- Returns:
trueif the dict was recorded andfalseif 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:
trueif the flag was recorded andfalseif it was already defined or it was incompatible with the existing flags
-
recordExport
public boolean recordExport()
-
removeExport
public boolean removeExport()
-
recordExpose
public boolean recordExpose()
-
recordImplicitCast
public boolean recordImplicitCast()
-
recordNoSideEffects
public boolean recordNoSideEffects()
Records that theJSDocInfobeing built should have itsJSDocInfo.isNoSideEffects()flag set totrue.
-
recordExterns
public boolean recordExterns()
-
recordTypeSummary
public boolean recordTypeSummary()
-
isInterfaceRecorded
public boolean isInterfaceRecorded()
-
hasParameter
public boolean hasParameter(java.lang.String name)
- Returns:
- Whether a parameter of the given name has already been recorded.
-
recordImplementedInterface
public boolean recordImplementedInterface(JSTypeExpression interfaceName)
Records an implemented interface.
-
recordExtendedInterface
public boolean recordExtendedInterface(JSTypeExpression interfaceType)
Records an extended interface type.
-
recordLends
public boolean recordLends(JSTypeExpression name)
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$injectproperty 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.
-
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.
-
mergePropertyBitfieldFrom
public void mergePropertyBitfieldFrom(JSDocInfo other)
-
-