Merge branch 'master' into query-cursor-api
This commit is contained in:
commit
f3ea60e23f
11 changed files with 150 additions and 119 deletions
|
|
@ -1645,6 +1645,7 @@ fn test_query_matches_with_too_many_permutations_to_track() {
|
|||
parser.set_language(language).unwrap();
|
||||
let tree = parser.parse(&source, None).unwrap();
|
||||
let mut cursor = QueryCursor::new();
|
||||
cursor.set_match_limit(32);
|
||||
let matches = cursor.matches(&query, tree.root_node(), source.as_bytes());
|
||||
|
||||
// For this pathological query, some match permutations will be dropped.
|
||||
|
|
@ -1686,6 +1687,7 @@ fn test_query_matches_with_alternatives_and_too_many_permutations_to_track() {
|
|||
parser.set_language(language).unwrap();
|
||||
let tree = parser.parse(&source, None).unwrap();
|
||||
let mut cursor = QueryCursor::new();
|
||||
cursor.set_match_limit(32);
|
||||
let matches = cursor.matches(&query, tree.root_node(), source.as_bytes());
|
||||
|
||||
assert_eq!(
|
||||
|
|
@ -2905,6 +2907,7 @@ fn test_query_captures_with_too_many_nested_results() {
|
|||
parser.set_language(language).unwrap();
|
||||
let tree = parser.parse(&source, None).unwrap();
|
||||
let mut cursor = QueryCursor::new();
|
||||
cursor.set_match_limit(32);
|
||||
let captures = cursor.captures(&query, tree.root_node(), source.as_bytes());
|
||||
let captures = collect_captures(captures, &query, &source);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use super::generate::parse_grammar::GrammarJSON;
|
|||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use which::which;
|
||||
|
||||
|
|
@ -23,15 +22,15 @@ pub fn compile_language_to_wasm(language_dir: &Path, force_docker: bool) -> Resu
|
|||
let grammar_name = get_grammar_name(&src_dir)?;
|
||||
let output_filename = format!("tree-sitter-{}.wasm", grammar_name);
|
||||
|
||||
let emcc_bin = if cfg!(windows) { "emcc.bat" } else { "emcc" };
|
||||
let emcc_path = which(emcc_bin)
|
||||
.ok()
|
||||
.and_then(|p| Command::new(&p).output().and(Ok(p)).ok());
|
||||
|
||||
let mut command;
|
||||
if !force_docker {
|
||||
let emcc_path = get_emcc_path();
|
||||
if emcc_path.is_ok() {
|
||||
command = Command::new(emcc_path.unwrap());
|
||||
command.current_dir(&language_dir);
|
||||
} else {
|
||||
return Err(emcc_path.unwrap_err());
|
||||
}
|
||||
if !force_docker && emcc_path.is_some() {
|
||||
command = Command::new(emcc_path.unwrap());
|
||||
command.current_dir(&language_dir);
|
||||
} else if Command::new("docker").output().is_ok() {
|
||||
command = Command::new("docker");
|
||||
command.args(&["run", "--rm"]);
|
||||
|
|
@ -123,23 +122,3 @@ pub fn compile_language_to_wasm(language_dir: &Path, force_docker: bool) -> Resu
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_emcc_path() -> Result<PathBuf> {
|
||||
let emcc_bin;
|
||||
if cfg!(windows) {
|
||||
emcc_bin = "emcc.bat";
|
||||
} else {
|
||||
emcc_bin = "emcc";
|
||||
};
|
||||
let emcc_which = which(emcc_bin);
|
||||
let emcc_path;
|
||||
if emcc_which.is_ok() {
|
||||
emcc_path = emcc_which.unwrap();
|
||||
} else {
|
||||
return Error::err("emcc was not found on PATH".to_string());
|
||||
}
|
||||
if Command::new(&emcc_path).output().is_ok() {
|
||||
return Ok(emcc_path);
|
||||
}
|
||||
return Error::err("emcc binary doesn't work properly".to_string());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue