Skip to content

Commit

Permalink
Merge pull request #3 from lukepistrol/main
Browse files Browse the repository at this point in the history
[feat]: Added java language support
  • Loading branch information
lukepistrol authored May 29, 2022
2 parents 806c2a6 + e00dab5 commit dc48745
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
"revision" : "68b8bed0c1ebecbaf1919d0a7ae4b27592e6cc45"
}
},
{
"identity" : "tree-sitter-java",
"kind" : "remoteSourceControl",
"location" : "https://github.com/lukepistrol/tree-sitter-java.git",
"state" : {
"branch" : "feature/spm",
"revision" : "4140d566eb446658187cdd0b72de7581cc686408"
}
},
{
"identity" : "tree-sitter-json",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let package = Package(
.package(url: "https://github.com/mattmassicotte/tree-sitter-go.git", branch: "feature/swift"),
.package(url: "https://github.com/camdencheek/tree-sitter-go-mod.git", branch: "main"),
.package(url: "https://github.com/mattmassicotte/tree-sitter-html.git", branch: "feature/spm"),
.package(url: "https://github.com/lukepistrol/tree-sitter-java.git", branch: "feature/spm"),
.package(url: "https://github.com/mattmassicotte/tree-sitter-json.git", branch: "feature/spm"),
.package(url: "https://github.com/lukepistrol/tree-sitter-python.git", branch: "feature/spm"),
.package(url: "https://github.com/mattmassicotte/tree-sitter-ruby.git", branch: "feature/swift"),
Expand All @@ -33,6 +34,7 @@ let package = Package(
.product(name: "TreeSitterGo", package: "tree-sitter-go"),
.product(name: "TreeSitterGoMod", package: "tree-sitter-go-mod"),
.product(name: "TreeSitterHTML", package: "tree-sitter-html"),
.product(name: "TreeSitterJava", package: "tree-sitter-java"),
.product(name: "TreeSitterJSON", package: "tree-sitter-json"),
.product(name: "TreeSitterPython", package: "tree-sitter-python"),
.product(name: "TreeSitterRuby", package: "tree-sitter-ruby"),
Expand Down
7 changes: 7 additions & 0 deletions Sources/CodeEditTextView/CodeLanguage/CodeLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SwiftTreeSitter
import TreeSitterGo
import TreeSitterGoMod
import TreeSitterHTML
import TreeSitterJava
import TreeSitterJSON
import TreeSitterPython
import TreeSitterRuby
Expand Down Expand Up @@ -58,6 +59,8 @@ public struct CodeLanguage {
return tree_sitter_gomod()
case .html:
return tree_sitter_html()
case .java:
return tree_sitter_java()
case .json:
return tree_sitter_json()
case .python:
Expand Down Expand Up @@ -105,6 +108,7 @@ public extension CodeLanguage {
.go,
.goMod,
.html,
.java,
.json,
.python,
.ruby,
Expand All @@ -121,6 +125,9 @@ public extension CodeLanguage {
/// A ``CodeLanguage`` structure for `HTML`
static let html: CodeLanguage = .init(id: .html, displayName: "HTML", extensions: ["html", "htm"])

/// A ``CodeLanguage`` structure for `JSON`
static let java: CodeLanguage = .init(id: .java, displayName: "Java", extensions: ["java"])

/// A ``CodeLanguage`` structure for `JSON`
static let json: CodeLanguage = .init(id: .json, displayName: "JSON", extensions: ["json"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum TreeSitterLanguage: String {
case go
case goMod
case html
case java
case json
case python
case ruby
Expand Down
7 changes: 7 additions & 0 deletions Sources/CodeEditTextView/CodeLanguage/TreeSitterModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class TreeSitterModel {
return goModQuery
case .html:
return htmlQuery
case .java:
return javaQuery
case .json:
return jsonQuery
case .python:
Expand Down Expand Up @@ -55,6 +57,11 @@ public class TreeSitterModel {
return queryFor(.html)
}()

/// Query for `Java` files.
public lazy var javaQuery: Query? = {
return queryFor(.java)
}()

/// Query for `JSON` files.
public lazy var jsonQuery: Query? = {
return queryFor(.json)
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodeEditTextView/Documentation.docc/CodeLanguage.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let language = CodeLanguage.detectLanguageFrom(url: fileURL)

- Go
- HTML
- Java
- JSON
- Python
- Ruby
Expand All @@ -44,6 +45,7 @@ let language = CodeLanguage.detectLanguageFrom(url: fileURL)
- ``go``
- ``goMod``
- ``html``
- ``java``
- ``json``
- ``python``
- ``ruby``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ let query = TreeSitterModel.shared.swiftQuery
- ``goQuery``
- ``goModQuery``
- ``htmlQuery``
- ``javaQuery``
- ``jsonQuery``
- ``pythonQuery``
- ``rubyQuery``
Expand Down

0 comments on commit dc48745

Please sign in to comment.