├── .gitignore ├── CodeGenerator.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── pan.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── CodeGenerator.xcscheme │ ├── Generate Code.xcscheme │ └── xcschememanagement.plist ├── CodeGenerator ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon_128x128.png │ │ ├── Icon_128x128@2x.png │ │ ├── Icon_16x16.png │ │ ├── Icon_16x16@2x.png │ │ ├── Icon_256x256.png │ │ ├── Icon_256x256@2x.png │ │ ├── Icon_32x32.png │ │ ├── Icon_32x32@2x.png │ │ ├── Icon_512x512.png │ │ └── Icon_512x512@2x.png ├── Base.lproj │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── CodeGeneratorTests ├── CodeGeneratorTests.m └── Info.plist ├── LICENSE ├── README.md ├── Source ├── AccessCodeGenerator.h ├── AccessCodeGenerator.m ├── PSProperty.h └── PSProperty.m ├── SourceEditorPlugin ├── Info.plist ├── SourceEditorCommand.h ├── SourceEditorCommand.m ├── SourceEditorExtension.h ├── SourceEditorExtension.m └── SourceEditorPlugin.entitlements └── images ├── preview.gif ├── system_plugin.png ├── system_setting.png └── xcode_setting.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/Preview.html 54 | fastlane/screenshots 55 | fastlane/test_output 56 | 57 | # Code Injection 58 | # 59 | # After new code Injection tools there's a generated folder /iOSInjectionProject 60 | # https://github.com/johnno1962/injectionforxcode 61 | 62 | iOSInjectionProject/ 63 | -------------------------------------------------------------------------------- /CodeGenerator.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3B11E9441EC9DA28001F4782 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E9431EC9DA28001F4782 /* AppDelegate.m */; }; 11 | 3B11E9471EC9DA28001F4782 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E9461EC9DA28001F4782 /* main.m */; }; 12 | 3B11E94A1EC9DA28001F4782 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E9491EC9DA28001F4782 /* ViewController.m */; }; 13 | 3B11E94C1EC9DA28001F4782 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3B11E94B1EC9DA28001F4782 /* Assets.xcassets */; }; 14 | 3B11E94F1EC9DA28001F4782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3B11E94D1EC9DA28001F4782 /* Main.storyboard */; }; 15 | 3B11E96B1EC9DA69001F4782 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B11E96A1EC9DA69001F4782 /* Cocoa.framework */; }; 16 | 3B11E9711EC9DA69001F4782 /* SourceEditorExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E9701EC9DA69001F4782 /* SourceEditorExtension.m */; }; 17 | 3B11E9741EC9DA69001F4782 /* SourceEditorCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E9731EC9DA69001F4782 /* SourceEditorCommand.m */; }; 18 | 3B11E9781EC9DA69001F4782 /* Generate Code.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 3B11E9681EC9DA69001F4782 /* Generate Code.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 19 | 3B11E9821EC9DAC0001F4782 /* AccessCodeGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E97F1EC9DAC0001F4782 /* AccessCodeGenerator.m */; }; 20 | 3B11E9831EC9DAC0001F4782 /* AccessCodeGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E97F1EC9DAC0001F4782 /* AccessCodeGenerator.m */; }; 21 | 3B11E9841EC9DAC0001F4782 /* PSProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E9811EC9DAC0001F4782 /* PSProperty.m */; }; 22 | 3B11E9851EC9DAC0001F4782 /* PSProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B11E9811EC9DAC0001F4782 /* PSProperty.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | 3B11E9761EC9DA69001F4782 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = 3B11E9371EC9DA28001F4782 /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 3B11E9671EC9DA69001F4782; 31 | remoteInfo = SourceEditorPlugin; 32 | }; 33 | /* End PBXContainerItemProxy section */ 34 | 35 | /* Begin PBXCopyFilesBuildPhase section */ 36 | 3B11E97C1EC9DA69001F4782 /* Embed App Extensions */ = { 37 | isa = PBXCopyFilesBuildPhase; 38 | buildActionMask = 2147483647; 39 | dstPath = ""; 40 | dstSubfolderSpec = 13; 41 | files = ( 42 | 3B11E9781EC9DA69001F4782 /* Generate Code.appex in Embed App Extensions */, 43 | ); 44 | name = "Embed App Extensions"; 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXCopyFilesBuildPhase section */ 48 | 49 | /* Begin PBXFileReference section */ 50 | 3B11E93F1EC9DA28001F4782 /* CodeGenerator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CodeGenerator.app; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 3B11E9421EC9DA28001F4782 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 52 | 3B11E9431EC9DA28001F4782 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 53 | 3B11E9461EC9DA28001F4782 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 54 | 3B11E9481EC9DA28001F4782 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 55 | 3B11E9491EC9DA28001F4782 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 56 | 3B11E94B1EC9DA28001F4782 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 57 | 3B11E94E1EC9DA28001F4782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 58 | 3B11E9501EC9DA28001F4782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 3B11E9591EC9DA28001F4782 /* CodeGeneratorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CodeGeneratorTests.m; sourceTree = ""; }; 60 | 3B11E95B1EC9DA28001F4782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 61 | 3B11E9681EC9DA69001F4782 /* Generate Code.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Generate Code.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; 62 | 3B11E96A1EC9DA69001F4782 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 63 | 3B11E96E1EC9DA69001F4782 /* SourceEditorPlugin.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SourceEditorPlugin.entitlements; sourceTree = ""; }; 64 | 3B11E96F1EC9DA69001F4782 /* SourceEditorExtension.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SourceEditorExtension.h; sourceTree = ""; }; 65 | 3B11E9701EC9DA69001F4782 /* SourceEditorExtension.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SourceEditorExtension.m; sourceTree = ""; }; 66 | 3B11E9721EC9DA69001F4782 /* SourceEditorCommand.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SourceEditorCommand.h; sourceTree = ""; }; 67 | 3B11E9731EC9DA69001F4782 /* SourceEditorCommand.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SourceEditorCommand.m; sourceTree = ""; }; 68 | 3B11E9751EC9DA69001F4782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 69 | 3B11E97E1EC9DAC0001F4782 /* AccessCodeGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessCodeGenerator.h; sourceTree = ""; }; 70 | 3B11E97F1EC9DAC0001F4782 /* AccessCodeGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AccessCodeGenerator.m; sourceTree = ""; }; 71 | 3B11E9801EC9DAC0001F4782 /* PSProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSProperty.h; sourceTree = ""; }; 72 | 3B11E9811EC9DAC0001F4782 /* PSProperty.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSProperty.m; sourceTree = ""; }; 73 | /* End PBXFileReference section */ 74 | 75 | /* Begin PBXFrameworksBuildPhase section */ 76 | 3B11E93C1EC9DA28001F4782 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | 3B11E9651EC9DA69001F4782 /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | 3B11E96B1EC9DA69001F4782 /* Cocoa.framework in Frameworks */, 88 | ); 89 | runOnlyForDeploymentPostprocessing = 0; 90 | }; 91 | /* End PBXFrameworksBuildPhase section */ 92 | 93 | /* Begin PBXGroup section */ 94 | 3B11E9361EC9DA28001F4782 = { 95 | isa = PBXGroup; 96 | children = ( 97 | 3B11E97D1EC9DAC0001F4782 /* Source */, 98 | 3B11E9411EC9DA28001F4782 /* CodeGenerator */, 99 | 3B11E9581EC9DA28001F4782 /* CodeGeneratorTests */, 100 | 3B11E96C1EC9DA69001F4782 /* SourceEditorPlugin */, 101 | 3B11E9691EC9DA69001F4782 /* Frameworks */, 102 | 3B11E9401EC9DA28001F4782 /* Products */, 103 | ); 104 | sourceTree = ""; 105 | }; 106 | 3B11E9401EC9DA28001F4782 /* Products */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 3B11E93F1EC9DA28001F4782 /* CodeGenerator.app */, 110 | 3B11E9681EC9DA69001F4782 /* Generate Code.appex */, 111 | ); 112 | name = Products; 113 | sourceTree = ""; 114 | }; 115 | 3B11E9411EC9DA28001F4782 /* CodeGenerator */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 3B11E9421EC9DA28001F4782 /* AppDelegate.h */, 119 | 3B11E9431EC9DA28001F4782 /* AppDelegate.m */, 120 | 3B11E9481EC9DA28001F4782 /* ViewController.h */, 121 | 3B11E9491EC9DA28001F4782 /* ViewController.m */, 122 | 3B11E94B1EC9DA28001F4782 /* Assets.xcassets */, 123 | 3B11E94D1EC9DA28001F4782 /* Main.storyboard */, 124 | 3B11E9501EC9DA28001F4782 /* Info.plist */, 125 | 3B11E9451EC9DA28001F4782 /* Supporting Files */, 126 | ); 127 | path = CodeGenerator; 128 | sourceTree = ""; 129 | }; 130 | 3B11E9451EC9DA28001F4782 /* Supporting Files */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | 3B11E9461EC9DA28001F4782 /* main.m */, 134 | ); 135 | name = "Supporting Files"; 136 | sourceTree = ""; 137 | }; 138 | 3B11E9581EC9DA28001F4782 /* CodeGeneratorTests */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 3B11E9591EC9DA28001F4782 /* CodeGeneratorTests.m */, 142 | 3B11E95B1EC9DA28001F4782 /* Info.plist */, 143 | ); 144 | path = CodeGeneratorTests; 145 | sourceTree = ""; 146 | }; 147 | 3B11E9691EC9DA69001F4782 /* Frameworks */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 3B11E96A1EC9DA69001F4782 /* Cocoa.framework */, 151 | ); 152 | name = Frameworks; 153 | sourceTree = ""; 154 | }; 155 | 3B11E96C1EC9DA69001F4782 /* SourceEditorPlugin */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | 3B11E96F1EC9DA69001F4782 /* SourceEditorExtension.h */, 159 | 3B11E9701EC9DA69001F4782 /* SourceEditorExtension.m */, 160 | 3B11E9721EC9DA69001F4782 /* SourceEditorCommand.h */, 161 | 3B11E9731EC9DA69001F4782 /* SourceEditorCommand.m */, 162 | 3B11E9751EC9DA69001F4782 /* Info.plist */, 163 | 3B11E96D1EC9DA69001F4782 /* Supporting Files */, 164 | ); 165 | path = SourceEditorPlugin; 166 | sourceTree = ""; 167 | }; 168 | 3B11E96D1EC9DA69001F4782 /* Supporting Files */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | 3B11E96E1EC9DA69001F4782 /* SourceEditorPlugin.entitlements */, 172 | ); 173 | name = "Supporting Files"; 174 | sourceTree = ""; 175 | }; 176 | 3B11E97D1EC9DAC0001F4782 /* Source */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 3B11E97E1EC9DAC0001F4782 /* AccessCodeGenerator.h */, 180 | 3B11E97F1EC9DAC0001F4782 /* AccessCodeGenerator.m */, 181 | 3B11E9801EC9DAC0001F4782 /* PSProperty.h */, 182 | 3B11E9811EC9DAC0001F4782 /* PSProperty.m */, 183 | ); 184 | path = Source; 185 | sourceTree = ""; 186 | }; 187 | /* End PBXGroup section */ 188 | 189 | /* Begin PBXNativeTarget section */ 190 | 3B11E93E1EC9DA28001F4782 /* CodeGenerator */ = { 191 | isa = PBXNativeTarget; 192 | buildConfigurationList = 3B11E95E1EC9DA28001F4782 /* Build configuration list for PBXNativeTarget "CodeGenerator" */; 193 | buildPhases = ( 194 | 3B11E93B1EC9DA28001F4782 /* Sources */, 195 | 3B11E93C1EC9DA28001F4782 /* Frameworks */, 196 | 3B11E93D1EC9DA28001F4782 /* Resources */, 197 | 3B11E97C1EC9DA69001F4782 /* Embed App Extensions */, 198 | ); 199 | buildRules = ( 200 | ); 201 | dependencies = ( 202 | 3B11E9771EC9DA69001F4782 /* PBXTargetDependency */, 203 | ); 204 | name = CodeGenerator; 205 | productName = CodeGenerator; 206 | productReference = 3B11E93F1EC9DA28001F4782 /* CodeGenerator.app */; 207 | productType = "com.apple.product-type.application"; 208 | }; 209 | 3B11E9671EC9DA69001F4782 /* Generate Code */ = { 210 | isa = PBXNativeTarget; 211 | buildConfigurationList = 3B11E9791EC9DA69001F4782 /* Build configuration list for PBXNativeTarget "Generate Code" */; 212 | buildPhases = ( 213 | 3B11E9641EC9DA69001F4782 /* Sources */, 214 | 3B11E9651EC9DA69001F4782 /* Frameworks */, 215 | 3B11E9661EC9DA69001F4782 /* Resources */, 216 | ); 217 | buildRules = ( 218 | ); 219 | dependencies = ( 220 | ); 221 | name = "Generate Code"; 222 | productName = SourceEditorPlugin; 223 | productReference = 3B11E9681EC9DA69001F4782 /* Generate Code.appex */; 224 | productType = "com.apple.product-type.xcode-extension"; 225 | }; 226 | /* End PBXNativeTarget section */ 227 | 228 | /* Begin PBXProject section */ 229 | 3B11E9371EC9DA28001F4782 /* Project object */ = { 230 | isa = PBXProject; 231 | attributes = { 232 | LastUpgradeCheck = 0830; 233 | ORGANIZATIONNAME = "Sheng Pan"; 234 | TargetAttributes = { 235 | 3B11E93E1EC9DA28001F4782 = { 236 | CreatedOnToolsVersion = 8.3.2; 237 | DevelopmentTeam = AE5B4P8L99; 238 | ProvisioningStyle = Automatic; 239 | }; 240 | 3B11E9671EC9DA69001F4782 = { 241 | CreatedOnToolsVersion = 8.3.2; 242 | DevelopmentTeam = AE5B4P8L99; 243 | ProvisioningStyle = Automatic; 244 | }; 245 | }; 246 | }; 247 | buildConfigurationList = 3B11E93A1EC9DA28001F4782 /* Build configuration list for PBXProject "CodeGenerator" */; 248 | compatibilityVersion = "Xcode 3.2"; 249 | developmentRegion = English; 250 | hasScannedForEncodings = 0; 251 | knownRegions = ( 252 | en, 253 | Base, 254 | ); 255 | mainGroup = 3B11E9361EC9DA28001F4782; 256 | productRefGroup = 3B11E9401EC9DA28001F4782 /* Products */; 257 | projectDirPath = ""; 258 | projectRoot = ""; 259 | targets = ( 260 | 3B11E93E1EC9DA28001F4782 /* CodeGenerator */, 261 | 3B11E9671EC9DA69001F4782 /* Generate Code */, 262 | ); 263 | }; 264 | /* End PBXProject section */ 265 | 266 | /* Begin PBXResourcesBuildPhase section */ 267 | 3B11E93D1EC9DA28001F4782 /* Resources */ = { 268 | isa = PBXResourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | 3B11E94C1EC9DA28001F4782 /* Assets.xcassets in Resources */, 272 | 3B11E94F1EC9DA28001F4782 /* Main.storyboard in Resources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | 3B11E9661EC9DA69001F4782 /* Resources */ = { 277 | isa = PBXResourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXResourcesBuildPhase section */ 284 | 285 | /* Begin PBXSourcesBuildPhase section */ 286 | 3B11E93B1EC9DA28001F4782 /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | 3B11E9821EC9DAC0001F4782 /* AccessCodeGenerator.m in Sources */, 291 | 3B11E9841EC9DAC0001F4782 /* PSProperty.m in Sources */, 292 | 3B11E94A1EC9DA28001F4782 /* ViewController.m in Sources */, 293 | 3B11E9471EC9DA28001F4782 /* main.m in Sources */, 294 | 3B11E9441EC9DA28001F4782 /* AppDelegate.m in Sources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | 3B11E9641EC9DA69001F4782 /* Sources */ = { 299 | isa = PBXSourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | 3B11E9831EC9DAC0001F4782 /* AccessCodeGenerator.m in Sources */, 303 | 3B11E9711EC9DA69001F4782 /* SourceEditorExtension.m in Sources */, 304 | 3B11E9741EC9DA69001F4782 /* SourceEditorCommand.m in Sources */, 305 | 3B11E9851EC9DAC0001F4782 /* PSProperty.m in Sources */, 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | /* End PBXSourcesBuildPhase section */ 310 | 311 | /* Begin PBXTargetDependency section */ 312 | 3B11E9771EC9DA69001F4782 /* PBXTargetDependency */ = { 313 | isa = PBXTargetDependency; 314 | target = 3B11E9671EC9DA69001F4782 /* Generate Code */; 315 | targetProxy = 3B11E9761EC9DA69001F4782 /* PBXContainerItemProxy */; 316 | }; 317 | /* End PBXTargetDependency section */ 318 | 319 | /* Begin PBXVariantGroup section */ 320 | 3B11E94D1EC9DA28001F4782 /* Main.storyboard */ = { 321 | isa = PBXVariantGroup; 322 | children = ( 323 | 3B11E94E1EC9DA28001F4782 /* Base */, 324 | ); 325 | name = Main.storyboard; 326 | sourceTree = ""; 327 | }; 328 | /* End PBXVariantGroup section */ 329 | 330 | /* Begin XCBuildConfiguration section */ 331 | 3B11E95C1EC9DA28001F4782 /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | ALWAYS_SEARCH_USER_PATHS = NO; 335 | CLANG_ANALYZER_NONNULL = YES; 336 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 337 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 338 | CLANG_CXX_LIBRARY = "libc++"; 339 | CLANG_ENABLE_MODULES = YES; 340 | CLANG_ENABLE_OBJC_ARC = YES; 341 | CLANG_WARN_BOOL_CONVERSION = YES; 342 | CLANG_WARN_CONSTANT_CONVERSION = YES; 343 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 344 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 345 | CLANG_WARN_EMPTY_BODY = YES; 346 | CLANG_WARN_ENUM_CONVERSION = YES; 347 | CLANG_WARN_INFINITE_RECURSION = YES; 348 | CLANG_WARN_INT_CONVERSION = YES; 349 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 350 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | CODE_SIGN_IDENTITY = "-"; 354 | COPY_PHASE_STRIP = NO; 355 | DEBUG_INFORMATION_FORMAT = dwarf; 356 | ENABLE_STRICT_OBJC_MSGSEND = YES; 357 | ENABLE_TESTABILITY = YES; 358 | GCC_C_LANGUAGE_STANDARD = gnu99; 359 | GCC_DYNAMIC_NO_PIC = NO; 360 | GCC_NO_COMMON_BLOCKS = YES; 361 | GCC_OPTIMIZATION_LEVEL = 0; 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 367 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 368 | GCC_WARN_UNDECLARED_SELECTOR = YES; 369 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 370 | GCC_WARN_UNUSED_FUNCTION = YES; 371 | GCC_WARN_UNUSED_VARIABLE = YES; 372 | MACOSX_DEPLOYMENT_TARGET = 10.12; 373 | MTL_ENABLE_DEBUG_INFO = YES; 374 | ONLY_ACTIVE_ARCH = YES; 375 | SDKROOT = macosx; 376 | }; 377 | name = Debug; 378 | }; 379 | 3B11E95D1EC9DA28001F4782 /* Release */ = { 380 | isa = XCBuildConfiguration; 381 | buildSettings = { 382 | ALWAYS_SEARCH_USER_PATHS = NO; 383 | CLANG_ANALYZER_NONNULL = YES; 384 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 385 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 386 | CLANG_CXX_LIBRARY = "libc++"; 387 | CLANG_ENABLE_MODULES = YES; 388 | CLANG_ENABLE_OBJC_ARC = YES; 389 | CLANG_WARN_BOOL_CONVERSION = YES; 390 | CLANG_WARN_CONSTANT_CONVERSION = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 393 | CLANG_WARN_EMPTY_BODY = YES; 394 | CLANG_WARN_ENUM_CONVERSION = YES; 395 | CLANG_WARN_INFINITE_RECURSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 399 | CLANG_WARN_UNREACHABLE_CODE = YES; 400 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 401 | CODE_SIGN_IDENTITY = "-"; 402 | COPY_PHASE_STRIP = NO; 403 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 404 | ENABLE_NS_ASSERTIONS = NO; 405 | ENABLE_STRICT_OBJC_MSGSEND = YES; 406 | GCC_C_LANGUAGE_STANDARD = gnu99; 407 | GCC_NO_COMMON_BLOCKS = YES; 408 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 409 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 410 | GCC_WARN_UNDECLARED_SELECTOR = YES; 411 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 412 | GCC_WARN_UNUSED_FUNCTION = YES; 413 | GCC_WARN_UNUSED_VARIABLE = YES; 414 | MACOSX_DEPLOYMENT_TARGET = 10.12; 415 | MTL_ENABLE_DEBUG_INFO = NO; 416 | SDKROOT = macosx; 417 | }; 418 | name = Release; 419 | }; 420 | 3B11E95F1EC9DA28001F4782 /* Debug */ = { 421 | isa = XCBuildConfiguration; 422 | buildSettings = { 423 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 424 | CODE_SIGN_IDENTITY = "Mac Developer"; 425 | COMBINE_HIDPI_IMAGES = YES; 426 | DEVELOPMENT_TEAM = AE5B4P8L99; 427 | INFOPLIST_FILE = CodeGenerator/Info.plist; 428 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 429 | PRODUCT_BUNDLE_IDENTIFIER = net.shengpan.CodeGenerator; 430 | PRODUCT_NAME = "$(TARGET_NAME)"; 431 | PROVISIONING_PROFILE_SPECIFIER = ""; 432 | }; 433 | name = Debug; 434 | }; 435 | 3B11E9601EC9DA28001F4782 /* Release */ = { 436 | isa = XCBuildConfiguration; 437 | buildSettings = { 438 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 439 | CODE_SIGN_IDENTITY = "Mac Developer"; 440 | COMBINE_HIDPI_IMAGES = YES; 441 | DEVELOPMENT_TEAM = AE5B4P8L99; 442 | INFOPLIST_FILE = CodeGenerator/Info.plist; 443 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 444 | PRODUCT_BUNDLE_IDENTIFIER = net.shengpan.CodeGenerator; 445 | PRODUCT_NAME = "$(TARGET_NAME)"; 446 | PROVISIONING_PROFILE_SPECIFIER = ""; 447 | }; 448 | name = Release; 449 | }; 450 | 3B11E97A1EC9DA69001F4782 /* Debug */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | CODE_SIGN_ENTITLEMENTS = SourceEditorPlugin/SourceEditorPlugin.entitlements; 454 | CODE_SIGN_IDENTITY = "Mac Developer"; 455 | COMBINE_HIDPI_IMAGES = YES; 456 | DEVELOPMENT_TEAM = AE5B4P8L99; 457 | INFOPLIST_FILE = SourceEditorPlugin/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; 459 | MACOSX_DEPLOYMENT_TARGET = 10.11; 460 | PRODUCT_BUNDLE_IDENTIFIER = net.shengpan.CodeGenerator.SourceEditorPlugin; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | PROVISIONING_PROFILE_SPECIFIER = ""; 463 | SKIP_INSTALL = YES; 464 | }; 465 | name = Debug; 466 | }; 467 | 3B11E97B1EC9DA69001F4782 /* Release */ = { 468 | isa = XCBuildConfiguration; 469 | buildSettings = { 470 | CODE_SIGN_ENTITLEMENTS = SourceEditorPlugin/SourceEditorPlugin.entitlements; 471 | CODE_SIGN_IDENTITY = "Mac Developer"; 472 | COMBINE_HIDPI_IMAGES = YES; 473 | DEVELOPMENT_TEAM = AE5B4P8L99; 474 | INFOPLIST_FILE = SourceEditorPlugin/Info.plist; 475 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; 476 | MACOSX_DEPLOYMENT_TARGET = 10.11; 477 | PRODUCT_BUNDLE_IDENTIFIER = net.shengpan.CodeGenerator.SourceEditorPlugin; 478 | PRODUCT_NAME = "$(TARGET_NAME)"; 479 | PROVISIONING_PROFILE_SPECIFIER = ""; 480 | SKIP_INSTALL = YES; 481 | }; 482 | name = Release; 483 | }; 484 | /* End XCBuildConfiguration section */ 485 | 486 | /* Begin XCConfigurationList section */ 487 | 3B11E93A1EC9DA28001F4782 /* Build configuration list for PBXProject "CodeGenerator" */ = { 488 | isa = XCConfigurationList; 489 | buildConfigurations = ( 490 | 3B11E95C1EC9DA28001F4782 /* Debug */, 491 | 3B11E95D1EC9DA28001F4782 /* Release */, 492 | ); 493 | defaultConfigurationIsVisible = 0; 494 | defaultConfigurationName = Release; 495 | }; 496 | 3B11E95E1EC9DA28001F4782 /* Build configuration list for PBXNativeTarget "CodeGenerator" */ = { 497 | isa = XCConfigurationList; 498 | buildConfigurations = ( 499 | 3B11E95F1EC9DA28001F4782 /* Debug */, 500 | 3B11E9601EC9DA28001F4782 /* Release */, 501 | ); 502 | defaultConfigurationIsVisible = 0; 503 | defaultConfigurationName = Release; 504 | }; 505 | 3B11E9791EC9DA69001F4782 /* Build configuration list for PBXNativeTarget "Generate Code" */ = { 506 | isa = XCConfigurationList; 507 | buildConfigurations = ( 508 | 3B11E97A1EC9DA69001F4782 /* Debug */, 509 | 3B11E97B1EC9DA69001F4782 /* Release */, 510 | ); 511 | defaultConfigurationIsVisible = 0; 512 | defaultConfigurationName = Release; 513 | }; 514 | /* End XCConfigurationList section */ 515 | }; 516 | rootObject = 3B11E9371EC9DA28001F4782 /* Project object */; 517 | } 518 | -------------------------------------------------------------------------------- /CodeGenerator.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CodeGenerator.xcodeproj/xcuserdata/pan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CodeGenerator.xcodeproj/xcuserdata/pan.xcuserdatad/xcschemes/CodeGenerator.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /CodeGenerator.xcodeproj/xcuserdata/pan.xcuserdatad/xcschemes/Generate Code.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | 16 | 22 | 23 | 24 | 30 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 70 | 74 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /CodeGenerator.xcodeproj/xcuserdata/pan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CodeGenerator.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | Generate Code.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 3B11E93E1EC9DA28001F4782 21 | 22 | primary 23 | 24 | 25 | 3B11E9541EC9DA28001F4782 26 | 27 | primary 28 | 29 | 30 | 3B11E9671EC9DA69001F4782 31 | 32 | primary 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /CodeGenerator/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CodeGenerator/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 18 | 19 | } 20 | @end 21 | -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "Icon_16x16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "Icon_16x16@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "Icon_32x32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "Icon_32x32@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "Icon_128x128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "Icon_128x128@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "Icon_256x256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "Icon_256x256@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "Icon_512x512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "Icon_512x512@2x.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_128x128.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_128x128@2x.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_16x16.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_16x16@2x.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_256x256.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_256x256@2x.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_32x32.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_32x32@2x.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_512x512.png -------------------------------------------------------------------------------- /CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/CodeGenerator/Assets.xcassets/AppIcon.appiconset/Icon_512x512@2x.png -------------------------------------------------------------------------------- /CodeGenerator/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | Default 509 | 510 | 511 | 512 | 513 | 514 | 515 | Left to Right 516 | 517 | 518 | 519 | 520 | 521 | 522 | Right to Left 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | Default 534 | 535 | 536 | 537 | 538 | 539 | 540 | Left to Right 541 | 542 | 543 | 544 | 545 | 546 | 547 | Right to Left 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | -------------------------------------------------------------------------------- /CodeGenerator/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.1.0 21 | CFBundleVersion 22 | 6 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2017年 Sheng Pan. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /CodeGenerator/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : NSViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CodeGenerator/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @implementation ViewController 12 | 13 | - (void)viewDidLoad { 14 | [super viewDidLoad]; 15 | 16 | // Do any additional setup after loading the view. 17 | } 18 | 19 | 20 | - (void)setRepresentedObject:(id)representedObject { 21 | [super setRepresentedObject:representedObject]; 22 | 23 | // Update the view, if already loaded. 24 | } 25 | 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /CodeGenerator/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /CodeGeneratorTests/CodeGeneratorTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CodeGeneratorTests.m 3 | // CodeGeneratorTests 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CodeGeneratorTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CodeGeneratorTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CodeGeneratorTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Sheng Pan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodeGenerator 2 | A Xcode plugin for generate Objectice-C code. 3 | 4 | ### Preview 5 | 6 | ![](https://raw.githubusercontent.com/DeveloperPans/CodeGenerator/master/images/preview.gif) 7 | 8 | > CodeGenerator Will add getter & setter in appropriate position even if there are several classes in one file 9 | 10 | 11 | ### Goal 12 | 13 | - [x] Lazy Getter. 14 | - [x] Setter. 15 | - [ ] Override Methods (waiting for more extension api) 16 | 17 | 18 | ## Install on Xcode 8 19 | 1. download [CodeGenerator.zip](https://github.com/DeveloperPans/CodeGenerator/releases/download/1.1.0/CodeGenerator.app.zip), and unarchive it. 20 | 2. copy `CodeGenerator.app` to `/Applications` folder. 21 | 3. Run it then close it. 22 | 23 | ## Usage 24 | ### 1. Enable Code Generator 25 | Check System Preferences -> Extensions -> Xocde Source Editor -> Code Generator 26 | 27 | ![](https://raw.githubusercontent.com/DeveloperPans/CodeGenerator/master/images/system_setting.png) 28 | 29 | ![](https://raw.githubusercontent.com/DeveloperPans/CodeGenerator/master/images/system_plugin.png) 30 | 31 | ### 2. Setting Shortcut in Xocde 32 | Preferences -> Key bindings -> Filter: generate code 33 | 34 | ![](https://raw.githubusercontent.com/DeveloperPans/CodeGenerator/master/images/xcode_setting.png) 35 | 36 | 37 | Set Lazy Getter command shortcut to + + G 38 | 39 | Set Setter command shortcut to + + S 40 | 41 | 42 | ## LICENSE 43 | 44 | [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Source/AccessCodeGenerator.h: -------------------------------------------------------------------------------- 1 | // 2 | // AccessCodeGenerator.h 3 | // PSCodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PSProperty.h" 11 | 12 | @interface AccessCodeGenerator : NSObject 13 | 14 | /** 15 | pattern matching the string, recognize Objective-C propertyies, generate their lazy getter code and return. 16 | 17 | basic data type and id will be ignored. 18 | 19 | @param string a string 20 | @return lazy getter code 21 | */ 22 | + (NSArray *)lazyGetterForString:(NSString *)string; 23 | 24 | /** 25 | pattern matching the string, recognize Objective-C propertyies, generate their setter code and return. 26 | 27 | @param string a string 28 | @return setter code 29 | */ 30 | + (NSArray *)setterForString:(NSString *)string; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Source/AccessCodeGenerator.m: -------------------------------------------------------------------------------- 1 | // 2 | // AccessCodeGenerator.m 3 | // PSCodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import "AccessCodeGenerator.h" 10 | 11 | @implementation AccessCodeGenerator 12 | 13 | + (NSArray *)lazyGetterForString:(NSString *)string { 14 | NSArray *props = [self propertyWithContent:string]; 15 | NSMutableArray *result = [NSMutableArray array]; 16 | for (PSProperty *model in props) { 17 | [result addObject:[self getterWithPSProperty:model]]; 18 | } 19 | NSArray *reverseArray = [[result reverseObjectEnumerator] allObjects]; 20 | return reverseArray; 21 | } 22 | 23 | + (NSArray *)setterForString:(NSString *)string { 24 | NSArray *props = [self propertyWithContent:string]; 25 | NSMutableArray *result = [NSMutableArray array]; 26 | for (PSProperty *model in props) { 27 | [result addObject:[self setterWithPSProperty:model]]; 28 | } 29 | return result; 30 | } 31 | 32 | + (NSArray *)propertyWithContent:(NSString *)content 33 | { 34 | NSMutableArray *result = [NSMutableArray array]; 35 | NSString * regularStr = @"@property([\\s\\S]*?);"; 36 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regularStr options:0 error:nil]; 37 | NSArray *matches = [regex matchesInString:content options:0 range:NSMakeRange(0, content.length)]; 38 | 39 | for (int i = 0; i < matches.count; i++) { 40 | 41 | NSRange propertyRange = [matches[i] range]; 42 | if (propertyRange.length > 0) { 43 | 44 | NSString *propertyString = [content substringWithRange:propertyRange]; 45 | if ([propertyString containsString:IB_OUTLET]) { 46 | continue; 47 | } 48 | 49 | NSArray *keywords = [self propertysKeywordsWithPropertyString:propertyString.copy]; 50 | NSArray *dataTypeAndName = [self propertyTypeAndNameWithProperty:propertyString.copy]; 51 | 52 | if (!dataTypeAndName.count) 53 | { 54 | continue; 55 | } 56 | // “NSArray"">""name" 57 | PSProperty * proMoel = [[PSProperty alloc] init]; 58 | proMoel.keywords = keywords; 59 | proMoel.dataType = [[dataTypeAndName subarrayWithRange:NSMakeRange(0, dataTypeAndName.count - 1)] componentsJoinedByString:@" *"]; 60 | proMoel.name = [dataTypeAndName lastObject]; 61 | proMoel.isObjectType = [propertyString containsString:@"*"]; 62 | [result addObject:proMoel]; 63 | } 64 | } 65 | return result; 66 | } 67 | 68 | 69 | + (NSArray *)propertysKeywordsWithPropertyString:(NSString *)propertyStr 70 | { 71 | NSString * propertyStr1 = propertyStr; 72 | NSString * regularStr = @"\\(.*\\)"; 73 | NSRegularExpression *regex1 = [NSRegularExpression regularExpressionWithPattern:regularStr options:0 error:nil]; 74 | NSArray *matches1 = [regex1 matchesInString:propertyStr1 options:0 range:NSMakeRange(0, propertyStr1.length)]; 75 | 76 | for (int i = 0; i < matches1.count; i++) 77 | { 78 | NSRange firstHalfRange = [matches1[i] range]; 79 | if (firstHalfRange.length > 0) 80 | { 81 | NSString *resultString = [[propertyStr1 substringWithRange:firstHalfRange] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; 82 | resultString = [resultString stringByReplacingOccurrencesOfString:@"(" withString:@""]; 83 | resultString = [resultString stringByReplacingOccurrencesOfString:@")" withString:@""]; 84 | resultString = [resultString stringByReplacingOccurrencesOfString:@" " withString:@""]; 85 | return [resultString componentsSeparatedByString:@","]; 86 | } 87 | } 88 | return nil; 89 | } 90 | 91 | + (NSMutableArray *)propertyTypeAndNameWithProperty:(NSString *)propertyStr; 92 | { 93 | 94 | NSString * regularStr = @"\\).*\\;"; 95 | NSRegularExpression *regex1 = [NSRegularExpression regularExpressionWithPattern:regularStr options:0 error:nil]; 96 | NSArray *matches1 = [regex1 matchesInString:propertyStr options:0 range:NSMakeRange(0, propertyStr.length)]; 97 | 98 | NSMutableArray *result = @[].mutableCopy; 99 | for (int i = 0 ; i < matches1.count; i++) 100 | { 101 | NSRange matchedRange = [matches1[i] range]; 102 | if (matchedRange.length > 0) 103 | { 104 | 105 | NSString *resultString = [[propertyStr substringWithRange:matchedRange] 106 | stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; 107 | // ) NSArray *> *name; 108 | resultString = [resultString stringByReplacingOccurrencesOfString:@")" withString:@""]; 109 | resultString = [resultString stringByReplacingOccurrencesOfString:@";" withString:@""]; 110 | // NSArray *> *name 111 | if([propertyStr containsString:@"*"]) 112 | { 113 | // NSArray*>*name 114 | resultString = [resultString stringByReplacingOccurrencesOfString:@" " withString:@""]; 115 | result = [resultString componentsSeparatedByString:@"*"].mutableCopy; 116 | } 117 | else 118 | { 119 | // 不带 * ,要么是 id 要么是基础类型,要么是宏定义的类型。 120 | result = [resultString componentsSeparatedByString:@" "].mutableCopy; 121 | [result enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 122 | if ([obj isEqualToString:@""]) { 123 | [result removeObject:obj]; 124 | } 125 | }]; 126 | } 127 | return result; 128 | } 129 | } 130 | return result; 131 | } 132 | 133 | 134 | + (NSString *)getterWithPSProperty:(PSProperty *)model 135 | { 136 | NSString *lazyGetter = @""; 137 | if (![model.keywords containsObject:ASSIGN] 138 | && ![model.dataType isEqualToString:ID]) { 139 | NSString *functionType = [model.keywords containsObject:CLASS] ? @"+" : @"-"; 140 | lazyGetter = [NSString stringWithFormat:@"\n%@ (%@ *)%@ {\n if (!_%@) {\n _%@ = [[%@ alloc] init];\n }\n return _%@;\n}", 141 | functionType, 142 | model.dataType, 143 | model.name, 144 | model.name, 145 | model.name, 146 | model.dataType, 147 | model.name]; 148 | } 149 | return lazyGetter; 150 | } 151 | 152 | + (NSString *)setterWithPSProperty:(PSProperty *)model { 153 | NSString *setter = @""; 154 | if (model.name.length < 1) { 155 | return setter; 156 | } 157 | 158 | NSString *firstLetter = [model.name substringToIndex:1]; 159 | NSString *name = [model.name stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:firstLetter.uppercaseString]; 160 | NSString *functionType = [model.keywords containsObject:CLASS] ? @"+" : @"-"; 161 | if (model.isObjectType) { 162 | setter = [NSString stringWithFormat:@"\n%@ (void)set%@:(%@ *)%@ {\n _%@ = %@;\n}", 163 | functionType, 164 | name, 165 | model.dataType, 166 | model.name, 167 | model.name, 168 | model.name]; 169 | } else { 170 | setter = [NSString stringWithFormat:@"\n%@ (void)set%@:(%@)%@ {\n _%@ = %@;\n}", 171 | functionType, 172 | name, 173 | model.dataType, 174 | model.name, 175 | model.name, 176 | model.name]; 177 | } 178 | return setter; 179 | } 180 | 181 | @end 182 | -------------------------------------------------------------------------------- /Source/PSProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSProperty.h 3 | // PSCodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | static NSString *const ASSIGN = @"assign"; 12 | static NSString *const WEAK = @"weak"; 13 | static NSString *const ID = @"id"; 14 | static NSString *const IB_OUTLET = @"IBOutlet"; 15 | static NSString *const CLASS = @"class"; 16 | 17 | //static NSString *const BASIC_DATA_TYPE = @"NSInteger,NSUInteger,char,int,float,double,long,short,signed,unsigned,BOOL,Bool,bool,Boolean"; 18 | 19 | 20 | @interface PSProperty : NSObject 21 | 22 | // nonatomic atomic strong weak assign retain getter= setter= class readonly ... 23 | @property (nonatomic, copy) NSArray *keywords; 24 | 25 | /** 26 | * 数据类型 27 | */ 28 | @property (nonatomic, copy) NSString *dataType; 29 | /** 30 | * 属性名称 31 | */ 32 | @property (nonatomic, copy) NSString *name; 33 | @property (nonatomic, assign) BOOL isObjectType;/**< 是不是带 * 的类型*/ 34 | @end 35 | -------------------------------------------------------------------------------- /Source/PSProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSProperty.m 3 | // PSCodeGenerator 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import "PSProperty.h" 10 | 11 | @interface PSProperty () 12 | 13 | @property (nonatomic, strong) NSString *string; 14 | @property (nonatomic, strong) NSArray *array; 15 | @property (nonatomic, strong) PSProperty *node; 16 | @property (nonatomic, assign) NSInteger haha; 17 | @property (nonatomic, strong) id idnAme; 18 | 19 | @end 20 | 21 | @implementation PSProperty 22 | 23 | 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /SourceEditorPlugin/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | Code Generator 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | XPC! 19 | CFBundleShortVersionString 20 | 1.1.0 21 | CFBundleVersion 22 | 6 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSExtension 26 | 27 | NSExtensionAttributes 28 | 29 | XCSourceEditorCommandDefinitions 30 | 31 | 32 | XCSourceEditorCommandClassName 33 | SourceEditorCommand 34 | XCSourceEditorCommandIdentifier 35 | $(PRODUCT_BUNDLE_IDENTIFIER).SourceEditorCommand 36 | XCSourceEditorCommandName 37 | Lazy Getter 38 | 39 | 40 | XCSourceEditorCommandClassName 41 | SourceEditorCommand 42 | XCSourceEditorCommandIdentifier 43 | $(PRODUCT_BUNDLE_IDENTIFIER).Setter 44 | XCSourceEditorCommandName 45 | Setter 46 | 47 | 48 | XCSourceEditorExtensionPrincipalClass 49 | SourceEditorExtension 50 | 51 | NSExtensionPointIdentifier 52 | com.apple.dt.Xcode.extension.source-editor 53 | 54 | NSHumanReadableCopyright 55 | Copyright © 2017年 Sheng Pan. All rights reserved. 56 | 57 | 58 | -------------------------------------------------------------------------------- /SourceEditorPlugin/SourceEditorCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // SourceEditorCommand.h 3 | // SourceEditorPlugin 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SourceEditorCommand : NSObject 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /SourceEditorPlugin/SourceEditorCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // SourceEditorCommand.m 3 | // SourceEditorPlugin 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import "SourceEditorCommand.h" 10 | #import "AccessCodeGenerator.h" 11 | 12 | @implementation SourceEditorCommand 13 | 14 | - (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable nilOrError))completionHandler 15 | { 16 | // get selected String 17 | NSMutableArray *selections = [NSMutableArray array]; 18 | for ( XCSourceTextRange *range in invocation.buffer.selections ) 19 | { 20 | NSInteger startLine = range.start.line; 21 | // make user select line easier 22 | NSInteger endLine = range.end.column > 0 ? range.end.line + 1 : range.end.line; 23 | 24 | for ( NSInteger i = startLine; i < endLine ; i++) 25 | { 26 | [selections addObject:invocation.buffer.lines[i]]; 27 | } 28 | } 29 | NSString *selectedString = [selections componentsJoinedByString:@""]; 30 | 31 | // find the insert location 32 | NSString *interface = [self interfaceContainerInBuffer:invocation.buffer 33 | initialLine:invocation.buffer.selections.firstObject.start.line]; 34 | NSInteger insertIndex = [self endLineOfImplementationForInterface:interface buffer:invocation.buffer]; 35 | insertIndex = (insertIndex == NSNotFound) 36 | ? invocation.buffer.selections.lastObject.end.line + 1 37 | : insertIndex; 38 | 39 | // do something for each command 40 | if ([invocation.commandIdentifier isEqualToString:@"net.shengpan.CodeGenerator.SourceEditorPlugin.SourceEditorCommand"]) 41 | { 42 | NSArray *getter = [AccessCodeGenerator lazyGetterForString:selectedString]; 43 | for (NSInteger i = 0; i < getter.count; i++) 44 | { 45 | [invocation.buffer.lines insertObject:getter[i] atIndex:insertIndex]; 46 | } 47 | } else if ([invocation.commandIdentifier isEqualToString:@"net.shengpan.CodeGenerator.SourceEditorPlugin.Setter"]) { 48 | 49 | NSArray *setter = [AccessCodeGenerator setterForString:selectedString]; 50 | for (NSInteger i = 0; i < setter.count; i++) 51 | { 52 | [invocation.buffer.lines insertObject:setter[i] atIndex:insertIndex]; 53 | } 54 | } 55 | 56 | completionHandler(nil); 57 | } 58 | 59 | 60 | - (NSString *)interfaceContainerInBuffer:(XCSourceTextBuffer *)buffer initialLine:(NSInteger)line 61 | { 62 | NSString *interfaceString = nil; 63 | while (line >= 0 && ![interfaceString containsString:@"@interface"]) 64 | { 65 | interfaceString = buffer.lines[line]; 66 | line--; 67 | } 68 | if (!interfaceString) { 69 | return nil; 70 | } 71 | 72 | NSArray *components = [interfaceString componentsSeparatedByString:@" "]; 73 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF != ''"]; 74 | return [components filteredArrayUsingPredicate:predicate][1]; 75 | } 76 | 77 | - (NSInteger)endLineOfImplementationForInterface:(NSString *)interface buffer:(XCSourceTextBuffer *)buffer 78 | { 79 | NSInteger result = NSNotFound; 80 | BOOL foundImplementation = NO; 81 | for (NSInteger i = 0; i < buffer.lines.count; i++) 82 | { 83 | NSString *lineContent = buffer.lines[i]; 84 | if (foundImplementation 85 | && [lineContent containsString:@"@end"]) { 86 | result = i; 87 | break; 88 | } 89 | 90 | if ([lineContent containsString:@"@implementation"] 91 | && [lineContent containsString:interface]) { 92 | foundImplementation = YES; 93 | } 94 | 95 | } 96 | return result; 97 | } 98 | 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /SourceEditorPlugin/SourceEditorExtension.h: -------------------------------------------------------------------------------- 1 | // 2 | // SourceEditorExtension.h 3 | // SourceEditorPlugin 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SourceEditorExtension : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /SourceEditorPlugin/SourceEditorExtension.m: -------------------------------------------------------------------------------- 1 | // 2 | // SourceEditorExtension.m 3 | // SourceEditorPlugin 4 | // 5 | // Created by Pan on 2017/5/15. 6 | // Copyright © 2017年 Sheng Pan. All rights reserved. 7 | // 8 | 9 | #import "SourceEditorExtension.h" 10 | 11 | @implementation SourceEditorExtension 12 | 13 | /* 14 | - (void)extensionDidFinishLaunching 15 | { 16 | // If your extension needs to do any work at launch, implement this optional method. 17 | } 18 | */ 19 | 20 | /* 21 | - (NSArray *> *)commandDefinitions 22 | { 23 | // If your extension needs to return a collection of command definitions that differs from those in its Info.plist, implement this optional property getter. 24 | return @[]; 25 | } 26 | */ 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /SourceEditorPlugin/SourceEditorPlugin.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /images/preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/images/preview.gif -------------------------------------------------------------------------------- /images/system_plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/images/system_plugin.png -------------------------------------------------------------------------------- /images/system_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/images/system_setting.png -------------------------------------------------------------------------------- /images/xcode_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrPans/CodeGenerator/4e19fe2df212d56b91b067151b04c4a3a1e14f6d/images/xcode_setting.png --------------------------------------------------------------------------------