Documentation
¶
Index ¶
- Constants
- func FindVersionCatalogPathForGradlePath(gradlePath string) (string, bool)
- func FindVersionCatalogPathsForGradlePath(gradlePath string) ([]string, bool)
- func ProjectProfileCacheDir(repoDir string) string
- func SaveProjectProfileCache(cacheDir string, paths []string, profile ProjectProfile) error
- type AndroidProfile
- type CatalogAliasKind
- type CatalogCompleteness
- type CatalogLibrary
- type CatalogPlugin
- type CatalogSource
- type CatalogSourceKind
- type Coordinate
- type DatabaseFacts
- type Dependency
- type Facts
- type JVMProfile
- type JavaKnownType
- type JavaSourceProfile
- type JavaTypeProfile
- func (p JavaTypeProfile) AnnotationImplies(annotation, implied string) bool
- func (p JavaTypeProfile) IsKnownFrameworkType(candidate string) bool
- func (p JavaTypeProfile) IsSubtypeCandidate(supertype, candidate string) bool
- func (p JavaTypeProfile) MethodReturn(owner, method string, arity int) string
- type KSPProfile
- type KotlinProfile
- type Presence
- type ProjectProfile
- func LoadProjectProfileCache(cacheDir string, paths []string) (ProjectProfile, bool)
- func ProfileFromBuildConfig(source string, cfg *android.BuildConfig) ProjectProfile
- func ProfileFromGradleContent(path, content string) ProjectProfile
- func ProfileFromGradleContentWithCatalog(path, content string, catalog VersionCatalog) ProjectProfile
- func ProfileFromGradlePaths(paths []string) ProjectProfile
- func (p ProjectProfile) HasAnyDependency(coords ...Coordinate) bool
- func (p ProjectProfile) HasDependency(group, name string) bool
- func (p ProjectProfile) HasDependencyGroup(group string) bool
- func (p ProjectProfile) MayUseAnyDependency(coords ...Coordinate) bool
- func (p *ProjectProfile) Merge(other ProjectProfile)
- func (p ProjectProfile) ProvesDependencyAbsent(coords ...Coordinate) bool
- type RoomFacts
- func (r RoomFacts) HasDaoAnnotation(name string) bool
- func (r RoomFacts) HasOperationAnnotation(name string) bool
- func (r RoomFacts) HasQueryAnnotation(name string) bool
- func (r RoomFacts) IsAsyncReturnType(header string) bool
- func (r RoomFacts) IsLoadAllMethod(name string) bool
- func (r RoomFacts) IsLoadOneTerminal(name string) bool
- type SQLDelightFacts
- type SQLiteFacts
- type UnresolvedCatalogAlias
- type VersionCatalog
- type VersionPolicy
- type VersionedPresence
Constants ¶
const ( LatestStableKotlinVersion = "2.2" LatestStableKSPVersion = "2.2" LatestStableAGPVersion = "8.13" LatestStableCompileSDK = "36" LatestStableTargetSDK = "36" LatestStableJavaVersion = "21" LatestStableKotlinJvmTarget = "21" )
const FingerprintVersion = 1
FingerprintVersion bumps the schema for Facts fingerprints. Bump this when adding fields whose absence would let stale cache entries silently apply.
Variables ¶
This section is empty.
Functions ¶
func ProjectProfileCacheDir ¶
ProjectProfileCacheDir returns the repository-local cache root for Gradle library model profiles.
func SaveProjectProfileCache ¶
func SaveProjectProfileCache(cacheDir string, paths []string, profile ProjectProfile) error
SaveProjectProfileCache persists the profile plus every discovered catalog input so warm runs can avoid repeating settings/build-logic discovery.
Types ¶
type AndroidProfile ¶
type AndroidProfile struct {
AGP VersionedPresence
CompileSDK VersionedPresence
TargetSDK VersionedPresence
MinSDK VersionedPresence
}
func (AndroidProfile) EffectiveAGPVersion ¶
func (a AndroidProfile) EffectiveAGPVersion() string
func (AndroidProfile) EffectiveCompileSDK ¶
func (a AndroidProfile) EffectiveCompileSDK() string
func (AndroidProfile) EffectiveMinSDK ¶
func (a AndroidProfile) EffectiveMinSDK() string
func (AndroidProfile) EffectiveTargetSDK ¶
func (a AndroidProfile) EffectiveTargetSDK() string
type CatalogAliasKind ¶
type CatalogAliasKind string
const ( CatalogAliasPlugin CatalogAliasKind = "plugin" CatalogAliasVersion CatalogAliasKind = "version" CatalogAliasLibrary CatalogAliasKind = "library" CatalogAliasBundle CatalogAliasKind = "bundle" )
type CatalogCompleteness ¶
type CatalogCompleteness int
const ( CatalogCompletenessNone CatalogCompleteness = iota CatalogCompletenessStandardTOML CatalogCompletenessMergedTOML CatalogCompletenessSettingsTOML CatalogCompletenessSettingsProgrammatic )
type CatalogLibrary ¶
type CatalogPlugin ¶
type CatalogSource ¶
type CatalogSource struct {
Path string
Kind CatalogSourceKind
}
func FindVersionCatalogSourcesForGradlePath ¶
func FindVersionCatalogSourcesForGradlePath(gradlePath string) ([]CatalogSource, bool)
type CatalogSourceKind ¶
type CatalogSourceKind string
const ( CatalogSourceStandardTOML CatalogSourceKind = "standard_toml" CatalogSourceMergedTOML CatalogSourceKind = "merged_toml" CatalogSourceSettingsTOML CatalogSourceKind = "settings_toml" CatalogSourceSettingsProgrammatic CatalogSourceKind = "settings_programmatic" )
type Coordinate ¶
type DatabaseFacts ¶
type DatabaseFacts struct {
SQLite SQLiteFacts
Room RoomFacts
SQLDelight SQLDelightFacts
}
func (DatabaseFacts) IsSQLiteBlockingMethod ¶
func (d DatabaseFacts) IsSQLiteBlockingMethod(name string) bool
type Dependency ¶
type Dependency struct {
Group string
Name string
Version string
Configuration string
Source string
}
Dependency is a normalized external library coordinate discovered from a target repository's build files.
type Facts ¶
type Facts struct {
Profile ProjectProfile
Database DatabaseFacts
Java JavaTypeProfile
}
Facts is the version/profile-aware semantic model consumed by rules.
func DefaultFacts ¶
func DefaultFacts() *Facts
DefaultFacts returns conservative built-in facts for contexts where Krit has no project profile. This preserves behavior for single-file editor/LSP use and unit tests while allowing repository scans to narrow facts from Gradle.
func EnsureFacts ¶
func FactsForProfile ¶
func FactsForProfile(profile ProjectProfile) *Facts
FactsForProfile builds library facts from a project profile.
func (*Facts) DatabaseFacts ¶
func (f *Facts) DatabaseFacts() DatabaseFacts
func (*Facts) Fingerprint ¶
Fingerprint returns a stable hex digest of the semantic content of f. Callers use this as part of cache keys for project-level analysis whose findings depend on library facts (Android phase, library-aware Kotlin rules). nil and zero-value Facts are distinguished from non-empty Facts by the version prefix.
type JVMProfile ¶
type JVMProfile struct {
ToolchainLanguageVersion VersionedPresence
SourceCompatibility VersionedPresence
TargetCompatibility VersionedPresence
KotlinJvmTarget VersionedPresence
}
func (JVMProfile) EffectiveTargetBytecode ¶
func (j JVMProfile) EffectiveTargetBytecode() string
type JavaKnownType ¶
type JavaSourceProfile ¶
type JavaSourceProfile struct {
SourceRoots []string
TestSourceRoots []string
AndroidTestSourceRoots []string
GeneratedSourceRoots []string
ClasspathCandidates []string
BootClasspathCandidates []string
ClasspathComplete bool
}
func JavaSourceProfileFromGradleContent ¶
func JavaSourceProfileFromGradleContent(path, content string, cfg *android.BuildConfig) JavaSourceProfile
func (JavaSourceProfile) JavacClasspathArg ¶
func (p JavaSourceProfile) JavacClasspathArg() string
func (JavaSourceProfile) JavacClasspathCandidates ¶
func (p JavaSourceProfile) JavacClasspathCandidates() []string
func (JavaSourceProfile) SourceRootsForScan ¶
func (p JavaSourceProfile) SourceRootsForScan(includeTests, includeAndroidTests, includeGenerated bool) []string
type JavaTypeProfile ¶
type JavaTypeProfile struct {
KnownTypes map[string]JavaKnownType
MethodReturns map[string]string
AnnotationAliases map[string]string
}
func DefaultJavaTypeProfile ¶
func DefaultJavaTypeProfile() JavaTypeProfile
func (JavaTypeProfile) AnnotationImplies ¶
func (p JavaTypeProfile) AnnotationImplies(annotation, implied string) bool
func (JavaTypeProfile) IsKnownFrameworkType ¶
func (p JavaTypeProfile) IsKnownFrameworkType(candidate string) bool
func (JavaTypeProfile) IsSubtypeCandidate ¶
func (p JavaTypeProfile) IsSubtypeCandidate(supertype, candidate string) bool
func (JavaTypeProfile) MethodReturn ¶
func (p JavaTypeProfile) MethodReturn(owner, method string, arity int) string
type KSPProfile ¶
type KSPProfile struct {
Tool VersionedPresence
Processors []Dependency
}
func (KSPProfile) EffectiveVersion ¶
func (k KSPProfile) EffectiveVersion() string
type KotlinProfile ¶
type KotlinProfile struct {
Compiler VersionedPresence
LanguageVersion VersionedPresence
APIVersion VersionedPresence
K2 Presence
}
func (KotlinProfile) EffectiveAPIVersion ¶
func (k KotlinProfile) EffectiveAPIVersion() string
func (KotlinProfile) EffectiveCompilerVersion ¶
func (k KotlinProfile) EffectiveCompilerVersion() string
func (KotlinProfile) EffectiveLanguageVersion ¶
func (k KotlinProfile) EffectiveLanguageVersion() string
type ProjectProfile ¶
type ProjectProfile struct {
MinSdkVersion int
TargetSdkVersion int
CompileSdkVersion int
Kotlin KotlinProfile
KSP KSPProfile
Android AndroidProfile
JVM JVMProfile
Java JavaSourceProfile
Dependencies []Dependency
CatalogSources []CatalogSource
CatalogCompleteness CatalogCompleteness
UnresolvedCatalogAliases []UnresolvedCatalogAlias
// HasGradle is true when at least one Gradle file was parsed.
HasGradle bool
// DependencyExtractionComplete is true only when parsed Gradle files use
// dependency forms this lightweight parser can treat as a complete-enough
// graph for absence decisions.
DependencyExtractionComplete bool
// HasUnresolvedDependencyRefs is true when a build file uses unresolved
// aliases, convention plugins, apply-from scripts, or other dependency
// forms this parser cannot resolve yet. In that case models stay
// conservative.
HasUnresolvedDependencyRefs bool
}
ProjectProfile contains project-wide library and platform facts. It is intentionally small: rules should consume derived Facts instead of parsing Gradle files or version catalogs themselves.
func LoadProjectProfileCache ¶
func LoadProjectProfileCache(cacheDir string, paths []string) (ProjectProfile, bool)
LoadProjectProfileCache loads a profile only when all known Gradle/catalog inputs still match. New standard catalog or settings files in ancestor dirs also change the fingerprint and force a miss.
func ProfileFromBuildConfig ¶
func ProfileFromBuildConfig(source string, cfg *android.BuildConfig) ProjectProfile
ProfileFromBuildConfig converts an android.BuildConfig into a library profile fragment.
func ProfileFromGradleContent ¶
func ProfileFromGradleContent(path, content string) ProjectProfile
ProfileFromGradleContent parses one Gradle file into a profile fragment.
func ProfileFromGradleContentWithCatalog ¶
func ProfileFromGradleContentWithCatalog(path, content string, catalog VersionCatalog) ProjectProfile
func ProfileFromGradlePaths ¶
func ProfileFromGradlePaths(paths []string) ProjectProfile
ProfileFromGradlePaths reads Gradle build files and returns a merged project profile. Unreadable or unparsable files are ignored so library models remain best-effort and never block analysis.
func (ProjectProfile) HasAnyDependency ¶
func (p ProjectProfile) HasAnyDependency(coords ...Coordinate) bool
func (ProjectProfile) HasDependency ¶
func (p ProjectProfile) HasDependency(group, name string) bool
func (ProjectProfile) HasDependencyGroup ¶
func (p ProjectProfile) HasDependencyGroup(group string) bool
func (ProjectProfile) MayUseAnyDependency ¶
func (p ProjectProfile) MayUseAnyDependency(coords ...Coordinate) bool
func (*ProjectProfile) Merge ¶
func (p *ProjectProfile) Merge(other ProjectProfile)
Merge adds another profile fragment into p.
func (ProjectProfile) ProvesDependencyAbsent ¶
func (p ProjectProfile) ProvesDependencyAbsent(coords ...Coordinate) bool
ProvesDependencyAbsent returns true only when the parsed dependency graph is complete enough to use absence as evidence. Unknown or partial profiles stay conservative.
type RoomFacts ¶
type RoomFacts struct {
Enabled bool
DaoAnnotations []string
OperationAnnotations []string
AsyncReturnTypeHints []string
LoadAllMethodNames []string
LoadOneTerminalNames []string
QueryAnnotationNames []string
}
func (RoomFacts) HasDaoAnnotation ¶
func (RoomFacts) HasOperationAnnotation ¶
func (RoomFacts) HasQueryAnnotation ¶
func (RoomFacts) IsAsyncReturnType ¶
func (RoomFacts) IsLoadAllMethod ¶
func (RoomFacts) IsLoadOneTerminal ¶
type SQLDelightFacts ¶
func (SQLDelightFacts) IsBlockingExecutionMethod ¶
func (s SQLDelightFacts) IsBlockingExecutionMethod(name string) bool
type SQLiteFacts ¶
type SQLiteFacts struct {
BlockingMethods []string
}
type UnresolvedCatalogAlias ¶
type UnresolvedCatalogAlias struct {
Kind CatalogAliasKind
Alias string
Source string
}
type VersionCatalog ¶
type VersionCatalog struct {
Versions map[string]string
Plugins map[string]CatalogPlugin
Libraries map[string]CatalogLibrary
Bundles map[string][]string
Sources []CatalogSource
Completeness CatalogCompleteness
}
VersionCatalog is a best-effort Gradle version-catalog model. It is not a general TOML or Gradle evaluator; it intentionally supports the catalog forms needed by the library model and records source/completeness metadata so callers can stay conservative when discovery is partial.
func LoadVersionCatalogForGradlePath ¶
func LoadVersionCatalogForGradlePath(gradlePath string) (VersionCatalog, bool)
func ParseSettingsVersionCatalogContent ¶
func ParseSettingsVersionCatalogContent(content string) VersionCatalog
func ParseVersionCatalogContent ¶
func ParseVersionCatalogContent(content string) VersionCatalog
func (VersionCatalog) Empty ¶
func (c VersionCatalog) Empty() bool
func (*VersionCatalog) Merge ¶
func (c *VersionCatalog) Merge(other VersionCatalog)
func (VersionCatalog) PluginByIDOrAlias ¶
func (c VersionCatalog) PluginByIDOrAlias(idOrAlias string) (CatalogPlugin, bool)
type VersionPolicy ¶
type VersionPolicy int
const ( VersionUnknown VersionPolicy = iota VersionKnown VersionAssumeLatestStable )
type VersionedPresence ¶
type VersionedPresence struct {
Presence Presence
Version string
VersionPolicy VersionPolicy
}
func KnownVersion ¶
func KnownVersion(version string) VersionedPresence
func PresentAssumeLatestStable ¶
func PresentAssumeLatestStable() VersionedPresence
func (VersionedPresence) EffectiveVersion ¶
func (v VersionedPresence) EffectiveVersion(latestStable string) string