Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Koneki » Execution Environment imported by default
Execution Environment imported by default [message #1416955] Thu, 01 August 2013 21:27 Go to next message
Andres Ispani is currently offline Andres IspaniFriend
Messages: 6
Registered: August 2013
Junior Member
Hi, I'm writing an Execution Environment, and want to have code completion working for some Lua libraries.
Right now, it's working correctly as long as I require the module like :
Quote:
> local moduleName = require('moduleName')


However, in our lua environment it's not necessary to do the require, the libraries are available by default. Is it possible to automatically enable completion (like it does for the built in modules like math, etc)?
Re: Execution Environment imported by default [message #1416956 is a reply to message #1416955] Fri, 02 August 2013 09:43 Go to previous messageGo to next message
Marc Aubry is currently offline Marc AubryFriend
Messages: 76
Registered: July 2009
Member
Hi Andres,

For the built-it modules like math, they are available through global variable. In the Execution Environments, global variable are declared in the "global.lua" file as field for the type "global". Declared fields and functions under the "global" type in the global module of the Execution Environment will be available for auto-completion everywhere in your project.

The type "global" is explain in the wiki documentation: http://wiki.eclipse.org/Koneki/LDT/User_Area/Documentation_Language#Global
The special behavior of the global.lua file in an Execution Environment is explain here : http://wiki.eclipse.org/Koneki/LDT/User_Area/Execution_Environment_file_format#File_structure

So it should be a good solution to create a global.lua file in your Execution Environment to declare your preloaded field and functions for your environment.

The declaration may look like the following sample:
--- @module global

--- @field[parent = #global] amodulename#amodulename amodulename preloaded module

Where the "amodulename" is the name of pre-loaded library.
In the @field line, the first "amodulename" is the module name, the second one is the implicit module type (which have the same name) and the third one the global variable name (which usually have the same name of the module) where the module is preloaded into.

Here the example of a global.lua file for EE lua 5.1 https://github.com/eclipse/koneki.ldt/blob/master/plugins/org.eclipse.koneki.ldt.support.lua51/src-ee/lua-5.1/api/global.lua

[1]: http://wiki.eclipse.org/Koneki/LDT/User_Area/Documentation_Language#Global
[2]: http://wiki.eclipse.org/Koneki/LDT/User_Area/Execution_Environment_file_format#File_structure
[3]: https://github.com/eclipse/koneki.ldt/blob/master/plugins/org.eclipse.koneki.ldt.support.lua51/src-ee/lua-5.1/api/global.lua
Re: Execution Environment imported by default [message #1416958 is a reply to message #1416956] Fri, 02 August 2013 17:02 Go to previous messageGo to next message
Andres Ispani is currently offline Andres IspaniFriend
Messages: 6
Registered: August 2013
Junior Member
Thank you, now it works. It seems I missed the note on globals when I was reading about the Execution Environment file.
I have another question, is there a way in the Documentation Language to define inheritance? If I have a type that inherits from another, do I have to copy all definitions from the parent type?
Re: Execution Environment imported by default [message #1416959 is a reply to message #1416958] Fri, 02 August 2013 19:49 Go to previous messageGo to next message
Andres Ispani is currently offline Andres IspaniFriend
Messages: 6
Registered: August 2013
Junior Member
Nevermind, I just read http://www.eclipse.org/forums/index.php/mv/msg/490020/1067396/#msg_1067396 that it's not possible... I'll just duplicate all definitions.

What I cannot find is how to do this for code outside the Execution Environment.
Say I have a lua module (on a specific project, not a part of the Execution Environment) that does something like:



SomeClass={} --global variable
SomeClass.__index=SomeClass

function SomeClass:create()
-- etc
end



How would I comment this to enable auto completion?
I tried "-- @field [parent=#global] #SomeClass SomeClass" but (as the documentation also says), this only works inside the module, and not if the module is required
Re: Execution Environment imported by default [message #1416962 is a reply to message #1416959] Mon, 05 August 2013 10:29 Go to previous message
Simon Bernard is currently offline Simon BernardFriend
Messages: 345
Registered: July 2009
Senior Member
Hi,
The inheritance is not yet supported in documentation language, the workaround is to duplicate definition as you said. (I open a https://bugs.eclipse.org/bugs/show_bug.cgi?id=414410on it now)

For the global variables, as it is explained in http://wiki.eclipse.org/Koneki/LDT/User_Area/Documentation_Language#Global (I just changed it to try to be more clear :/), there are not workaround for your use case.
Sry, Hope we could find time to support it in a near future.
If you have some ideas, no not hesitate to comment the bug :).
Previous Topic:Koneki LDT 1.0 (on Windows): Debugging not working
Next Topic:Could not initialize class com.naef.jnlua.LuaState
Goto Forum:
  


Current Time: Tue Apr 16 13:55:22 GMT 2024

Powered by FUDForum. Page generated in 0.87252 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top