                 }
             }
         }
-        
-        do {
-            regex = try NSRegularExpression(pattern: " *:", options: .caseInsensitive)
-        } catch _ {
-            completionHandler(NSError(domain: "SampleExtension", code: -1, userInfo: [NSLocalizedDescriptionKey: ""]))
-            return
-        }
-        
+    }
+
+    func alignTypeDeclaration(invocation: XCSourceEditorCommandInvocation, selection: XCSourceTextRange) throws {
+        var regex: NSRegularExpression?
+        regex = try NSRegularExpression(pattern: " *:", options: .caseInsensitive)
+
         let alignPosition1 = invocation.buffer.lines.enumerated().map { i, line -> Int in
             guard i >= selection.start.line && i <= selection.end.line,
                 let line = line as? String,

            return
        }

        var regex: NSRegularExpression?
        do {
            regex = try NSRegularExpression(pattern: "[^+^%^*^^^<^>^&^|^?^=^-](\\s*)(=)[^=]", options: .caseInsensitive)
        } catch _ {
            completionHandler(NSError(domain: "SampleExtension", code: -1, userInfo: [NSLocalizedDescriptionKey: ""]))
            return
        }

        let alignPosition = invocation.buffer.lines.enumerated().map { i, line -> Int in
            guard i >= selection.start.line && i <= selection.end.line,

            }
            return result.range.location
            }.max()

        for index in selection.start.line ... selection.end.line {
            guard let line = invocation.buffer.lines[index] as? NSString else {
                continue
            }

            let range = line.range(of: ":")
            if range.location != NSNotFound {
                let repeatCount = alignPosition1! - range.location + 1
                if repeatCount != 0 {
                    let whiteSpaces = String(repeating: " ", count: abs(repeatCount))

                    if repeatCount > 0 {
                        invocation.buffer.lines.replaceObject(at: index, with: line.replacingOccurrences(of: ":", with: "\(whiteSpaces):"))
                    } else {
