Skip to content

Commit 7815019

Browse files
committed
more lint cleanup
1 parent 3082e38 commit 7815019

26 files changed

+1021
-800
lines changed

Line.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// Created by Leo Dion on 6/16/25.
66
//
77

8-
/// Represents a single comment line that can be attached to a syntax node when using `.comment { ... }` in the DSL.
8+
/// Represents a single comment line that can be attached to a syntax node when using
9+
/// `.comment { ... }` in the DSL.
910
public struct Line {
1011
public enum Kind {
1112
/// Regular line comment that starts with `//`.

Sources/SyntaxKit/Case.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// Permission is hereby granted, free of charge, to any person
99
// obtaining a copy of this software and associated documentation
10-
// files (the "Software"), to deal in the Software without
10+
// files (the Software), to deal in the Software without
1111
// restriction, including without limitation the rights to use,
1212
// copy, modify, merge, publish, distribute, sublicense, and/or
1313
// sell copies of the Software, and to permit persons to whom the
@@ -17,7 +17,7 @@
1717
// The above copyright notice and this permission notice shall be
1818
// included in all copies or substantial portions of the Software.
1919
//
20-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
2121
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
2222
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2323
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -41,7 +41,8 @@ public struct Case: CodeBlock {
4141
/// - Parameters:
4242
/// - patterns: The patterns to match for the case.
4343
/// - content: A ``CodeBlockBuilder`` that provides the body of the case.
44-
public init(_ patterns: PatternConvertible..., @CodeBlockBuilderResult content: () -> [CodeBlock]) {
44+
public init(_ patterns: PatternConvertible..., @CodeBlockBuilderResult content: () -> [CodeBlock])
45+
{
4546
self.patterns = patterns
4647
self.body = content()
4748
self.isEnumCase = false

Sources/SyntaxKit/DictionaryExpr.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// Permission is hereby granted, free of charge, to any person
99
// obtaining a copy of this software and associated documentation
10-
// files (the "Software"), to deal in the Software without
10+
// files (the Software), to deal in the Software without
1111
// restriction, including without limitation the rights to use,
1212
// copy, modify, merge, publish, distribute, sublicense, and/or
1313
// sell copies of the Software, and to permit persons to whom the
@@ -17,7 +17,7 @@
1717
// The above copyright notice and this permission notice shall be
1818
// included in all copies or substantial portions of the Software.
1919
//
20-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
2121
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
2222
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2323
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -49,15 +49,15 @@ public struct DictionaryExpr: CodeBlock, LiteralValue {
4949

5050
/// Renders this dictionary as a Swift literal string.
5151
public var literalString: String {
52-
let elementStrings = elements.map { key, value in
52+
let elementStrings = elements.map { _, _ in
5353
let keyString: String
5454
let valueString: String
5555

5656
// For now, we'll use a simple representation
5757
// In a real implementation, we'd need to convert DictionaryValue to string
5858
keyString = "key"
5959
valueString = "value"
60-
60+
6161
return "\(keyString): \(valueString)"
6262
}
6363
return "[\(elementStrings.joined(separator: ", "))]"
@@ -86,4 +86,4 @@ public struct DictionaryExpr: CodeBlock, LiteralValue {
8686
return DictionaryExprSyntax(content: .elements(dictionaryElements))
8787
}
8888
}
89-
}
89+
}

Sources/SyntaxKit/DictionaryValue.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// Permission is hereby granted, free of charge, to any person
99
// obtaining a copy of this software and associated documentation
10-
// files (the "Software"), to deal in the Software without
10+
// files (the Software), to deal in the Software without
1111
// restriction, including without limitation the rights to use,
1212
// copy, modify, merge, publish, distribute, sublicense, and/or
1313
// sell copies of the Software, and to permit persons to whom the
@@ -17,7 +17,7 @@
1717
// The above copyright notice and this permission notice shall be
1818
// included in all copies or substantial portions of the Software.
1919
//
20-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
2121
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
2222
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2323
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -49,11 +49,11 @@ extension CodeBlock where Self: DictionaryValue {
4949
if let expr = self.syntax.as(ExprSyntax.self) {
5050
return expr
5151
}
52-
52+
5353
if let token = self.syntax.as(TokenSyntax.self) {
5454
return ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier(token.text)))
5555
}
56-
56+
5757
fatalError("CodeBlock of type \(type(of: self.syntax)) cannot be represented as ExprSyntax")
5858
}
5959
}
@@ -65,4 +65,4 @@ extension Init: DictionaryValue {}
6565
extension VariableExp: DictionaryValue {}
6666
extension PropertyAccessExp: DictionaryValue {}
6767
extension FunctionCallExp: DictionaryValue {}
68-
extension Infix: DictionaryValue {}
68+
extension Infix: DictionaryValue {}

Sources/SyntaxKit/EnumCase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// Permission is hereby granted, free of charge, to any person
99
// obtaining a copy of this software and associated documentation
10-
// files (the "Software"), to deal in the Software without
10+
// files (the Software), to deal in the Software without
1111
// restriction, including without limitation the rights to use,
1212
// copy, modify, merge, publish, distribute, sublicense, and/or
1313
// sell copies of the Software, and to permit persons to whom the
@@ -17,7 +17,7 @@
1717
// The above copyright notice and this permission notice shall be
1818
// included in all copies or substantial portions of the Software.
1919
//
20-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
2121
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
2222
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2323
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//
2+
// Function+Effects.swift
3+
// SyntaxKit
4+
//
5+
// Created by Leo Dion.
6+
// Copyright © 2025 BrightDigit.
7+
//
8+
// Permission is hereby granted, free of charge, to any person
9+
// obtaining a copy of this software and associated documentation
10+
// files (the “Software”), to deal in the Software without
11+
// restriction, including without limitation the rights to use,
12+
// copy, modify, merge, publish, distribute, sublicense, and/or
13+
// sell copies of the Software, and to permit persons to whom the
14+
// Software is furnished to do so, subject to the following
15+
// conditions:
16+
//
17+
// The above copyright notice and this permission notice shall be
18+
// included in all copies or substantial portions of the Software.
19+
//
20+
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
21+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22+
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27+
// OTHER DEALINGS IN THE SOFTWARE.
28+
//
29+
30+
import SwiftSyntax
31+
32+
extension Function {
33+
/// Function effect specifiers (async/throws combinations)
34+
internal enum Effect {
35+
case none
36+
/// synchronous effect specifier: throws or rethrows
37+
case `throws`(isRethrows: Bool)
38+
case async
39+
/// combined async and throws/rethrows
40+
case asyncThrows(isRethrows: Bool)
41+
}
42+
43+
/// Marks the function as `throws` or `rethrows`.
44+
/// - Parameter rethrows: Pass `true` to emit `rethrows` instead of `throws`.
45+
public func `throws`(isRethrows: Bool = false) -> Self {
46+
var copy = self
47+
copy.effect = .throws(isRethrows: isRethrows)
48+
return copy
49+
}
50+
51+
/// Marks the function as `async`.
52+
public func async() -> Self {
53+
var copy = self
54+
copy.effect = .async
55+
return copy
56+
}
57+
58+
/// Marks the function as `async throws` or `async rethrows`.
59+
/// - Parameter rethrows: Pass `true` to emit `async rethrows`.
60+
public func asyncThrows(isRethrows: Bool = false) -> Self {
61+
var copy = self
62+
copy.effect = .asyncThrows(isRethrows: isRethrows)
63+
return copy
64+
}
65+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// Function+Modifiers.swift
3+
// SyntaxKit
4+
//
5+
// Created by Leo Dion.
6+
// Copyright © 2025 BrightDigit.
7+
//
8+
// Permission is hereby granted, free of charge, to any person
9+
// obtaining a copy of this software and associated documentation
10+
// files (the “Software”), to deal in the Software without
11+
// restriction, including without limitation the rights to use,
12+
// copy, modify, merge, publish, distribute, sublicense, and/or
13+
// sell copies of the Software, and to permit persons to whom the
14+
// Software is furnished to do so, subject to the following
15+
// conditions:
16+
//
17+
// The above copyright notice and this permission notice shall be
18+
// included in all copies or substantial portions of the Software.
19+
//
20+
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
21+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22+
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27+
// OTHER DEALINGS IN THE SOFTWARE.
28+
//
29+
30+
import SwiftSyntax
31+
32+
extension Function {
33+
/// Marks the function as `static`.
34+
/// - Returns: A copy of the function marked as `static`.
35+
public func `static`() -> Self {
36+
var copy = self
37+
copy.isStatic = true
38+
return copy
39+
}
40+
41+
/// Marks the function as `mutating`.
42+
/// - Returns: A copy of the function marked as `mutating`.
43+
public func mutating() -> Self {
44+
var copy = self
45+
copy.isMutating = true
46+
return copy
47+
}
48+
49+
/// Adds an attribute to the function declaration.
50+
/// - Parameters:
51+
/// - attribute: The attribute name (without the @ symbol).
52+
/// - arguments: The arguments for the attribute, if any.
53+
/// - Returns: A copy of the function with the attribute added.
54+
public func attribute(_ attribute: String, arguments: [String] = []) -> Self {
55+
var copy = self
56+
copy.attributes.append(AttributeInfo(name: attribute, arguments: arguments))
57+
return copy
58+
}
59+
}

0 commit comments

Comments
 (0)