KetraTerm
API · DevelopmentAll versions

resolve

fun resolve(request: TerminalCompletionRequest, commandSpecs: List<TerminalCommandSpec> = TerminalCommandSpecs.defaults()): TerminalCompletionContext

Parses and resolves one request using the same operation as the stock engine. Custom engines can resolve once, then share this context with stock or custom sources and candidate projectors using the same request.

Uses the request's captured shell syntax and the supplied command catalog. Empty, unknown, and incomplete command lines produce a valid partial context; no shell is executed and no host I/O, scheduling, ranking, or caching occurs. At an operator position, activePosition is TerminalCompletionActivePosition.OPERATOR; callers should skip source evaluation there, as the stock engine does.

The context and its owned collections may be retained across suspension and overlapping requests. Specifications are referenced rather than deep-copied: do not mutate the catalog or its nested collections during resolution, and keep referenced specs unchanged while a returned context is in use. Supplying a new catalog for later requests does not invalidate earlier contexts. Concurrent resolutions are safe with an unchanged catalog. Candidate limits and source lifecycle remain the custom engine's responsibility.

Return

request-owned context with consistent derived fields and replacement offsets.

Parameters

request

validated command line, cursor, and captured shell capabilities.

commandSpecs

the same catalog used by the caller's spec-aware sources; defaults to the bundled command specifications. An empty catalog resolves lexical context without inferred command, option, or positional metadata.