Skip to content

Conversation

NickHackman
Copy link
Collaborator

This PR is all cleanup of either confusing (spec-query.lua), unused methods/functions/files. It also moves tests to the top level as that's what other projects do.

Changes

  • Remove unused files
  • Remove unused functions/methods
  • Move tests to the top level (my bad, didn't know where this was supposed to go when I started)
  • Don't gitignore the Gradle wrapper (this required you to pull it down multiple times)

@NickHackman NickHackman marked this pull request as ready for review June 25, 2025 17:57
@codymikol
Copy link
Owner

If you rebase and fixup those conflicts, this looks good to me ✔️

@NickHackman
Copy link
Collaborator Author

Going to put this further behind #41 because that does parts of this, but also implemented GitHub actions for CI and supports running whole directories

@codymikol
Copy link
Owner

Will need another fixup, figured I'd get the features / fixes in prior to the refactor 😅

This method looks like it was maybe used in init.lua before, but has
been replaced by code directly.
This file can't be used to test the plugin. Instead just use
example-project
This file is unused and was confusing to the implementer of FunSpec (who
implemented it here instead of in the file that is used).
This follows other neotest plugin project structures.
This puts all the logic that is associated with treesitter parsing of
files into one directory
Conforming to the same style for all functions
Tests all cases for the neotest-kotlin/filter.lua
This includes tests:
- java_package
- list_all_classes
- parse_positions
This keeps the interface clear and well documented rather than calling
nested modules or functions in them.
The command isn't parsed at all, it's really construct/built
@NickHackman
Copy link
Collaborator Author

OK, resolved conflicts and did some more stuff.

Additional Changes

  • Moved everything out of the src/ folder
  • Moved all treesitter related code into a treesitter module
  • TESTS, I wrote a ton of tests. There's now coverage for filter.lua and the new treesitter/init.lua
  • Functions now all use the same format function M.<func_name>()

I'll call more specifics in comments

".idea",
"buildSrc",
"kapt",
"target",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"target" was typo'd as "taret" super minor change, doesn't really make sense in a refactor, but couldn't help myself

Comment on lines +51 to +72
---List all classes in a provided file using treesitter
---@param file string
---@return string[] classes
function M.list_all_classes(file)
return get_all_matches_as_string(file, class_query)
end

---Get the first java package in a provided file using treesitter
---@param file string
---@return string? package
function M.java_package(file)
return get_all_matches_as_string(file, package_query)[1]
end

return nil
---Uses neotest.treeistter.parse_positions to discover all namespaces/tests in a file.
---@param file string
---@return neotest.Tree?
function M.parse_positions(file)
return neotest.treesitter.parse_positions(file, kotest_query, {
nested_namespaces = true,
nested_tests = false,
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of exposing the raw Treesitter queries using the init.lua here to only expose functions that use the treesitter queries. Moved the kotest query and parse_positions in here too. Trying to encapsulate all treesitter logic in one spot

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More tests! Really simple functions, but might as well test them now that it's in CI

end)

describe("parse_positions", function()
nio.tests.it("FunSpec", function()
Copy link
Collaborator Author

@NickHackman NickHackman Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to force all future test treesitter queries to write these tests, just so that we can catch minor bugs in our treesitter queries or breaks underneath us.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree!

@NickHackman
Copy link
Collaborator Author

@codymikol should be good for review now, was on the same page of getting the other PR in first. Going to update the title here to include adding more tests

@NickHackman NickHackman changed the title refactor: Cleanup / Tidying refactor: Cleanup / Tidying + missing tests Jun 27, 2025
@codymikol
Copy link
Owner

Not sure why, but now I'm unable to run the test examples

image

I'll try on some other projects

@codymikol
Copy link
Owner

In the projects I've usually been testing with, everything still works and I'm able to see all the expected results ✔️

@codymikol
Copy link
Owner

codymikol commented Jun 28, 2025

oh, the jar isn't there. I think it was before the rebase, do we want to include that in a follow up so the example project can also be run?

@codymikol codymikol merged commit 7c6cb56 into codymikol:main Jun 28, 2025
1 check passed
@codymikol
Copy link
Owner

oh dude, I'm running the test from my own project cwd and not yours

image

codymikol pushed a commit that referenced this pull request Jul 4, 2025
this allows the plugin to work upon opening the first time
and will probably solve some other issues.

happy 4th of july, I'm going to buy a grill and make some wings

Fixes #40
codymikol pushed a commit that referenced this pull request Jul 4, 2025
this allows the plugin to work upon opening the first time
and will probably solve some other issues.

happy 4th of july, I'm going to buy a grill and make some wings

Fixes #40
NickHackman pushed a commit to NickHackman/neotest-kotlin that referenced this pull request Jul 7, 2025
this allows the plugin to work upon opening the first time
and will probably solve some other issues.

happy 4th of july, I'm going to buy a grill and make some wings

Fixes codymikol#40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants