Permalink
Browse files

Updated voodoo to highlight known table fields :-)

  • Loading branch information...
1 parent 035e58f commit 4126f67651005dd186a45c5fa6f9584cee86fa58 @xolox committed Aug 18, 2010
Showing with 8 additions and 8 deletions.
  1. +8 −8 luainspect4vim.lua
View
@@ -11,6 +11,7 @@
local LI = require 'luainspect.init'
local LA = require 'luainspect.ast'
+local LT = require 'luainspect.types'
local MAX_PREVIEW_KEYS = 20
local actions = {}
local myprint
@@ -37,12 +38,6 @@ local function getcurvar(tokenlist, line, column) -- {{{1
end
end
-local function knownvarorfield(token) -- {{{1
- local a = token.ast
- local v = a.seevalue or a
- return a.definedglobal or v.valueknown and v.value ~= nil
-end
-
function actions.highlight(tokenlist, line, column, src) -- {{{1
local function dump(token, hlgroup)
local l1, c1 = unpack(token.ast.lineinfo.first, 1, 2)
@@ -69,7 +64,7 @@ function actions.highlight(tokenlist, line, column, src) -- {{{1
end
if token.tag == 'Id' then
if not token.ast.localdefinition then
- dump(token, knownvarorfield(token) and 'luaInspectGlobalDefined' or 'luaInspectGlobalUndefined')
+ dump(token, token.ast.definedglobal and 'luaInspectGlobalDefined' or 'luaInspectGlobalUndefined')
elseif not token.ast.localdefinition.isused then
dump(token, 'luaInspectLocalUnused')
elseif token.ast.localdefinition.functionlevel < token.ast.functionlevel then
@@ -82,7 +77,12 @@ function actions.highlight(tokenlist, line, column, src) -- {{{1
dump(token, 'luaInspectLocal')
end
elseif token.ast.isfield then
- dump(token, knownvarorfield(token) and 'luaInspectFieldDefined' or 'luaInspectFieldUndefined')
+ local a = token.ast
+ if a.definedglobal or not LT.istype[a.seevalue.value] and a.seevalue.value ~= nil then
+ dump(token, 'luaInspectFieldDefined')
+ else
+ dump(token, 'luaInspectFieldUndefined')
+ end
end
end
end

0 comments on commit 4126f67

Please sign in to comment.