Skip to content
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

How to handle async adapters? #323

Closed
s1n7ax opened this issue Nov 21, 2023 Discussed in #322 · 1 comment
Closed

How to handle async adapters? #323

s1n7ax opened this issue Nov 21, 2023 Discussed in #322 · 1 comment

Comments

@s1n7ax
Copy link

s1n7ax commented Nov 21, 2023

Discussed in #322

Originally posted by s1n7ax November 19, 2023
I'm working on https://github.com/nvim-java/nvim-java. So far, I have created only two APIs to run tests.

  • run_current_test_class
  • debug_current_test_class

Both these are ran using nvim-dap & test discovery is done by communicating to jdtls language server.

However, I would like to have an adapter so I can get all the neotest features come with it. However, I don't really understand how to do asynchronous stuff from the given adapter interface. I can see that you have the @async annotation in each method, however, there is no callback function passed to any APIs.

So I would like to get help on

  • doing async stuff
    For instance, there is a language sever command for checking if the given file is a test or not in jdtls. It's java.project.isTestFile. However calling this has to be done asynchronously. So my adapter function should look like this with a callback function. But looking at the interface there is not? So how should this be handled?
adapter.is_test_file = function(file_path, callback)
	jdtls.executeCommand({
		command = 'java.project.isTestFile',
		arguments = { uri },
	}, function(err, is_test_file)
		assert(err, 'could not check the file')

		callback(is_test_file)
	end)
end
  • What should build_spec return? Is it a dap laucher config?
@rcarriga
Copy link
Collaborator

Closing and continuing in discussion linked

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

No branches or pull requests

2 participants