From 19dd94e4af06254595a949a61c9bd05c5a911328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sat, 5 Dec 2020 22:02:19 +0800 Subject: stash --- script/core/code-action.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'script') diff --git a/script/core/code-action.lua b/script/core/code-action.lua index 3a7f7374..13d5220d 100644 --- a/script/core/code-action.lua +++ b/script/core/code-action.lua @@ -279,6 +279,34 @@ local function solveDiagnostic(uri, diag, results) disableDiagnostic(uri, diag.code, results) end +local function checkSwapParams(results, uri, start, finish) + local ast = files.getAst(uri) + if not ast then + return + end + local result = guide.eachSourceBetween(ast.ast, start, finish, function (source) + if source.type == 'callargs' then + return { + node = source.parent.node, + args = source, + } + end + if source.type == 'funcargs' then + return { + node = source.parent, + args = source, + } + end + end) + if not result then + return + end +end + +local function checkExtractAsFunction(results, uri, start, finish) + +end + return function (uri, start, finish, diagnostics) local ast = files.getAst(uri) if not ast then @@ -291,5 +319,8 @@ return function (uri, start, finish, diagnostics) solveDiagnostic(uri, diag, results) end + checkSwapParams(results, uri, start, finish) + checkExtractAsFunction(results, uri, start, finish) + return results end -- cgit v1.2.3