-
Notifications
You must be signed in to change notification settings - Fork 3
/
Driver.cpp
71 lines (62 loc) · 1.8 KB
/
Driver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#import "Logging.hpp"
#import "SwiftCompleter.hpp"
#import <dispatch/dispatch.h>
#import <iostream>
#import <string>
using namespace ssvim;
using namespace std;
struct Runner {
std::string complete(std::string fileName, std::string fileContents,
std::vector<std::string> flags, unsigned line,
unsigned column) {
auto completer = SwiftCompleter(LogLevelExtreme);
auto files = std::vector<UnsavedFile>();
auto unsavedFile = UnsavedFile();
unsavedFile.contents = fileContents;
unsavedFile.fileName = fileName;
files.push_back(unsavedFile);
auto result = completer.CandidatesForLocationInFile(fileName, line, column,
files, flags);
return result;
}
};
std::string contents = "// \n\
// some_swift.swift \n\
// Swift Completer \n\
// \n\
// Created by Jerry Marino on 4/30/16. \n\
// Copyright © 2016 Jerry Marino. All rights reserved. \n\
// \n\
\n\
\n\
func someOtherFunc(){ \n\
} \n\
\n\
func anotherFunction(){ \n\
someOther()\n\
} \n\
\n";
using namespace ssvim;
static ssvim::Logger logger(LogLevelInfo);
int wrapped_main() {
Runner runner;
std::cout << contents;
vector<string> flags;
flags.push_back("-sdk");
flags.push_back("/Applications/Xcode.app/Contents/Developer/Platforms/"
"MacOSX.platform/Developer/SDKs/MacOSX.sdk");
flags.push_back("-target");
flags.push_back("x86_64-apple-macosx10.12");
auto exampleFilePath = "/tmp/x";
auto result = runner.complete(exampleFilePath, contents, flags, 19, 13);
logger << result;
logger << "Done";
exit(0);
}
int main() {
logger << "Running Test Driver";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
wrapped_main();
});
dispatch_main();
}