Package dev.amp.validator
Class ExtensionsContext
- java.lang.Object
-
- dev.amp.validator.ExtensionsContext
-
public class ExtensionsContext extends Object
The extensions context keys track of the extensions that the validator has seen, as well as which have been used, which are required to be used, etc.- Author:
- nhant01, GeorgeLuo
-
-
Constructor Summary
Constructors Constructor Description ExtensionsContext()A constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisExtensionLoaded(String extension)Returns false if the named extension has not yet been loaded.List<dev.amp.validator.ValidatorProtos.ValidationError>missingExtensionErrors()Returns a list of errors accrued while processing the head for tags requiring an extension which was not found.voidrecordFutureErrorsIfMissing(ParsedTagSpec parsedTagSpec, Locator lineCol)Record a possible error to report once we have collected all extensions in the document.voidrecordUsedExtensions(List<String> extensions)Records extensions that are used within the document.List<String>unusedExtensionsRequired()Returns a list of unused extensions which produce validation errors when unused.voidupdateFromTagResult(ValidateTagResult result)Update ExtensionContext state when we encounter an amp extension or tag using an extension.
-
-
-
Method Detail
-
missingExtensionErrors
public List<dev.amp.validator.ValidatorProtos.ValidationError> missingExtensionErrors()
Returns a list of errors accrued while processing the head for tags requiring an extension which was not found.- Returns:
- returns a list of errors found while processing head
-
isExtensionLoaded
public boolean isExtensionLoaded(@Nonnull String extension)Returns false if the named extension has not yet been loaded. Note that this assumes that all extensions will be loaded in the document earlier than their first usage. This is true for amp-foo tags, since the extension must be loaded in the head and amp-foo tags are not supported in the head as per HTML spec.- Parameters:
extension- to check for.- Returns:
- returns true iff extension is loaded.
-
unusedExtensionsRequired
public List<String> unusedExtensionsRequired()
Returns a list of unused extensions which produce validation errors when unused.- Returns:
- returns a list of unused extensions.
-
updateFromTagResult
public void updateFromTagResult(@Nonnull ValidateTagResult result)Update ExtensionContext state when we encounter an amp extension or tag using an extension.- Parameters:
result- a ValidateTagResult.
-
recordUsedExtensions
public void recordUsedExtensions(@Nonnull List<String> extensions)Records extensions that are used within the document.- Parameters:
extensions- the list of extensions.
-
recordFutureErrorsIfMissing
public void recordFutureErrorsIfMissing(@Nonnull ParsedTagSpec parsedTagSpec, @Nonnull Locator lineCol)Record a possible error to report once we have collected all extensions in the document. If the given extension is missing, then report the given error.- Parameters:
parsedTagSpec- parsed tag spec.lineCol- a line/col.
-
-