Class 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 Detail

      • ExtensionsContext

        public ExtensionsContext()
        A constructor.
    • 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.