Release tree-sitter-stack-graphs v0.9.0

Includes a bit of code cleanup.
This commit is contained in:
Hendrik van Antwerpen 2024-07-09 15:47:20 +02:00
Родитель f715ed1ba2
Коммит 106c728e1d
21 изменённых файлов: 46 добавлений и 144 удалений

Просмотреть файл

@ -41,8 +41,8 @@ cli = ["anyhow", "clap", "tree-sitter-stack-graphs/cli"]
anyhow = { version = "1.0", optional = true }
clap = { version = "4", features = ["derive"], optional = true }
tree-sitter-java = { version = "=0.20.2" }
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs" }
tree-sitter-stack-graphs = { path = "../../tree-sitter-stack-graphs" }
[dev-dependencies]
anyhow = { version = "1.0" }
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs", features = ["cli"] }
tree-sitter-stack-graphs = { path = "../../tree-sitter-stack-graphs", features = ["cli"] }

Просмотреть файл

@ -14,8 +14,6 @@ pub const STACK_GRAPHS_BUILTINS_PATH: &str = "src/builtins.java";
/// The stack graphs builtins source for this language.
pub const STACK_GRAPHS_BUILTINS_SOURCE: &str = include_str!("../src/builtins.java");
/// The name of the file path global variable
pub const FILE_PATH_VAR: &str = "FILE_PATH";
/// The name of the project name global variable
pub const PROJECT_NAME_VAR: &str = "PROJECT_NAME";

Просмотреть файл

@ -33,8 +33,8 @@ serde_json = "1.0"
stack-graphs = { path = "../../stack-graphs" }
tree-sitter-graph = "0.11.2"
tree-sitter-javascript = "=0.20.4"
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs" }
tree-sitter-stack-graphs = { path = "../../tree-sitter-stack-graphs" }
[dev-dependencies]
anyhow = "1.0"
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs", features = ["cli"] }
tree-sitter-stack-graphs = { path = "../../tree-sitter-stack-graphs", features = ["cli"] }

Просмотреть файл

@ -26,8 +26,7 @@ pub const STACK_GRAPHS_BUILTINS_PATH: &str = "src/builtins.js";
/// The stack graphs builtins source for this language.
pub const STACK_GRAPHS_BUILTINS_SOURCE: &str = include_str!("../src/builtins.js");
/// The name of the file path global variable.
pub const FILE_PATH_VAR: &str = "FILE_PATH";
/// The name of the project name global variable
pub const PROJECT_NAME_VAR: &str = "PROJECT_NAME";
pub fn language_configuration(cancellation_flag: &dyn CancellationFlag) -> LanguageConfiguration {

Просмотреть файл

@ -30,9 +30,9 @@ cli = ["anyhow", "clap", "tree-sitter-stack-graphs/cli"]
[dependencies]
anyhow = { version = "1.0", optional = true }
clap = { version = "4", optional = true, features = ["derive"] }
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs" }
tree-sitter-stack-graphs = { path = "../../tree-sitter-stack-graphs" }
tree-sitter-python = "=0.20.4"
[dev-dependencies]
anyhow = "1.0"
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs", features = ["cli"] }
tree-sitter-stack-graphs = { path = "../../tree-sitter-stack-graphs", features = ["cli"] }

Просмотреть файл

@ -21,9 +21,6 @@ pub const STACK_GRAPHS_BUILTINS_PATH: &str = "src/builtins.py";
/// The stack graphs builtins source for this language.
pub const STACK_GRAPHS_BUILTINS_SOURCE: &str = include_str!("../src/builtins.py");
/// The name of the file path global variable.
pub const FILE_PATH_VAR: &str = "FILE_PATH";
pub fn language_configuration(cancellation_flag: &dyn CancellationFlag) -> LanguageConfiguration {
try_language_configuration(cancellation_flag).unwrap_or_else(|err| panic!("{}", err))
}

Просмотреть файл

@ -33,13 +33,13 @@ glob = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
stack-graphs = { path = "../../stack-graphs" }
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs" }
tree-sitter-stack-graphs = { path = "../../tree-sitter-stack-graphs" }
tree-sitter-typescript = "=0.20.2"
tsconfig = "0.1.0"
[dev-dependencies]
anyhow = { version = "1.0" }
tree-sitter-stack-graphs = { version = "0.8", path = "../../tree-sitter-stack-graphs", features = ["cli"] }
tree-sitter-stack-graphs = { path = "../../tree-sitter-stack-graphs", features = ["cli"] }
[build-dependencies]
anyhow = { version = "1.0" }

Просмотреть файл

@ -31,8 +31,6 @@ pub const STACK_GRAPHS_BUILTINS_PATH: &str = "src/builtins.ts";
/// The stack graphs builtins source for this language
pub const STACK_GRAPHS_BUILTINS_SOURCE: &str = include_str!("../src/builtins.ts");
/// The name of the file path global variable
pub const FILE_PATH_VAR: &str = "FILE_PATH";
/// The name of the project name global variable
pub const PROJECT_NAME_VAR: &str = "PROJECT_NAME";

Просмотреть файл

@ -5,18 +5,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.8.2 -- unreleased
## v0.9.0 -- 2024-07-09
### Library
- New crate-level constants `FILE_PATH_VAR` and `ROOT_PATH_VAR` standardize the TSG global variable names to use for the file and root path.
- The file path variable will only use the filename set in the stack graph if no value was explicitly set.
### CLI
#### Added
- Tests run faster for languages with builtins sources by caching the partial paths for the builtins.
- Indexing will set a value for the root path variable that is passed to TSG. The value is based on the directory that was provided on the command line.
#### Changed
- Failure to index a file will not abort indexing anymore, but simply mark the file as failed, as we already do for files with parse errors.
#### Removed
- The NPM distribution has been deprecated.
## v0.8.1 -- 2024-03-06
The `stack-graphs` dependency was updated to `v0.13` to fix the build problems of the `v0.8.0` release.

Просмотреть файл

@ -1,6 +1,6 @@
[package]
name = "tree-sitter-stack-graphs"
version = "0.8.2"
version = "0.9.0"
description = "Create stack graphs using tree-sitter parsers"
homepage = "https://github.com/github/stack-graphs/tree/main/tree-sitter-stack-graphs"
repository = "https://github.com/github/stack-graphs/"

Просмотреть файл

@ -14,7 +14,7 @@ To use this library, add the following to your `Cargo.toml`:
```toml
[dependencies]
tree-sitter-stack-graphs = "0.8"
tree-sitter-stack-graphs = "0.9"
```
Check out our [documentation](https://docs.rs/tree-sitter-stack-graphs/*/) for more details on how to use this library.

4
tree-sitter-stack-graphs/npm/.gitignore поставляемый
Просмотреть файл

@ -1,4 +0,0 @@
/.crates.toml
/.crates2.json
/bin/
/package-lock.json

Просмотреть файл

@ -1,13 +0,0 @@
# tree-sitter-stack-graphs
This package provides a convenient way to install the [tree-sitter-stack-graphs](https://crates.io/crates/tree-sitter-stack-graphs) CLI in an NPM project.
Add it as a dev dependency to an existing project using:
npm i -D tree-sitter-stack-graphs
It is also possible to invoke it directly using:
npx tree-sitter-stack-graphs
See the tree-sitter-stack-graphs [documentation](https://crates.io/crates/tree-sitter-stack-graphs) for details on usage.

Просмотреть файл

@ -1,15 +0,0 @@
#!/usr/bin/env node
const spawn = require("child_process").spawn;
const path = require("path");
const tssg = process.platform === "win32"
? "tree-sitter-stack-graphs.exe"
: "tree-sitter-stack-graphs";
spawn(
path.join(__dirname, "bin", tssg), process.argv.slice(2),
{
"stdio": "inherit"
},
).on('close', process.exit);

Просмотреть файл

@ -1,30 +0,0 @@
#!/usr/bin/env node
const child_process = require("child_process");
const packageJSON = require("./package.json");
const cargo = process.platform === "win32"
? "cargo.exe"
: "cargo";
try {
child_process.execSync(cargo);
} catch (error) {
console.error(error.message);
console.error("Failed to execute Cargo. Cargo needs to be available to install this package!");
process.exit(1);
}
child_process.spawn(
cargo, [
"install",
"--quiet",
"--root", ".",
"--version", "^"+packageJSON.version,
"--features", "cli",
packageJSON.name,
],
{
"stdio": "inherit"
},
).on('close', process.exit);

Просмотреть файл

@ -1,26 +0,0 @@
{
"name": "tree-sitter-stack-graphs",
"version": "0.7.0",
"description": "Create stack graphs using tree-sitter parsers",
"homepage": "https://github.com/github/stack-graphs/tree/main/tree-sitter-stack-graphs",
"repository": {
"type": "git",
"url": "https://github.com/github/stack-graphs.git"
},
"keywords": [
"tree-sitter",
"stack-graphs"
],
"license": "MIT OR Apache-2.0",
"author": "GitHub <opensource+stack-graphs@github.com>",
"contributors": [
"Douglas Creager <dcreager@dcreager.net>",
"Hendrik van Antwerpen <hendrikvanantwerpen@github.com>"
],
"bin": {
"tree-sitter-stack-graphs": "./cli.js"
},
"scripts": {
"install": "node install.js"
}
}

Просмотреть файл

@ -770,9 +770,6 @@ impl ProjectSettings<'_> {
/// The stack graphs builtins source for this language.
pub const STACK_GRAPHS_BUILTINS_SOURCE: &str = include_str!("../src/builtins.{}");
/// The name of the file path global variable.
pub const FILE_PATH_VAR: &str = "FILE_PATH";
pub fn language_configuration(cancellation_flag: &dyn CancellationFlag) -> LanguageConfiguration {{
try_language_configuration(cancellation_flag).unwrap_or_else(|err| panic!("{{}}", err))
}}

Просмотреть файл

@ -320,14 +320,12 @@ impl TestArgs {
test_fragment.add_globals_to(&mut globals);
if globals.get(&FILE_PATH_VAR.into()).is_none() {
globals
.add(
FILE_PATH_VAR.into(),
test_fragment.path.to_str().unwrap().into(),
)
.expect("failed to add file path variable");
}
globals
.add(
FILE_PATH_VAR.into(),
test_fragment.path.to_str().unwrap().into(),
)
.unwrap_or_default();
lc.sgl.build_stack_graph_into(
&mut test.graph,

Просмотреть файл

@ -440,7 +440,7 @@ pub const ROOT_NODE_VAR: &'static str = "ROOT_NODE";
/// Name of the variable used to pass the jump-to-scope node.
pub const JUMP_TO_SCOPE_NODE_VAR: &'static str = "JUMP_TO_SCOPE_NODE";
/// Name of the variable used to pass the file path.
/// If a root path is given, it should be a descendant the root path.
/// If a root path is given, it should be a descendant of the root path.
pub const FILE_PATH_VAR: &'static str = "FILE_PATH";
/// Name of the variable used to pass the root path.
/// If given, should be an ancestor of the file path.
@ -643,12 +643,10 @@ impl<'a> Builder<'a> {
let mut globals = Variables::nested(globals);
if globals.get(&ROOT_NODE_VAR.into()).is_none() {
let root_node = self.inject_node(NodeID::root());
globals
.add(ROOT_NODE_VAR.into(), root_node.into())
.expect("Failed to set ROOT_NODE");
}
let root_node = self.inject_node(NodeID::root());
globals
.add(ROOT_NODE_VAR.into(), root_node.into())
.unwrap_or_default();
let jump_to_scope_node = self.inject_node(NodeID::jump_to());
globals

Просмотреть файл

@ -83,11 +83,9 @@ impl LanguageConfiguration {
Loader::load_globals_from_config_str(builtins_config, &mut builtins_globals)?;
}
if builtins_globals.get(&FILE_PATH_VAR.into()).is_none() {
builtins_globals
.add(FILE_PATH_VAR.into(), BUILTINS_FILENAME.into())
.expect("failed to add file path variable");
}
builtins_globals
.add(FILE_PATH_VAR.into(), BUILTINS_FILENAME.into())
.unwrap_or_default();
let file = builtins.add_file(BUILTINS_FILENAME).unwrap();
sgl.build_stack_graph_into(
@ -342,11 +340,9 @@ impl Loader {
Self::load_globals_from_config_str(&config, &mut globals)?;
if globals.get(&FILE_PATH_VAR.into()).is_none() {
globals
.add(FILE_PATH_VAR.into(), BUILTINS_FILENAME.into())
.expect("failed to add file path variable");
}
globals
.add(FILE_PATH_VAR.into(), BUILTINS_FILENAME.into())
.unwrap_or_default();
sgl.build_stack_graph_into(graph, file, &source, &globals, cancellation_flag)
.map_err(|err| LoadError::Builtins {

Просмотреть файл

@ -102,14 +102,12 @@ fn check_test(
fragments.add_globals_to(&mut globals);
if globals.get(&FILE_PATH_VAR.into()).is_none() {
globals
.add(
FILE_PATH_VAR.into(),
fragments.path.to_str().unwrap().into(),
)
.expect("failed to add file path variable");
}
globals
.add(
FILE_PATH_VAR.into(),
fragments.path.to_str().unwrap().into(),
)
.unwrap_or_default();
build_stack_graph_into(
&mut test.graph,