languageservice

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package languageservice provides editor-independent analysis used by the REPL and future browser and language-server adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallInfo

type CallInfo struct {
	ParameterCount        int
	ExplicitTypeArguments bool
	TypeParameters        []string
	Parameters            []CallParameter
	Alternatives          []CallSignature
}

CallInfo records structured call syntax without making adapters parse the human-readable signature in Detail.

type CallParameter added in v0.2.0

type CallParameter struct {
	Name                 string
	Label                string
	Keyword              bool
	Definition           *DefinitionLocation
	LiteralValues        []string
	LiteralArrays        [][]string
	LiteralArrayElements []string
}

type CallSignature added in v0.2.0

type CallSignature struct {
	Parameters []CallParameter
}

type CompletionItem

type CompletionItem struct {
	Label       string
	InsertText  string
	Kind        CompletionKind
	Detail      string
	Replacement OffsetRange
}

CompletionItem separates the displayed label from the exact source text that replaces Replacement.

func Complete

func Complete(request CompletionRequest) []CompletionItem

type CompletionKind

type CompletionKind string
const (
	CompletionKeyword    CompletionKind = "keyword"
	CompletionVariable   CompletionKind = "variable"
	CompletionParameter  CompletionKind = "parameter"
	CompletionConstant   CompletionKind = "constant"
	CompletionFunction   CompletionKind = "function"
	CompletionMethod     CompletionKind = "method"
	CompletionField      CompletionKind = "field"
	CompletionType       CompletionKind = "type"
	CompletionEnumMember CompletionKind = "enum_member"
	CompletionModule     CompletionKind = "module"
	CompletionValue      CompletionKind = "value"
	CompletionCommand    CompletionKind = "command"
)

type CompletionRequest

type CompletionRequest struct {
	Source  string
	Cursor  int
	Mode    string
	Context Context
}

type Context

type Context struct {
	Symbols     []Symbol
	TypeMembers map[string][]Symbol
}

Context is the checked project information available at a cursor position. REPL contexts are rebuilt from typed IR after every accepted submission.

func BuildContext

func BuildContext(programs []*ir.Program, modulePath string) Context

BuildContext indexes only declarations visible from modulePath. Other project modules contribute names through explicit imports.

type DefinitionInfo added in v0.2.5

type DefinitionInfo struct {
	ID    SymbolID
	Name  string
	Path  string
	Range OffsetRange
}

func Definition added in v0.2.5

func Definition(request SemanticRequest) (DefinitionInfo, bool)

Definition resolves project declarations, imported declarations, receiver members, and common lexical bindings to their TypeRB source location.

type DefinitionLocation added in v0.2.5

type DefinitionLocation struct {
	ID    SymbolID
	Name  string
	Path  string
	Range OffsetRange
}

type HighlightKind

type HighlightKind string
const (
	HighlightKeyword  HighlightKind = "keyword"
	HighlightType     HighlightKind = "type"
	HighlightConstant HighlightKind = "constant"
	HighlightString   HighlightKind = "string"
	HighlightNumber   HighlightKind = "number"
	HighlightBoolean  HighlightKind = "boolean"
	HighlightComment  HighlightKind = "comment"
	HighlightFunction HighlightKind = "function"
	HighlightMethod   HighlightKind = "method"
	HighlightInvalid  HighlightKind = "invalid"
)

type HighlightRequest

type HighlightRequest struct {
	Source  string
	Mode    string
	Context Context
}

type HighlightSpan

type HighlightSpan struct {
	Range OffsetRange
	Kind  HighlightKind
}

func Highlight

func Highlight(request HighlightRequest) []HighlightSpan

Highlight classifies source without adding terminal or browser formatting. Lexical diagnostics override ordinary token classifications.

type HoverInfo added in v0.2.5

type HoverInfo struct {
	Range  OffsetRange
	Detail string
}

func Hover added in v0.2.5

func Hover(request SemanticRequest) (HoverInfo, bool)

Hover resolves the checked symbol at a source position without exposing any editor-protocol representation to the compiler service.

type OffsetRange

type OffsetRange struct {
	Start int
	End   int
}

OffsetRange is a half-open UTF-8 byte range. Protocol adapters may convert it to their own position representation without changing completion logic.

type ReferenceInfo added in v0.2.5

type ReferenceInfo struct {
	ID          SymbolID
	Path        string
	Range       OffsetRange
	Declaration bool
}

func References added in v0.2.5

func References(request SemanticRequest, documents []SemanticDocument, includeDeclaration bool) ([]ReferenceInfo, bool)

References resolves only occurrences that bind to the same checked source declaration. Textually equal names owned by another type or lexical binding are intentionally excluded.

type SemanticDocument added in v0.2.5

type SemanticDocument struct {
	Path    string
	Source  string
	Mode    string
	Context Context
}

SemanticDocument supplies one checked project file to project-wide semantic queries without exposing compiler snapshots or editor protocol types.

type SemanticRequest added in v0.2.5

type SemanticRequest struct {
	Path    string
	Source  string
	Cursor  int
	Mode    string
	Context Context
}

SemanticRequest identifies a source position using the same checked context as completion while keeping editor protocol details outside this package.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service owns a checked project snapshot while keeping terminal and browser presentation concerns outside the language analysis layer.

func New

func New(mode string) *Service

func (*Service) Complete

func (s *Service) Complete(source string, cursor int) []CompletionItem

func (*Service) Definition added in v0.2.5

func (s *Service) Definition(path, source string, cursor int) (DefinitionInfo, bool)

func (*Service) Highlight

func (s *Service) Highlight(source string) []HighlightSpan

func (*Service) Hover added in v0.2.5

func (s *Service) Hover(source string, cursor int) (HoverInfo, bool)

func (*Service) SetCandidates added in v0.2.3

func (s *Service) SetCandidates(context Context)

SetCandidates adds declarations that tooling may offer before source has imported them. They participate in completion and highlighting only; the compiler remains responsible for activating the corresponding import.

func (*Service) Signatures added in v0.2.5

func (s *Service) Signatures(source string, cursor int) (SignatureHelp, bool)

func (*Service) Update

func (s *Service) Update(programs []*ir.Program, modulePath string)

type SignatureHelp added in v0.2.5

type SignatureHelp struct {
	Signatures      []SignatureInfo
	ActiveSignature int
	ActiveParameter int
}

func Signatures added in v0.2.5

func Signatures(request SemanticRequest) (SignatureHelp, bool)

Signatures resolves the innermost call and its active argument using the same structured call metadata that powers completion.

type SignatureInfo added in v0.2.5

type SignatureInfo struct {
	Label      string
	Parameters []SignatureParameter
}

type SignatureParameter added in v0.2.5

type SignatureParameter struct {
	Label string
}

type Symbol

type Symbol struct {
	Name       string
	Kind       CompletionKind
	Detail     string
	Type       types.Type
	Call       *CallInfo
	Members    []Symbol
	Definition *DefinitionLocation
}

Symbol is the UI-independent semantic shape consumed by completion.

type SymbolID added in v0.2.5

type SymbolID string

SymbolID is a project-stable identity derived from a source declaration. Protocol adapters use it indirectly through semantic queries; generated and built-in symbols intentionally have no identity or source location.

Jump to

Keyboard shortcuts

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