mirror of
https://github.com/dense-analysis/ale.git
synced 2026-07-29 19:26:46 +08:00
Support astgrep (#4975)
CI / Build (push) Canceled after 0s
CI / Neovim 0.10 Windows (push) Canceled after 0s
CI / Neovim 0.12 Windows (push) Canceled after 0s
CI / Vim 8.2 Windows (push) Canceled after 0s
CI / Vim 9.2 Windows (push) Canceled after 0s
CI / Lint (push) Canceled after 0s
CI / Lua (push) Canceled after 0s
CI / Neovim 0.10 Linux (push) Canceled after 0s
CI / Neovim 0.12 Linux (push) Canceled after 0s
CI / Vim 8.2 Linux (push) Canceled after 0s
CI / Vim 9.2 Linux (push) Canceled after 0s
CI / Build (push) Canceled after 0s
CI / Neovim 0.10 Windows (push) Canceled after 0s
CI / Neovim 0.12 Windows (push) Canceled after 0s
CI / Vim 8.2 Windows (push) Canceled after 0s
CI / Vim 9.2 Windows (push) Canceled after 0s
CI / Lint (push) Canceled after 0s
CI / Lua (push) Canceled after 0s
CI / Neovim 0.10 Linux (push) Canceled after 0s
CI / Neovim 0.12 Linux (push) Canceled after 0s
CI / Vim 8.2 Linux (push) Canceled after 0s
CI / Vim 9.2 Linux (push) Canceled after 0s
* astgrep: support its LSP Fixes: #4974 * astgrep: add a fixer
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
Before:
|
||||
Save g:ale_astgrep_executable
|
||||
Save g:ale_astgrep_scan_options
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
Execute(The ast-grep callback should return the correct default values):
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('ast-grep') . ' scan --update-all %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\ },
|
||||
\ ale#fixers#astgrep#Fix(bufnr(''))
|
||||
|
||||
Execute(The astgrep executable and options should be configurable):
|
||||
let g:ale_astgrep_executable = '/path/to/ast-grep'
|
||||
let g:ale_astgrep_scan_options = '--interactive'
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('/path/to/ast-grep')
|
||||
\ . ' scan'
|
||||
\ . ' --interactive %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\ },
|
||||
\ ale#fixers#astgrep#Fix(bufnr(''))
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('c', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.c')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('cpp', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.cpp')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('cs', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.cs')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('css', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.css')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('elixir', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.ex')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('go', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.go')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('haskell', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.hs')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('html', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.html')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('java', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.java')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('javascript', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.js')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('json', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.json')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('kotlin', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.kt')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('lua', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.lua')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('nix', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.nix')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('php', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.php')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('python', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.py')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('ruby', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.rb')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('rust', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.rs')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('scala', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.scala')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('sh', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.sh')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('solidity', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.sol')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('swift', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.swift')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('tsx', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.tsx')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('typescript', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.ts')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
@@ -0,0 +1,18 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('yaml', 'astgrep')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default executable path should be correct):
|
||||
AssertLinter 'ast-grep', ale#Escape('ast-grep') . ' lsp'
|
||||
|
||||
Execute(The project root should be detected correctly with a configuration file):
|
||||
call ale#test#SetFilename('../test-files/generic/astgrep/subdir/file.yaml')
|
||||
|
||||
AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/generic/astgrep')
|
||||
|
||||
Execute(The project root should be empty when no project files can be detected):
|
||||
call ale#test#SetFilename('../test-files/dummy')
|
||||
|
||||
AssertLSPProject ''
|
||||
Reference in New Issue
Block a user