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 language binding: tree-sitter-gitattributes #83

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
[submodule "tree-sitter-fortran"]
path = tree-sitter-fortran
url = https://github.com/stadelmanma/tree-sitter-fortran.git
[submodule "tree-sitter-gitattributes"]
path = tree-sitter-gitattributes
url = https://github.com/ObserverOfTime/tree-sitter-gitattributes.git
[submodule "tree-sitter-go"]
path = tree-sitter-go
url = https://github.com/tree-sitter/tree-sitter-go.git
Expand Down
3 changes: 3 additions & 0 deletions lib/ch_usi_si_seart_treesitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ TSLanguage* tree_sitter_erlang();
#ifdef TS_LANGUAGE_FORTRAN
TSLanguage* tree_sitter_fortran();
#endif
#ifdef TS_LANGUAGE_GITATTRIBUTES
TSLanguage* tree_sitter_gitattributes();
#endif
#ifdef TS_LANGUAGE_GO
TSLanguage* tree_sitter_go();
#endif
Expand Down
9 changes: 9 additions & 0 deletions lib/ch_usi_si_seart_treesitter_Language.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ JNIEXPORT jlong JNICALL Java_ch_usi_si_seart_treesitter_Language_fortran(
#endif
}

JNIEXPORT jlong JNICALL Java_ch_usi_si_seart_treesitter_Language_gitattributes(
JNIEnv* env, jclass self) {
#ifdef TS_LANGUAGE_GITATTRIBUTES
return (jlong)tree_sitter_gitattributes();
#else
return (jlong)ch_usi_si_seart_treesitter_Language_INVALID;
#endif
}

JNIEXPORT jlong JNICALL Java_ch_usi_si_seart_treesitter_Language_go(
JNIEnv* env, jclass self) {
#ifdef TS_LANGUAGE_GO
Expand Down
8 changes: 8 additions & 0 deletions lib/ch_usi_si_seart_treesitter_Language.h

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

13 changes: 13 additions & 0 deletions src/main/java/ch/usi/si/seart/treesitter/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ public enum Language {
*/
FORTRAN(fortran(), "f", "F90", "f77", "f90", "f95"),

/**
* Configurations used for associating attributes with file and path patterns in a repository.
*
* @see <a href="https://github.com/ObserverOfTime/tree-sitter-gitattributes">tree-sitter-gitattributes</a>
*/
GITATTRIBUTES(gitattributes(), "gitattributes"),

/**
* Go programming language.
*
Expand Down Expand Up @@ -390,6 +397,7 @@ public enum Language {
private static native long embeddedTemplate();
private static native long erlang();
private static native long fortran();
private static native long gitattributes();
private static native long go();
private static native long graphQl();
private static native long haskell();
Expand Down Expand Up @@ -535,6 +543,11 @@ public String toString() {
case TSX:
case YAML:
return name();
/*
* Lowercase
*/
case GITATTRIBUTES:
return name().toLowerCase();
/*
* Capital Case
*/
Expand Down
1 change: 1 addition & 0 deletions src/test/java/ch/usi/si/seart/treesitter/LanguageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext extensionCo
return Stream.of(
Arguments.of("requirements.txt", List.of()),
Arguments.of(".py", List.of(Language.PYTHON)),
Arguments.of(".gitattributes", List.of(Language.GITATTRIBUTES)),
Arguments.of("__init__.py", List.of(Language.PYTHON)),
Arguments.of("Main.java", List.of(Language.JAVA)),
Arguments.of("example.h", List.of(
Expand Down
1 change: 1 addition & 0 deletions tree-sitter-gitattributes