semantics

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfidenceForEvidence

func ConfidenceForEvidence(base float64, evidence SemanticEvidence) (float64, bool)

ConfidenceForEvidence applies the shared policy for unresolved semantic data. Unresolved evidence is not actionable by default.

func DeclarationName

func DeclarationName(file *scanner.File, idx uint32) string

DeclarationName returns the declared identifier for common declaration nodes.

func IsMapLikeReceiver

func IsMapLikeReceiver(ctx *api.Context, expr uint32) bool

IsMapLikeReceiver reports whether expr resolves to a Kotlin or Java map.

func IsNullableExpression

func IsNullableExpression(ctx *api.Context, expr uint32) (bool, bool)

IsNullableExpression reports nullability when the resolver can prove it.

func IsResolvedCall

func IsResolvedCall(ctx *api.Context, call uint32, fqNames ...string) bool

IsResolvedCall reports whether a call has a resolved callable target that matches one of the supplied fully-qualified names.

func IsSupportedIsNullOrEmptyReceiver

func IsSupportedIsNullOrEmptyReceiver(ctx *api.Context, expr uint32) bool

IsSupportedIsNullOrEmptyReceiver reports whether expr is a string, collection, array, or map receiver supported by isNullOrEmpty.

func MatchQualifiedReceiver

func MatchQualifiedReceiver(ctx *api.Context, call uint32, allowed ...string) bool

MatchQualifiedReceiver reports whether the call receiver resolves to or structurally names one of allowed.

func OracleCallTarget

func OracleCallTarget(ctx *api.Context, idx uint32) string

OracleCallTarget resolves the compiler-backed call target for a FlatNode.

func OracleCallTargetAnnotations

func OracleCallTargetAnnotations(ctx *api.Context, idx uint32) []string

OracleCallTargetAnnotations returns annotations on the resolved call target.

func OracleCallTargetSuspend

func OracleCallTargetSuspend(ctx *api.Context, idx uint32) (bool, bool)

OracleCallTargetSuspend resolves suspend-call evidence for a FlatNode.

func OracleDiagnosticsForFlatRange

func OracleDiagnosticsForFlatRange(ctx *api.Context, idx uint32) []oracle.Diagnostic

OracleDiagnosticsForFlatRange returns compiler diagnostics inside a FlatNode.

func ReferenceName

func ReferenceName(file *scanner.File, idx uint32) string

ReferenceName returns the terminal identifier for a reference-like node.

func SameDeclaration

func SameDeclaration(ctx *api.Context, decl uint32, ref uint32) bool

SameDeclaration reports whether ref structurally points at decl. Resolved data is preferred when available, with same-file declaration matching as the conservative fallback.

func SameEnclosingOwner

func SameEnclosingOwner(file *scanner.File, a uint32, b uint32) bool

SameEnclosingOwner reports whether both nodes belong to the same enclosing class/object/interface owner. Top-level nodes share owner 0.

func SameFileDeclarationMatch

func SameFileDeclarationMatch(ctx *api.Context, decl uint32, ref uint32) bool

SameFileDeclarationMatch performs the explicit local fallback used when external resolution is unavailable.

Types

type CallTarget

type CallTarget struct {
	CalleeName    string
	QualifiedName string
	Receiver      NodeRef
	Arguments     []NodeRef
	Resolved      bool
}

CallTarget is the rule-facing view of a Kotlin call expression.

func ResolveCallTarget

func ResolveCallTarget(ctx *api.Context, call uint32) (CallTarget, bool)

ResolveCallTarget inspects a call expression structurally and, when the resolver wraps the Kotlin oracle, attaches the resolved callable target.

type ConstValue

type ConstValue struct {
	Kind     string
	Int64    int64
	Float64  float64
	String   string
	Bool     bool
	Resolved bool
}

ConstValue is a conservative constant value extracted from literal nodes or same-file constant declarations.

func EvalConst

func EvalConst(ctx *api.Context, expr uint32) (ConstValue, bool)

EvalConst evaluates simple literal constants and same-file constant refs.

func EvalSameFileConst

func EvalSameFileConst(ctx *api.Context, ref uint32) (ConstValue, bool)

EvalSameFileConst resolves a same-file val/const reference to a literal initializer when the declaration belongs to the same owner.

type ExceptionHandler

type ExceptionHandler struct {
	Node      uint32
	ParamName string
	TypeName  string
}

ExceptionHandler records an enclosing catch handler.

func EnclosingCaughtExceptionHandlers

func EnclosingCaughtExceptionHandlers(ctx *api.Context, call uint32) []ExceptionHandler

EnclosingCaughtExceptionHandlers returns enclosing catch handlers.

type NodeRef

type NodeRef struct {
	File *scanner.File
	Node uint32
}

NodeRef identifies a flat syntax node in a source file.

func (NodeRef) Valid

func (r NodeRef) Valid() bool

Valid reports whether the reference points at an existing flat node.

type PermissionGuard

type PermissionGuard struct {
	Node       uint32
	Permission ConstValue
	Positive   bool
}

PermissionGuard records an enclosing permission check.

func EnclosingPermissionGuards

func EnclosingPermissionGuards(ctx *api.Context, call uint32) []PermissionGuard

EnclosingPermissionGuards returns obvious enclosing permission guards.

type SemanticEvidence

type SemanticEvidence int

SemanticEvidence describes the strength of a rule's semantic proof.

const (
	EvidenceResolved SemanticEvidence = iota
	EvidenceQualifiedReceiver
	EvidenceSameOwner
	EvidenceSameFileDeclaration
	EvidenceUnresolved
)

type SymbolRef

type SymbolRef struct {
	Name          string
	Node          uint32
	Owner         uint32
	QualifiedName string
	Resolved      bool
}

SymbolRef is the rule-facing view of a reference-like node.

func ResolveReference

func ResolveReference(ctx *api.Context, ref uint32) (SymbolRef, bool)

ResolveReference returns the terminal identifier and the nearest enclosing owner for a reference-like node. It intentionally does not treat substrings in comments or string literals as references.

type TypeFact

type TypeFact struct {
	Expr     uint32
	TypeName string
	Positive bool
}

TypeFact records a local, structurally provable type relationship.

func DominatingTypeFacts

func DominatingTypeFacts(ctx *api.Context, node uint32) []TypeFact

DominatingTypeFacts returns simple type facts from enclosing if bodies.

type TypeInfo

type TypeInfo struct {
	Name     string
	FQN      string
	Kind     typeinfer.TypeKind
	Nullable bool
	Type     *typeinfer.ResolvedType
}

TypeInfo wraps resolver output in a stable shape for rule helpers.

func ExpressionType

func ExpressionType(ctx *api.Context, expr uint32) (TypeInfo, bool)

ExpressionType resolves the type of an expression through ctx.Resolver.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL