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
5 changes: 3 additions & 2 deletions Sources/SwordGenerator/Parser/Visitor/ComponentVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ final class ComponentVisitor: SourceFileVisitor<RootComponentDescriptor> {
let arguments: [ComponentArgument]
}

override func visitPost(_ node: ClassDeclSyntax) {
guard let componentAttribute = extractComponentAttribute(from: node.attributes) else { return }
override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind {
guard let componentAttribute = extractComponentAttribute(from: node.attributes) else { return .skipChildren }

results.append(
RootComponentDescriptor(
Expand All @@ -17,6 +17,7 @@ final class ComponentVisitor: SourceFileVisitor<RootComponentDescriptor> {
location: node.startLocation(converter: locationConverter)
)
)
return .skipChildren
}

private func extractComponentAttribute(from attributes: AttributeListSyntax)
Expand Down
9 changes: 6 additions & 3 deletions Sources/SwordGenerator/Parser/Visitor/DependencyVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,34 @@ final class DependencyVisitor: SourceFileVisitor<DependencyDescriptor> {
let scope: Scope?
}

override func visitPost(_ node: StructDeclSyntax) {
override func visit(_ node: StructDeclSyntax) -> SyntaxVisitorContinueKind {
registerDependencyIfNeeded(
name: node.name,
attributes: node.attributes,
members: node.memberBlock.members,
isReferenceType: false
)
return .skipChildren
}

override func visitPost(_ node: ClassDeclSyntax) {
override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind {
registerDependencyIfNeeded(
name: node.name,
attributes: node.attributes,
members: node.memberBlock.members,
isReferenceType: true
)
return .skipChildren
}

override func visitPost(_ node: ActorDeclSyntax) {
override func visit(_ node: ActorDeclSyntax) -> SyntaxVisitorContinueKind {
registerDependencyIfNeeded(
name: node.name,
attributes: node.attributes,
members: node.memberBlock.members,
isReferenceType: true
)
return .skipChildren
}

private func registerDependencyIfNeeded(
Expand Down
3 changes: 2 additions & 1 deletion Sources/SwordGenerator/Parser/Visitor/ImportVisitor.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import SwiftSyntax

final class ImportVisitor: SourceFileVisitor<Import> {
override func visitPost(_ node: ImportDeclSyntax) {
override func visit(_ node: ImportDeclSyntax) -> SyntaxVisitorContinueKind {
results.append(
Import(
path: "\(node.trimmed.path)",
kind: node.trimmed.importKindSpecifier?.text
)
)
return .skipChildren
}
}
6 changes: 3 additions & 3 deletions Sources/SwordGenerator/Parser/Visitor/ModuleVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ final class ModuleVisitor: SourceFileVisitor<ModuleDescriptor> {
private struct ProviderAttribute {
let scope: Scope?
}

override func visitPost(_ node: StructDeclSyntax) {
guard let moduleAttribute = extractModuleAttribute(from: node.attributes) else { return }
override func visit(_ node: StructDeclSyntax) -> SyntaxVisitorContinueKind {
guard let moduleAttribute = extractModuleAttribute(from: node.attributes) else { return .skipChildren }

let providers: [ProviderDescriptor] = node.memberBlock.members.compactMap { member in
guard
Expand Down Expand Up @@ -51,6 +50,7 @@ final class ModuleVisitor: SourceFileVisitor<ModuleDescriptor> {
providers: providers
)
)
return .skipChildren
}

private func extractModuleAttribute(from attributes: AttributeListSyntax) -> ModuleAttribute? {
Expand Down
21 changes: 11 additions & 10 deletions Sources/SwordGenerator/Parser/Visitor/SubcomponentVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ final class SubcomponentVisitor: SourceFileVisitor<SubcomponentDescriptor> {
let arguments: [ComponentArgument]
}

override func visitPost(_ node: ClassDeclSyntax) {
if let subcomponentAttribute = extractSubcomponentAttribute(from: node.attributes) {
results.append(
SubcomponentDescriptor(
name: ComponentName(value: node.name.text),
arguments: subcomponentAttribute.arguments,
parentName: subcomponentAttribute.parent,
location: node.startLocation(converter: locationConverter)
)
override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind {
guard let subcomponentAttribute = extractSubcomponentAttribute(from: node.attributes) else { return .skipChildren }

results.append(
SubcomponentDescriptor(
name: ComponentName(value: node.name.text),
arguments: subcomponentAttribute.arguments,
parentName: subcomponentAttribute.parent,
location: node.startLocation(converter: locationConverter)
)
}
)
return .skipChildren
}

private func extractSubcomponentAttribute(from attributes: AttributeListSyntax)
Expand Down