diff --git a/CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.pbxproj b/CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.pbxproj index 7a5c6a8..27c8791 100644 --- a/CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.pbxproj +++ b/CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.pbxproj @@ -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 */ @@ -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 */, @@ -193,6 +195,7 @@ 7DB18E9629FDC51C00F8EC00 /* TreeSitterScala */, 9DFDC3652A02D9BE0023B3BC /* TreeSitterMarkdown */, 9D6E74502A2B9B2A0070701E /* TreeSitterOCaml */, + 9DB1B4352A2C0DAA0027B04E /* TreeSitterJSDoc */, ); productName = "CodeLanguages-Container"; productReference = 28B3F00C290C207D000CD04D /* CodeLanguages_Container.framework */; @@ -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 = ""; @@ -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"; @@ -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" */; diff --git a/CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7771c3e..03108a3 100644 --- a/CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -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", diff --git a/CodeLanguages-Container/CodeLanguages-Container/CodeLanguages_Container.h b/CodeLanguages-Container/CodeLanguages-Container/CodeLanguages_Container.h index fa082e3..8015f8e 100644 --- a/CodeLanguages-Container/CodeLanguages-Container/CodeLanguages_Container.h +++ b/CodeLanguages-Container/CodeLanguages-Container/CodeLanguages_Container.h @@ -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(); diff --git a/CodeLanguagesContainer.xcframework.zip b/CodeLanguagesContainer.xcframework.zip index ba0a1ba..ea657de 100644 Binary files a/CodeLanguagesContainer.xcframework.zip and b/CodeLanguagesContainer.xcframework.zip differ diff --git a/README.md b/README.md index 75fbb11..2820534 100644 --- a/README.md +++ b/README.md @@ -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) | ✅ | ✅ | diff --git a/Sources/CodeEditLanguages/CodeLanguage+Definitions.swift b/Sources/CodeEditLanguages/CodeLanguage+Definitions.swift index dd25e3e..a8b91dd 100644 --- a/Sources/CodeEditLanguages/CodeLanguage+Definitions.swift +++ b/Sources/CodeEditLanguages/CodeLanguage+Definitions.swift @@ -25,6 +25,7 @@ public extension CodeLanguage { .html, .java, .javascript, + .jsdoc, .json, .jsx, .kotlin, @@ -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, diff --git a/Sources/CodeEditLanguages/CodeLanguage.swift b/Sources/CodeEditLanguages/CodeLanguage.swift index 3cfd45f..7387ce1 100644 --- a/Sources/CodeEditLanguages/CodeLanguage.swift +++ b/Sources/CodeEditLanguages/CodeLanguage.swift @@ -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: diff --git a/Sources/CodeEditLanguages/Documentation.docc/CodeLanguage.md b/Sources/CodeEditLanguages/Documentation.docc/CodeLanguage.md index 2af2b92..45f1ac1 100644 --- a/Sources/CodeEditLanguages/Documentation.docc/CodeLanguage.md +++ b/Sources/CodeEditLanguages/Documentation.docc/CodeLanguage.md @@ -85,6 +85,7 @@ let language = CodeLanguage.detectLanguageFrom(url: fileURL) - ``html`` - ``java`` - ``javascript`` +- ``jsdoc`` - ``json`` - ``jsx`` - ``kotlin`` diff --git a/Sources/CodeEditLanguages/Documentation.docc/TreeSitterModel.md b/Sources/CodeEditLanguages/Documentation.docc/TreeSitterModel.md index b282c65..48becbb 100644 --- a/Sources/CodeEditLanguages/Documentation.docc/TreeSitterModel.md +++ b/Sources/CodeEditLanguages/Documentation.docc/TreeSitterModel.md @@ -46,6 +46,7 @@ let query = TreeSitterModel.shared.swiftQuery - ``htmlQuery`` - ``javaQuery`` - ``javascriptQuery`` +- ``jsdocQuery`` - ``jsonQuery`` - ``jsxQuery`` - ``kotlinQuery`` diff --git a/Sources/CodeEditLanguages/Resources/tree-sitter-jsdoc/highlights.scm b/Sources/CodeEditLanguages/Resources/tree-sitter-jsdoc/highlights.scm new file mode 100644 index 0000000..4b4266c --- /dev/null +++ b/Sources/CodeEditLanguages/Resources/tree-sitter-jsdoc/highlights.scm @@ -0,0 +1,2 @@ +(tag_name) @keyword +(type) @type diff --git a/Sources/CodeEditLanguages/TreeSitterLanguage.swift b/Sources/CodeEditLanguages/TreeSitterLanguage.swift index 711d646..b7616ac 100644 --- a/Sources/CodeEditLanguages/TreeSitterLanguage.swift +++ b/Sources/CodeEditLanguages/TreeSitterLanguage.swift @@ -23,6 +23,7 @@ public enum TreeSitterLanguage: String { case html case java case javascript + case jsdoc case json case jsx case kotlin diff --git a/Sources/CodeEditLanguages/TreeSitterModel.swift b/Sources/CodeEditLanguages/TreeSitterModel.swift index 3fa6b74..73be026 100644 --- a/Sources/CodeEditLanguages/TreeSitterModel.swift +++ b/Sources/CodeEditLanguages/TreeSitterModel.swift @@ -48,6 +48,8 @@ public class TreeSitterModel { return javaQuery case .javascript: return javascriptQuery + case .jsdoc: + return jsdocQuery case .json: return jsonQuery case .jsx: @@ -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) diff --git a/Tests/CodeEditLanguagesTests/CodeEditLanguagesTests.swift b/Tests/CodeEditLanguagesTests/CodeEditLanguagesTests.swift index c6ed868..b6d8224 100644 --- a/Tests/CodeEditLanguagesTests/CodeEditLanguagesTests.swift +++ b/Tests/CodeEditLanguagesTests/CodeEditLanguagesTests.swift @@ -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 {