Class CelSource

  • All Implemented Interfaces:
    Source

    @Immutable
    public abstract class CelSource
    extends java.lang.Object
    implements Source
    Represents the source content of an expression and related metadata.
    • Constructor Detail

      • CelSource

        public CelSource()
    • Method Detail

      • getContent

        public CelCodePointArray getContent()
        Description copied from interface: Source
        Gets the original textual content of this source, represented in an array of code points.
        Specified by:
        getContent in interface Source
      • getDescription

        public java.lang.String getDescription()
        Description copied from interface: Source
        Gets the description of this source that may optionally be set (example: location of the file containing the source).
        Specified by:
        getDescription in interface Source
      • getPositionsMap

        public com.google.common.collect.ImmutableMap<java.lang.Long,​java.lang.Integer> getPositionsMap()
        Description copied from interface: Source
        Gets the map of each parsed node ID (ex: expression ID, policy ID) to their source positions.
        Specified by:
        getPositionsMap in interface Source
      • getLineOffsets

        public com.google.common.collect.ImmutableList<java.lang.Integer> getLineOffsets()
        Get the code point offsets (NOT code unit offsets) for new line characters '\n' within the source expression text.

        NOTE: The indices point to the index just after the '\n' not the index of '\n' itself.

      • getMacroCalls

        public com.google.common.collect.ImmutableMap<java.lang.Long,​CelExpr> getMacroCalls()
      • getExtensions

        public com.google.common.collect.ImmutableSet<CelSource.Extension> getExtensions()
      • getLocationOffset

        public java.util.Optional<java.lang.Integer> getLocationOffset​(int line,
                                                                       int column)
        Get the code point offset within the source expression text that corresponds with the line and column.
        Parameters:
        line - the line number starting from 1
        column - the column number starting from 0
      • getOffsetLocation

        public java.util.Optional<CelSourceLocation> getOffsetLocation​(int offset)
        Get the line and column in the source expression text for the given code point offset.
      • getSnippet

        public java.util.Optional<java.lang.String> getSnippet​(int line)
        Description copied from interface: Source
        Get the text from the source text that corresponds to line. Snippets are split based on the newline ('\n').
        Specified by:
        getSnippet in interface Source
        Parameters:
        line - the line number starting from 1.