Skip to content

Commit b999688

Browse files
add NSCoding command
1 parent 93cf4e7 commit b999688

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

CodeGenerator.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
A083A3861ED45DD900C9B024 /* CodingGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = A083A3841ED45DD500C9B024 /* CodingGenerator.swift */; };
5656
A083A3B31ED6DC2400C9B024 /* GeneratedNSCoder.txt in Resources */ = {isa = PBXBuildFile; fileRef = A083A3B21ED6DC2400C9B024 /* GeneratedNSCoder.txt */; };
5757
A083A3B51ED6E17D00C9B024 /* NSCodingGeneratorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = A083A3B41ED6E17D00C9B024 /* NSCodingGeneratorTest.swift */; };
58+
A083A3B71ED6EA9000C9B024 /* GenerateCodingCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = A083A3B61ED6EA9000C9B024 /* GenerateCodingCommand.swift */; };
5859
A08C585B1E13C5AA00034B76 /* ClosureType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A08C585A1E13C5AA00034B76 /* ClosureType.swift */; };
5960
A08C585C1E13C5AA00034B76 /* ClosureType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A08C585A1E13C5AA00034B76 /* ClosureType.swift */; };
6061
A08C585E1E13CB8300034B76 /* SwiftType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A08C585D1E13CB8300034B76 /* SwiftType.swift */; };
@@ -160,6 +161,7 @@
160161
A083A3841ED45DD500C9B024 /* CodingGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodingGenerator.swift; sourceTree = "<group>"; };
161162
A083A3B21ED6DC2400C9B024 /* GeneratedNSCoder.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GeneratedNSCoder.txt; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
162163
A083A3B41ED6E17D00C9B024 /* NSCodingGeneratorTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSCodingGeneratorTest.swift; sourceTree = "<group>"; };
164+
A083A3B61ED6EA9000C9B024 /* GenerateCodingCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GenerateCodingCommand.swift; sourceTree = "<group>"; };
163165
A08C585A1E13C5AA00034B76 /* ClosureType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClosureType.swift; sourceTree = "<group>"; };
164166
A08C585D1E13CB8300034B76 /* SwiftType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftType.swift; sourceTree = "<group>"; };
165167
A0A02CC21E1A60EA001900DC /* Generator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Generator.swift; sourceTree = "<group>"; };
@@ -320,6 +322,7 @@
320322
A031BD421E8D1DA6003235D5 /* GenerateAsExtensionCommand.swift */,
321323
A0A02CD11E1A7236001900DC /* GenerateEquatableCommand.swift */,
322324
A0A02CD41E1A739A001900DC /* GenerateHashableCommand.swift */,
325+
A083A3B61ED6EA9000C9B024 /* GenerateCodingCommand.swift */,
323326
A03920861E0F3A8B005A6E89 /* GenerateMockCommand.swift */,
324327
A03920901E0F3AEF005A6E89 /* String+regexr.swift */,
325328
A03920881E0F3A8B005A6E89 /* Info.plist */,
@@ -544,6 +547,7 @@
544547
files = (
545548
A01E46931E102CBB00395AED /* VarSignature.swift in Sources */,
546549
A03920851E0F3A8B005A6E89 /* SourceEditorExtension.swift in Sources */,
550+
A083A3B71ED6EA9000C9B024 /* GenerateCodingCommand.swift in Sources */,
547551
A0E2766B1E156738003CC557 /* ClosureParamMocker.swift in Sources */,
548552
A0A02CD31E1A7236001900DC /* GenerateEquatableCommand.swift in Sources */,
549553
A031BD391E8D1126003235D5 /* GenerateInitCommand.swift in Sources */,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// GenerateCodingCommand.swift
3+
// CodeGenerator
4+
//
5+
// Created by WANG Jie on 25/05/2017.
6+
// Copyright © 2017 wangjie. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import XcodeKit
11+
12+
class GenerateCodingCommand: NSObject, GenerateAsExtensionCommand {
13+
14+
var generatorType: Generator.Type {
15+
return CodingGenerator.self
16+
}
17+
18+
func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void) {
19+
swiftPerform(with: invocation, completionHandler: completionHandler)
20+
}
21+
}

Generate.../Info.plist

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,22 @@
5252
<key>XCSourceEditorCommandName</key>
5353
<string>Hashable</string>
5454
</dict>
55-
<dict>
56-
<key>XCSourceEditorCommandClassName</key>
57-
<string>$(PRODUCT_MODULE_NAME).GenerateInitCommand</string>
58-
<key>XCSourceEditorCommandIdentifier</key>
59-
<string>$(PRODUCT_BUNDLE_IDENTIFIER).GenerateInitCommand</string>
60-
<key>XCSourceEditorCommandName</key>
61-
<string>Init</string>
62-
</dict>
55+
<dict>
56+
<key>XCSourceEditorCommandClassName</key>
57+
<string>$(PRODUCT_MODULE_NAME).GenerateInitCommand</string>
58+
<key>XCSourceEditorCommandIdentifier</key>
59+
<string>$(PRODUCT_BUNDLE_IDENTIFIER).GenerateInitCommand</string>
60+
<key>XCSourceEditorCommandName</key>
61+
<string>Init</string>
62+
</dict>
63+
<dict>
64+
<key>XCSourceEditorCommandClassName</key>
65+
<string>$(PRODUCT_MODULE_NAME).GenerateCodingCommand</string>
66+
<key>XCSourceEditorCommandIdentifier</key>
67+
<string>$(PRODUCT_BUNDLE_IDENTIFIER).GenerateCodingCommand</string>
68+
<key>XCSourceEditorCommandName</key>
69+
<string>NSCoding</string>
70+
</dict>
6371
</array>
6472
<key>XCSourceEditorExtensionPrincipalClass</key>
6573
<string>$(PRODUCT_MODULE_NAME).SourceEditorExtension</string>

0 commit comments

Comments
 (0)