Skip to content

Commit 7f65704

Browse files
committed
adding periphery and fixing issues
1 parent 46d64a6 commit 7f65704

File tree

11 files changed

+49
-93
lines changed

11 files changed

+49
-93
lines changed

.periphery.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
retain_public: true

Package.swift

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,43 @@
44
import PackageDescription
55

66
let package = Package(
7-
name: "SyntaxKit",
8-
platforms: [
9-
.macOS(.v13),
10-
.iOS(.v13),
11-
.watchOS(.v6),
12-
.tvOS(.v13),
13-
.visionOS(.v1)
14-
],
15-
products: [
16-
// Products define the executables and libraries a package produces, making them visible to other packages.
17-
.library(
18-
name: "SyntaxKit",
19-
targets: ["SyntaxKit"]
20-
),
21-
.executable(
22-
name: "skit",
23-
targets: ["skit"]
24-
),
25-
],
26-
dependencies: [
27-
.package(url: "https://github.com/apple/swift-syntax.git", from: "601.0.1")
28-
],
29-
targets: [
30-
// Targets are the basic building blocks of a package, defining a module or a test suite.
31-
// Targets can depend on other targets in this package and products from dependencies.
32-
.target(
33-
name: "SyntaxKit",
34-
dependencies: [
35-
.product(name: "SwiftSyntax", package: "swift-syntax"),
36-
.product(name: "SwiftOperators", package: "swift-syntax"),
37-
.product(name: "SwiftParser", package: "swift-syntax")
38-
]
39-
),
40-
.executableTarget(
41-
name: "skit",
42-
dependencies: ["SyntaxKit"]
43-
),
44-
.testTarget(
45-
name: "SyntaxKitTests",
46-
dependencies: ["SyntaxKit"]
47-
),
48-
]
7+
name: "SyntaxKit",
8+
platforms: [
9+
.macOS(.v13),
10+
.iOS(.v13),
11+
.watchOS(.v6),
12+
.tvOS(.v13),
13+
.visionOS(.v1)
14+
],
15+
products: [
16+
.library(
17+
name: "SyntaxKit",
18+
targets: ["SyntaxKit"]
19+
),
20+
.executable(
21+
name: "skit",
22+
targets: ["skit"]
23+
),
24+
],
25+
dependencies: [
26+
.package(url: "https://github.com/apple/swift-syntax.git", from: "601.0.1")
27+
],
28+
targets: [
29+
.target(
30+
name: "SyntaxKit",
31+
dependencies: [
32+
.product(name: "SwiftSyntax", package: "swift-syntax"),
33+
.product(name: "SwiftOperators", package: "swift-syntax"),
34+
.product(name: "SwiftParser", package: "swift-syntax")
35+
]
36+
),
37+
.executableTarget(
38+
name: "skit",
39+
dependencies: ["SyntaxKit"]
40+
),
41+
.testTarget(
42+
name: "SyntaxKitTests",
43+
dependencies: ["SyntaxKit"]
44+
),
45+
]
4946
)

Scripts/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ $PACKAGE_DIR/Scripts/header.sh -d $PACKAGE_DIR/Sources -c "Leo Dion" -o "Bright
7575
run_command $MINT_RUN swiftlint lint $SWIFTLINT_OPTIONS
7676
run_command $MINT_RUN swift-format lint --recursive --parallel $SWIFTFORMAT_OPTIONS Sources Tests
7777

78-
#$MINT_RUN periphery scan $PERIPHERY_OPTIONS --disable-update-check
78+
run_command $MINT_RUN periphery scan $PERIPHERY_OPTIONS --disable-update-check
7979

8080
popd

Sources/SyntaxKit/CodeBlock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public protocol CodeBlockBuilder {
4646

4747
/// A result builder for creating arrays of ``CodeBlock``s.
4848
@resultBuilder
49-
public struct CodeBlockBuilderResult {
49+
public enum CodeBlockBuilderResult {
5050
/// Builds a block of ``CodeBlock``s.
5151
public static func buildBlock(_ components: CodeBlock...) -> [CodeBlock] {
5252
components

Sources/SyntaxKit/ParameterBuilderResult.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import Foundation
3131

3232
/// A result builder for creating arrays of ``Parameter``s.
3333
@resultBuilder
34-
public struct ParameterBuilderResult {
34+
public enum ParameterBuilderResult {
3535
/// Builds a block of ``Parameter``s.
3636
public static func buildBlock(_ components: Parameter...) -> [Parameter] {
3737
components

Sources/SyntaxKit/ParameterExpBuilderResult.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import Foundation
3131

3232
/// A result builder for creating arrays of ``ParameterExp``s.
3333
@resultBuilder
34-
public struct ParameterExpBuilderResult {
34+
public enum ParameterExpBuilderResult {
3535
/// Builds a block of ``ParameterExp``s.
3636
public static func buildBlock(_ components: ParameterExp...) -> [ParameterExp] {
3737
components

Sources/SyntaxKit/parser/SyntaxParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import SwiftOperators
3232
import SwiftParser
3333
import SwiftSyntax
3434

35-
package struct SyntaxParser {
35+
package enum SyntaxParser {
3636
package static func parse(code: String, options: [String] = []) throws -> SyntaxResponse {
3737
let sourceFile = Parser.parse(source: code)
3838

@@ -53,6 +53,6 @@ package struct SyntaxParser {
5353
let encoder = JSONEncoder()
5454
let json = String(decoding: try encoder.encode(tree), as: UTF8.self)
5555

56-
return SyntaxResponse(syntaxJSON: json, swiftVersion: version)
56+
return SyntaxResponse(syntaxJSON: json)
5757
}
5858
}

Sources/SyntaxKit/parser/SyntaxResponse.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,5 @@
3030
import Foundation
3131

3232
package struct SyntaxResponse: Codable {
33-
// package let syntaxHTML: String
3433
package let syntaxJSON: String
35-
package let swiftVersion: String
3634
}

Sources/SyntaxKit/parser/TokenVisitor.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ final class TokenVisitor: SyntaxRewriter {
9797
range: Range(
9898
startRow: start.line,
9999
startColumn: start.column,
100-
graphemeStartColumn: graphemeStartColumn,
101100
endRow: end.line,
102-
endColumn: end.column,
103-
graphemeEndColumn: graphemeEndColumn
101+
endColumn: end.column
104102
),
105103
type: syntaxType
106104
)
@@ -185,9 +183,7 @@ final class TokenVisitor: SyntaxRewriter {
185183
.escapeHTML()
186184
.replaceInvisiblesWithHTML()
187185
.replaceHTMLWhitespacesWithSymbols()
188-
if token.presence == .missing {
189-
current.class = "\(token.presence)"
190-
}
186+
191187
current.token = Token(kind: "\(token.tokenKind)", leadingTrivia: "", trailingTrivia: "")
192188

193189
token.leadingTrivia.forEach { piece in

Sources/SyntaxKit/parser/TreeNode.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ final class TreeNode: Codable {
3535

3636
var text: String
3737
var range = Range(
38-
startRow: 0, startColumn: 0, graphemeStartColumn: 0, endRow: 0, endColumn: 0,
39-
graphemeEndColumn: 0)
38+
startRow: 0, startColumn: 0, endRow: 0, endColumn: 0)
4039
var structure = [StructureProperty]()
4140
var type: SyntaxType
4241
var token: Token?
43-
var `class`: String?
4442

4543
init(id: Int, text: String, range: Range, type: SyntaxType) {
4644
self.id = id
@@ -76,10 +74,8 @@ extension TreeNode: CustomStringConvertible {
7674
struct Range: Codable, Equatable {
7775
let startRow: Int
7876
let startColumn: Int
79-
let graphemeStartColumn: Int
8077
let endRow: Int
8178
let endColumn: Int
82-
let graphemeEndColumn: Int
8379
}
8480

8581
extension Range: CustomStringConvertible {

0 commit comments

Comments
 (0)