From 8e37c891d562caefbd563dc205fb33649714f466 Mon Sep 17 00:00:00 2001 From: MellongLau <121382647@qq.com> Date: Tue, 22 Sep 2015 12:48:20 +0800 Subject: [PATCH] Support Xcode7. --- AMMethod2Implement/AMMethod2Implement.m | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/AMMethod2Implement/AMMethod2Implement.m b/AMMethod2Implement/AMMethod2Implement.m index 59945e6..5b27bc6 100755 --- a/AMMethod2Implement/AMMethod2Implement.m +++ b/AMMethod2Implement/AMMethod2Implement.m @@ -100,7 +100,7 @@ - (NSArray *)escapeCharacterWithArray:(NSArray *)array return mutableArray; } -- (void)implementMethod:selectString +- (void)implementMethod:(NSString *)selectString { NSArray *currentClassName = [AMIDEHelper getCurrentClassNameByCurrentSelectedRangeWithFileType:AMIDEFileTypeHFile]; NSArray *methodList = [selectString componentsSeparatedByString:@";"]; @@ -116,13 +116,20 @@ - (void)implementMethod:selectString NSInteger matchIndex = [methodItem getMatchIndexWithRegexList:_declareMap]; + if (matchIndex != -1) { + NSString *mfilePath = [AMIDEHelper getMFilePathOfCurrentEditFile]; if (hasOpenMFile == NO) { - [AMIDEHelper openFile:[AMIDEHelper getMFilePathOfCurrentEditFile]]; + [AMIDEHelper openFile:mfilePath]; hasOpenMFile = YES; } + + + while (![[AMIDEHelper getCurrentEditFilePath] isEqualToString:mfilePath]) { + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; + } NSTextView *textView = [AMXcodeHelper currentSourceCodeTextView]; NSString *mFileText = textView.textStorage.string; @@ -196,7 +203,14 @@ - (void)declareMethod:(NSString *)selectString{ if (matchIndex == AMImplementTypeMethod) { NSArray *currentClassName = [AMIDEHelper getCurrentClassNameByCurrentSelectedRangeWithFileType:AMIDEFileTypeMFile]; - [AMIDEHelper openFile:[AMIDEHelper getHFilePathOfCurrentEditFile]]; + NSString *hfilePath = [AMIDEHelper getHFilePathOfCurrentEditFile]; + [AMIDEHelper openFile:hfilePath]; + + while (![[AMIDEHelper getCurrentEditFilePath] isEqualToString:hfilePath]) { + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; + } + + NSTextView *textView = [AMXcodeHelper currentSourceCodeTextView]; NSString *hFileText = textView.textStorage.string; NSRange trimStringRange = [selectString rangeOfString:@"{"];