vscode-bazel icon indicating copy to clipboard operation
vscode-bazel copied to clipboard

"Build/Test Target" only work from bazel target panel

Open ashi009 opened this issue 5 years ago • 2 comments

Currently "Build/Test Target" commands only work from bazel target panel, and that panel is not very useful when there are hundreds of targets (eg. in a monolithic repo). Any attempt to run those commands from a build file or source file will result in a failure like "Running the contributed command:'bazel.buildTarget' failed."

[2018-12-27 02:23:24.051] [exthost] [error] TypeError: Cannot read property 'getBazelCommandArgs' of undefined
    at bazelBuildTarget (/Users/xiaoyi/.vscode/extensions/bazelbuild.vscode-bazel-0.0.2/out/src/extension/extension.js:41:26)
    at e._executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:501:455)
    at e.$executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:502:6)
    at t._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:658:837)
    at t._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:658:509)
    at t._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:657:126)
    at t._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:656:59)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:653:895
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:130:793
    at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:133:218)
    at a (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:186:147)
    at Socket.n._socketDataListener (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:186:368)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20) bazel.buildTarget

I think there should be an option to run those commands directly from source code, the target could be as simple as :all or dynamically queried based on the bazel package that the focusing file belongs to (basically iterate through all the parent directories to find the build file). Which will eliminate the initial query time, and make the extension scale in a large repo.

ashi009 avatar Dec 26 '18 18:12 ashi009

The main issue you describe is a duplicate of #23. It was addressed by #28, but we haven't pushed it out in a release yet (I'll do one after the holidays). The new behavior is to pop up a quick-pick with the target list when the command is run from the command palette.

That being said, you're right that in a large repo, the query to populate the quick pick is still going to take a long time to complete. I do like the idea of trying to be smarter about it based on context by doing something like querying the targets in the package closest to the active file, so I'll keep this issue open for that particular feature.

allevato avatar Dec 26 '18 21:12 allevato

Also opened #83 for the general question of should the quickpicks be rooted at the workspace folder (like the tree view). It seems a little odd that the command pallet/quick picks support all targets while the tree doesn't.

thomasvl avatar Apr 09 '19 20:04 thomasvl