Documentation
¶
Index ¶
- func FindTestRegion(content []byte) (startLine, endLine int, ok bool)
- func IsTestFile(filePath string) bool
- func IsTestFileWithContent(filePath string, contentReader vcs.ContentReader) bool
- func ResolveRustProjectImports(absPath string, filePath string, suppliedFiles map[string]bool, ...) ([]string, error)
- func SplitDiff(oldContent, newContent []byte, diff vcs.FileDiff) (prod, test vcs.FileStats)
- type Module
- type PhantomDecision
- type ProjectImportResolver
- type RustImport
- type RustImportKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindTestRegion ¶ added in v0.22.0
FindTestRegion returns the inclusive 1-indexed line range covering test-only code in a Rust source file. A test region is any item carrying an attribute that gates it to test builds:
- `#[cfg(test)]`, `#[cfg(all(test, ...))]`, `#[cfg(any(test, ...))]` (and nested combinations), but NOT `#[cfg(not(test))]`
- `#[test]`, `#[tokio::test]`, `#[async_std::test]`, `#[rstest]`, `#[test_case]`
Doctests inside `///` comments are NOT counted. Returns ok=false when no such region exists.
Known limitation: the item-end finder uses naive brace counting and does not strip string literals or `// }` comments. Hand-crafted Rust that places a `}` inside a string in the test region can mis-balance the count.
func IsTestFile ¶
IsTestFile reports whether the given Rust path is a test file.
func IsTestFileWithContent ¶
func IsTestFileWithContent(filePath string, contentReader vcs.ContentReader) bool
IsTestFileWithContent reports whether the given Rust path is a test file, using file content when available to confirm.
Types ¶
type Module ¶
type Module struct{}
func (Module) Extensions ¶
func (Module) IsTestFile ¶
func (Module) IsTestFile(filePath string, contentReader vcs.ContentReader) bool
func (Module) Maturity ¶
func (Module) Maturity() moduleapi.MaturityLevel
func (Module) NewResolver ¶
type PhantomDecision ¶ added in v0.22.0
type PhantomDecision struct {
HasPhantom bool
ProdChanged bool
ProdStats vcs.FileStats
TestStats vcs.FileStats
}
PhantomDecision describes whether a Rust file should be rendered with a sibling "phantom" test node, and how additions/deletions split between the prod-side node and the phantom test node.
func DecidePhantomShow ¶ added in v0.22.0
func DecidePhantomShow(newContent []byte) PhantomDecision
DecidePhantomShow returns the phantom decision for `clarity show` (point-in- time) mode: the phantom is present iff newContent contains a test region.
func DecidePhantomWatch ¶ added in v0.22.0
func DecidePhantomWatch(oldContent, newContent []byte, diff vcs.FileDiff) PhantomDecision
DecidePhantomWatch returns the phantom decision for `clarity watch` (uncommitted) mode using the pre/post images and per-line diff. The phantom is present iff the test region has any additions or deletions.
type ProjectImportResolver ¶ added in v0.18.0
type ProjectImportResolver struct {
// contains filtered or unexported fields
}
func NewProjectImportResolver ¶ added in v0.18.0
func NewProjectImportResolver(suppliedFiles map[string]bool, contentReader vcs.ContentReader) *ProjectImportResolver
func (*ProjectImportResolver) ResolveProjectImports ¶ added in v0.18.0
func (r *ProjectImportResolver) ResolveProjectImports(absPath string, filePath string) ([]string, error)
type RustImport ¶
type RustImport struct {
Path string
Kind RustImportKind
}
RustImport represents a Rust import statement or module declaration.
func ParseRustImports ¶
func ParseRustImports(sourceCode []byte) ([]RustImport, error)
ParseRustImports parses Rust source code and extracts imports.
func RustImports ¶
func RustImports(filePath string) ([]RustImport, error)
RustImports parses a Rust file and returns its imports.
type RustImportKind ¶
type RustImportKind int
RustImportKind describes the type of Rust import-like declaration.
const ( RustImportUse RustImportKind = iota RustImportExternCrate RustImportModDecl )