commit 96f08b2a33fad19ca950ef599a9108c3012026cd Author: yuya.tanaka Date: Mon Apr 4 17:28:36 2016 +0900 Initial Commit diff --git a/SwiftLintAutoCorrect.xcodeproj/project.pbxproj b/SwiftLintAutoCorrect.xcodeproj/project.pbxproj new file mode 100644 index 0000000..09eda13 --- /dev/null +++ b/SwiftLintAutoCorrect.xcodeproj/project.pbxproj @@ -0,0 +1,266 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 04E4BF341CB25D3200BC7305 /* SwiftLintAutoCorrect.xcscheme in Resources */ = {isa = PBXBuildFile; fileRef = 04E4BF331CB25D3200BC7305 /* SwiftLintAutoCorrect.xcscheme */; }; + 04E4BF361CB25D3200BC7305 /* SwiftLintAutoCorrect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E4BF351CB25D3200BC7305 /* SwiftLintAutoCorrect.swift */; }; + 04E4BF381CB25D3200BC7305 /* NSObject_Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E4BF371CB25D3200BC7305 /* NSObject_Extension.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 04E4BF2F1CB25D3100BC7305 /* SwiftLintAutoCorrect.xcplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftLintAutoCorrect.xcplugin; sourceTree = BUILT_PRODUCTS_DIR; }; + 04E4BF331CB25D3200BC7305 /* SwiftLintAutoCorrect.xcscheme */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = SwiftLintAutoCorrect.xcscheme; path = SwiftLintAutoCorrect.xcodeproj/xcshareddata/xcschemes/SwiftLintAutoCorrect.xcscheme; sourceTree = SOURCE_ROOT; }; + 04E4BF351CB25D3200BC7305 /* SwiftLintAutoCorrect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftLintAutoCorrect.swift; sourceTree = ""; }; + 04E4BF371CB25D3200BC7305 /* NSObject_Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSObject_Extension.swift; sourceTree = ""; }; + 04E4BF391CB25D3200BC7305 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXGroup section */ + 04E4BF271CB25D3100BC7305 = { + isa = PBXGroup; + children = ( + 04E4BF311CB25D3200BC7305 /* SwiftLintAutoCorrect */, + 04E4BF301CB25D3100BC7305 /* Products */, + ); + sourceTree = ""; + }; + 04E4BF301CB25D3100BC7305 /* Products */ = { + isa = PBXGroup; + children = ( + 04E4BF2F1CB25D3100BC7305 /* SwiftLintAutoCorrect.xcplugin */, + ); + name = Products; + sourceTree = ""; + }; + 04E4BF311CB25D3200BC7305 /* SwiftLintAutoCorrect */ = { + isa = PBXGroup; + children = ( + 04E4BF351CB25D3200BC7305 /* SwiftLintAutoCorrect.swift */, + 04E4BF371CB25D3200BC7305 /* NSObject_Extension.swift */, + 04E4BF391CB25D3200BC7305 /* Info.plist */, + 04E4BF321CB25D3200BC7305 /* Supporting Files */, + ); + path = SwiftLintAutoCorrect; + sourceTree = ""; + }; + 04E4BF321CB25D3200BC7305 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 04E4BF331CB25D3200BC7305 /* SwiftLintAutoCorrect.xcscheme */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 04E4BF2E1CB25D3100BC7305 /* SwiftLintAutoCorrect */ = { + isa = PBXNativeTarget; + buildConfigurationList = 04E4BF3C1CB25D3200BC7305 /* Build configuration list for PBXNativeTarget "SwiftLintAutoCorrect" */; + buildPhases = ( + 04E4BF2C1CB25D3100BC7305 /* Sources */, + 04E4BF2D1CB25D3100BC7305 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwiftLintAutoCorrect; + productName = SwiftLintAutoCorrect; + productReference = 04E4BF2F1CB25D3100BC7305 /* SwiftLintAutoCorrect.xcplugin */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 04E4BF281CB25D3100BC7305 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0730; + ORGANIZATIONNAME = "Yuya Tanaka"; + TargetAttributes = { + 04E4BF2E1CB25D3100BC7305 = { + CreatedOnToolsVersion = 7.3; + }; + }; + }; + buildConfigurationList = 04E4BF2B1CB25D3100BC7305 /* Build configuration list for PBXProject "SwiftLintAutoCorrect" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 04E4BF271CB25D3100BC7305; + productRefGroup = 04E4BF301CB25D3100BC7305 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 04E4BF2E1CB25D3100BC7305 /* SwiftLintAutoCorrect */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 04E4BF2D1CB25D3100BC7305 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 04E4BF341CB25D3200BC7305 /* SwiftLintAutoCorrect.xcscheme in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 04E4BF2C1CB25D3100BC7305 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 04E4BF361CB25D3200BC7305 /* SwiftLintAutoCorrect.swift in Sources */, + 04E4BF381CB25D3200BC7305 /* NSObject_Extension.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 04E4BF3A1CB25D3200BC7305 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + }; + name = Debug; + }; + 04E4BF3B1CB25D3200BC7305 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = NO; + }; + name = Release; + }; + 04E4BF3D1CB25D3200BC7305 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + DEPLOYMENT_LOCATION = YES; + DSTROOT = "$(HOME)"; + EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; + INFOPLIST_FILE = SwiftLintAutoCorrect/Info.plist; + INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins"; + LD_RUNPATH_SEARCH_PATHS = "$(DT_TOOLCHAIN_DIR)/usr/lib/swift/macosx"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = net.ypresto.SwiftLintAutoCorrect; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = xcplugin; + }; + name = Debug; + }; + 04E4BF3E1CB25D3200BC7305 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + DEPLOYMENT_LOCATION = YES; + DSTROOT = "$(HOME)"; + EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; + INFOPLIST_FILE = SwiftLintAutoCorrect/Info.plist; + INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins"; + LD_RUNPATH_SEARCH_PATHS = "$(DT_TOOLCHAIN_DIR)/usr/lib/swift/macosx"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + PRODUCT_BUNDLE_IDENTIFIER = net.ypresto.SwiftLintAutoCorrect; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = xcplugin; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 04E4BF2B1CB25D3100BC7305 /* Build configuration list for PBXProject "SwiftLintAutoCorrect" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 04E4BF3A1CB25D3200BC7305 /* Debug */, + 04E4BF3B1CB25D3200BC7305 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 04E4BF3C1CB25D3200BC7305 /* Build configuration list for PBXNativeTarget "SwiftLintAutoCorrect" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 04E4BF3D1CB25D3200BC7305 /* Debug */, + 04E4BF3E1CB25D3200BC7305 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 04E4BF281CB25D3100BC7305 /* Project object */; +} diff --git a/SwiftLintAutoCorrect.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/SwiftLintAutoCorrect.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..869a245 --- /dev/null +++ b/SwiftLintAutoCorrect.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/SwiftLintAutoCorrect.xcodeproj/xcshareddata/xcschemes/SwiftLintAutoCorrect.xcscheme b/SwiftLintAutoCorrect.xcodeproj/xcshareddata/xcschemes/SwiftLintAutoCorrect.xcscheme new file mode 100755 index 0000000..50569e5 --- /dev/null +++ b/SwiftLintAutoCorrect.xcodeproj/xcshareddata/xcschemes/SwiftLintAutoCorrect.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SwiftLintAutoCorrect.xcodeproj/xcuserdata/yuya.tanaka.xcuserdatad/xcschemes/xcschememanagement.plist b/SwiftLintAutoCorrect.xcodeproj/xcuserdata/yuya.tanaka.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..a0786de --- /dev/null +++ b/SwiftLintAutoCorrect.xcodeproj/xcuserdata/yuya.tanaka.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SuppressBuildableAutocreation + + 04E4BF2E1CB25D3100BC7305 + + primary + + + + + diff --git a/SwiftLintAutoCorrect/Info.plist b/SwiftLintAutoCorrect/Info.plist new file mode 100644 index 0000000..0511040 --- /dev/null +++ b/SwiftLintAutoCorrect/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + DVTPlugInCompatibilityUUIDs + + C4A681B0-4A26-480E-93EC-1218098B9AA0 + F41BD31E-2683-44B8-AE7F-5F09E919790E + AD68E85B-441B-4301-B564-A45E4919A6AD + A16FF353-8441-459E-A50C-B071F53F51B7 + 9F75337B-21B4-4ADC-B558-F9CADF7073A7 + E969541F-E6F9-4D25-8158-72DC3545A6C6 + 8DC44374-2B35-4C57-A6FE-2AD66A36AAD9 + AABB7188-E14E-4433-AD3B-5CD791EAD9A3 + 8DC44374-2B35-4C57-A6FE-2AD66A36AAD9 + AABB7188-E14E-4433-AD3B-5CD791EAD9A3 + 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90 + 0420B86A-AA43-4792-9ED0-6FE0F2B16A13 + 7265231C-39B4-402C-89E1-16167C4CC990 + ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C + + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSPrincipalClass + SwiftLintAutoCorrect + XC4Compatible + + XCPluginHasUI + + + diff --git a/SwiftLintAutoCorrect/NSObject_Extension.swift b/SwiftLintAutoCorrect/NSObject_Extension.swift new file mode 100644 index 0000000..ff65933 --- /dev/null +++ b/SwiftLintAutoCorrect/NSObject_Extension.swift @@ -0,0 +1,19 @@ +// +// NSObject_Extension.swift +// +// Created by yuya.tanaka on 2016/04/04. +// Copyright © 2016年 Yuya Tanaka. All rights reserved. +// + +import Foundation + +extension NSObject { + class func pluginDidLoad(bundle: NSBundle) { + let appName = NSBundle.mainBundle().infoDictionary?["CFBundleName"] as? NSString + if appName == "Xcode" { + if sharedPlugin == nil { + sharedPlugin = SwiftLintAutoCorrect(bundle: bundle) + } + } + } +} \ No newline at end of file diff --git a/SwiftLintAutoCorrect/SwiftLintAutoCorrect.swift b/SwiftLintAutoCorrect/SwiftLintAutoCorrect.swift new file mode 100755 index 0000000..6a20e78 --- /dev/null +++ b/SwiftLintAutoCorrect/SwiftLintAutoCorrect.swift @@ -0,0 +1,49 @@ +// +// SwiftLintAutoCorrect.swift +// +// Created by yuya.tanaka on 2016/04/04. +// Copyright © 2016年 Yuya Tanaka. All rights reserved. +// + +import AppKit + +var sharedPlugin: SwiftLintAutoCorrect? + +class SwiftLintAutoCorrect: NSObject { + + var bundle: NSBundle + lazy var center = NSNotificationCenter.defaultCenter() + + init(bundle: NSBundle) { + self.bundle = bundle + + super.init() + center.addObserver(self, selector: Selector("createMenuItems"), name: NSApplicationDidFinishLaunchingNotification, object: nil) + } + + deinit { + removeObserver() + } + + func removeObserver() { + center.removeObserver(self) + } + + func createMenuItems() { + removeObserver() + + var item = NSApp.mainMenu!.itemWithTitle("Edit") + if item != nil { + var actionMenuItem = NSMenuItem(title:"Do Action", action:"doMenuAction", keyEquivalent:"") + actionMenuItem.target = self + item!.submenu!.addItem(NSMenuItem.separatorItem()) + item!.submenu!.addItem(actionMenuItem) + } + } + + func doMenuAction() { + let error = NSError(domain: "Hello World!", code:42, userInfo:nil) + NSAlert(error: error).runModal() + } +} +