languageservice

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 10 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
}

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

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"
	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 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 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 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) Highlight

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

func (*Service) Update

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

type Symbol

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

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

Jump to

Keyboard shortcuts

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