Skip to content

Commit

Permalink
Merge commit '70b4fe63c4973b04cc7bd40c6b7646d9c2430db8' into update-s…
Browse files Browse the repository at this point in the history
…cala-treesitter

# Conflicts:
#	vendored_parsers/tree-sitter-scala/queries/scala/highlights.scm
  • Loading branch information
hugo-vrijswijk committed Mar 25, 2024
2 parents e34185f + 70b4fe6 commit d0c9e1d
Show file tree
Hide file tree
Showing 31 changed files with 567,935 additions and 492,798 deletions.
39 changes: 39 additions & 0 deletions vendored_parsers/tree-sitter-scala/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,toml,yml,gyp}]
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.rs]
indent_style = space
indent_size = 4

[*.{c,cc,h}]
indent_style = space
indent_size = 4

[*.{py,pyi}]
indent_style = space
indent_size = 4

[*.swift]
indent_style = space
indent_size = 4

[*.go]
indent_style = tab
indent_size = 8

[Makefile]
indent_style = tab
indent_size = 8
20 changes: 10 additions & 10 deletions vendored_parsers/tree-sitter-scala/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
- master
jobs:
changedfiles:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
all: ${{ steps.changes.outputs.all}}
c: ${{ steps.changes.outputs.c }}
gen: ${{ steps.changes.outputs.gen }}
steps:
- name: checkout tree-sitter-scala
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 10

Expand All @@ -30,39 +30,39 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-20.04, macos-latest, windows-2019]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: checkout tree-sitter-scala
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 10

- name: checkout scala/scala
if: ${{ runner.os == 'Linux' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: scala/scala
ref: v2.13.10
path: scala_scala

- name: checkout lampepfl/dotty
if: ${{ runner.os == 'Linux' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: lampepfl/dotty
ref: 3.3.0
path: dotty

- name: checkout nvim-treesitter/nvim-treesitter
if: ${{ runner.os == 'Linux' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: nvim-treesitter/nvim-treesitter
path: nvim_treesitter

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Test C stack code
run: gcc test/test-stack.c -o a.out && ./a.out
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:

- name: Check if queries are out of sync with nvim-treesitter
if: ${{ runner.os == 'Linux' }}
uses: tj-actions/verify-changed-files@v13
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Parser fuzzing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: vigoux/tree-sitter-fuzz-action@v1
with:
language: scala
Expand Down
10 changes: 7 additions & 3 deletions vendored_parsers/tree-sitter-scala/.github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:

jobs:
check-and-sync:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
all: ${{ steps.changes.outputs.all}}
c: ${{ steps.changes.outputs.c }}
steps:
- name: checkout tree-sitter-scala
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 10

Expand All @@ -27,14 +27,18 @@ jobs:
npm run format
- name: Check for changes
uses: tj-actions/verify-changed-files@v13
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: |
bindings/c/tree-sitter-scala.h
bindings/c/tree-sitter-scala.pc.in
grammar.js
src/grammar.json
src/node-types.json
src/parser.c
src/tree_sitter/alloc.h
src/tree_sitter/array.h
src/tree_sitter/parser.h
- name: Commit changes if necessary
Expand Down
6 changes: 3 additions & 3 deletions vendored_parsers/tree-sitter-scala/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "tree-sitter-scala"
description = "scala grammar for the tree-sitter parsing library"
version = "0.20.0"
version = "0.21.0"
keywords = ["incremental", "parsing", "scala"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-scala"
edition = "2018"
edition = "2021"
license = "MIT"

build = "bindings/rust/build.rs"
Expand All @@ -20,7 +20,7 @@ include = [
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "0.20.7"
tree-sitter = "0.21.0"

[build-dependencies]
cc = "1.0"
13 changes: 12 additions & 1 deletion vendored_parsers/tree-sitter-scala/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# tree-sitter-scala

[![Test the grammar](https://github.com/tree-sitter/tree-sitter-scala/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-scala/actions/workflows/ci.yml)
[![CI][ci]](https://github.com/tree-sitter/tree-sitter-scala/actions/workflows/ci.yml)
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
[![crates][crates]](https://crates.io/crates/tree-sitter-scala)
[![npm][npm]](https://www.npmjs.com/package/tree-sitter-scala)

Scala grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
covering both Scala 2 and 3.

## References

_Scala 2_

- [The Scala 2 Language Specification](https://www.scala-lang.org/files/archive/spec/2.13/)
- [Scala 2 Syntax Summary](https://www.scala-lang.org/files/archive/spec/2.13/13-syntax-summary.html)

Expand All @@ -19,3 +24,9 @@ _Scala 3_

Please refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) for instructions on
getting set up.

[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/tree-sitter-scala/ci.yml?logo=github&label=CI
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
[npm]: https://img.shields.io/npm/v/tree-sitter-scala?logo=npm
[crates]: https://img.shields.io/crates/v/tree-sitter-scala?logo=rust
14 changes: 8 additions & 6 deletions vendored_parsers/tree-sitter-scala/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
"targets": [
{
"target_name": "tree_sitter_scala_binding",
"dependencies": [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"src"
"src",
],
"sources": [
"src/parser.c",
"bindings/node/binding.cc",
"src/scanner.c"
"src/parser.c",
"src/scanner.c",
],
"cflags_c": [
"-std=c99",
]
"-std=c11",
],
}
]
}
36 changes: 14 additions & 22 deletions vendored_parsers/tree-sitter-scala/bindings/node/binding.cc
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
#include "tree_sitter/parser.h"
#include <node.h>
#include "nan.h"
#include <napi.h>

using namespace v8;
typedef struct TSLanguage TSLanguage;

extern "C" TSLanguage * tree_sitter_scala();
extern "C" TSLanguage *tree_sitter_scala();

namespace {
// "tree-sitter", "language" hashed with BLAKE2
const napi_type_tag LANGUAGE_TYPE_TAG = {
0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
};

NAN_METHOD(New) {}

void Init(Local<Object> exports, Local<Object> module) {
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);

Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_scala());

Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("scala").ToLocalChecked());
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports["name"] = Napi::String::New(env, "scala");
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_scala());
language.TypeTag(&LANGUAGE_TYPE_TAG);
exports["language"] = language;
return exports;
}

NODE_MODULE(tree_sitter_scala_binding, Init)

} // namespace
NODE_API_MODULE(tree_sitter_scala_binding, Init)
28 changes: 28 additions & 0 deletions vendored_parsers/tree-sitter-scala/bindings/node/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type BaseNode = {
type: string;
named: boolean;
};

type ChildNode = {
multiple: boolean;
required: boolean;
types: BaseNode[];
};

type NodeInfo =
| (BaseNode & {
subtypes: BaseNode[];
})
| (BaseNode & {
fields: { [name: string]: ChildNode };
children: ChildNode[];
});

type Language = {
name: string;
language: unknown;
nodeTypeInfo: NodeInfo[];
};

declare const language: Language;
export = language;
18 changes: 3 additions & 15 deletions vendored_parsers/tree-sitter-scala/bindings/node/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
try {
module.exports = require("../../build/Release/tree_sitter_scala_binding");
} catch (error1) {
if (error1.code !== 'MODULE_NOT_FOUND') {
throw error1;
}
try {
module.exports = require("../../build/Debug/tree_sitter_scala_binding");
} catch (error2) {
if (error2.code !== 'MODULE_NOT_FOUND') {
throw error2;
}
throw error1
}
}
const root = require("path").join(__dirname, "..", "..");

module.exports = require("node-gyp-build")(root);

try {
module.exports.nodeTypeInfo = require("../../src/node-types.json");
Expand Down
4 changes: 2 additions & 2 deletions vendored_parsers/tree-sitter-scala/bindings/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! ```
//! let code = "";
//! let mut parser = tree_sitter::Parser::new();
//! parser.set_language(tree_sitter_scala::language()).expect("Error loading scala grammar");
//! parser.set_language(&tree_sitter_scala::language()).expect("Error loading scala grammar");
//! let tree = parser.parse(code, None).unwrap();
//! ```
//!
Expand Down Expand Up @@ -46,7 +46,7 @@ mod tests {
fn test_can_load_grammar() {
let mut parser = tree_sitter::Parser::new();
parser
.set_language(super::language())
.set_language(&super::language())
.expect("Error loading scala language");
}
}
15 changes: 14 additions & 1 deletion vendored_parsers/tree-sitter-scala/corpus/comments.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Using directives
//> using jvm graalvm:21
//> using scala 3.3.0
//> using dep foo:bar:1,2,3,url=https://github.com
//> using exclude "examples/*" "*/resources/*"
//> using exclude "examples/*" "*/resources/*"
// > just a comment

--------------------------------------------------------------------------------
Expand All @@ -87,3 +87,16 @@ Using directives
(using_directive_key)
(using_directive_value)))
(comment))

================================================================================
Shebang
================================================================================

#!/usr/bin/env -S scala-cli shebang -S 3

"shebang"
--------------------------------------------------------------------------------

(compilation_unit
(comment)
(string))
Loading

0 comments on commit d0c9e1d

Please sign in to comment.