1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-28 00:59:31 +00:00

Separate function and class injections

This commit is contained in:
Étienne Fildadut 2022-09-16 21:55:06 +09:00
parent c43266260d
commit e017a391ec
4 changed files with 31 additions and 13 deletions

View file

@ -66,7 +66,8 @@ common = {
injections = {
["function start"] = "function_start", ["function end"] = "function_end", ["function return"] = "function_return",
["scoped function start"] = "scoped_function_start", ["scoped function end"] = "scoped_function_end", ["scoped function return"] = "scoped_function_return",
["checkpoint start"] = "checkpoint_start", ["checkpoint end"] = "checkpoint_end"
["checkpoint start"] = "checkpoint_start", ["checkpoint end"] = "checkpoint_end",
["class start"] = "class_start", ["class end"] = "class_end"
},
--- escape a string to be used as an exact match pattern
escape = function(str)

View file

@ -225,26 +225,39 @@ local function parse_line(line, state, namespace, parent_function)
table.insert(line.children, 1, { content = ":🔖=()", source = line.source })
end
-- custom code injection
if r.scoped then
if state.inject.scoped_function_start then
for i, ll in ipairs(state.inject.scoped_function_start) do
if r.subtype == "class" then
if state.inject.class_start then
for i, ll in ipairs(state.inject.class_start) do
table.insert(line.children, 1+i, copy(ll))
end
end
if state.inject.scoped_function_end then
for _, ll in ipairs(state.inject.scoped_function_end) do
if state.inject.class_end then
for _, ll in ipairs(state.inject.class_end) do
table.insert(line.children, copy(ll))
end
end
else
if state.inject.function_start then
for i, ll in ipairs(state.inject.function_start) do
table.insert(line.children, 1+i, copy(ll))
if r.scoped then
if state.inject.scoped_function_start then
for i, ll in ipairs(state.inject.scoped_function_start) do
table.insert(line.children, 1+i, copy(ll))
end
end
end
if state.inject.function_end then
for _, ll in ipairs(state.inject.function_end) do
table.insert(line.children, copy(ll))
if state.inject.scoped_function_end then
for _, ll in ipairs(state.inject.scoped_function_end) do
table.insert(line.children, copy(ll))
end
end
else
if state.inject.function_start then
for i, ll in ipairs(state.inject.function_start) do
table.insert(line.children, 1+i, copy(ll))
end
end
if state.inject.function_end then
for _, ll in ipairs(state.inject.function_end) do
table.insert(line.children, copy(ll))
end
end
end
end