Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ build --spawn_strategy=sandboxed
build --sandbox_default_allow_network=false

common --remote_cache=
common --disk_cache=/home/user/.cache/bzl-scip-lsp
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ jobs:
go install golang.org/x/tools/cmd/goimports@latest

- name: Format check - Go
run: bazel run //tools:goimports_check
run: bazel run //tools:goimports -- check

- name: Format check - Python (black)
run: bazel run //tools:black_check

- name: Format check - Python (isort)
run: bazel run //tools:isort_check

- name: Build all targets
run: bazel build //...

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# scip-lsp

A Java project built with Bazel (using Bzlmod) that implements a SCIP aggregator for Java code intelligence.
A language agnostic language server that uses [SCIP]{github.com/sourcegraph/scip} as it's index source. Built with Bazel for Bazel.

## Overview

This project provides a Java implementation for generating SCIP (Source Code Intelligence Protocol) indices for Java codebases. It helps Sourcegraph provide precise code navigation, references, and hover documentation for Java projects.
This project includes a Go based Language Server that handles ingesting SCIP files, as well as a SCIP generator for Bazel.

## Prerequisites

Expand Down
2 changes: 0 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
# pip-compile --output-file=requirements.lock requirements.txt
#
--index-url http://artifactory.uber.internal:4587/artifactory/api/pypi/pypi/simple/
--trusted-host artifactory.uber.internal

black==25.1.0
# via -r requirements.txt
Expand Down
991 changes: 497 additions & 494 deletions src/extension/package-lock.json

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ load("@scip_lsp_pip_deps//:requirements.bzl", "requirement")

# Go formatting and linting
sh_binary(
name = "goimports_check",
srcs = ["goimports_check.sh"],
name = "goimports",
srcs = ["goimports.sh"],
data = ["@rules_go//go"],
visibility = ["//visibility:public"],
)

sh_binary(
name = "goimports_fix",
srcs = ["goimports_fix.sh"],
data = ["@rules_go//go"],
visibility = ["//visibility:public"],
)

# Python formatting and linting
py_binary(
Expand Down
86 changes: 86 additions & 0 deletions tools/goimports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash
set -euo pipefail

# Unified goimports tool. Usage:
# goimports_common.sh check # verify formatting (default)
# goimports_common.sh fix # apply formatting
# Environment variables:
# GOIMPORTS_PATHS Space separated list of directories / files to process (default: src)

MODE="${1:-check}"
TARGET_PATHS=${GOIMPORTS_PATHS:-src}

echo "goimports mode: $MODE"

go_root_workspace() {
if [[ "$PWD" == *"execroot"* ]]; then
if [ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]; then
cd "$BUILD_WORKSPACE_DIRECTORY"
echo "Changed to workspace directory: $BUILD_WORKSPACE_DIRECTORY"
fi
fi
}

setup_path() {
GOBIN_DIR="$(go env GOBIN || true)"
if [ -z "${GOBIN_DIR}" ]; then
GOBIN_DIR="$(go env GOPATH)/bin"
fi
export PATH="$GOBIN_DIR:$PATH"
}

ensure_goimports() {
if ! command -v goimports >/dev/null 2>&1; then
echo "Installing goimports..."
go install golang.org/x/tools/cmd/goimports@latest
fi
if ! command -v goimports >/dev/null 2>&1; then
echo "goimports not found after installation" >&2
exit 2
fi
}

run_check() {
# We run once for listing; goimports does not accept multiple dirs with -l reliably when globs missing
unformatted=""
for p in $TARGET_PATHS; do
# Accumulate outputs; ignore errors for non-existing paths
if [ -e "$p" ]; then
out=$(goimports -l "$p" || true)
if [ -n "$out" ]; then
unformatted+="$out\n"
fi
fi
done
if [ -n "$unformatted" ]; then
echo "The following Go files need import formatting:" | sed 's/\\n$//'
# De-duplicate & sort
printf "%b" "$unformatted" | sed '/^$/d' | sort -u
echo ""
echo "Run 'bazel run //tools:goimports_fix' to fix formatting"
exit 1
fi
echo "All Go imports are properly formatted"
}

run_fix() {
for p in $TARGET_PATHS; do
if [ -e "$p" ]; then
goimports -w "$p"
fi
done
echo "Go imports formatting applied"
}

main() {
go_root_workspace
setup_path
ensure_goimports
case "$MODE" in
check) run_check ;;
fix) run_fix ;;
*) echo "Unknown mode: $MODE (expected 'check' or 'fix')" >&2; exit 3 ;;
esac
}

main "$@"
34 changes: 0 additions & 34 deletions tools/goimports_check.sh

This file was deleted.

25 changes: 0 additions & 25 deletions tools/goimports_fix.sh

This file was deleted.

Loading