MetaCredo. SourceFile
(MetaCredo v0.1.0)
View Source
Wraps a Metastatic.Document with source text and filename for analysis.
Analogous to Credo.SourceFile, providing access to the AST, source lines,
and metadata needed by checks.
Summary
Functions
Returns the MetaAST for this source file.
Returns the language of this source file.
Returns the line at the given 1-based line number.
Returns lines as [{line_no, line_content}].
Parses source code into a SourceFile.
Returns the source code as a string.
Types
@type t() :: %MetaCredo.SourceFile{ document: Metastatic.Document.t(), filename: String.t(), language: atom(), lines: [{pos_integer(), String.t()}], source: String.t(), status: :valid | :invalid | :timed_out }
Functions
@spec ast(t()) :: Metastatic.AST.meta_ast()
Returns the MetaAST for this source file.
Returns the language of this source file.
@spec line_at(t(), pos_integer()) :: String.t() | nil
Returns the line at the given 1-based line number.
@spec lines(t()) :: [{pos_integer(), String.t()}]
Returns lines as [{line_no, line_content}].
Parses source code into a SourceFile.
Uses the appropriate Metastatic.Adapter for the given language to
produce a Metastatic.Document, then wraps it with source metadata.
Returns the source code as a string.