Skip to content

Commit

Permalink
Finishing SwiftSyntax touches.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyáš Kříž committed Apr 22, 2024
1 parent 2a28139 commit d2d44b9
Show file tree
Hide file tree
Showing 13 changed files with 1,027 additions and 750 deletions.
4 changes: 2 additions & 2 deletions Cuckoo.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Pod::Spec.new do |s|
s.author = { 'Matyas Kriz' => '[email protected]', 'Tadeas Kriz' => '[email protected]', 'Filip Dolnik' => '[email protected]' }
s.source = { :git => 'https://github.com/Brightify/Cuckoo.git', :tag => s.version.to_s }

s.ios.deployment_target = '12.0'
s.ios.deployment_target = '13.0'
s.osx.deployment_target = '11'
#s.watchos.deployment_target = '2.0' # watchos does not include XCTest framework :(
s.tvos.deployment_target = '12.0'
s.tvos.deployment_target = '13.0'
generator_name = 'cuckoonator'
s.swift_version = '5.0'
s.preserve_paths = ['Generator/**/*', 'version', 'run', 'build_generator', generator_name]
Expand Down
357 changes: 136 additions & 221 deletions Cuckoo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ GEM
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-21
Expand Down
962 changes: 690 additions & 272 deletions Generator/Generator.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,102 +1,120 @@
{
"pins" : [
{
"identity" : "commandant",
"identity" : "aexml",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Carthage/Commandant.git",
"location" : "https://github.com/tadija/AEXML.git",
"state" : {
"revision" : "07cad52573bad19d95844035bf0b25acddf6b0f6",
"version" : "0.15.0"
"revision" : "38f7d00b23ecd891e1ee656fa6aeebd6ba04ecc3",
"version" : "4.6.1"
}
},
{
"identity" : "filekit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nvzqz/FileKit.git",
"state" : {
"branch" : "develop",
"revision" : "9006d2888025fbe893c3c396327b2fe45a8c177b"
"revision" : "9006d2888025fbe893c3c396327b2fe45a8c177b",
"version" : "6.1.0"
}
},
{
"identity" : "nimble",
"identity" : "pathkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"location" : "https://github.com/kylef/PathKit.git",
"state" : {
"revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
"version" : "7.3.4"
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version" : "1.0.1"
}
},
{
"identity" : "pathkit",
"identity" : "rainbow",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/PathKit.git",
"location" : "https://github.com/onevcat/Rainbow",
"state" : {
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version" : "1.0.1"
"revision" : "e0dada9cd44e3fa7ec3b867e49a8ddbf543e3df3",
"version" : "4.0.1"
}
},
{
"identity" : "quick",
"identity" : "spectre",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Quick.git",
"location" : "https://github.com/kylef/Spectre.git",
"state" : {
"revision" : "f2b5a06440ea87eba1a167cab37bf6496646c52e",
"version" : "1.3.4"
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version" : "0.10.1"
}
},
{
"identity" : "result",
"identity" : "stencil",
"kind" : "remoteSourceControl",
"location" : "https://github.com/antitypical/Result.git",
"location" : "https://github.com/kylef/Stencil.git",
"state" : {
"revision" : "2ca499ba456795616fbc471561ff1d963e6ae160",
"version" : "4.1.0"
"revision" : "4f222ac85d673f35df29962fc4c36ccfdaf9da5b",
"version" : "0.15.1"
}
},
{
"identity" : "sourcekitten",
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/SourceKitten.git",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "79ca340f609adee48defa966e6a3dd0e0acbeb08",
"version" : "0.21.3"
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
}
},
{
"identity" : "spectre",
"identity" : "swift-cmark",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/Spectre.git",
"location" : "https://github.com/apple/swift-cmark.git",
"state" : {
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version" : "0.10.1"
"revision" : "f218e5d7691f78b55bfa39b367763f4612486c35",
"version" : "0.3.0"
}
},
{
"identity" : "stencil",
"identity" : "swift-format",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/Stencil.git",
"location" : "https://github.com/apple/swift-format.git",
"state" : {
"revision" : "83248b4fa37919f78ffbd4650946759bcc54c2b5",
"version" : "509.0.0"
}
},
{
"identity" : "swift-markdown",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-markdown.git",
"state" : {
"revision" : "e4f95e2dc23097a1a9a1dfdfe3fe3ee44de77378",
"version" : "0.3.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "ccd9402682f4c07dac9561befd207c8156e80e20",
"version" : "0.14.2"
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
}
},
{
"identity" : "swxmlhash",
"identity" : "tomlkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/drmohundro/SWXMLHash.git",
"location" : "https://github.com/LebJe/TOMLKit.git",
"state" : {
"revision" : "f43166a8e18fdd0857f29e303b1bb79a5428bca0",
"version" : "4.9.0"
"revision" : "404c4dd011743461bff12d00a5118d0ed59d630c",
"version" : "0.5.5"
}
},
{
"identity" : "yams",
"identity" : "xcodeproj",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"location" : "https://github.com/tuist/XcodeProj.git",
"state" : {
"revision" : "b08dba4bcea978bf1ad37703a384097d3efce5af",
"version" : "1.0.2"
"revision" : "3797181813ee963fe305d939232bc576d23ddbb0",
"version" : "8.15.0"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Copy executable"
scriptText = "\cp &quot;$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME&quot; &quot;$PROJECT_DIR/bin/cuckoo_generator&quot;">
scriptText = "\cp &quot;$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME&quot; &quot;$PROJECT_DIR/bin/cuckoonator&quot;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BFA35E87D881C5E54340E27C"
BuildableName = "cuckoo_generator"
BlueprintName = "CuckooGenerator"
BlueprintIdentifier = "B015B928C38A178E17010830"
BuildableName = "cuckoonator"
BlueprintName = "Cuckoonator"
ReferencedContainer = "container:Generator.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
Expand All @@ -32,9 +32,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BFA35E87D881C5E54340E27C"
BuildableName = "cuckoo_generator"
BlueprintName = "CuckooGenerator"
BlueprintIdentifier = "B015B928C38A178E17010830"
BuildableName = "cuckoonator"
BlueprintName = "Cuckoonator"
ReferencedContainer = "container:Generator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -44,9 +44,18 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "210A2D4A8CA610B2DBD38F07"
BuildableName = "CuckoonatorTests.xctest"
BlueprintName = "CuckoonatorTests"
ReferencedContainer = "container:Generator.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand All @@ -64,31 +73,19 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BFA35E87D881C5E54340E27C"
BuildableName = "cuckoo_generator"
BlueprintName = "CuckooGenerator"
BlueprintIdentifier = "B015B928C38A178E17010830"
BuildableName = "cuckoonator"
BlueprintName = "Cuckoonator"
ReferencedContainer = "container:Generator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "generate"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--testable Cuckoo"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--exclude ExcludedTestClass,ExcludedProtocol"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--output &quot;$PROJECT_DIR&quot;/GeneratedMocks.swift"
argument = "--configuration ../Cuckoofile"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--glob &quot;$PROJECT_DIR&quot;/../Tests/Swift/Source/*.swift"
argument = "--verbose"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
Expand All @@ -105,9 +102,9 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BFA35E87D881C5E54340E27C"
BuildableName = "cuckoo_generator"
BlueprintName = "CuckooGenerator"
BlueprintIdentifier = "B015B928C38A178E17010830"
BuildableName = "cuckoonator"
BlueprintName = "Cuckoonator"
ReferencedContainer = "container:Generator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand Down
10 changes: 7 additions & 3 deletions Generator/Sources/CLI/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ final class Generator {
}
}
let flatMappedFiles = files.map { $0.flatMappingMemberContainers() }
let finalFiles = module.options.noInheritance ? flatMappedFiles : inheritNSObject(mergingInheritance(flatMappedFiles))
let finalFiles = if module.options.enableInheritance {
inheritNSObject(mergingInheritance(flatMappedFiles))
} else {
flatMappedFiles
}

// filter classes/protocols based on the settings passed to the generator
var typeFilters: [TokenFilter] = []
if module.options.noClassMocking {
if module.options.protocolsOnly {
typeFilters.append(ignoreClasses)
}
if let regex = module.regex {
Expand All @@ -63,7 +67,7 @@ final class Generator {
GeneratedFile(
path: file.file.path,
contents: [
module.options.noHeaders ? nil : FileHeaderHandler.header(for: file, timestamp: timestamp),
module.options.omitHeaders ? nil : FileHeaderHandler.header(for: file, timestamp: timestamp),
FileHeaderHandler.imports(for: file, imports: module.imports, testableImports: module.testableImports),
try GeneratorHelper.generate(tokens: file.tokens),
]
Expand Down
24 changes: 12 additions & 12 deletions Generator/Sources/CLI/Module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ final class Module {
self.options = Options(
glob: dto.options?.glob ?? true,
keepDocumentation: dto.options?.keepDocumentation ?? true,
noInheritance: dto.options?.noInheritance ?? false,
noClassMocking: dto.options?.noClassMocking ?? false,
noHeaders: dto.options?.noHeaders ?? false
enableInheritance: dto.options?.enableInheritance ?? true,
protocolsOnly: dto.options?.protocolsOnly ?? false,
omitHeaders: dto.options?.omitHeaders ?? false
)

if let xcodeproj = dto.xcodeproj {
Expand All @@ -61,9 +61,9 @@ final class Module {
struct Options {
let glob: Bool
let keepDocumentation: Bool
let noInheritance: Bool
let noClassMocking: Bool
let noHeaders: Bool
let enableInheritance: Bool
let protocolsOnly: Bool
let omitHeaders: Bool
}

struct Xcodeproj {
Expand Down Expand Up @@ -104,9 +104,9 @@ extension Module {
struct Options: Decodable {
let glob: Bool?
let keepDocumentation: Bool?
let noInheritance: Bool?
let noClassMocking: Bool?
let noHeaders: Bool?
let enableInheritance: Bool?
let protocolsOnly: Bool?
let omitHeaders: Bool?
}

struct Xcodeproj: Decodable {
Expand Down Expand Up @@ -139,9 +139,9 @@ extension Module.Options: CustomDebugStringConvertible {
[
"glob: \(String(glob).bold)",
"keep documentation: \(String(keepDocumentation).bold)",
"disabled inheritance: \(String(noInheritance).bold)",
"disabled class mocking: \(String(noClassMocking).bold)",
"disabled headers: \(String(noHeaders).bold)",
"enable inheritance: \(String(enableInheritance).bold)",
"protocols only: \(String(protocolsOnly).bold)",
"omit headers: \(String(omitHeaders).bold)",
]
.compactMap { $0 }
.joined(separator: "\n")
Expand Down
Loading

0 comments on commit d2d44b9

Please sign in to comment.