summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-10-29 19:25:24 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-10-30 12:51:40 (GMT)
commit826041be3ee406c90b34401ab4510d7c50dbd4a6 (patch)
tree902f0dfed8ff1e67ed7f36e469136ffabd3a6802 /SwifTools/MacOSXChecker.mm
parentefb98f5c83fc5e0fb598a88e04c8bf6f642b5e2a (diff)
downloadswift-826041be3ee406c90b34401ab4510d7c50dbd4a6.zip
swift-826041be3ee406c90b34401ab4510d7c50dbd4a6.tar.bz2
Change OS X spell checker to non-deprecated API
Test-Information: Verified that there are still suggestions by comparing misspelled test phrases in Swift without this change and Swift with this change. Change-Id: Ice11af65028a96c86b1b5cc57ddad8eeda1ccf76
Diffstat (limited to 'SwifTools/MacOSXChecker.mm')
-rw-r--r--SwifTools/MacOSXChecker.mm10
1 files changed, 9 insertions, 1 deletions
diff --git a/SwifTools/MacOSXChecker.mm b/SwifTools/MacOSXChecker.mm
index 3e687d1..0c73427 100644
--- a/SwifTools/MacOSXChecker.mm
+++ b/SwifTools/MacOSXChecker.mm
@@ -2,20 +2,28 @@
2 * Copyright (c) 2013 Tobias Markmann 2 * Copyright (c) 2013 Tobias Markmann
3 * Licensed under the Simplified BSD license. 3 * Licensed under the Simplified BSD license.
4 * See Documentation/Licenses/BSD-simplified.txt for more information. 4 * See Documentation/Licenses/BSD-simplified.txt for more information.
5 */ 5 */
6 6
7/*
8 * Copyright (c) 2015 Isode Limited.
9 * All rights reserved.
10 * See the COPYING file for more information.
11 */
12
7#include <SwifTools/MacOSXChecker.h> 13#include <SwifTools/MacOSXChecker.h>
8 14
9#include <algorithm> 15#include <algorithm>
10#include <boost/algorithm/string.hpp> 16#include <boost/algorithm/string.hpp>
11 17
12#include <AppKit/AppKit.h> 18#include <AppKit/AppKit.h>
13 19
14namespace Swift { 20namespace Swift {
15 21
16MacOSXChecker::MacOSXChecker() { 22MacOSXChecker::MacOSXChecker() {
23 NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
24 [spellChecker setAutomaticallyIdentifiesLanguages:YES];
17} 25}
18 26
19MacOSXChecker::~MacOSXChecker() { 27MacOSXChecker::~MacOSXChecker() {
20} 28}
21 29
@@ -25,11 +33,11 @@ bool MacOSXChecker::isCorrect(const std::string& /*word*/) {
25} 33}
26 34
27void MacOSXChecker::getSuggestions(const std::string& word, std::vector<std::string>& list) { 35void MacOSXChecker::getSuggestions(const std::string& word, std::vector<std::string>& list) {
28 NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker]; 36 NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
29 NSString* wordString = [[NSString alloc] initWithUTF8String: word.c_str()]; 37 NSString* wordString = [[NSString alloc] initWithUTF8String: word.c_str()];
30 NSArray* suggestions = [spellChecker guessesForWord: wordString]; 38 NSArray* suggestions = [spellChecker guessesForWordRange:NSMakeRange(0, [wordString length]) inString:wordString language:nil inSpellDocumentWithTag:0];
31 for(unsigned int i = 0; i < [suggestions count]; ++i) { 39 for(unsigned int i = 0; i < [suggestions count]; ++i) {
32 list.push_back(std::string([[suggestions objectAtIndex:i] UTF8String])); 40 list.push_back(std::string([[suggestions objectAtIndex:i] UTF8String]));
33 } 41 }
34 [wordString release]; 42 [wordString release];
35} 43}