feat(server): index PSC scripts and provide cross-file TclOO navigation/completions
Add PSC (.psc) indexing and share TclOO class metadata across files so class definitions discovered via PSC layers can be used for completions, signature help, inlay hints, and "go to definition". Key behavior changes: - Client file watcher now includes *.psc and .vscode launch paths/tests updated to use the postprocessor test folder; .gitignore updated to ignore that folder. - Server watches .psc changes and refreshes a PSC script index; new tools/tcloo_navigation.py exposes tcloo_definition used by the language server to resolve cross-file class/constructor/method definitions. - Language server uses class_snapshot(document.path) when producing TclOO completions, signature help, and inlay hints so resolved class metadata is available across files. Also includes related docs/changelog updates, minor code formatting cleanups, and added tests for PSC/TclOO behavior.
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import * as vscode from "vscode"
|
||||
import {
|
||||
cdlEventHandlerAtLine,
|
||||
createCdlEventHandlerSnippet
|
||||
} from "./cdlEventHandler"
|
||||
import { cdlEventHandlerAtLine, createCdlEventHandlerSnippet } from "./cdlEventHandler"
|
||||
|
||||
const MACHINE_HEADER_REGEX = /^MACHINE\s+\S+/
|
||||
|
||||
@@ -65,10 +62,7 @@ export function diagnosticHandler(document: vscode.TextDocument) {
|
||||
if (document.languageId === "cdl" || document.languageId === "def") {
|
||||
const text = document.getText()
|
||||
if (!isFirstLineMachine(text)) {
|
||||
const range = new vscode.Range(
|
||||
document.positionAt(0),
|
||||
document.positionAt(text.length)
|
||||
)
|
||||
const range = new vscode.Range(document.positionAt(0), document.positionAt(text.length))
|
||||
const diagnostic = new vscode.Diagnostic(
|
||||
range,
|
||||
"The first line should contain 'MACHINE'.",
|
||||
@@ -82,7 +76,7 @@ export function diagnosticHandler(document: vscode.TextDocument) {
|
||||
|
||||
export function completionHandlerCdl(document: vscode.TextDocument, position: vscode.Position) {
|
||||
const linePrefix = document.lineAt(position).text.substring(0, position.character)
|
||||
const categories = ["MILL", "LATHE", "DRILL"]
|
||||
const categories = ["MILL", "LATHE", "DRILL", "INVALID"]
|
||||
|
||||
if (linePrefix.endsWith("TYPE ")) {
|
||||
return [
|
||||
@@ -193,8 +187,7 @@ export async function definitionCdlEventHandler(
|
||||
.filter(
|
||||
(symbol) =>
|
||||
symbol.kind === vscode.SymbolKind.Function &&
|
||||
(symbol.name === handlerName ||
|
||||
symbol.name.endsWith(`::${handlerName}`))
|
||||
(symbol.name === handlerName || symbol.name.endsWith(`::${handlerName}`))
|
||||
)
|
||||
.map((symbol) => symbol.location)
|
||||
if (indexedLocations.length > 0) {
|
||||
@@ -204,9 +197,7 @@ export async function definitionCdlEventHandler(
|
||||
// The Tcl language server may still be starting; use the file fallback below.
|
||||
}
|
||||
|
||||
const declaration = new RegExp(
|
||||
`^\\s*proc\\s+(?:::)?${escapeRegExp(handlerName)}(?=\\s|\\{)`
|
||||
)
|
||||
const declaration = new RegExp(`^\\s*proc\\s+(?:::)?${escapeRegExp(handlerName)}(?=\\s|\\{)`)
|
||||
const tclFiles = await vscode.workspace.findFiles(
|
||||
"**/*.tcl",
|
||||
"**/{.git,.nox,.venv,dist,node_modules,out}/**"
|
||||
@@ -233,12 +224,7 @@ export async function definitionCdlEventHandler(
|
||||
locations.push(
|
||||
new vscode.Location(
|
||||
uri,
|
||||
new vscode.Range(
|
||||
lineNumber,
|
||||
start,
|
||||
lineNumber,
|
||||
start + handlerName.length
|
||||
)
|
||||
new vscode.Range(lineNumber, start, lineNumber, start + handlerName.length)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ async function createServer(
|
||||
}
|
||||
|
||||
// Options to control the language client
|
||||
const tclFileWatcher = workspace.createFileSystemWatcher("**/*.tcl")
|
||||
const tclFileWatcher = workspace.createFileSystemWatcher("**/*.{tcl,psc}")
|
||||
const clientOptions: LanguageClientOptions = {
|
||||
// Register the server for python documents
|
||||
documentSelector: isVirtualWorkspace()
|
||||
|
||||
Reference in New Issue
Block a user