Skip to content

Commit

Permalink
Use language names (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanheule committed Sep 3, 2024
1 parent d24ceef commit 2d495d6
Show file tree
Hide file tree
Showing 64 changed files with 14 additions and 44 deletions.
2 changes: 1 addition & 1 deletion polyglot_piranha.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from __future__ import annotations
from typing import List, Optional, Literal

# Languages that Piranha supports (see ./src/models/language.rs)
PiranhaLanguage = Literal["java", "kt", "kotlin", "go", "py", "swift", "ts", "tsx", "thrift", "strings", "scm", "scala", "rb", "yaml", "yml"]
PiranhaLanguage = Literal["java", "kt", "kotlin", "go", "python", "swift", "typescript", "tsx", "thrift", "strings", "scm", "scala", "ruby", "yaml", "yml"]


def execute_piranha(piranha_argument: PiranhaArguments) -> list[PiranhaOutputSummary]:
Expand Down
6 changes: 3 additions & 3 deletions src/models/default_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ pub const JAVA_CS: &str = "java_cs";
pub const KOTLIN: &str = "kt";
pub const KOTLIN_ALIAS: &str = "kotlin";
pub const GO: &str = "go";
pub const PYTHON: &str = "py";
pub const PYTHON: &str = "python";
pub const SWIFT: &str = "swift";
pub const TYPESCRIPT: &str = "ts";
pub const TYPESCRIPT: &str = "typescript";
pub const TSX: &str = "tsx";
pub const THRIFT: &str = "thrift";
pub const STRINGS: &str = "strings";
pub const TS_SCHEME: &str = "scm"; // We support scheme files that contain tree-sitter query
pub const SCALA: &str = "scala";
pub const RUBY: &str = "rb";
pub const RUBY: &str = "ruby";
pub const YAML: &str = "yaml";
pub const YAML_ALIAS: &str = "yml";

Expand Down
6 changes: 3 additions & 3 deletions src/models/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl std::str::FromStr for PiranhaLanguage {
})
}
PYTHON => Ok(PiranhaLanguage {
extension: language.to_string(),
extension: "py".to_string(),
supported_language: SupportedLanguage::Python,
language: tree_sitter_python::language(),
rules: None,
Expand All @@ -219,7 +219,7 @@ impl std::str::FromStr for PiranhaLanguage {
})
}
TYPESCRIPT => Ok(PiranhaLanguage {
extension: language.to_string(),
extension: "ts".to_string(),
supported_language: SupportedLanguage::Ts,
language: tree_sitter_typescript::language_typescript(),
rules: None,
Expand Down Expand Up @@ -278,7 +278,7 @@ impl std::str::FromStr for PiranhaLanguage {
let ruby_rules: Rules = parse_toml(include_str!("../cleanup_rules/ruby/rules.toml"));
let ruby_edges: Edges = parse_toml(include_str!("../cleanup_rules/ruby/edges.toml"));
Ok(PiranhaLanguage {
extension: language.to_string(),
extension: "rs".to_string(),
supported_language: SupportedLanguage::Ruby,
language: tree_sitter_ruby::language(),
scopes: parse_toml::<ScopeConfig>(include_str!(
Expand Down
1 change: 0 additions & 1 deletion src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ mod test_piranha_scala;

mod test_piranha_thrift;

mod test_piranha_ruby;
mod test_piranha_scm;
mod test_piranha_strings;
mod test_piranha_yaml;
Expand Down
11 changes: 7 additions & 4 deletions src/tests/test_piranha_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ fn test_delete_modify_str_literal_from_list_via_cli() {

let mut cmd = Command::cargo_bin("polyglot_piranha").unwrap();
cmd
.args(["-c", "test-resources/py/delete_cleanup_str_in_list/input"])
.args([
"-c",
"test-resources/python/delete_cleanup_str_in_list/input",
])
.args([
"-f",
"test-resources/py/delete_cleanup_str_in_list/configurations",
"test-resources/python/delete_cleanup_str_in_list/configurations",
])
.args(["-l", "py"])
.args(["-l", "python"])
.args(["-j", temp_file.to_str().unwrap()])
.arg("--dry-run")
.args(["-s", "str_literal=dependency2"])
Expand All @@ -50,7 +53,7 @@ fn test_delete_modify_str_literal_from_list_via_cli() {
let content = read_file(&temp_file).unwrap();
let output: Vec<PiranhaOutputSummary> = serde_json::from_str(&content).unwrap();
let expected_path =
Path::new("test-resources/py/delete_cleanup_str_in_list/expected/only_lists.py");
Path::new("test-resources/python/delete_cleanup_str_in_list/expected/only_lists.py");
let expected = read_file(&expected_path.to_path_buf()).unwrap();
assert!(eq_without_whitespace(output[0].content(), &expected));

Expand Down
32 changes: 0 additions & 32 deletions src/tests/test_piranha_ruby.rs

This file was deleted.

0 comments on commit 2d495d6

Please sign in to comment.