mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
fix get root block for root block
This commit is contained in:
parent
182969dc81
commit
b1ecc7defc
@ -55,7 +55,7 @@ do
|
|||||||
local _parent_0 = Block
|
local _parent_0 = Block
|
||||||
local _base_0 = {
|
local _base_0 = {
|
||||||
lint_check_unused = function(self)
|
lint_check_unused = function(self)
|
||||||
if not (self.lint_unused_names) then
|
if not (self.lint_unused_names and next(self.lint_unused_names)) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local names_by_position = { }
|
local names_by_position = { }
|
||||||
@ -102,13 +102,7 @@ do
|
|||||||
self:lint_check_unused()
|
self:lint_check_unused()
|
||||||
return _parent_0.render(self, ...)
|
return _parent_0.render(self, ...)
|
||||||
end,
|
end,
|
||||||
get_root_block = function(self)
|
|
||||||
return self
|
|
||||||
end,
|
|
||||||
block = function(self, ...)
|
block = function(self, ...)
|
||||||
self.get_root_block = self.get_root_block or function()
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
do
|
do
|
||||||
local _with_0 = _parent_0.block(self, ...)
|
local _with_0 = _parent_0.block(self, ...)
|
||||||
_with_0.block = self.block
|
_with_0.block = self.block
|
||||||
@ -129,6 +123,9 @@ do
|
|||||||
whitelist_globals = default_whitelist
|
whitelist_globals = default_whitelist
|
||||||
end
|
end
|
||||||
_parent_0.__init(self, ...)
|
_parent_0.__init(self, ...)
|
||||||
|
self.get_root_block = function()
|
||||||
|
return self
|
||||||
|
end
|
||||||
self.lint_errors = { }
|
self.lint_errors = { }
|
||||||
local vc = self.value_compilers
|
local vc = self.value_compilers
|
||||||
self.value_compilers = setmetatable({
|
self.value_compilers = setmetatable({
|
||||||
|
@ -55,6 +55,8 @@ default_whitelist = Set {
|
|||||||
class LinterBlock extends Block
|
class LinterBlock extends Block
|
||||||
new: (whitelist_globals=default_whitelist, ...) =>
|
new: (whitelist_globals=default_whitelist, ...) =>
|
||||||
super ...
|
super ...
|
||||||
|
@get_root_block = -> @
|
||||||
|
|
||||||
@lint_errors = {}
|
@lint_errors = {}
|
||||||
|
|
||||||
vc = @value_compilers
|
vc = @value_compilers
|
||||||
@ -98,7 +100,8 @@ class LinterBlock extends Block
|
|||||||
|
|
||||||
|
|
||||||
lint_check_unused: =>
|
lint_check_unused: =>
|
||||||
return unless @lint_unused_names
|
return unless @lint_unused_names and next @lint_unused_names
|
||||||
|
|
||||||
names_by_position = {}
|
names_by_position = {}
|
||||||
for name, pos in pairs @lint_unused_names
|
for name, pos in pairs @lint_unused_names
|
||||||
names_by_position[pos] or= {}
|
names_by_position[pos] or= {}
|
||||||
@ -117,10 +120,7 @@ class LinterBlock extends Block
|
|||||||
@lint_check_unused!
|
@lint_check_unused!
|
||||||
super ...
|
super ...
|
||||||
|
|
||||||
get_root_block: => @
|
|
||||||
|
|
||||||
block: (...) =>
|
block: (...) =>
|
||||||
@get_root_block or= -> @
|
|
||||||
|
|
||||||
with super ...
|
with super ...
|
||||||
.block = @block
|
.block = @block
|
||||||
|
Loading…
Reference in New Issue
Block a user