Skip to content

Commit b931a2e

Browse files
authored
Add codesearch feature (#33)
Integrates Bzl codeesearch with the vscode extension
2 parents c53b85b + dd7cab9 commit b931a2e

68 files changed

Lines changed: 3998 additions & 161 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
out
22
tmp
33
node_modules
4-
.vscode
54
.vscode-test/
65
*.vsix
76
vendor

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.vscode/launch.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"runtimeExecutable": "${execPath}",
13+
"args": [
14+
"--extensionDevelopmentPath=${workspaceFolder}"
15+
],
16+
"outFiles": [
17+
"${workspaceFolder}/out/**/*.js"
18+
],
19+
"preLaunchTask": "${defaultBuildTask}"
20+
},
21+
{
22+
"name": "Extension Tests",
23+
"type": "extensionHost",
24+
"request": "launch",
25+
"runtimeExecutable": "${execPath}",
26+
"args": [
27+
"--extensionDevelopmentPath=${workspaceFolder}",
28+
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
29+
],
30+
"outFiles": [
31+
"${workspaceFolder}/out/test/**/*.js"
32+
],
33+
"preLaunchTask": "${defaultBuildTask}"
34+
}
35+
]
36+
}

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"files.exclude": {
4+
"out": false // set this to true to hide the "out" folder with the compiled JS files
5+
},
6+
"search.exclude": {
7+
"out": true // set this to false to include "out" folder in search results
8+
},
9+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10+
"typescript.tsc.autoDetect": "off"
11+
}

.vscode/tasks.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// for the documentation about the tasks.json format
3+
{
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$tsc-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
}
18+
}
19+
]
20+
}

docs/searching.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: default
3+
title: Searching
4+
permalink: /searching
5+
nav_order: 5
6+
---
7+
8+
## Codesearch
9+
10+
<p></p>
11+
12+
The codesearch feature allows one to:
13+
14+
1. create a search index of source files
15+
defined by a bazel query
16+
1. query the index (optionally with regular expressions).
17+
18+
To define a codesearch index, add a line to your `launch.bazelrc` such as:
19+
20+
```
21+
codesearch deps(//...)
22+
```
23+
24+
Upon save, vscode will add two *code lenses* above the line:
25+
26+
![codesearch-define](https://user-images.githubusercontent.com/50580/96071853-3abc4b80-0e60-11eb-8d3b-897004d5bd8c.gif)
27+
28+
- To (re-)create the index, click the `Index` lens.
29+
- To search, click the `Search` lens.
30+
- Click on a matching line to nagivate to the file.
31+
32+
Display of the code lenses is dependent on knowing which bazel workspace you are
33+
operating within, so if you don't see them after opening your `launch.bazelrc`
34+
file, open the Bazel activity view pane.
35+
36+
> Note that you are responsible for updating the index manually, there isn't
37+
currently a way to have the index automatically be updated.

package-lock.json

Lines changed: 78 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)