Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
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
98 changes: 97 additions & 1 deletion docker-images/syntax-highlighter/Cargo.Bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions docker-images/syntax-highlighter/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docker-images/syntax-highlighter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ tree-sitter-highlight = "0.20.1"
walkdir = "2"
path-clean = "1"
camino = "1.1"
nom = "7.1.3"

scip = "0.3.2"
protobuf = "3"
Expand Down
16 changes: 11 additions & 5 deletions docker-images/syntax-highlighter/crates/scip-syntax/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ WORKSPACE_DEPS = [
rust_library(
name = "scip_syntax_lib",
srcs = glob(
[
"src/*.rs",
],
["src/**/*.rs"],
allow_empty = False,
exclude = ["src/main.rs"],
),
Expand All @@ -49,7 +47,11 @@ rust_library(
rust_test(
name = "unit_test",
size = "small",
srcs = glob(["src/*.rs"]),
srcs = glob(
["src/**/*.rs"],
allow_empty = False,
exclude = ["src/main.rs"],
),
proc_macro_deps = all_crate_deps(
proc_macro = True,
),
Expand All @@ -68,7 +70,11 @@ rust_test(
rust_test(
name = "integration_test",
size = "small",
srcs = glob(["tests/*.rs"]),
srcs = glob(
["src/**/*.rs"],
allow_empty = False,
exclude = ["src/main.rs"],
),
compile_data = glob(
[
"testdata/**",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ edition = "2021"
[[bin]]
name = "scip-syntax"

[[bench]]
name = "symbol_parsing"
harness = false

[dependencies]
assert_cmd = "2.0.12"
predicates = "3.0.4"
Expand All @@ -26,10 +30,12 @@ walkdir = { workspace = true }
path-clean = { workspace = true }
camino = { workspace = true }
tree-sitter = { workspace = true }
nom = { workspace = true }

syntax-analysis = { path = "../syntax-analysis" }
tree-sitter-all-languages = { path = "../tree-sitter-all-languages" }
tar = "0.4.40"

[dev-dependencies]
tempfile="3.10.1"
criterion = { version = "0.4", features = ["html_reports"] }
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use camino::Utf8Path;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use scip_syntax::{io::read_index_from_file, scip_strict};

fn parse_symbols(symbols: &[&str]) {
for symbol in symbols {
scip::symbol::parse_symbol(symbol).unwrap();
}
}

fn parse_symbols_v2(symbols: &[&str]) {
for symbol in symbols {
scip_strict::Symbol::parse(&symbol).unwrap();
}
}

fn symbols_from_index(path: &str) -> impl Iterator<Item = String> {
let index = read_index_from_file(Utf8Path::new(path))
.unwrap();
index
.documents
.into_iter()
.flat_map(|document| {
document
.occurrences
.into_iter()
.map(|occurrence| occurrence.symbol)
})
}

fn bench_symbol_parsing(c: &mut Criterion) {
// let all_symbols: Vec<String> = symbols_from_index("~/work/scip-indices/spring-framework-syntactic.scip").collect();
let all_symbols: Vec<String> = symbols_from_index("/Users/creek/work/scip-indices/chromium-1.scip").collect();
let mut group = c.benchmark_group("symbol parsing");
for n in [10_000, 100_000, 1_000_000] {
let symbols: Vec<&str> = all_symbols.iter().take(n).map(|s| s.as_str()).collect();
group.bench_with_input(BenchmarkId::new("parse_v1", n), &symbols, |b, syms| {
b.iter(|| parse_symbols(syms))
});
group.bench_with_input(BenchmarkId::new("parse_v2", n), &symbols, |b, syms| {
b.iter(|| parse_symbols_v2(syms))
});
}
}

criterion_group!(benches, bench_symbol_parsing);
criterion_main!(benches);
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::Serializer;
use string_interner::{symbol::SymbolU32, StringInterner, Symbol};
use syntax_analysis::range::Range;

use crate::{io::read_index_from_file, progress::*};
use crate::{io::read_index_from_file, progress::*, scip_strict};

pub fn evaluate_command(
candidate: &Utf8Path,
Expand Down Expand Up @@ -731,16 +731,12 @@ impl SymbolFormatter {

fn try_strip_package_details<T: Copy>(&mut self, sym: SymbolId<T>) -> SymbolId<T> {
let s = self.display_symbol(sym);
if s.as_bytes().iter().filter(|&c| *c == b' ').count() != 5 {
let Result::Ok(scip_strict::Symbol::NonLocal(mut symbol)) = scip_strict::Symbol::parse(s)
else {
return sym;
}
let parts: Vec<&str> = s.splitn(5, ' ').collect();
let scheme = parts[0];
let _manager = parts[1];
let _package_name = parts[2];
let _version = parts[3];
let descriptor = parts[4];
self.make_symbol_id(&format!("{scheme} . . . {descriptor}"))
};
symbol.package = scip_strict::Package::default();
self.make_symbol_id(&symbol.to_string())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pub mod evaluate;
pub mod index;
pub mod io;
pub mod progress;
pub mod scip_strict;
Loading