set posmap for declare on assign for functions

This commit is contained in:
leaf corcoran 2014-06-14 18:49:22 -07:00
parent 01555dc4f4
commit 5964d06eee
4 changed files with 15 additions and 7 deletions

View File

@ -415,8 +415,14 @@ do
}) })
return name return name
end, end,
add = function(self, item) add = function(self, item, pos)
self._lines:add(item) do
local _with_0 = self._lines
_with_0:add(item)
if pos then
_with_0:mark_pos(pos)
end
end
return item return item
end, end,
render = function(self, buffer) render = function(self, buffer)

View File

@ -288,9 +288,11 @@ class Block
@stm {"assign", {name}, {value}} @stm {"assign", {name}, {value}}
name name
-- add a line object -- add something to the line buffer
add: (item) => add: (item, pos) =>
@_lines\add item with @_lines
\add item
\mark_pos pos if pos
item item
-- todo: pass in buffer as argument -- todo: pass in buffer as argument

View File

@ -78,7 +78,7 @@ return {
_with_0:append(declare) _with_0:append(declare)
else else
if #undeclared > 0 then if #undeclared > 0 then
self:add(declare) self:add(declare, node[-1])
end end
_with_0:append_list((function() _with_0:append_list((function()
local _accum_0 = { } local _accum_0 = { }

View File

@ -43,7 +43,7 @@ import concat, insert from table
if #undeclared == #names and not has_fndef if #undeclared == #names and not has_fndef
\append declare \append declare
else else
@add declare if #undeclared > 0 @add declare, node[-1] if #undeclared > 0
\append_list [@value name for name in *names], ", " \append_list [@value name for name in *names], ", "
\append " = " \append " = "