Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Lua Development Tools » Code completion - missing features?
Code completion - missing features? [message #1783330] Mon, 12 March 2018 06:58 Go to next message
mep eisen is currently offline mep eisenFriend
Messages: 3
Registered: March 2018
Junior Member
Let us assume I have a class framework. This framework ensures that I get some private variable space.

cmr.class("myclass").func("myfunc",
function(self, clazz, privates, myarg)
   -- do whatever I like
end)


For code completion I can use doc:
------
-- @type myclass
cmr.class("myclass").func("myfunc",
------
-- @function [parent=#myclass] myfunc
-- @param #myclass self
-- @param clazz#clazz clazz
-- @param #myprivates privates
-- @param #number myarg
function(self, clazz, privates, myarg)
   privates.| -- code completion works here
end)


My problem ist code completion if I use this class.
f.e.:
local foo = cmr.new("myclass") -- #myclass
foo:myfunc| -- code completion at this Point


Eclipse shows me the "internal" function signature. Self parameter is ok, but it shows me three parameters (clazz, privates, myarg). Of Course this is what I described in doc. Is there some way to hide parameters "clazz" and "privates"? If I simply remove them from doc it works but the code completion inside my function does not work :-(
------
-- @type myclass
cmr.class("myclass").func("myfunc",
------
-- @function [parent=#myclass] myfunc
-- @param #myclass self
-- @param #number myarg
function(self, clazz, privates, myarg)
   privates.| -- code completion does not work here becuase it does not know which type privates should be
end)

Re: Code completion - missing features? [message #1783357 is a reply to message #1783330] Mon, 12 March 2018 11:20 Go to previous messageGo to next message
Simon Bernard is currently offline Simon BernardFriend
Messages: 337
Registered: July 2009
Senior Member
It seems you want a kind of way to declare privates parameters for a function.
There is no features like that.

But a tricks to do that in your case is something like this :

---
-- @type myclass
cmr.class("myclass")
---
-- @function [parent=#myclass] myfunc
-- @param #myclass self
-- @param #number myarg
.func("myfunc", 

---
-- @param self
-- @param clazz
-- @param #string privates
-- @param #number myarg
function (self, clazz, privates, myarg)
privates:byte(i,j)
end
);


But this makes strange to me that clazz and privates args was before public one ? how users could use your function ?
Re: Code completion - missing features? [message #1783360 is a reply to message #1783330] Mon, 12 March 2018 11:42 Go to previous messageGo to next message
mep eisen is currently offline mep eisenFriend
Messages: 3
Registered: March 2018
Junior Member
Quote:
to declare privates parameters for a function.

Excactly.

Quote:
how users could use your function ?

Technically the helper "cmr" builds wrappers around the functions.
So from public view you will invoke the first method declaration (without clazz and privates Parameter) but the function itself has to see ist privates.

Simple "real life" example:
cmr.class("myaccount").ctor(function(self, clazz, privates, initial)
    privates.balance = initial
end)
.func("add", function(self, clazz, privates, difference)
    privates.balance = privates.balance + difference
end)
.func("print", function(self, clazz, privates, difference)
    print(privates.balance)
end)

local account1 = cmr.new("myaccount", 1000)
account1:add(500)
account1:print() -- prints "1500"
print(account1.balance) -- prints "nil", no way to manipulate the private Balance variable

Actually it works but now I look for a way to hide the Parameters during code completion. So that eclipse does not Show me the clazz and private Parameter because as API user I do not know about them and do not want to pass them to the function :-)

[Updated on: Mon, 12 March 2018 11:50]

Report message to a moderator

Re: Code completion - missing features? [message #1783374 is a reply to message #1783360] Mon, 12 March 2018 13:15 Go to previous messageGo to next message
Simon Bernard is currently offline Simon BernardFriend
Messages: 337
Registered: July 2009
Senior Member
I see.
Did you try my "trick" ? does it works for you ?
Re: Code completion - missing features? [message #1783381 is a reply to message #1783374] Mon, 12 March 2018 14:06 Go to previous message
mep eisen is currently offline mep eisenFriend
Messages: 3
Registered: March 2018
Junior Member
yes, it works. thx. Not that smart if I have to repeat all the parameters/docs. But it works. So I have to add a "public doc" and a "private doc".
Previous Topic:How to config LDT to support a big number of functions in one doclua file?
Next Topic:LDT Default Workpace File Position
Goto Forum:
  


Current Time: Mon Sep 24 01:33:33 GMT 2018

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

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

Back to the top