From 3ba4e9f3cda663eefd0f9671a6ec4ee0c35dcf54 Mon Sep 17 00:00:00 2001 From: Max Muthig Date: Sat, 28 Nov 2015 02:58:18 +0100 Subject: [PATCH] -C++ Support by using #include instead of #import if there's no #import statements in this file --- AutoImporter/AutoImporter/LAFIDESourceCodeEditor.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/AutoImporter/AutoImporter/LAFIDESourceCodeEditor.m b/AutoImporter/AutoImporter/LAFIDESourceCodeEditor.m index b366b25..4893a66 100644 --- a/AutoImporter/AutoImporter/LAFIDESourceCodeEditor.m +++ b/AutoImporter/AutoImporter/LAFIDESourceCodeEditor.m @@ -22,10 +22,19 @@ @interface LAFIDESourceCodeEditor() @implementation LAFIDESourceCodeEditor +// changed to support C++, it would be better though to check for the actual files +// if there is a .cpp file -> use include - (NSString *)importStatementFor:(NSString *)header { - return [NSString stringWithFormat:@"#import \"%@\"", header]; + NSTextView *textView = [MHXcodeDocumentNavigator currentSourceCodeTextView]; + NSRange range = [textView.string rangeOfString: @"#import"]; + if (range.length > 0) { + return [NSString stringWithFormat:@"#import \"%@\"", header]; + } else { + return [NSString stringWithFormat:@"#include \"%@\"", header]; + } } + - (void)cacheImports { [self invalidateImportsCache];