Skip to content
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 numberDiff line numberDiff line change
@@ -0,0 +1 @@
retain_public: true
81 changes: 39 additions & 42 deletions Package.swift
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@ import SwiftOperators
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 @@ package struct SyntaxParser {
let encoder = JSONEncoder()
let json = String(decoding: try encoder.encode(tree), as: UTF8.self)

return SyntaxResponse(syntaxJSON: json, swiftVersion: version)
return SyntaxResponse(syntaxJSON: json)
}
}
2 changes: 0 additions & 2 deletions Sources/SyntaxKit/parser/SyntaxResponse.swift
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff line change
Expand Up@@ -97,10 +97,8 @@ final class TokenVisitor: SyntaxRewriter {
range: Range(
startRow: start.line,
startColumn: start.column,
graphemeStartColumn: graphemeStartColumn,
endRow: end.line,
endColumn: end.column,
graphemeEndColumn: graphemeEndColumn
endColumn: end.column
),
type: syntaxType
)
Expand DownExpand Up@@ -185,9 +183,7 @@ final class TokenVisitor: SyntaxRewriter {
.escapeHTML()
.replaceInvisiblesWithHTML()
.replaceHTMLWhitespacesWithSymbols()
if token.presence == .missing {
current.class = "\(token.presence)"
}

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 numberDiff line numberDiff line change
Expand Up@@ -35,12 +35,10 @@ final class TreeNode: Codable {

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)
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 DownExpand Up@@ -76,10 +74,8 @@ extension TreeNode: CustomStringConvertible {
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.