Home » Archived » Lua Development Tools » Limited autocomplete issue(@return statement doesn't seem to work)
Limited autocomplete issue [message #1113893] |
Sat, 21 September 2013 18:39  |
Eclipse User |
|
|
|
Hi there,
If I take the following sample from this documentation:
--- A module that allow to manage geometry shapes
-- @module geometry
local M = {}
--- A rectangle
-- @type rectangle
-- @field [parent=#rectangle] #number x horizontal position, 0 by default
-- @field [parent=#rectangle] #number y vertical position, 0 by default
-- @field [parent=#rectangle] #number width, 100 by default
-- @field [parent=#rectangle] #number height, 100 by default
local R = {x=0, y=0, width=100, height=100, }
--- Move the rectangle
-- @function [parent=#rectangle] move
-- @param #rectangle self
-- @param #number x
-- @param #number y
function R.move(self,x,y)
self.x = self.x + x
self.y = self.y + y
end
--- Create a new rectangle
-- @function [parent=#geometry] newRectangle
-- @param #number x
-- @param #number y
-- @param #number width
-- @param #number height
-- @return #rectangle the created rectangle
function M.newRectangle(x,y,width,height)
local newrectangle = {x=x,y=y,width=width,height=height}
-- set to new rectangle the properties of a rectangle
setmetatable(newrectangle, {__index = R})
return newrectangle
end
return M
And I save it as "geometry.lua".
Then in an another lua file I try to use it:
geo=require('geometry');
myRectangle = geo.newRectangle(1,1,1,1); --autocomplete work fine here
myRectangle. --??? autocomplete doesn't work anymore
or
geo=require('geometry');
geo.newRectangle(1,1,1,1). --??? autocomplete doesn't work either
Even in geometry.lua if I use newRectangle, it seem that the autocomplete won't be able to reach the variable and move method.
Alhought,
In the local scope of "geometry.lua"
R.y --autocomplete work fine here
Did I do something wrong?
I use Lua 5.1 with Koneki standalone 1.0
|
|
| | |
Re: Limited autocomplete issue [message #1184360 is a reply to message #1141440] |
Wed, 13 November 2013 06:49   |
Eclipse User |
|
|
|
Alright, I have one question(I'm currently testing with koneki 1.1_M2):
Let's say, I want to use the geometry module in an another module, such as a cartesianDiagram module.
--- A Cartesian Diagram
--@module cartesianDiagram
local geo=require("geometry");
M={}
--- A Cartesian Diagram Instance
-- @type cartesianDiagramInstance
-- @field [parent=#cartesianDiagramInstance] #number row, 0 by default
-- @field [parent=#cartesianDiagramInstance] #number column, 0 by default
-- @field [parent=#cartesianDiagramInstance] @{geometry#(rectangle)} rect, minimal rectangle by default
local C={row=0,column=0,rect=geo.newRectangle(0,0,0,0)}
--- Create a new cartesianDiagram with a specfic number of row and column for each quadrants
-- @function [parent=#cartesianDiagram] newCartesianDiagram
-- @param #number row
-- @param #number column
-- @param @{geometry#(rectangle)} rect
-- @return #cartesianDiagram the created rectangle
function M.newCartesianDiagram(row, column, rect)
local newCartesianDiagram = {row=row,column=column, rect=rect}
-- set to new cartesianDiagramInstance properties of a cartesianDiagramInstance
setmetatable(newCartesianDiagram, {__index = C})
return newCartesianDiagram
end
return M;
Here's I'm not 100% sure if I used the #type annotation correctly for "cartesianDiagramInstance", but so far if I tried something like this and as you can see, the sugestions are messed up. He doesn't recognize the "rect" field either.
In this sample, the only way to get the autocomplete kinda right, is to remove the cartesianDiagramInstance luadoc like this, because I use rect=geo.newRectangle(0,0,0,0) instead of something like rect=nil.
So I guess it's a bug with the short references? Or did I do something wrong?
edit: Ok, I just renamed geo=require("geometry") to geometry=require("geometry")... and it seem to work now... I'll check later if there aren't any other use case missing.
[Updated on: Wed, 13 November 2013 08:26] by Moderator
|
|
|
Re: Limited autocomplete issue [message #1184575 is a reply to message #1184360] |
Wed, 13 November 2013 09:52   |
Eclipse User |
|
|
|
hi,
The short reference is used to reference a types and their fields in a textual description.
If you want to type fields, parameters, return values ... you should use type reference notation.
So the right way to write your code is :
--- A Cartesian Diagram
--@module cartesianDiagram
local geo=require("geometry");
M={}
--- A Cartesian Diagram Instance
-- @type cartesianDiagramInstance
-- @field #number row, 0 by default
-- @field #number column, 0 by default
-- @field geometry#rectangle rect, minimal rectangle by default
local C={row=0,column=0,rect=geo.newRectangle(0,0,0,0)}
--- Create a new cartesianDiagram with a specfic number of row and column for each quadrants
-- @function [parent=#cartesianDiagram] newCartesianDiagram
-- @param #number row
-- @param #number column
-- @param geometry#rectangle rect
-- @return #cartesianDiagramInstance the created rectangle
function M.newCartesianDiagram(row, column, rect)
local newCartesianDiagram = {row=row,column=column, rect=rect}
-- set to new cartesianDiagramInstance properties of a cartesianDiagramInstance
setmetatable(newCartesianDiagram, {__index = R})
return newCartesianDiagram
end
return M;
But rect is still not recognize because you find a new bug .
(I just open it)
1 remarks : "@function [parent=#cartesianDiagram] newCartesianDiagram" is now optional because we can guess the name and the parent function from code.
Thx again for your feedback , that's really help.
|
|
| | | |
Goto Forum:
Current Time: Wed Mar 19 19:25:22 EDT 2025
Powered by FUDForum. Page generated in 0.03848 seconds
|