summaryrefslogtreecommitdiff
path: root/script/files.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/files.lua')
-rw-r--r--script/files.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/script/files.lua b/script/files.lua
index 62f01136..7998ceed 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -655,6 +655,17 @@ function m.compileStateAsync(uri, callback)
end)
end
+local function pluginOnTransformAst(uri, state)
+ local plugin = require 'plugin'
+ ---TODO: maybe deepcopy astNode
+ local suc, result = plugin.dispatch('OnTransformAst', uri, state.ast)
+ if not suc then
+ return state
+ end
+ state.ast = result
+ return state
+end
+
---@param uri uri
---@return parser.state?
function m.compileState(uri)
@@ -700,6 +711,12 @@ function m.compileState(uri)
return nil
end
+ state = pluginOnTransformAst(uri, state)
+ if not state then
+ log.error('pluginOnTransformAst failed! discard the file state')
+ return nil
+ end
+
m.compileStateThen(state, file)
return state