Skip to content

Commit

Permalink
asf
Browse files Browse the repository at this point in the history
  • Loading branch information
svermeulen committed Sep 20, 2024
1 parent 9532d39 commit bcfb293
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
19 changes: 6 additions & 13 deletions gen/teal_language_server/document.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ local tl = require("tl")









Expand Down Expand Up @@ -109,7 +106,7 @@ end
function Document:get_tokens()
local cache = self._cache
if not cache.tokens then
cache.tokens, cache.err_tokens = tl.lex(self._content)
cache.tokens, cache.err_tokens = tl.lex(self._content, self._uri.path)
if not cache.err_tokens then
cache.err_tokens = {}
end
Expand Down Expand Up @@ -151,14 +148,10 @@ function Document:get_result()
end

function Document:get_type_report()
local result, has_errors = self:get_result()

local cache = self._cache
if not cache.type_report then
cache.type_report, cache.type_report_env = tl.get_types(result)
end
local _result, has_errors = self:get_result()
local env = self._server_state:get_env()

return cache.type_report, cache.type_report_env, has_errors
return env.reporter:get_report(), env.reporter, has_errors
end

local function _strip_trailing_colons(text)
Expand Down Expand Up @@ -307,7 +300,7 @@ end

function Document:get_type_info_for_symbol(identifier, where)
local tr, _ = self:get_type_report()
local symbols = tl.symbols_in_scope(tr, where.line + 1, where.character + 1)
local symbols = tl.symbols_in_scope(tr, where.line + 1, where.character + 1, self._uri.path)
local type_id = symbols[identifier]
local result = nil

Expand All @@ -331,7 +324,7 @@ end
function Document:type_information_for_token(token)
local tr, _ = self:get_type_report()

local symbols = tl.symbols_in_scope(tr, token.y, token.x)
local symbols = tl.symbols_in_scope(tr, token.y, token.x, self._uri.path)
local type_id = symbols[token.tk]
local local_type_info = tr.types[type_id]

Expand Down
12 changes: 11 additions & 1 deletion gen/teal_language_server/env_updater.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,17 @@ function EnvUpdater:_init_env_from_config(cfg)
end

local function init_teal_env(gen_compat, gen_target, env_def)
return tl.init_env(false, gen_compat, gen_target, { env_def })
local opts = {
defaults = {
gen_compat = gen_compat,
gen_target = gen_target,
},
predefined_modules = { env_def },
}

local env = tl.new_env(opts)
env.report_types = true
return env
end

cfg = cfg or {}
Expand Down
2 changes: 1 addition & 1 deletion gen/teal_language_server/lsp_events_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function LspEventsManager:_trigger(method, params, id)
if ok then
tracing.debug(_module_name, "Successfully handled request with method {}", { method })
else
tracing.error(_module_name, "Error in handler for request with method {}: {}", { method, err })
tracing.error(_module_name, "Error in handler for request with method {method}: {error}", { method, err })
end
else
tracing.warning(_module_name, "No handler found for event with method {}", { method })
Expand Down
9 changes: 7 additions & 2 deletions gen/teal_language_server/misc_handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,14 @@ function MiscHandlers:_on_hover(params, id)

tracing.trace(_module_name, "Successfully found type_info: {}", { type_info })

local type_str = doc:show_type(type_info)




local type_str = type_info.str

self._lsp_reader_writer:send_rpc(id, {
contents = { tk.tk .. ":", type_str },
contents = { type_str },
range = {
start = lsp.position(token_pos.line, token_pos.character),
["end"] = lsp.position(token_pos.line, token_pos.character + #tk.tk),
Expand Down

0 comments on commit bcfb293

Please sign in to comment.