-
Notifications
You must be signed in to change notification settings - Fork 7
refactor: Cleanup / Tidying + missing tests #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If you rebase and fixup those conflicts, this looks good to me ✔️ |
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 |
Will need another fixup, figured I'd get the features / fixes in prior to the refactor 😅 |
a72727b
to
6da0583
Compare
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
6da0583
to
15ac5da
Compare
OK, resolved conflicts and did some more stuff. Additional Changes
I'll call more specifics in comments |
".idea", | ||
"buildSrc", | ||
"kapt", | ||
"target", |
There was a problem hiding this comment.
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
---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, | ||
}) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree!
@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 |
In the projects I've usually been testing with, everything still works and I'm able to see all the expected results ✔️ |
|
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
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
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
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
tests
to the top level (my bad, didn't know where this was supposed to go when I started)