fix regex , fix mapError,add error infomation

This commit is contained in:
BackNotGod 2017-03-17 18:32:12 +08:00
parent e764cc81e3
commit 0df3ad7a87
4 changed files with 15 additions and 11 deletions

View File

@ -15,8 +15,8 @@ enum FileType :String{
}
let VERSION = "0.0.1"
let SWIFT_REGEX = "NSLocalizedString\\(\"([^\\x00-\\xff]+)\", comment: \"\"\\)"
let OC_REGEX = "NSLocalizedString\\(@\"([^\\x00-\\xff]+)\", (.*?)\\)"
let SWIFT_REGEX = "NSLocalizedString\\(\"(.+?)\", comment: (.+?)\\)"
let OC_REGEX = "NSLocalizedString\\(@\"(.+?)\", (.+?)\\)"
let LOCAL_ERGEX = "\".*?\""
let COMMONT = "/* No comment provided by engineer. */"
let TEST_REGEX = "NSLocalizedString\\(\"([^\\x00-\\xff]+)\", comment: \"\"\\)"

View File

@ -44,7 +44,7 @@ public struct localizationCommand :RegexStringsSearcher,RegexStringsWriter{
}
for item in Progress(swiftPath) {
patterns = [TEST_REGEX]
patterns = [SWIFT_REGEX]
search(in: item)
}
@ -67,7 +67,7 @@ public struct localizationCommand :RegexStringsSearcher,RegexStringsWriter{
}
defer {
// DataHandleManager.defaltManager.mapError()
DataHandleManager.defaltManager.mapError()
}
}

View File

@ -60,19 +60,23 @@ extension RegexStringsSearcher {
/// over here, if localizedString is isAmbiguous,we analysis error
if localizedString.isAmbiguous {
print(path.description.red)
errors.append(value)
}else{
extracts.append(value)
}
}
if path.lastComponent.contains("swift") {
DataHandleManager.defaltManager.swift_listNode?.insert(values: extracts, className: path.lastComponent, path: path.description)
}else{
DataHandleManager.defaltManager.oc_listNode?.insert(values: extracts, className: path.lastComponent, path: path.description)
if extracts.count > 0 {
if path.lastComponent.contains("swift") {
DataHandleManager.defaltManager.swift_listNode?.insert(values: extracts, className: path.lastComponent, path: path.description)
}else{
DataHandleManager.defaltManager.oc_listNode?.insert(values: extracts, className: path.lastComponent, path: path.description)
}
}
if errors.count > 0 {
DataHandleManager.defaltManager.error_listNode?.insert(values: errors, className: path.lastComponent, path: path.description)
}
}
}

View File

@ -93,11 +93,11 @@ public func CommandLineToolSpectre() {
$0.it("isAmbiguous test correct?"){
let str1 = "fdjaklfda%j@fdklafjkld"
let str2 = "_shiftButton setTitle:@\"ABC\" forState:UIControlStateNorma"
let str2 = "_shiftButton setTi%dtle:@\"ABC\" forState:UIControlStateNorma"
let str3 = "[_shiftButton setTitle:@\"\" forState:UIControlStateNormal];"
let str4 = "nsstring.init(%d,213123);"
try expect(str1.isAmbiguous).to.beFalse()
try expect(str2.isAmbiguous).to.beFalse()
try expect(str2.isAmbiguous).to.beTrue()
try expect(str3.isAmbiguous).to.beFalse()
try expect(str4.isAmbiguous).to.beTrue()