feat: add Explorer context menu to add directory to Bazel project scope#32
Merged
monkey666-cr merged 1 commit intoJun 3, 2026
Conversation
Right-clicking a directory in VS Code Explorer now shows "Bazel: Add to Project" under a dedicated bazel-jdt group. The action appends the directory to the existing .bazelproject (or creates one), which triggers the file watcher to reimport with the expanded scope. Also fix handleImportProject() to create Eclipse projects for newly discovered targets — previously only BazelProjectImporter (run once at JDT.LS startup) created projects, so targets from a scope-change reimport were never registered with JDT, causing "Main class does not exist" errors when debugging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
09c9cf9 to
ff6cb56
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.bazelproject(or creates the file if absent), which triggers the existing file watcher to reimport with the expanded scopeBUILDorBUILD.bazelfile exists in the selected directory before modifying.bazelprojectChanges
vscode-extension/package.json: registerbazel-jdt.addDirectoryToProjectcommand andexplorer/contextmenu contribution (groupbazel-jdt@1,when: explorerResourceIsFolder)vscode-extension/src/bazelproject.ts: addaddDirectoryToBazelproject()— inserts directory into existingdirectories:section or creates a minimal.bazelprojectvscode-extension/src/commands.ts: addregisterAddDirectoryCommand()— validates BUILD file exists, computes relative path, callsaddDirectoryToBazelprojectvscode-extension/src/extension.ts: register new command in both activation paths (with and without existing.bazelproject)Test plan
BUILDfile → "Bazel: Add to Project" appears in context menu under abazel-jdtgroup.bazelproject, reimport triggers automaticallyBUILDfile → warning message shown, no change to.bazelproject🤖 Generated with Claude Code