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 JSDoc Grammar #45

Merged
merged 3 commits into from
Jun 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
6CEC70FE29C3A85000B61C7A /* TreeSitterRegex in Frameworks */ = {isa = PBXBuildFile; productRef = 6CEC70FD29C3A85000B61C7A /* TreeSitterRegex */; };
7DB18E9729FDC51C00F8EC00 /* TreeSitterScala in Frameworks */ = {isa = PBXBuildFile; productRef = 7DB18E9629FDC51C00F8EC00 /* TreeSitterScala */; };
9D6E74512A2B9B2A0070701E /* TreeSitterOCaml in Frameworks */ = {isa = PBXBuildFile; productRef = 9D6E74502A2B9B2A0070701E /* TreeSitterOCaml */; };
9DB1B4362A2C0DAA0027B04E /* TreeSitterJSDoc in Frameworks */ = {isa = PBXBuildFile; productRef = 9DB1B4352A2C0DAA0027B04E /* TreeSitterJSDoc */; };
9DFDC3662A02D9BE0023B3BC /* TreeSitterMarkdown in Frameworks */ = {isa = PBXBuildFile; productRef = 9DFDC3652A02D9BE0023B3BC /* TreeSitterMarkdown */; };
/* End PBXBuildFile section */

Expand All @@ -58,6 +59,7 @@
28B3F042290C365C000CD04D /* TreeSitterHaskell in Frameworks */,
285BF67329AAA45B00641989 /* TreeSitterLua in Frameworks */,
6CA62EAB29F9D36700785B11 /* TreeSitterTSX in Frameworks */,
9DB1B4362A2C0DAA0027B04E /* TreeSitterJSDoc in Frameworks */,
2846B262296BA1CF005F60B6 /* TreeSitterDockerfile in Frameworks */,
9D6E74512A2B9B2A0070701E /* TreeSitterOCaml in Frameworks */,
282C119329AA32C8004F1EA6 /* TreeSitterSQL in Frameworks */,
Expand Down Expand Up @@ -193,6 +195,7 @@
7DB18E9629FDC51C00F8EC00 /* TreeSitterScala */,
9DFDC3652A02D9BE0023B3BC /* TreeSitterMarkdown */,
9D6E74502A2B9B2A0070701E /* TreeSitterOCaml */,
9DB1B4352A2C0DAA0027B04E /* TreeSitterJSDoc */,
);
productName = "CodeLanguages-Container";
productReference = 28B3F00C290C207D000CD04D /* CodeLanguages_Container.framework */;
Expand Down Expand Up @@ -254,6 +257,7 @@
7DB18E9529FDC51C00F8EC00 /* XCRemoteSwiftPackageReference "tree-sitter-scala" */,
9DFDC3642A02D9BE0023B3BC /* XCRemoteSwiftPackageReference "tree-sitter-markdown" */,
9D6E744F2A2B9B2A0070701E /* XCRemoteSwiftPackageReference "tree-sitter-ocaml" */,
9DB1B4342A2C0DA90027B04E /* XCRemoteSwiftPackageReference "tree-sitter-jsdoc" */,
);
productRefGroup = 28B3F00D290C207D000CD04D /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -743,6 +747,14 @@
kind = branch;
};
};
9DB1B4342A2C0DA90027B04E /* XCRemoteSwiftPackageReference "tree-sitter-jsdoc" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/cengelbart39/tree-sitter-jsdoc.git";
requirement = {
branch = feature/spm;
kind = branch;
};
};
9DFDC3642A02D9BE0023B3BC /* XCRemoteSwiftPackageReference "tree-sitter-markdown" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/MDeiml/tree-sitter-markdown";
Expand Down Expand Up @@ -909,6 +921,11 @@
package = 9D6E744F2A2B9B2A0070701E /* XCRemoteSwiftPackageReference "tree-sitter-ocaml" */;
productName = TreeSitterOCaml;
};
9DB1B4352A2C0DAA0027B04E /* TreeSitterJSDoc */ = {
isa = XCSwiftPackageProductDependency;
package = 9DB1B4342A2C0DA90027B04E /* XCRemoteSwiftPackageReference "tree-sitter-jsdoc" */;
productName = TreeSitterJSDoc;
};
9DFDC3652A02D9BE0023B3BC /* TreeSitterMarkdown */ = {
isa = XCSwiftPackageProductDependency;
package = 9DFDC3642A02D9BE0023B3BC /* XCRemoteSwiftPackageReference "tree-sitter-markdown" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@
"revision" : "5720b249490b3c17245ba772f6be4a43edb4e3b7"
}
},
{
"identity" : "tree-sitter-jsdoc",
"kind" : "remoteSourceControl",
"location" : "https://github.com/cengelbart39/tree-sitter-jsdoc.git",
"state" : {
"branch" : "feature/spm",
"revision" : "b25a13f0521a80cbb6157d7466b837d19bdc3549"
}
},
{
"identity" : "tree-sitter-json",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern TSLanguage *tree_sitter_haskell();
extern TSLanguage *tree_sitter_html();
extern TSLanguage *tree_sitter_java();
extern TSLanguage *tree_sitter_javascript();
extern TSLanguage *tree_sitter_jsdoc();
extern TSLanguage *tree_sitter_json();
extern TSLanguage *tree_sitter_kotlin();
extern TSLanguage *tree_sitter_lua();
Expand Down
Binary file modified CodeLanguagesContainer.xcframework.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ In order to add support for additional languages we have a complete guide on how
| [HTML](https://github.com/mattmassicotte/tree-sitter-html) | ✅ | ✅ |
| [Java](https://github.com/tree-sitter/tree-sitter-java) | ✅ | ✅ |
| [JavaScript/JSX](https://github.com/tree-sitter/tree-sitter-javascript) | ✅ | ✅ |
| [JSDoc](https://github.com/tree-sitter/tree-sitter-jsdoc) | | |
| [JSDoc](https://github.com/cengelbart39/tree-sitter-jsdoc/tree/feature/spm) | | |
| [JSON](https://github.com/mattmassicotte/tree-sitter-json) | ✅ | ✅ |
| [Julia](https://github.com/tree-sitter/tree-sitter-julia) | | _not available_ |
| [Kotlin](https://github.com/lukepistrol/tree-sitter-kotlin/tree/feature/spm-queries) | ✅ | ✅ |
Expand Down
8 changes: 8 additions & 0 deletions Sources/CodeEditLanguages/CodeLanguage+Definitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public extension CodeLanguage {
.html,
.java,
.javascript,
.jsdoc,
.json,
.jsx,
.kotlin,
Expand Down Expand Up @@ -151,6 +152,13 @@ public extension CodeLanguage {
highlights: ["injections"]
)

/// A language structure for `JSDoc`
static let jsdoc: CodeLanguage = .init(
id: .jsdoc,
tsName: "jsdoc",
extensions: []
)

/// A language structure for `JSON`
static let json: CodeLanguage = .init(
id: .json,
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodeEditLanguages/CodeLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public struct CodeLanguage {
return tree_sitter_java()
case .javascript:
return tree_sitter_javascript()
case .jsdoc:
return tree_sitter_jsdoc()
case .json:
return tree_sitter_json()
case .jsx:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ let language = CodeLanguage.detectLanguageFrom(url: fileURL)
- ``html``
- ``java``
- ``javascript``
- ``jsdoc``
- ``json``
- ``jsx``
- ``kotlin``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ let query = TreeSitterModel.shared.swiftQuery
- ``htmlQuery``
- ``javaQuery``
- ``javascriptQuery``
- ``jsdocQuery``
- ``jsonQuery``
- ``jsxQuery``
- ``kotlinQuery``
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(tag_name) @keyword
(type) @type
1 change: 1 addition & 0 deletions Sources/CodeEditLanguages/TreeSitterLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum TreeSitterLanguage: String {
case html
case java
case javascript
case jsdoc
case json
case jsx
case kotlin
Expand Down
7 changes: 7 additions & 0 deletions Sources/CodeEditLanguages/TreeSitterModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class TreeSitterModel {
return javaQuery
case .javascript:
return javascriptQuery
case .jsdoc:
return jsdocQuery
case .json:
return jsonQuery
case .jsx:
Expand Down Expand Up @@ -165,6 +167,11 @@ public class TreeSitterModel {
return queryFor(.javascript)
}()

/// Query for `JSDoc` files.
public private(set) lazy var jsdocQuery: Query? = {
return queryFor(.jsdoc)
}()

/// Query for `JSX` files.
public private(set) lazy var jsxQuery: Query? = {
return queryFor(.jsx)
Expand Down
12 changes: 12 additions & 0 deletions Tests/CodeEditLanguagesTests/CodeEditLanguagesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,18 @@ final class CodeEditLanguagesTests: XCTestCase {
XCTAssertNotEqual(query?.patternCount, 0)
}

// MARK: - JSDoc

func test_FetchQueryJSDoc() throws {
var language = CodeLanguage.jsdoc
language.resourceURL = bundleURL

let data = try Data(contentsOf: language.queryURL!)
let query = try? Query(language: language.language!, data: data)
XCTAssertNotNil(query)
XCTAssertNotEqual(query?.patternCount, 0)
}

// MARK: - JSON

func test_CodeLanguageJSON() throws {
Expand Down