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 TypeMethodDescriptionbooleanaddLicense(String license) build()Builds aJSDocInfoobject based on the populated information and returns it.@Nullable JSDocInfobuild(boolean always) Builds aJSDocInfoobject based on the populated information and returns it.Builds aJSDocInfoobject based on the populated information and returns it.booleanChanges a base type, even if one has already been set on currentInfo.static JSDocInfo.Builderstatic JSDocInfo.BuildercopyFromWithNewType(JSDocInfo info, JSTypeExpression typeExpression) booleanhasParameter(String name) Returns whether a parameter of the given name has already been recorded.booleanReturns whether JSDoc is annotated with the@closureUnawareannotation.booleanbooleanReturns whether current JSDoc is annotated with@customElement.booleanReturns whether a deprecation reason has been recorded.booleanReturns whether this builder recorded a description.booleanbooleanbooleanReturns whether current JSDoc is annotated with@mixinClass.booleanReturns whether current JSDoc is annotated with@mixinFunction.booleanReturns whether this builder recorded a modded namespace.booleanReturns whether current JSDoc is annotated with@ngInject.booleanReturns whether the@noinlineannotation is present on thisJSDocInfo.booleanReturns whether current JSDoc is annotated with@polymerBehavior.booleanReturns whether current JSDoc is annotated with@polymer.booleanbooleanReturns whether the@requireInliningannotation is present on thisJSDocInfo.booleanReturns whether current JSDoc is annotated with@sassGeneratedCssTs.booleanbooleanbooleanReturns whether current JSDoc is annotated with@wizaction.booleanReturns if current JSDoc is annotated with@wizcallback.booleanReturns whether we should log the type of values passed to this function.voidmarkAnnotation(String annotation, int lineno, int charno) Adds a marker to the current JSDocInfo and populates the marker with the annotation information.voidAdds a name declaration to the current marker.voidAdds 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 JSDocInfo.BuildermaybeCopyFrom(@Nullable JSDocInfo info) static JSDocInfo.BuildermaybeCopyFromAndReplaceNames(JSDocInfo info, Set<String> moduleLocalNamesToReplace) Returns a JSDocInfo.Builder that contains a JSDoc in which all module local types (which may be inside@param,@typeor@returnsare replaced with unknown.static JSDocInfo.BuildermaybeCopyFromWithNewType(JSDocInfo info, JSTypeExpression typeExpression) Returns a JSDocInfo.Builder that contains a copy of the given JSDocInfo in which only the@typefield of the JSDocInfo is replaced with the given typeExpression.voidoverwriteVisibility(JSDocInfo.Visibility visibility) Configures the builder to parse documentation.booleanbooleanrecordAlternateMessageId(String alternateMessageId) Records an ID for an alternate message to be used if this message is not yet translated.booleanrecordAuthor(String author) Adds an author to the current information.booleanRecords a base type.booleanrecordBlockDescription(String description) Records a block-level description.booleanrecordClosurePrimitiveId(String closurePrimitiveId) Records an identifier for a Closure Primitive.booleanRecords that this JSDoc was annotated with the@closureUnawareannotation.booleanRecords that theJSDocInfobeing built should have itsJSDocInfo.isCollapsibleOrBreakMyCode()flag set totrue.booleanRecords that theJSDocInfobeing built should have itsJSDocInfo.isConsistentIdGenerator()flag set totrue.booleanbooleanbooleanRecords that this method is to be exposed as a customElement.booleanRecords the type of a define.booleanbooleanrecordDeprecationReason(String reason) Records the deprecation reason.booleanrecordDescription(String description) Records a description giving context for translation (i18n).booleanbooleanrecordEnhance(String namespace) Records enhanced namespace.booleanRecords a parameter type to an enum.booleanbooleanrecordExtendedInterface(JSTypeExpression interfaceType) Records an extended interface type.booleanbooleanrecordFileOverview(String description) Records a fileoverview description.booleanbooleanbooleanrecordImplementedInterface(JSTypeExpression interfaceType) Records an implemented interface.booleanbooleanRecords that theJSDocInfobeing built should have itsJSDocInfo.usesImplicitMatch()flag set totrue.voidbooleanbooleanrecordLends(JSTypeExpression name) Records that we're lending to another name.booleanrecordLicense(String license) booleanRecords that the types of values passed to this method should be logged in the compiler.booleanRecords that theJSDocInfobeing built should have itsJSDocInfo.isStableIdGenerator()flag set totrue.booleanrecordMeaning(String meaning) Records a meaning giving context for translation (i18n).booleanRecords that this method is to be exposed as a mixinClass.booleanRecords that this method is to be exposed as a mixinFunction.booleanrecordModifies(Set<String> modifies) Records the list of modifies warnings.booleanrecordMods(String namespace) Records modded namespace.booleanbooleanrecordNgInject(boolean ngInject) Records that we'd like to add$injectproperty inferred from parameters.booleanbooleanbooleanbooleanRecords that theJSDocInfobeing built should have itsflag set toinvalid reference
JSDocInfo#isNoDtsOutput()true.booleanbooleanRecords that theJSDocInfobeing built should have itsJSDocInfo.isNoSideEffects()flag set totrue.voidrecordOriginalCommentPosition(int position) Sets the position of original JSDoc comment.voidrecordOriginalCommentString(String sourceComment) Sets the original JSDoc comment string.booleanbooleanrecordParameter(String parameterName, JSTypeExpression type) Records a typed parameter.booleanrecordParameterDescription(String parameterName, String description) Records a parameter's description.booleanRecords that this method is to be exposed as a polymer element.booleanRecords that this method is to be exposed as a polymerBehavior.booleanbooleanbooleanRecords that theJSDocInfobeing built should have itsJSDocInfo.isPureOrBreakMyCode()flag set totrue.booleanrecordReference(String reference) Adds a reference ("@see") to the current information.booleanRecords that theJSDocInfobeing built should have itsJSDocInfo.isRequireInlining()flag set totrue.booleanrecordReturnDescription(String description) Records a return descriptionbooleanRecords a return type.voidRecords that this script was generated by Sass from a.css.ts file.booleanRecords that theJSDocInfobeing built should have itsJSDocInfo.isStableIdGenerator()flag set totrue.booleanvoidrecordSuppression(String suppression) voidrecordSuppressions(com.google.common.collect.ImmutableSet<String> suppressions, String description) voidrecordSuppressions(Set<String> suppressions) Records the list of suppressed warnings, possibly adding to the set of already configured warnings.booleanrecordTemplateTypeName(String name) Records a template type name.booleanrecordTemplateTypeName(String name, @Nullable JSTypeExpression bound) booleanRecords a type for@thisannotation.booleanrecordThrowsAnnotation(String annotation) Records a throw annotation description.voidrecordTsType(String tsType) Records a tsType giving context for .d.ts generationbooleanrecordType(JSTypeExpression type) Records a type.booleanRecords that theJSDocInfobeing built should be populated with atypedef'd type.booleanbooleanrecordTypeTransformation(String name, Node expr) Records a type transformation expression together with its template type name.booleanRecords that theJSDocInfobeing built should have itsJSDocInfo.makesUnrestricted()flag set totrue.booleanRecords that this JSDoc was annotated with the@usedViaDotConstructorannotation.booleanrecordVisibility(JSDocInfo.Visibility visibility) Records a visibility.booleanRecords that this method is to be exposed as a wizaction.booleanRecords that this method is to be exposed as a wizcallback.booleanbooleanRemoves the@closureUnawareannotation from this JSDoc, returning true the annotation was present before removal.booleanboolean
-
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@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 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,@typeor@returnsare 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@noinlineannotation is present on thisJSDocInfo. -
isRequireInlining
public boolean isRequireInlining()Returns whether the@requireInliningannotation is present on thisJSDocInfo. -
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
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
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
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:
trueif the description was recorded.
-
recordVisibility
Records a visibility.- Returns:
trueif the visibility was recorded andfalseif it was already defined
-
overwriteVisibility
-
recordParameter
Records a typed parameter.- Returns:
trueif the typed parameter was recorded andfalseif a parameter with the same name was already defined
-
recordParameterDescription
Records a parameter's description.- Returns:
trueif the parameter's description was recorded andfalseif a parameter with the same name was already defined
-
recordTemplateTypeName
Records a template type name.- Returns:
trueif the template type name was recorded andfalseif 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:
trueif 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 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.
-
recordIdGenerator
public boolean recordIdGenerator()- Returns:
trueif the idGenerator flag was recorded andfalseif 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:
trueif the type was recorded andfalseif it is invalid or was already defined
-
recordInlineType
public void recordInlineType() -
recordTypedef
Records that theJSDocInfobeing built should be populated with atypedef'd type. -
recordReturnType
Records a return type.- Returns:
trueif the return type was recorded andfalseif it is invalid or was already defined
-
recordReturnDescription
Records a return description- Returns:
trueif the return description was recorded andfalseif 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:
trueif the enum's parameter type was recorded andfalseif it was invalid or already defined
-
recordThisType
Records a type for@thisannotation.- Returns:
trueif the type was recorded andfalseif it is invalid or if it collided with@enumor@typeannotations
-
recordBaseType
Records a base type.- Returns:
trueif the base type was recorded andfalseif it was already defined
-
changeBaseType
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
Records a description giving context for translation (i18n).- Returns:
trueif the description was recorded andfalseif 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:
trueIf the meaning was successfully updated.
-
recordAlternateMessageId
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
Records an identifier for a Closure Primitive. function.- Returns:
trueIf the id was successfully updated.
-
recordFileOverview
Records a fileoverview description.- Returns:
trueif the description was recorded andfalseif the description was invalid or was already defined.
-
recordEnhance
Records enhanced namespace.- Returns:
trueIf the enhanced namespace was recorded.
-
isModsRecorded
public boolean isModsRecorded()Returns whether this builder recorded a modded namespace. -
recordMods
Records modded namespace.- Returns:
trueIf the modded namespace was recorded.
-
recordLicense
-
addLicense
-
recordNoCompile
public boolean recordNoCompile()- Returns:
trueif the no compile flag was recorded andfalseif it was already recorded
-
recordNoDts
public boolean recordNoDts()Records that theJSDocInfobeing built should have itsflag set toinvalid reference
JSDocInfo#isNoDtsOutput()true.- 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
-
recordRequireInlining
@CanIgnoreReturnValue public boolean recordRequireInlining()Records that theJSDocInfobeing built should have itsJSDocInfo.isRequireInlining()flag set totrue.- Returns:
trueif the requireInlining flag was recorded andfalseif it was already recorded
-
recordPureOrBreakMyCode
public boolean recordPureOrBreakMyCode()Records that theJSDocInfobeing built should have itsJSDocInfo.isPureOrBreakMyCode()flag set totrue.- Returns:
trueif the no pureOrBreakMyCode flag was recorded andfalseif it was already recorded
-
recordCollapsibleOrBreakMyCode
public boolean recordCollapsibleOrBreakMyCode()Records that theJSDocInfobeing built should have itsJSDocInfo.isCollapsibleOrBreakMyCode()flag set totrue.- Returns:
trueif the no collapsibleOrBreakMyCode 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
-
recordProvideGoog
public boolean recordProvideGoog() -
recordProvideAlreadyProvided
public boolean recordProvideAlreadyProvided() -
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() -
recordImplicitCast
public boolean recordImplicitCast() -
recordNoSideEffects
public boolean recordNoSideEffects()Records that theJSDocInfobeing 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$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. -
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@closureUnawareannotation. -
recordClosureUnawareCode
public boolean recordClosureUnawareCode()Records that this JSDoc was annotated with the@closureUnawareannotation. -
removeClosureUnawareCode
@CanIgnoreReturnValue public boolean removeClosureUnawareCode()Removes the@closureUnawareannotation from this JSDoc, returning true the annotation was present before removal. -
recordUsedViaDotConstructor
public boolean recordUsedViaDotConstructor()Records that this JSDoc was annotated with the@usedViaDotConstructorannotation.
-