Skip to content

Commit

Permalink
feat(treesitter): support for objdump files (#320)
Browse files Browse the repository at this point in the history
* Added aerial queries for objdump

Added objdump to minimal_init.lua

* ci: tests fail if changes to snapshot files

* cleanup: comments on test filetype special cases

* test: add objdump test snapshots

---------

Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
  • Loading branch information
ColinKennedy and stevearc committed Oct 31, 2023
1 parent 3a3baf0 commit eb301a4
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ jobs:
run: |
bash ./run_tests.sh
- name: Check for changes
run: |
git add tests
git diff --quiet --staged || echo "Changes to snapshot file detected. Run 'make update_snapshots' and commit the changes"
git diff --stat --staged
git diff --quiet --staged
update_docs:
name: Update docs
runs-on: ubuntu-22.04
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ In addition, you will need to have either Treesitter or a working LSP client. Yo
- make
- markdown
- norg
- objdump
- org
- php
- proto
Expand Down
7 changes: 7 additions & 0 deletions queries/objdump/aerial.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(disassembly_section_label
(identifier) @name
(#set! "kind" "Interface")) @type

(disassembly_section
(identifier) @name
(#set! "kind" "Function")) @type
10 changes: 6 additions & 4 deletions tests/minimal_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ vim.cmd([[set runtimepath+=.]])
vim.o.swapfile = false
vim.bo.swapfile = false
vim.filetype.add({
-- Neovim doesn't have built-in filetype detection for these filetypes
extension = {
norg = "norg", -- Neovim doesn't have built-in norg filetype detection
usd = "usd", -- Neovim doesn't have built-in USD filetype detection
usda = "usd", -- Neovim doesn't have built-in USD filetype detection
smk = "snakemake", -- Neovim doesn't have built-in Snakemake filetype detection
norg = "norg",
objdump = "objdump",
usd = "usd",
usda = "usd",
smk = "snakemake",
},
})

Expand Down
32 changes: 32 additions & 0 deletions tests/symbols/objdump_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"col": 0,
"end_col": 29,
"end_lnum": 1,
"kind": "Interface",
"level": 0,
"lnum": 1,
"name": ".text",
"selection_range": {
"col": 23,
"end_col": 28,
"end_lnum": 1,
"lnum": 1
}
},
{
"col": 0,
"end_col": 91,
"end_lnum": 9,
"kind": "Function",
"level": 0,
"lnum": 3,
"name": "<engine::world::World::createEntity()>",
"selection_range": {
"col": 17,
"end_col": 55,
"end_lnum": 3,
"lnum": 3
}
}
]
9 changes: 9 additions & 0 deletions tests/treesitter/objdump_test.objdump
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Disassembly of section .text:

0000000000000000 <engine::world::World::createEntity()> (File Offset: 0x70):
_ZN6engine5world5World12createEntityEv():
/home/selecaoone/repositories/jumpy/engine/src/lib/world.cpp:14
0: 48 89 f8 mov rax,rdi
_ZNKSt15__uniq_ptr_implIN6engine13entityManager13EntityManagerESt14default_deleteIS2_EE6_M_ptrEv():
/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/unique_ptr.h:154
3: 48 8b 4f 40 mov rcx,QWORD PTR [rdi+0x40]

0 comments on commit eb301a4

Please sign in to comment.