Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build checking and fixed issues. #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions LinkMap.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -107,7 +107,7 @@
6E7367DD1CB7843200722B99 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0720;
LastUpgradeCheck = 1240;
ORGANIZATIONNAME = ND;
TargetAttributes = {
6E7367E41CB7843200722B99 = {
Expand All @@ -116,8 +116,8 @@
};
};
buildConfigurationList = 6E7367E01CB7843200722B99 /* Build configuration list for PBXProject "LinkMap" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
compatibilityVersion = "Xcode 12.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -175,17 +175,29 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -201,6 +213,9 @@
"DEBUG=1",
"$(inherited)",
);
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -218,17 +233,29 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -238,6 +265,9 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -254,9 +284,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = LinkMap/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.nd.LinkMap;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -267,9 +301,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = LinkMap/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.nd.LinkMap;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
51 changes: 34 additions & 17 deletions LinkMap/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ - (IBAction)chooseFile:(id)sender {
panel.resolvesAliases = NO;
panel.canChooseFiles = YES;

__weak typeof(self) weakSelf = self;
[panel beginWithCompletionHandler:^(NSInteger result){
if (result == NSFileHandlingPanelOKButton) {
NSURL *document = [[panel URLs] objectAtIndex:0];
_filePathField.stringValue = document.path;
self.linkMapFileURL = document;
if (weakSelf == nil) return;
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf->_filePathField.stringValue = document.path;
strongSelf.linkMapFileURL = document;
}
}];
}
Expand All @@ -69,43 +72,54 @@ - (IBAction)analyze:(id)sender {
return;
}

__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *content = [NSString stringWithContentsOfURL:_linkMapFileURL encoding:NSMacOSRomanStringEncoding error:nil];
if (weakSelf == nil) return;
__strong typeof(weakSelf) strongSelf = weakSelf;
NSString *content = [NSString stringWithContentsOfURL:strongSelf->_linkMapFileURL encoding:NSMacOSRomanStringEncoding error:nil];

if (![self checkContent:content]) {
if (![strongSelf checkContent:content]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self showAlertWithText:@"Link Map文件格式有误"];
if (weakSelf == nil) return;
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf showAlertWithText:@"Link Map文件格式有误"];
});
return ;
}

dispatch_async(dispatch_get_main_queue(), ^{
self.indicator.hidden = NO;
[self.indicator startAnimation:self];
if (weakSelf == nil) return;
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf.indicator.hidden = NO;
[strongSelf.indicator startAnimation:self];

});

NSDictionary *symbolMap = [self symbolMapFromContent:content];
NSDictionary *symbolMap = [strongSelf symbolMapFromContent:content];

NSArray <SymbolModel *>*symbols = [symbolMap allValues];

NSArray *sortedSymbols = [self sortSymbols:symbols];
NSArray *sortedSymbols = [strongSelf sortSymbols:symbols];

__block NSControlStateValue groupButtonState;
__block NSControlStateValue groupButtonState = 0;
dispatch_sync(dispatch_get_main_queue(), ^{
groupButtonState = _groupButton.state;
if (weakSelf == nil) return;
__strong typeof(weakSelf) strongSelf = weakSelf;
groupButtonState = strongSelf->_groupButton.state;
});

if (1 == groupButtonState) {
[self buildCombinationResultWithSymbols:sortedSymbols];
[strongSelf buildCombinationResultWithSymbols:sortedSymbols];
} else {
[self buildResultWithSymbols:sortedSymbols];
[strongSelf buildResultWithSymbols:sortedSymbols];
}

dispatch_async(dispatch_get_main_queue(), ^{
self.contentTextView.string = _result;
self.indicator.hidden = YES;
[self.indicator stopAnimation:self];
if (weakSelf == nil) return;
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf.contentTextView.string = strongSelf->_result;
strongSelf.indicator.hidden = YES;
[strongSelf.indicator stopAnimation:self];

});
});
Expand Down Expand Up @@ -253,13 +267,16 @@ - (IBAction)ouputFile:(id)sender {
[panel setResolvesAliases:NO];
[panel setCanChooseFiles:NO];

__weak typeof(self) weakSelf = self;
[panel beginWithCompletionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) {
if (weakSelf == nil) return;
__strong typeof(weakSelf) strongSelf = weakSelf;
NSURL* theDoc = [[panel URLs] objectAtIndex:0];
NSMutableString *content =[[NSMutableString alloc]initWithCapacity:0];
[content appendString:[theDoc path]];
[content appendString:@"/linkMap.txt"];
[_result writeToFile:content atomically:YES encoding:NSUTF8StringEncoding error:nil];
[strongSelf->_result writeToFile:content atomically:YES encoding:NSUTF8StringEncoding error:nil];
}
}];
}
Expand Down