Skip to content

Adding Periphery and Fixing Linting Issues #20

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

Merged
merged 2 commits into from
Jun 17, 2025
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
1 change: 1 addition & 0 deletions .periphery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
retain_public: true
81 changes: 39 additions & 42 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,43 @@
import PackageDescription

let package = Package(
name: "SyntaxKit",
platforms: [
.macOS(.v13),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
.visionOS(.v1)
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "SyntaxKit",
targets: ["SyntaxKit"]
),
.executable(
name: "skit",
targets: ["skit"]
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax.git", from: "601.0.1")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "SyntaxKit",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftOperators", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax")
]
),
.executableTarget(
name: "skit",
dependencies: ["SyntaxKit"]
),
.testTarget(
name: "SyntaxKitTests",
dependencies: ["SyntaxKit"]
),
]
name: "SyntaxKit",
platforms: [
.macOS(.v13),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
.visionOS(.v1)
],
products: [
.library(
name: "SyntaxKit",
targets: ["SyntaxKit"]
),
.executable(
name: "skit",
targets: ["skit"]
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax.git", from: "601.0.1")
],
targets: [
.target(
name: "SyntaxKit",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftOperators", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax")
]
),
.executableTarget(
name: "skit",
dependencies: ["SyntaxKit"]
),
.testTarget(
name: "SyntaxKitTests",
dependencies: ["SyntaxKit"]
),
]
)
4 changes: 3 additions & 1 deletion Scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ $PACKAGE_DIR/Scripts/header.sh -d $PACKAGE_DIR/Sources -c "Leo Dion" -o "Bright
run_command $MINT_RUN swiftlint lint $SWIFTLINT_OPTIONS
run_command $MINT_RUN swift-format lint --recursive --parallel $SWIFTFORMAT_OPTIONS Sources Tests

#$MINT_RUN periphery scan $PERIPHERY_OPTIONS --disable-update-check
if [ -z "$CI" ]; then
run_command $MINT_RUN periphery scan $PERIPHERY_OPTIONS --disable-update-check
fi

popd
2 changes: 1 addition & 1 deletion Sources/SyntaxKit/CodeBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public protocol CodeBlockBuilder {

/// A result builder for creating arrays of ``CodeBlock``s.
@resultBuilder
public struct CodeBlockBuilderResult {
public enum CodeBlockBuilderResult {
/// Builds a block of ``CodeBlock``s.
public static func buildBlock(_ components: CodeBlock...) -> [CodeBlock] {
components
Expand Down
2 changes: 1 addition & 1 deletion Sources/SyntaxKit/ParameterBuilderResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Foundation

/// A result builder for creating arrays of ``Parameter``s.
@resultBuilder
public struct ParameterBuilderResult {
public enum ParameterBuilderResult {
/// Builds a block of ``Parameter``s.
public static func buildBlock(_ components: Parameter...) -> [Parameter] {
components
Expand Down
2 changes: 1 addition & 1 deletion Sources/SyntaxKit/ParameterExpBuilderResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Foundation

/// A result builder for creating arrays of ``ParameterExp``s.
@resultBuilder
public struct ParameterExpBuilderResult {
public enum ParameterExpBuilderResult {
/// Builds a block of ``ParameterExp``s.
public static func buildBlock(_ components: ParameterExp...) -> [ParameterExp] {
components
Expand Down
4 changes: 2 additions & 2 deletions Sources/SyntaxKit/parser/SyntaxParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import SwiftParser
import SwiftSyntax

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

Expand All @@ -53,6 +53,6 @@
let encoder = JSONEncoder()
let json = String(decoding: try encoder.encode(tree), as: UTF8.self)

return SyntaxResponse(syntaxJSON: json, swiftVersion: version)
return SyntaxResponse(syntaxJSON: json)

Check warning on line 56 in Sources/SyntaxKit/parser/SyntaxParser.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SyntaxKit/parser/SyntaxParser.swift#L56

Added line #L56 was not covered by tests
}
}
2 changes: 0 additions & 2 deletions Sources/SyntaxKit/parser/SyntaxResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,5 @@
import Foundation

package struct SyntaxResponse: Codable {
// package let syntaxHTML: String
package let syntaxJSON: String
package let swiftVersion: String
}
8 changes: 2 additions & 6 deletions Sources/SyntaxKit/parser/TokenVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@
range: Range(
startRow: start.line,
startColumn: start.column,
graphemeStartColumn: graphemeStartColumn,
endRow: end.line,
endColumn: end.column,
graphemeEndColumn: graphemeEndColumn
endColumn: end.column

Check warning on line 101 in Sources/SyntaxKit/parser/TokenVisitor.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SyntaxKit/parser/TokenVisitor.swift#L101

Added line #L101 was not covered by tests
),
type: syntaxType
)
Expand Down Expand Up @@ -185,9 +183,7 @@
.escapeHTML()
.replaceInvisiblesWithHTML()
.replaceHTMLWhitespacesWithSymbols()
if token.presence == .missing {
current.class = "\(token.presence)"
}

Check warning on line 186 in Sources/SyntaxKit/parser/TokenVisitor.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SyntaxKit/parser/TokenVisitor.swift#L186

Added line #L186 was not covered by tests
current.token = Token(kind: "\(token.tokenKind)", leadingTrivia: "", trailingTrivia: "")

token.leadingTrivia.forEach { piece in
Expand Down
6 changes: 1 addition & 5 deletions Sources/SyntaxKit/parser/TreeNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@

var text: String
var range = Range(
startRow: 0, startColumn: 0, graphemeStartColumn: 0, endRow: 0, endColumn: 0,
graphemeEndColumn: 0)
startRow: 0, startColumn: 0, endRow: 0, endColumn: 0)

Check warning on line 38 in Sources/SyntaxKit/parser/TreeNode.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SyntaxKit/parser/TreeNode.swift#L38

Added line #L38 was not covered by tests
var structure = [StructureProperty]()
var type: SyntaxType
var token: Token?
var `class`: String?

init(id: Int, text: String, range: Range, type: SyntaxType) {
self.id = id
Expand Down Expand Up @@ -76,10 +74,8 @@
struct Range: Codable, Equatable {
let startRow: Int
let startColumn: Int
let graphemeStartColumn: Int
let endRow: Int
let endColumn: Int
let graphemeEndColumn: Int
}

extension Range: CustomStringConvertible {
Expand Down
32 changes: 0 additions & 32 deletions Sources/SyntaxKit/parser/Version.swift

This file was deleted.

Loading