-
Notifications
You must be signed in to change notification settings - Fork 2
Changes from Swift-App-Template #125
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
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7e52a1d
V1.0.0 beta.1 (#11)
leogdion 1fd6c9e
Fix lint findings and lint.sh tooling after v0.0.5 rebase
leogdion 00aaec1
Address PR #125 reviews: PoundIf, InitializerDecl rename, lint.sh revert
leogdion d77a56f
Address PR #125 review: de-global attribute helper, fix init effects …
leogdion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // | ||
| // Class+Modifiers.swift | ||
| // SyntaxKit | ||
| // | ||
| // Created by Leo Dion. | ||
| // Copyright © 2026 BrightDigit. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person | ||
| // obtaining a copy of this software and associated documentation | ||
| // files (the “Software”), to deal in the Software without | ||
| // restriction, including without limitation the rights to use, | ||
| // copy, modify, merge, publish, distribute, sublicense, and/or | ||
| // sell copies of the Software, and to permit persons to whom the | ||
| // Software is furnished to do so, subject to the following | ||
| // conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be | ||
| // included in all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, | ||
| // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
| // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
| // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| // OTHER DEALINGS IN THE SOFTWARE. | ||
| // | ||
|
|
||
| extension Class { | ||
| /// Sets the generic parameters for the class. | ||
| /// - Parameter generics: The list of generic parameter names. | ||
| /// - Returns: A copy of the class with the generic parameters set. | ||
| public func generic(_ generics: String...) -> Self { | ||
| var copy = self | ||
| copy.genericParameters = generics | ||
| return copy | ||
| } | ||
|
|
||
| /// Sets the inheritance for the class. | ||
| /// - Parameter inheritance: The types to inherit from. | ||
| /// - Returns: A copy of the class with the inheritance set. | ||
| public func inherits(_ inheritance: String...) -> Self { | ||
| var copy = self | ||
| copy.inheritance = inheritance | ||
| return copy | ||
| } | ||
|
|
||
| /// Marks the class declaration as `final`. | ||
| /// - Returns: A copy of the class marked as `final`. | ||
| public func final() -> Self { | ||
| var copy = self | ||
| copy.isFinal = true | ||
| return copy | ||
| } | ||
|
|
||
| /// Sets the access modifier for the class declaration. | ||
| /// - Parameter access: The access modifier. | ||
| /// - Returns: A copy of the class with the access modifier set. | ||
| public func access(_ access: AccessModifier) -> Self { | ||
| var copy = self | ||
| copy.accessModifier = access | ||
| return copy | ||
| } | ||
|
|
||
| /// Adds an attribute to the class declaration. | ||
| /// - Parameters: | ||
| /// - attribute: The attribute name (without the @ symbol). | ||
| /// - arguments: The arguments for the attribute, if any. | ||
| /// - Returns: A copy of the class with the attribute added. | ||
| public func attribute(_ attribute: String, arguments: [String] = []) -> Self { | ||
| var copy = self | ||
| copy.attributes.append(AttributeInfo(name: attribute, arguments: arguments)) | ||
| return copy | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // | ||
| // IfCanImport.swift | ||
| // SyntaxKit | ||
| // | ||
| // Created by Leo Dion. | ||
| // Copyright © 2026 BrightDigit. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person | ||
| // obtaining a copy of this software and associated documentation | ||
| // files (the “Software”), to deal in the Software without | ||
| // restriction, including without limitation the rights to use, | ||
| // copy, modify, merge, publish, distribute, sublicense, and/or | ||
| // sell copies of the Software, and to permit persons to whom the | ||
| // Software is furnished to do so, subject to the following | ||
| // conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be | ||
| // included in all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, | ||
| // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
| // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
| // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| // OTHER DEALINGS IN THE SOFTWARE. | ||
| // | ||
|
|
||
| public import SwiftSyntax | ||
|
|
||
| /// A `#if canImport(Module)` … `#endif` conditional compilation block. | ||
| public struct IfCanImport: CodeBlock, Sendable { | ||
|
leogdion marked this conversation as resolved.
Outdated
|
||
| private let moduleName: String | ||
| private let content: [any CodeBlock] | ||
|
|
||
| /// The SwiftSyntax representation of this conditional compilation block. | ||
| public var syntax: any SyntaxProtocol { | ||
| let canImportRef = DeclReferenceExprSyntax(baseName: .identifier("canImport")) | ||
| let moduleRef = DeclReferenceExprSyntax(baseName: .identifier(moduleName)) | ||
| let condition = FunctionCallExprSyntax( | ||
| calledExpression: ExprSyntax(canImportRef), | ||
| leftParen: .leftParenToken(), | ||
| arguments: LabeledExprListSyntax([ | ||
| LabeledExprSyntax(expression: ExprSyntax(moduleRef)) | ||
| ]), | ||
| rightParen: .rightParenToken() | ||
| ) | ||
|
|
||
| let items = CodeBlockItemListSyntax( | ||
| content.compactMap { block -> CodeBlockItemSyntax? in | ||
| CodeBlockItemSyntax.Item.create(from: block.syntax).map { | ||
| CodeBlockItemSyntax(item: $0, trailingTrivia: .newline) | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| let clause = IfConfigClauseSyntax( | ||
| poundKeyword: .poundIfToken(trailingTrivia: .space), | ||
| condition: ExprSyntax(condition).with(\.trailingTrivia, .newline), | ||
| elements: .statements(items) | ||
| ) | ||
|
|
||
| return IfConfigDeclSyntax( | ||
| clauses: IfConfigClauseListSyntax([clause]), | ||
| poundEndif: .poundEndifToken(leadingTrivia: .newline) | ||
| ) | ||
| } | ||
|
|
||
| /// Creates a `#if canImport(moduleName)` block wrapping the given content. | ||
| /// - Parameters: | ||
| /// - moduleName: The module name passed to `canImport`. | ||
| /// - content: The code blocks to emit when the module is available. | ||
| public init(_ moduleName: String, @CodeBlockBuilderResult _ content: () -> [any CodeBlock]) { | ||
| self.moduleName = moduleName | ||
| self.content = content() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.