Don't know how to configure LDT to make it works ...
[hello.lua]
local m = {}
function m.print()
print("hello")
end
function m.test()
m.print() -- press F3 on 'print' won't go to declaration
-- with error: current text selection does not resolve to a script element
end
return m
[main.lua]
local hello = require("hello")
hello.test() -- 1) no code assist
-- 2) press F3 on 'test' won't go to declaration in 'hello.lua'
-- same error: current text selection does not resolve to a script element
Benjamin CABE Messages: 146 Registered: July 2009 Location: Toulouse, France
Senior Member
Hi Cheyi Lin,
Your code needs to be documented so as LDT can know what are the different methods contained in your module:
---
-- @module m
local m = {}
------------------------------------------------------------------------------
-- Print something
-- @function [parent=#m] print
function m.print()
print("hello")
end
------------------------------------------------------------------------------
-- Test something
-- @function [parent=#m] test
function m.test()
m.print()
end
return m
1.
In my example code, I saw 'm' listed twice in outline
...
[M] > m
* test()
[o] m
...
The first one is the module, and the second one is the local variable. Is it normal?
It seems that all top level local variables are shown in outline. (including 'local string, io = string, io')
2.
In wiki page: wiki.eclipse.org/Koneki/LDT/Technical_Discussions/Documentation_Language (sorry I can't post link)
I don't understand the use of 'type comment block' and 'field comment block'.
Could you please explain these with some code examples?
1.
This is the expected behavior. The first 'm' is the module (@module m) and the second one the local variable (local m = {}).
This is maybe a bit weird but currently the IDE is not able make the link between this 2 declaration.
2.
The 'type comment block' is used to describe a type, like a file handle in the io module.
This type could be returned by function (like open in io module).
Thanks to this information, in some case, we are able to infer type to local variable and so propose relevant auto-completion.
The 'field comment block' is used to attach a field to a type (or to a module, in fact a module is managed like a type). A field is a table index which is not a function like stdin in the io module.
You could download and add the Lua 5.1 execution environment support to your project to test the io module and so the possibility of type and field comment block.