davidm / lua-inspect Goto Github PK
View Code? Open in Web Editor NEWLua code analysis, with plugins for HTML and SciTE
Home Page: http://lua-users.org/wiki/LuaInspect
License: Other
Lua code analysis, with plugins for HTML and SciTE
Home Page: http://lua-users.org/wiki/LuaInspect
License: Other
Perhaps unused "" should't be marked? That's the point of using "", after all.
$ ~/projects/lua-inspect/luainspect -f html -o luainspect.html . lua: ...agladysh/projects/lua-inspect/lib/luainspect/ast.lua:119: attempt to index local 'text' (a nil value) stack traceback: ...agladysh/projects/lua-inspect/lib/luainspect/ast.lua:119: in function 'linecount' ...agladysh/projects/lua-inspect/lib/luainspect/ast.lua:142: in function 'ast_from_string' ...dysh/projects/lua-inspect/lib/luainspect/command.lua:64: in main chunk [C]: in function 'require' /home/agladysh/projects/lua-inspect/luainspect:16: in main chunk [C]: ? ~/projects/lua-inspect$ git rev-parse HEAD ca3988019a2f5f1b3f4e94b285eb6e77e5923dd3
Or rather, it's correct html, but contains (1) numbered lines (with no content other than the line number), and (2) a bunch of messages at the bottom. There's no actual highlighted source code...
Here's the complete output (copied from the browser window) of running luainspect on the "test.lua" file in the source directory, like:
lua5.1 ./luainspect -fhtml -lhtmllib -o /tmp/x.html test.lua
output:
1:
2:
3:
4:
5:
6:
7:
#!/usr/bin/env lua
-- test writing examples.lua to examples.html
argattributes: known global
value: table: 0x1bb8310
used-line:3 = {[0]=argattributes: known global
value: table: 0x1bb8310
used-line:3[0], '-fhtml', '-lhtmllib', '-oexamples.html', 'examples.lua'}
dofileattributes: known global
value: function: 0x1b02480
signature: dofile (filename)
used-line:4 'luainspect'
printattributes: known global
value: function: 0x1b02a40
signature: print (...)
used-line:5 'output written to examples.html'
It would be great if the work being done for smart code-assist in the Koneki LDT project could be integrated with LuaInspect. These two tools complement each other very well. LDT uses type inference via MetaLua to provide context sensitive code completion in the editor obtained from LDoc style commented code. See here for the announcement of code-assist in LDT: http://lua-users.org/lists/lua-l/2012-02/msg00536.html.
The original author of MetaLua is involved in the LDT project and some of the work they've done in MetaLua for code-assist is on the MetaLua git hub (probably the luaeclipse branch): https://github.com/fab13n/metalua/branches
Do you have any plans on doing something like this?
Perhaps this is already possible, but I couldn't figure out how to do it--I'm writing code that uses love2d, and I know (for instance) that a love.graphics.line
function exists which takes x1, y1, x2, y2
. Is there a way for me to provide this data to luainspect so it doesn't flag my calls to this function as "unknown field"?
lua-inspect could be really useful for Lua coders. Would you like to publish lua-inspect to LuaDist?
This way, users can install it easily with luadist install lua-inspect
.
Hi,
I tried run lua-inspect in Lua 5.2.0 (compiled with LUA_COMPAT_ALL) and had errors (getfenv,setfenv).
I made some changes, and it seems, that goes -> C:\JS_LUA\lua-5.2.0\Debug\lua52.exe test.lua successfully produces examples.html
I'm sure (Lua newbie), that my changes are not fully correct, if somebody know, how do things correctly, please report.
...\metalualib\metalua\base.lua (only 1 row chaged):
.... row 9: metalua={} -- if not metalua then rawset(getfenv(), 'metalua', { }) end ....
...\luainspect (version dependant empty getfenv/setfenv function added):
#!/usr/bin/env lua -- Set Lua library paths. -- based on findbin -- https://gist.github.com/1342365 -- and lib -- https://gist.github.com/1342319 local function findbin() local script = arg and arg[0] or '' local bin = script:gsub('[/\\]?[^/\\]+$', '') -- remove file name if bin == '' then bin = '.' end return bin end local bin = findbin() package.path = package.path..';'..bin..'/metalualib/?.lua' package.path = package.path..';'..bin..'/luainspectlib/?.lua' -- added for dummy (in Lua 5.2 not exists) functions print (_VERSION) if _VERSION=="Lua 5.2" then function getfenv() end function setfenv() end function debug.getfenv() end function debug.setfenv() end end -- print (getfenv,setfenv,debug.getfenv,debug.setfenv) require 'luainspect.command'
Test output:
C:\JS_LUA\davidm-lua-inspect>C:\JS_LUA\lua-5.2.0\Debug\lua52.exe test.lua Lua 5.2 warning: [string " context.apply_value('shape$', {color='?', si..."]:1: attempt to index global 'context' (a nil value) : context.apply_value('shape$', {color ='?', size={x=1,y=1}, f=function() return "?" end}) warning: [string " context.apply_value('^n.*', number)"]:1: attempt to index global 'context' (a nil value) : context.apply_value('^n.*', number) warning: [string " context.apply_value('^s.*', string)"]:1: attempt to index global 'context' (a nil value) : context.apply_value('^s.*', string) warning: [string " context.apply_value('^b.*', boolean)"]:1: attempt to index global 'context' (a nil value) : context.apply_value('^b.*', boolean) status: loading:math warning: module not found: math output written to examples.html C:\JS_LUA\davidm-lua-inspect>lua test.lua Lua 5.1 status: loading:math warning: module not found: math output written to examples.html
Hi,
I've found possibly another lexer error on this simple code:
if (tmp > 1) then return end
It's the () making troubles.
-- ynezz
after install luaforwindows its changes package.path and it can't lookup for files in script current path, so i add the following line to function load_module_source in init.lua
package.path = package.path .. ';'..props['FileDir']..'\\?.lua'
as seen below:
-- Loads source code of given module name.
-- Returns code followed by path.
-- CATEGORY: utility/package
local function load_module_source(name)
--
package.path = package.path .. ';'..props['FileDir']..'\\?.lua'
--
for spec in package.path:gmatch'[^;]+' do
local testpath = plain_gsub(spec, '%?', (name:gsub('%.', '/')))
local src, err_ = readfile(testpath)
if src then return src, testpath end
end
return nil
end
lua-inspect is not compatible with scite 3.2.1, minor tweaks are needed, see:
https://groups.google.com/forum/?fromgroups#!topic/scite-interest/8PdNdUtGfBo
For a valid lua code:
a=1.0
I get lexer error:
warning: metalua failed to compile code that compiles with loadstring. error in metalua?
lua-inspect/metalualib/gg.lua:56: lua-inspect/metalualib/lexer.lua:129: assertion failed! 6
I made a workaround, but not sure what is the real fix:
metalualib/lexer.lua:129 if tag=='Number' and not content then content=0 end
lua-inspect is really handy; I wish there was good sublime text integration.
I see a lot of these messages (from the html, they do also appear in vim and scite):
attributes: unknown field
value: error:./luainspectlib/luainspect/init.lua:337: attempt to index local 't' (a nil value)
used-line:33
The error line in init.lua is also seen as 364.
I've seen this on several source files of mine, if needed could extract a test case.
From html.lua:98
if ast.id then
class = class .. " id" .. ast.id
elseif ast.id then
class = class .. " id" .. ast.localdefinition.id
end
Hello
lexer:extract_short_string does not handle situations where there are mixed ' and " in same line.
For example:
LuaCode = "returnTxt='Hello from Lua!' .. inTxt .. ' / ' .. jit.version"
The readme has "See LICENSE file." in the License section, but there is not LICENSE file and no licensing information I can find.
When using lua-inspect in SciTE, when encountering Unicode text encoded in utf8, the syntax highlighting following the text is offset to where it is supposed to be - screenshot demonstrating the problem.
Also, the output pane of SciTE shows the following error:
lua-inspect/luainspectlib/luainspect/scite.lua:885: bad argument #1 to 'char' (invalid value)
I am not sure what causes this, but when I type a simple assignment containing a boolean value, part of it is highlighted as unknown global, see screenshot
After typing other lines, the incorrect highlighting disappears, even after erasing them and leaving only the first line, it works correctly for a while. After few more edits (erasing everything, typing something again), the following error comes up:
lua-inspect/luainspectlib/luainspect/ast.lua:204: attempt to perform arithmetic on local 'src_lpos' (a nil value)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.