-
Notifications
You must be signed in to change notification settings - Fork 0
Added superclass inference #18
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 20 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
0d9af5d
-
NSFatalError d1012f1
-
NSFatalError c0cdfaf
[SwiftFormat] Applied formatting
NSFatalError 5f93e9b
-
NSFatalError 77acc75
-
NSFatalError 0495316
-
NSFatalError b218f68
[SwiftFormat] Applied formatting
NSFatalError 3823d0a
-
NSFatalError a9d5ff6
[SwiftFormat] Applied formatting
NSFatalError 4d47af1
-
NSFatalError 6f59de2
-
NSFatalError 87bf3bd
-
NSFatalError b519312
-
NSFatalError ed34e2b
-
NSFatalError 40f666c
-
NSFatalError 600d256
[SwiftFormat] Applied formatting
NSFatalError 2dc4d9b
-
NSFatalError d252434
-
NSFatalError a37ce11
[SwiftFormat] Applied formatting
NSFatalError 39bedd1
-
NSFatalError 58d9aa7
-
NSFatalError 9d7a483
-
NSFatalError a7567a0
-
NSFatalError 46b1776
-
NSFatalError ea7344a
-
NSFatalError cd74d85
-
NSFatalError 8cf6797
-
NSFatalError b2ac2d1
-
NSFatalError 514fa36
-
NSFatalError 3e565d4
-
NSFatalError 310be1b
-
NSFatalError cea794f
-
NSFatalError 82a1709
-
NSFatalError c794584
-
NSFatalError dd5d1aa
-
NSFatalError 4d647d5
-
NSFatalError bad8a9f
-
NSFatalError 906bd5f
-
NSFatalError 26a5f14
-
NSFatalError 0f7a856
-
NSFatalError 1f5fd7f
-
NSFatalError a1a517f
-
NSFatalError 78f41cf
[SwiftFormat] Applied formatting
NSFatalError 4715a6a
-
NSFatalError fef7ff9
-
NSFatalError b6753bb
-
NSFatalError 2fb77b4
-
NSFatalError 003b250
-
NSFatalError 4d154d0
-
NSFatalError 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
21 changes: 21 additions & 0 deletions
21
Sources/PrincipleMacros/Diagnostics/DiagnosticsError.swift
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,21 @@ | ||
| // | ||
| // DiagnosticsError.swift | ||
| // PrincipleMacros | ||
| // | ||
| // Created by Kamil Strzelecki on 21/11/2025. | ||
| // Copyright © 2025 Kamil Strzelecki. All rights reserved. | ||
| // | ||
|
|
||
| import SwiftSyntaxMacros | ||
|
|
||
| extension DiagnosticsError { | ||
|
|
||
| public init( | ||
| node: some SyntaxProtocol, | ||
| message: String | ||
| ) { | ||
| let message = MacroExpansionErrorMessage(message) | ||
| let diagnostic = Diagnostic(node: node, message: message) | ||
| self.init(diagnostics: [diagnostic]) | ||
| } | ||
| } |
File renamed without changes.
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 was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
Sources/PrincipleMacros/Parsers/Common/_ParserResultsCollection.swift
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
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
37 changes: 0 additions & 37 deletions
37
Sources/PrincipleMacros/Syntax/Extensions/AttributeListSyntax.swift
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
Sources/PrincipleMacros/Syntax/Extensions/AttributeSyntax.swift
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
Sources/PrincipleMacros/Syntax/Extensions/ClassDeclSyntax.swift
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,56 @@ | ||
| // | ||
| // ClassDeclSyntax.swift | ||
| // PrincipleMacros | ||
| // | ||
| // Created by Kamil Strzelecki on 21/11/2025. | ||
| // Copyright © 2025 Kamil Strzelecki. All rights reserved. | ||
| // | ||
|
|
||
| import SwiftSyntaxMacros | ||
|
|
||
| extension ClassDeclSyntax { | ||
|
|
||
| public func inferredSuperclass() -> TypeSyntax? { | ||
| let superclassFinder = SuperclassFinder(for: self) | ||
| return superclassFinder.find()?.trimmed | ||
| } | ||
| } | ||
|
|
||
| extension ClassDeclSyntax { | ||
|
|
||
| private final class SuperclassFinder: SyntaxVisitor { | ||
|
|
||
| private let classDecl: ClassDeclSyntax | ||
| private var didFind = false | ||
|
|
||
| init(for classDecl: ClassDeclSyntax) { | ||
| self.classDecl = classDecl | ||
| super.init(viewMode: .sourceAccurate) | ||
| } | ||
|
|
||
| func find() -> TypeSyntax? { | ||
| guard let inheritanceClause = classDecl.inheritanceClause, | ||
| let firstInheritedType = inheritanceClause.inheritedTypes.first?.type | ||
| else { | ||
| return nil | ||
| } | ||
|
|
||
| walk(classDecl) | ||
| return didFind ? firstInheritedType : nil | ||
| } | ||
|
|
||
| override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind { | ||
| node == classDecl ? .visitChildren : .skipChildren | ||
| } | ||
|
|
||
| override func visit(_ node: DeclModifierSyntax) -> SyntaxVisitorContinueKind { | ||
| didFind = didFind || node.overrideSpecifier != nil | ||
| return .visitChildren | ||
| } | ||
|
|
||
| override func visit(_: SuperExprSyntax) -> SyntaxVisitorContinueKind { | ||
| didFind = true | ||
| return .visitChildren | ||
| } | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Parser helpers for declarations, members, and if-configs are well factored — verify conformers’ signatures
The new
throws-basedParser.parse(declaration:)requirement and the addedparse(ifConfig:),parse(members:), andparse(memberBlock:)helpers give a clear, reusable traversal story for members and nested#ifblocks. The flat-mapping of per-clause/per-memberResultsCollections into a singleResultsCollectionmatches the existing collection design.One thing to double-check is that every
Parserconformer’sparse(declaration:)implementation and all call sites have been updated to the newthrowssignature where appropriate.🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 2102
🏁 Script executed:
Length of output: 2102
🏁 Script executed:
Length of output: 463
EnumCasesParser.parse(declaration:) must be updated to match the new
throwsprotocol requirementThe Parser protocol now requires
parse(declaration:)to throw, but EnumCasesParser's implementation at Sources/PrincipleMacros/Parsers/EnumCases/EnumCasesParser.swift:13 is still missing thethrowskeyword. PropertiesParser was correctly updated, but EnumCasesParser was not. Update the signature to:🤖 Prompt for AI Agents