Skip to main content



      Home
Home » Archived » Lua Development Tools » Execution Environment imported by default
Execution Environment imported by default [message #1077540] Thu, 01 August 2013 17:23 Go to next message
Eclipse UserFriend
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 #1077903 is a reply to message #1077540] Fri, 02 August 2013 05:43 Go to previous messageGo to next message
Eclipse UserFriend
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: [1]
The special behavior of the global.lua file in an Execution Environment is explain here : [2]

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 [3]

Maybe the documentations about this is not enough developed or the way to declare preloaded global can be enhanced, any feedback will be appreciated Smile

[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

[Updated on: Fri, 02 August 2013 05:47] by Moderator

Re: Execution Environment imported by default [message #1078197 is a reply to message #1077903] Fri, 02 August 2013 13:02 Go to previous messageGo to next message
Eclipse UserFriend
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 #1078275 is a reply to message #1078197] Fri, 02 August 2013 15:49 Go to previous messageGo to next message
Eclipse UserFriend
Nevermind, I just read here that it's not possible... I'll just duplicate all definitions.

What I cannot find is if it's possible to access global variables defined on a module 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



The module is then used just using 'require "SomeClass"', (instead of 'SomeClass = require "SomeClass")

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

[Updated on: Fri, 02 August 2013 16:59] by Moderator

Re: Execution Environment imported by default [message #1079990 is a reply to message #1078275] Mon, 05 August 2013 06:29 Go to previous message
Eclipse UserFriend
Hi,
The inheritance is not yet supported in documentation language, the workaround is to duplicate definition as you said. (I open a bug on it now)

For the global variables, as it is explained in documentation (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 Smile.

Previous Topic:Strange problem trying to use LDT on second machine
Next Topic:Could not initialize class com.naef.jnlua.LuaState
Goto Forum:
  


Current Time: Wed Mar 19 18:02:14 EDT 2025

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

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

Back to the top