Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Prisma Schema #724

Open
wants to merge 122 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
15c8c09
First commit
victorhqc Aug 9, 2019
1d745e3
Add grammar for datasources
victorhqc Aug 9, 2019
7006083
WIP: Add grammar for
victorhqc Aug 9, 2019
43d5787
Add Readme warning
victorhqc Aug 9, 2019
b970d92
Update patch
victorhqc Aug 9, 2019
dbdc5ae
Add comments
victorhqc Aug 13, 2019
2c10a64
WIP: Grammar improvements
victorhqc Aug 13, 2019
21d9afc
WIP: Model grammar
victorhqc Aug 14, 2019
9fc6109
Improvements to Model grammar.
victorhqc Aug 14, 2019
29a7cdf
Add type definition
victorhqc Aug 14, 2019
94dcbf0
Remove dead code
victorhqc Aug 14, 2019
22ed472
Some changes in grammar
victorhqc Aug 15, 2019
4921b49
Rename declarations
victorhqc Aug 16, 2019
85dca95
WIP: Handle uncovered cases
victorhqc Aug 17, 2019
eaf6eb9
fix declaration bug.
victorhqc Sep 19, 2019
dbfd7c4
feat: support enum
victorhqc Sep 19, 2019
27fe749
fix: model parsing
victorhqc Sep 19, 2019
d51e8c9
fix: assignment_expression
victorhqc Sep 19, 2019
39cfea3
fix: rename `namespace` -> `attribute`
victorhqc Sep 20, 2019
5cb11f1
chore: cleanup
victorhqc Sep 20, 2019
7d81261
feat: AST comment as specified by prisma docs
victorhqc Sep 20, 2019
074c768
fix: changes in comments
victorhqc Sep 20, 2019
9cdc9f5
chore: Improve README
victorhqc Sep 20, 2019
b3a667a
chore: improve readme
victorhqc Sep 20, 2019
52bb8f5
build: setup ci
victorhqc Sep 20, 2019
e949ef8
chore: contributing
victorhqc Sep 20, 2019
d37fdb8
Merge branch 'master' into feat/build_1
victorhqc Sep 20, 2019
2fd2384
Merge pull request #1 from victorhqc/feat/build_1
victorhqc Sep 20, 2019
6a2184a
build: prepare dependencies & config
victorhqc Sep 20, 2019
032de44
Merge pull request #2 from victorhqc/feat/auto-publish
victorhqc Sep 20, 2019
13fcb6a
build: auto-publish
victorhqc Sep 20, 2019
3b54b57
Merge branch 'master' into victorhqc-patch-1
victorhqc Sep 20, 2019
750888a
Merge pull request #3 from victorhqc/victorhqc-patch-1
victorhqc Sep 20, 2019
3fb6d2e
Rename publish to publish.yml
victorhqc Sep 20, 2019
70ff8d5
Merge pull request #4 from victorhqc/victorhqc-patch-1
victorhqc Sep 20, 2019
057d907
build: add workflow name
victorhqc Sep 20, 2019
e93677a
build: configure semantic release
victorhqc Sep 20, 2019
e7c3ed7
Merge pull request #5 from victorhqc/fix/publish
victorhqc Sep 20, 2019
5777c4d
build: fix semantic release config
victorhqc Sep 20, 2019
b979b91
build: inject environment variables
victorhqc Sep 20, 2019
801c82d
build: nodejs excluded from master
victorhqc Sep 20, 2019
df6d71c
Merge branch 'master' into fix/publish
victorhqc Sep 20, 2019
8545b3c
build: put back as it was
victorhqc Sep 20, 2019
8f826c8
Merge pull request #6 from victorhqc/fix/publish
victorhqc Sep 20, 2019
d6492e9
build: attempt to fix auth
victorhqc Sep 20, 2019
ab7184d
Merge branch 'master' into fix/publish
victorhqc Sep 20, 2019
6397659
Merge pull request #7 from victorhqc/fix/publish
victorhqc Sep 20, 2019
9b15a52
build: attempt to fix auth
victorhqc Sep 20, 2019
d3f0655
Merge branch 'master' into fix/publish
victorhqc Sep 20, 2019
ac870cc
Merge pull request #8 from victorhqc/fix/publish
victorhqc Sep 20, 2019
16aa49e
build: attempt to fix auth
victorhqc Sep 20, 2019
350ab73
Merge branch 'master' into fix/publish
victorhqc Sep 20, 2019
0e07036
Merge pull request #9 from victorhqc/fix/publish
victorhqc Sep 20, 2019
77abc55
build: fixes yml
victorhqc Sep 20, 2019
ceba4e9
Merge branch 'fix/publish' of github.com:victorhqc/tree-sitter-prisma…
victorhqc Sep 20, 2019
866a78e
Merge branch 'master' of github.com:victorhqc/tree-sitter-prisma into…
victorhqc Sep 20, 2019
37583ee
Merge pull request #10 from victorhqc/fix/publish
victorhqc Sep 20, 2019
b8585ff
build: fix yml
victorhqc Sep 20, 2019
8b133b5
build: debug
victorhqc Sep 20, 2019
8dc7170
build: remove dependency
victorhqc Sep 20, 2019
838d151
build: debug
victorhqc Sep 20, 2019
218403b
build: add badge & rename job
victorhqc Sep 20, 2019
ba24e35
build: clean workflow debugging
victorhqc Sep 20, 2019
4f342a8
build: improve release process
victorhqc Sep 20, 2019
65e1a41
build: include dependencies
victorhqc Sep 20, 2019
1ff3430
chore: fix typo
victorhqc Sep 23, 2019
e32d6a0
build(deps): bump npm from 6.11.3 to 6.13.4
dependabot[bot] Dec 13, 2019
1343e01
Merge pull request #11 from victorhqc/dependabot/npm_and_yarn/npm-6.13.4
victorhqc Dec 19, 2019
3592630
build(deps): bump handlebars from 4.2.0 to 4.5.3
dependabot[bot] Dec 30, 2019
ec8fddb
docs: add project info
victorhqc Jan 22, 2020
60edfd4
Merge pull request #12 from victorhqc/dependabot/npm_and_yarn/handleb…
victorhqc Jan 22, 2020
7d37a66
Merge branch 'master' into docs/repo
victorhqc Jan 22, 2020
7e13ee4
Merge pull request #13 from victorhqc/docs/repo
victorhqc Jan 22, 2020
960619f
build(deps): bump https-proxy-agent from 2.2.2 to 2.2.4
dependabot[bot] Apr 16, 2020
548a0dd
Merge pull request #14 from victorhqc/dependabot/npm_and_yarn/https-p…
victorhqc Apr 17, 2020
fcb9326
build(deps): bump npm from 6.13.4 to 6.14.6
dependabot[bot] Jul 7, 2020
3427ea2
Merge pull request #15 from victorhqc/dependabot/npm_and_yarn/npm-6.14.6
victorhqc Jul 9, 2020
d4e5eac
update dependency & fix syntax for comments
victorhqc Nov 12, 2021
e966b1e
update node.js
victorhqc Nov 12, 2021
9d8ef68
Merge pull request #29 from victorhqc/feat/upgrade-ci
victorhqc Nov 12, 2021
ce77b2e
update current version
victorhqc Nov 12, 2021
39f0bc0
Merge pull request #30 from victorhqc/fix/release
victorhqc Nov 12, 2021
0738d27
fix(ci): fixes when to call ci
victorhqc Nov 12, 2021
7b21638
fix(grammar): Fixes grammar on comments
Nov 12, 2021
cc199c3
Merge branch 'master' into fix/release
victorhqc Nov 12, 2021
cf5b154
Merge pull request #31 from victorhqc/fix/release
victorhqc Nov 12, 2021
8100d2c
bump patch
victorhqc Nov 12, 2021
d01a186
Add neovim queries for syntax highlighting
richin13 Nov 19, 2021
a50eef5
Merge pull request #28 from richin13/master
victorhqc Nov 19, 2021
74a721e
bump minor
victorhqc Nov 19, 2021
3373d0e
remove automatic version
victorhqc Mar 17, 2022
c828c43
avoid automatic format in vscode
victorhqc Mar 17, 2022
ce98df8
add composite type declaration
victorhqc Mar 17, 2022
39fb692
update grammar
victorhqc Mar 17, 2022
354e6b3
remove obsolete release config
victorhqc Mar 17, 2022
7a8a429
update lock file with Node 16
victorhqc Mar 17, 2022
9ea5bcc
Merge pull request #33 from victorhqc/feat/composite-types
victorhqc Mar 18, 2022
bf0833c
bump minor
victorhqc Mar 18, 2022
0b31fb6
update name for crates.io
victorhqc Apr 20, 2022
2e6a0ac
update version in cargo file
victorhqc Apr 20, 2022
0ac307e
bump minor & fix repo link
victorhqc Apr 20, 2022
f2c7edb
chore: add license
victorhqc Jun 10, 2022
3234323
Merge pull request #36 from victorhqc/license
victorhqc Jun 10, 2022
3817ba9
fix: infinite loop on invalid syntax
victorhqc Jun 10, 2022
861bf85
chore: remove dead code
victorhqc Jun 10, 2022
8661eb3
chore: add models name test
victorhqc Jun 10, 2022
ec78e2e
Merge pull request #37 from victorhqc/fix/core-dumps
victorhqc Jun 10, 2022
a3eaf13
chore: update patch
victorhqc Jun 10, 2022
8a25b42
refactor: grammar
victorhqc Jun 11, 2022
204dee3
chore: fix test
victorhqc Jun 11, 2022
f1761d8
check for more errors
victorhqc Jun 11, 2022
c2dd1bc
extend model column_type
victorhqc Jun 11, 2022
36a8e66
feat: tokenize '?' char
victorhqc Jun 11, 2022
346453d
Merge pull request #39 from victorhqc/fix/seg-fault
victorhqc Jun 11, 2022
17a5923
chore: bump minor version
victorhqc Jun 11, 2022
2aa1332
feat: support for the view keyword
Jan 5, 2023
06b45ea
Merge pull request #41 from prisma/view-keyword
victorhqc Jan 5, 2023
8292b8a
chore: update minor version
victorhqc Jan 5, 2023
2ffdc54
chore: bump minor version
victorhqc Jan 5, 2023
eca2596
Merge branch 'master' of https://github.com/victorhqc/tree-sitter-prisma
victorhqc Jan 5, 2023
5d8a14d
Add 'vendored_parsers/tree-sitter-prisma/' from commit 'eca2596a355b1…
ewen-lbh May 30, 2024
9c57b21
feat: add Prisma Schema language support
ewen-lbh May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ fn main() {
src_dir: "vendored_parsers/tree-sitter-solidity-src",
extra_files: vec![],
},
TreeSitterParser {
name: "tree-sitter-prisma",
src_dir: "vendored_parsers/tree-sitter-prisma-src",
extra_files: vec![],
},
];

// Only rerun if relevant files in the vendored_parsers/ directory change.
Expand Down
3 changes: 3 additions & 0 deletions src/parse/guess_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub(crate) enum Language {
Pascal,
Perl,
Php,
Prisma,
Python,
Qml,
R,
Expand Down Expand Up @@ -154,6 +155,7 @@ pub(crate) fn language_name(language: Language) -> &'static str {
Pascal => "Pascal",
Perl => "Perl",
Php => "PHP",
Prisma => "Prisma",
Python => "Python",
Qml => "QML",
R => "R",
Expand Down Expand Up @@ -339,6 +341,7 @@ pub(crate) fn language_globs(language: Language) -> Vec<glob::Pattern> {
Php => &[
"*.php", "*.phtml", "*.php3", "*.php4", "*.php5", "*.php7", "*.phps",
],
Prisma => &["*.prisma"],
Python => &["*.py", "*.py3", "*.pyi", "*.bzl", "TARGETS", "BUCK", "DEPS"],
Qml => &["*.qml"],
R => &["*.R", "*.r", "*.rd", "*.rsx", ".Rprofile", "expr-dist"],
Expand Down
15 changes: 15 additions & 0 deletions src/parse/tree_sitter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extern "C" {
fn tree_sitter_dart() -> ts::Language;
fn tree_sitter_devicetree() -> ts::Language;
fn tree_sitter_elisp() -> ts::Language;
fn tree_sitter_prisma() -> ts::Language;
fn tree_sitter_elixir() -> ts::Language;
fn tree_sitter_elm() -> ts::Language;
fn tree_sitter_elvish() -> ts::Language;
Expand Down Expand Up @@ -881,6 +882,20 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
sub_languages: vec![],
}
}
Prisma => {
let language = unsafe { tree_sitter_prisma() };
TreeSitterConfig {
language,
atom_nodes: vec!["string"].into_iter().collect(),
delimiter_tokens: vec![("{", "}"), ("(", ")"), ("[", "]")],
highlight_query: ts::Query::new(
language,
include_str!("../../vendored_parsers/highlights/prisma.scm"),
)
.unwrap(),
sub_languages: vec![],
}
}
Python => {
let language = unsafe { tree_sitter_python() };
TreeSitterConfig {
Expand Down
1 change: 1 addition & 0 deletions vendored_parsers/highlights/prisma.scm
26 changes: 13 additions & 13 deletions vendored_parsers/tree-sitter-c/test/corpus/crlf.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
============================================
Line comments with escaped CRLF line endings
============================================
// hello \
this is still a comment
this_is_not a_comment;
---
(translation_unit
(comment)
(declaration (type_identifier) (identifier)))
============================================
Line comments with escaped CRLF line endings
============================================

// hello \
this is still a comment
this_is_not a_comment;

---

(translation_unit
(comment)
(declaration (type_identifier) (identifier)))
1 change: 1 addition & 0 deletions vendored_parsers/tree-sitter-prisma-src
24 changes: 24 additions & 0 deletions vendored_parsers/tree-sitter-prisma/.github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Node CI

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }} & Rust
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install and test
run: |
npm install
npm test
env:
CI: true
27 changes: 27 additions & 0 deletions vendored_parsers/tree-sitter-prisma/.github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish CI

on:
push:
branches:
- master

jobs:
publish:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }} & Rust
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install and test
run: |
npm install
npm test
env:
CI: true
3 changes: 3 additions & 0 deletions vendored_parsers/tree-sitter-prisma/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build
target
3 changes: 3 additions & 0 deletions vendored_parsers/tree-sitter-prisma/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": false
}
92 changes: 92 additions & 0 deletions vendored_parsers/tree-sitter-prisma/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
3. Make sure the commits follow the [conventional commits convention](https://www.conventionalcommits.org/en/v1.0.0-beta.4/)
it'll make it easier to update correctly using [SemVer](http://semver.org/)
3. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
59 changes: 59 additions & 0 deletions vendored_parsers/tree-sitter-prisma/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions vendored_parsers/tree-sitter-prisma/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "tree-sitter-prisma-io"
description = "prisma grammar for the tree-sitter parsing library"
version = "1.4.0"
keywords = ["incremental", "parsing", "prisma"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/victorhqc/tree-sitter-prisma.git"
edition = "2018"
license = "MIT"

build = "bindings/rust/build.rs"
include = [
"bindings/rust/*",
"grammar.js",
"queries/*",
"src/*",
]

[lib]
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "~0.20.0"

[build-dependencies]
cc = "1.0"
18 changes: 18 additions & 0 deletions vendored_parsers/tree-sitter-prisma/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
The MIT License (MIT)

Copyright © 2022 Victor Quiroz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the “Software”), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading
Loading