chore: update & format manifests & bindings

syntax_id
Amaan Qureshi 2023-07-26 02:05:59 +07:00
parent 2e2dd6b434
commit f18130bae7
No known key found for this signature in database
GPG Key ID: E67890ADC4227273
9 changed files with 43 additions and 45 deletions

4
.gitattributes vendored

@ -1,2 +1,6 @@
/src/** linguist-vendored /src/** linguist-vendored
/examples/* linguist-vendored /examples/* linguist-vendored
src/grammar.json -diff
src/node-types.json -diff
src/parser.c -diff

@ -14,12 +14,7 @@ repository = "https://github.com/tree-sitter/tree-sitter-go"
edition = "2018" edition = "2018"
build = "bindings/rust/build.rs" build = "bindings/rust/build.rs"
include = [ include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]
"bindings/rust/*",
"grammar.js",
"queries/*",
"src/*",
]
[lib] [lib]
path = "bindings/rust/lib.rs" path = "bindings/rust/lib.rs"

@ -1,5 +1,4 @@
tree-sitter-go # tree-sitter-go
===========================
[![Build/test](https://github.com/tree-sitter/tree-sitter-go/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-go/actions/workflows/ci.yml) [![Build/test](https://github.com/tree-sitter/tree-sitter-go/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-go/actions/workflows/ci.yml)

@ -1,10 +1,10 @@
#include "nan.h"
#include "tree_sitter/parser.h" #include "tree_sitter/parser.h"
#include <node.h> #include <node.h>
#include "nan.h"
using namespace v8; using namespace v8;
extern "C" TSLanguage * tree_sitter_go(); extern "C" TSLanguage *tree_sitter_go();
namespace { namespace {
@ -16,10 +16,12 @@ void Init(Local<Object> exports, Local<Object> module) {
tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->InstanceTemplate()->SetInternalFieldCount(1);
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked(); Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); Local<Object> instance =
constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_go()); Nan::SetInternalFieldPointer(instance, 0, tree_sitter_go());
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("go").ToLocalChecked()); Nan::Set(instance, Nan::New("name").ToLocalChecked(),
Nan::New("go").ToLocalChecked());
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
} }

@ -1,19 +1,19 @@
try { try {
module.exports = require("../../build/Release/tree_sitter_go_binding"); module.exports = require('../../build/Release/tree_sitter_go_binding');
} catch (error1) { } catch (error1) {
if (error1.code !== 'MODULE_NOT_FOUND') { if (error1.code !== 'MODULE_NOT_FOUND') {
throw error1; throw error1;
} }
try { try {
module.exports = require("../../build/Debug/tree_sitter_go_binding"); module.exports = require('../../build/Debug/tree_sitter_go_binding');
} catch (error2) { } catch (error2) {
if (error2.code !== 'MODULE_NOT_FOUND') { if (error2.code !== 'MODULE_NOT_FOUND') {
throw error2; throw error2;
} }
throw error1 throw error1;
} }
} }
try { try {
module.exports.nodeTypeInfo = require("../../src/node-types.json"); module.exports.nodeTypeInfo = require('../../src/node-types.json');
} catch (_) {} } catch (_) {}

@ -6,16 +6,16 @@ file. (Note that you will probably also need to depend on the
[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful [`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful
way.) way.)
``` toml ```toml
[dependencies] [dependencies]
tree-sitter = "0.20" tree-sitter = "0.20"
tree-sitter-go = "0.19" tree-sitter-go = "0.19"
``` ```
Typically, you will use the [language][language func] function to add this Typically, you will use the [language][language] function to add this
grammar to a tree-sitter [Parser][], and then use the parser to parse some code: grammar to a tree-sitter [Parser][], and then use the parser to parse some code:
``` rust ```rust
let code = r#" let code = r#"
func double(x int) int { func double(x int) int {
return x * 2 return x * 2
@ -29,8 +29,7 @@ let parsed = parser.parse(code, None);
If you have any questions, please reach out to us in the [tree-sitter If you have any questions, please reach out to us in the [tree-sitter
discussions] page. discussions] page.
[Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html [language]: https://docs.rs/tree-sitter-go/*/tree_sitter_go/fn.language.html
[language func]: https://docs.rs/tree-sitter-go/*/tree_sitter_go/fn.language.html
[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
[tree-sitter]: https://tree-sitter.github.io/ [tree-sitter]: https://tree-sitter.github.io/
[tree-sitter crate]: https://crates.io/crates/tree-sitter [tree-sitter crate]: https://crates.io/crates/tree-sitter

@ -1,7 +1,7 @@
fn main() { fn main() {
let src_dir = std::path::Path::new("src"); let src_dir = std::path::Path::new("src");
let mut c_config = cc::Build::new(); let mut c_config = cc::Build::new();
c_config.include(&src_dir); c_config.include(src_dir);
c_config c_config
.flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable") .flag_if_supported("-Wno-unused-but-set-variable")

@ -19,10 +19,9 @@
//! "#; //! "#;
//! let mut parser = Parser::new(); //! let mut parser = Parser::new();
//! parser.set_language(tree_sitter_go::language()).expect("Error loading Go grammar"); //! parser.set_language(tree_sitter_go::language()).expect("Error loading Go grammar");
//! let parsed = parser.parse(code, None); //! let parsed = parser.parse(code, None).unwrap();
//! # let parsed = parsed.unwrap(); //! let root = parsed.root_node();
//! # let root = parsed.root_node(); //! assert!(!root.has_error());
//! # assert!(!root.has_error());
//! ``` //! ```
//! //!
//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html //! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
@ -44,18 +43,18 @@ pub fn language() -> Language {
} }
/// The source of the Go tree-sitter grammar description. /// The source of the Go tree-sitter grammar description.
pub const GRAMMAR: &'static str = include_str!("../../grammar.js"); pub const GRAMMAR: &str = include_str!("../../grammar.js");
/// The syntax highlighting query for this language. /// The syntax highlighting query for this language.
pub const HIGHLIGHT_QUERY: &'static str = include_str!("../../queries/highlights.scm"); pub const HIGHLIGHT_QUERY: &str = include_str!("../../queries/highlights.scm");
/// The content of the [`node-types.json`][] file for this grammar. /// The content of the [`node-types.json`][] file for this grammar.
/// ///
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json"); pub const NODE_TYPES: &str = include_str!("../../src/node-types.json");
/// The symbol tagging query for this language. /// The symbol tagging query for this language.
pub const TAGGING_QUERY: &'static str = include_str!("../../queries/tags.scm"); pub const TAGGING_QUERY: &str = include_str!("../../queries/tags.scm");
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {