Merge remote-tracking branch 'origin/master' into actions-ci

This commit is contained in:
Patrick Thomson 2020-11-24 13:40:09 -05:00
commit 72243e116d
6 changed files with 15 additions and 11 deletions

View file

@ -739,7 +739,7 @@ fn test_node_numeric_symbols_respect_simple_aliases() {
let root = tree.root_node();
assert_eq!(
root.to_sexp(),
"(program (binary left: (unary (identifier)) right: (identifier)))",
"(program (binary left: (unary operand: (identifier)) right: (identifier)))",
);
let binary_node = root.child(0).unwrap();

View file

@ -1507,7 +1507,7 @@ fn test_query_matches_with_supertypes() {
value: (expression) @kw_arg)
(assignment
left: (left_hand_side (identifier) @var_def))
left: (identifier) @var_def)
(primary_expression/identifier) @var_ref
"#,

View file

@ -62,6 +62,7 @@ Parsers for these languages are in development:
* [Julia](https://github.com/tree-sitter/tree-sitter-julia)
* [Nix](https://github.com/cstrahan/tree-sitter-nix)
* [Scala](https://github.com/tree-sitter/tree-sitter-scala)
* [SPARQL](https://github.com/BonaBeavis/tree-sitter-sparql)
* [Swift](https://github.com/tree-sitter/tree-sitter-swift)
### Talks on Tree-sitter

View file

@ -17,7 +17,7 @@ extern "C" tree_sitter_javascript();
Define the list of highlight names that you will recognize:
```rust
let highlight_names = [
let highlight_names : Vec<String> = [
"attribute",
"constant",
"function.builtin",
@ -93,14 +93,14 @@ let highlights = highlighter.highlight(
).unwrap();
for event in highlights {
match event? {
match event.unwrap() {
HighlightEvent::Source {start, end} => {
eprintln!("source: {}-{}", start, end);
},
HighlightEvent::HighlightStart(s) {
HighlightEvent::HighlightStart(s) => {
eprintln!("highlight style started: {:?}", s);
},
HighlightEvent::HighlightEnd {
HighlightEvent::HighlightEnd => {
eprintln!("highlight style ended");
},
}

View file

@ -1,6 +1,7 @@
use super::{Error, TagsConfiguration, TagsContext};
use std::collections::HashMap;
use std::ffi::CStr;
use std::os::raw::c_char;
use std::process::abort;
use std::sync::atomic::AtomicUsize;
use std::{fmt, slice, str};
@ -73,7 +74,7 @@ pub extern "C" fn ts_tagger_delete(this: *mut TSTagger) {
#[no_mangle]
pub extern "C" fn ts_tagger_add_language(
this: *mut TSTagger,
scope_name: *const i8,
scope_name: *const c_char,
language: Language,
tags_query: *const u8,
locals_query: *const u8,
@ -109,7 +110,7 @@ pub extern "C" fn ts_tagger_add_language(
#[no_mangle]
pub extern "C" fn ts_tagger_tag(
this: *mut TSTagger,
scope_name: *const i8,
scope_name: *const c_char,
source_code: *const u8,
source_code_len: u32,
output: *mut TSTagsBuffer,
@ -234,7 +235,7 @@ pub extern "C" fn ts_tags_buffer_found_parse_error(this: *const TSTagsBuffer) ->
#[no_mangle]
pub extern "C" fn ts_tagger_syntax_kinds_for_scope_name(
this: *mut TSTagger,
scope_name: *const i8,
scope_name: *const c_char,
len: *mut u32,
) -> *const *const i8 {
let tagger = unwrap_mut_ptr(this);

View file

@ -5,6 +5,7 @@ use regex::Regex;
use std::collections::HashMap;
use std::ffi::{CStr, CString};
use std::ops::Range;
use std::os::raw::c_char;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::{char, fmt, mem, str};
use tree_sitter::{
@ -230,8 +231,9 @@ impl TagsConfiguration {
pub fn syntax_type_name(&self, id: u32) -> &str {
unsafe {
let cstr = CStr::from_ptr(self.syntax_type_names[id as usize].as_ptr() as *const i8)
.to_bytes();
let cstr =
CStr::from_ptr(self.syntax_type_names[id as usize].as_ptr() as *const c_char)
.to_bytes();
str::from_utf8(cstr).expect("syntax type name was not valid utf-8")
}
}