docs: encourage adding comments; fix nested IF/ELSIF indentation
- Update AGENTS.md to encourage comments instead of forbidding them - Add docstrings to all public functions in src/ modules - Add module headers and function comments to lua/scl/ modules - Fix formatter to properly indent multi-line IF/ELSIF conditions - Fix FB call detection to not match IF statements with parentheses
This commit is contained in:
@@ -154,6 +154,9 @@ end
|
||||
|
||||
local handlers = {}
|
||||
|
||||
--- Handle LSP initialize request
|
||||
--- @param params table Initialization parameters from client
|
||||
--- @return table Server capabilities and info
|
||||
function handlers.initialize(params)
|
||||
return {
|
||||
capabilities = capabilities,
|
||||
@@ -161,8 +164,13 @@ function handlers.initialize(params)
|
||||
}
|
||||
end
|
||||
|
||||
--- Handle initialized notification (no response needed)
|
||||
--- @param params table Parameters (usually empty)
|
||||
function handlers.initialized(params) end
|
||||
|
||||
--- Handle shutdown request
|
||||
--- @param params table Parameters (usually empty)
|
||||
--- @return nil
|
||||
function handlers.shutdown(params)
|
||||
return nil
|
||||
end
|
||||
@@ -206,10 +214,15 @@ local function find_project_root(start_path)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Handle exit notification - terminates the server
|
||||
--- @param params table Parameters (usually empty)
|
||||
function handlers.exit(params)
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
--- Handle textDocument/didOpen notification
|
||||
--- Parses document content, extracts symbols, and stores in documents cache
|
||||
--- @param params table Contains textDocument with uri, text, version
|
||||
function handlers.textDocument_didOpen(params)
|
||||
local uri = params.textDocument.uri
|
||||
local content = params.textDocument.text
|
||||
@@ -247,6 +260,9 @@ function handlers.textDocument_didOpen(params)
|
||||
}
|
||||
end
|
||||
|
||||
--- Handle textDocument/didChange notification
|
||||
--- Re-parses document content after edits
|
||||
--- @param params table Contains textDocument with uri and contentChanges array
|
||||
function handlers.textDocument_didChange(params)
|
||||
local uri = params.textDocument.uri
|
||||
local content = params.contentChanges[1].text
|
||||
@@ -285,11 +301,18 @@ function handlers.textDocument_didChange(params)
|
||||
clear_symbol_cache()
|
||||
end
|
||||
|
||||
--- Handle textDocument/didClose notification
|
||||
--- Removes document from cache
|
||||
--- @param params table Contains textDocument with uri
|
||||
function handlers.textDocument_didClose(params)
|
||||
documents[params.textDocument.uri] = nil
|
||||
clear_symbol_cache()
|
||||
end
|
||||
|
||||
--- Handle textDocument/hover request
|
||||
--- Provides hover information for variables, types, and built-in instructions
|
||||
--- @param params table Contains textDocument with uri and position
|
||||
--- @return table|nil Hover result with contents and range, or nil
|
||||
function handlers.textDocument_hover(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -699,6 +722,10 @@ function handlers.textDocument_hover(params)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Handle textDocument/completion request
|
||||
--- Provides completion items based on context (VAR section, member access, etc.)
|
||||
--- @param params table Contains textDocument with uri and position
|
||||
--- @return table Completion list with items array
|
||||
function handlers.textDocument_completion(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -879,6 +906,10 @@ function handlers.textDocument_completion(params)
|
||||
return { isIncomplete = false, items = items }
|
||||
end
|
||||
|
||||
--- Handle textDocument/definition request
|
||||
--- Finds definition location for symbol at position
|
||||
--- @param params table Contains textDocument with uri and position
|
||||
--- @return table|nil Location with uri and range, or nil
|
||||
function handlers.textDocument_definition(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -921,6 +952,10 @@ function handlers.textDocument_definition(params)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Handle textDocument/declaration request
|
||||
--- Finds declaration locations for symbol at position across workspace
|
||||
--- @param params table Contains textDocument with uri and position
|
||||
--- @return table|nil Array of locations, or nil
|
||||
function handlers.textDocument_declaration(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -1141,6 +1176,10 @@ function handlers.textDocument_declaration(params)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Handle textDocument/references request
|
||||
--- Finds all references to symbol at position in current document
|
||||
--- @param params table Contains textDocument with uri and position
|
||||
--- @return table|nil Array of reference locations, or nil
|
||||
function handlers.textDocument_references(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -1202,6 +1241,10 @@ function handlers.textDocument_references(params)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Handle textDocument/documentSymbol request
|
||||
--- Returns all symbols in document for outline/navigation
|
||||
--- @param params table Contains textDocument with uri
|
||||
--- @return table Array of DocumentSymbol objects
|
||||
function handlers.textDocument_documentSymbol(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -1286,6 +1329,10 @@ function handlers.textDocument_documentSymbol(params)
|
||||
return symbols
|
||||
end
|
||||
|
||||
--- Handle textDocument/diagnostic request
|
||||
--- Validates document and returns diagnostics
|
||||
--- @param params table Contains textDocument with uri
|
||||
--- @return table Diagnostic report with items array
|
||||
function handlers.textDocument_diagnostic(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -1302,6 +1349,10 @@ function handlers.textDocument_diagnostic(params)
|
||||
return { items = diag_results }
|
||||
end
|
||||
|
||||
--- Handle textDocument/semanticTokens/full request
|
||||
--- Returns semantic tokens for syntax highlighting (currently disabled)
|
||||
--- @param params table Contains textDocument with uri
|
||||
--- @return table Semantic tokens with data array
|
||||
function handlers.textDocument_semanticTokensFull(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -1399,6 +1450,10 @@ function handlers.textDocument_semanticTokensFull(params)
|
||||
return { data = tokens }
|
||||
end
|
||||
|
||||
--- Handle textDocument/semanticTokens/range request
|
||||
--- Returns semantic tokens for a range (delegates to full)
|
||||
--- @param params table Contains textDocument with uri and range
|
||||
--- @return table Semantic tokens with data array
|
||||
function handlers.textDocument_semanticTokensRange(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -1412,6 +1467,10 @@ end
|
||||
handlers["textDocument_semanticTokens_full"] = handlers.textDocument_semanticTokensFull
|
||||
handlers["textDocument_semanticTokens_range"] = handlers.textDocument_semanticTokensRange
|
||||
|
||||
--- Handle textDocument/inlayHint request
|
||||
--- Provides inlay hints for variable types in VAR sections
|
||||
--- @param params table Contains textDocument with uri and range
|
||||
--- @return table Array of InlayHint objects
|
||||
function handlers.textDocument_inlayHint(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
@@ -1449,6 +1508,10 @@ function handlers.textDocument_inlayHint(params)
|
||||
return hints
|
||||
end
|
||||
|
||||
--- Handle workspace/symbol request
|
||||
--- Searches workspace for symbols matching query
|
||||
--- @param params table Contains query string and optional maxResults
|
||||
--- @return table Array of SymbolInformation objects
|
||||
function handlers.workspace_symbol(params)
|
||||
local query = params.query or ""
|
||||
local max_results = params.maxResults or 50
|
||||
@@ -1586,6 +1649,10 @@ function handlers.workspace_symbol(params)
|
||||
return final_results
|
||||
end
|
||||
|
||||
--- Handle textDocument/formatting request
|
||||
--- Formats entire document using SCL formatter
|
||||
--- @param params table Contains textDocument with uri and options
|
||||
--- @return table|nil Array of TextEdit objects, or nil
|
||||
function handlers.textDocument_formatting(params)
|
||||
local uri = params.textDocument.uri
|
||||
local doc = documents[uri]
|
||||
|
||||
Reference in New Issue
Block a user