Reformat code

This commit is contained in:
Jacob Dufault 2017-11-19 14:11:54 -08:00
parent 297ed1d13e
commit 97417ecc93
9 changed files with 537 additions and 529 deletions

View File

@ -146,7 +146,8 @@ void BuildDetailString(CXCompletionString completion_string,
case CXCompletionChunk_Optional: { case CXCompletionChunk_Optional: {
CXCompletionString nested = CXCompletionString nested =
clang_getCompletionChunkCompletionString(completion_string, i); clang_getCompletionChunkCompletionString(completion_string, i);
BuildDetailString(nested, label, detail, insert, parameters, include_snippets); BuildDetailString(nested, label, detail, insert, parameters,
include_snippets);
break; break;
} }
@ -156,7 +157,10 @@ void BuildDetailString(CXCompletionString completion_string,
parameters->push_back(text); parameters->push_back(text);
detail += text; detail += text;
// Add parameter declarations as snippets if enabled // Add parameter declarations as snippets if enabled
if (include_snippets) { insert += "${" + std::to_string(parameters->size()) + ":" + text + "}"; } if (include_snippets) {
insert +=
"${" + std::to_string(parameters->size()) + ":" + text + "}";
}
break; break;
} }
@ -198,7 +202,9 @@ void BuildDetailString(CXCompletionString completion_string,
detail += "("; detail += "(";
insert += "("; insert += "(";
// Put cursor between parentheses if snippets are not enabled // Put cursor between parentheses if snippets are not enabled
if (!include_snippets) { insert += "$1"; } if (!include_snippets) {
insert += "$1";
}
break; break;
case CXCompletionChunk_RightParen: case CXCompletionChunk_RightParen:
detail += ")"; detail += ")";
@ -231,7 +237,9 @@ void BuildDetailString(CXCompletionString completion_string,
case CXCompletionChunk_Comma: case CXCompletionChunk_Comma:
detail += ", "; detail += ", ";
// Only put comma's between parentheses if snippets are enabled // Only put comma's between parentheses if snippets are enabled
if (include_snippets) { insert += ", "; } if (include_snippets) {
insert += ", ";
}
break; break;
case CXCompletionChunk_Colon: case CXCompletionChunk_Colon:
detail += ":"; detail += ":";
@ -409,9 +417,9 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
// kind/label/detail/docs/sortText // kind/label/detail/docs/sortText
ls_completion_item.kind = GetCompletionKind(result.CursorKind); ls_completion_item.kind = GetCompletionKind(result.CursorKind);
BuildDetailString(result.CompletionString, ls_completion_item.label, BuildDetailString(
ls_completion_item.detail, result.CompletionString, ls_completion_item.label,
ls_completion_item.insertText, ls_completion_item.detail, ls_completion_item.insertText,
&ls_completion_item.parameters_, &ls_completion_item.parameters_,
completion_manager->config_->enableSnippetInsertion); completion_manager->config_->enableSnippetInsertion);

View File

@ -65,7 +65,8 @@ struct Config {
// Version of the client. // Version of the client.
int clientVersion = 0; int clientVersion = 0;
// If true parameter declarations are included in code completion when calling a function or method // If true parameter declarations are included in code completion when calling
// a function or method
bool enableSnippetInsertion = true; bool enableSnippetInsertion = true;
}; };
MAKE_REFLECT_STRUCT(Config, MAKE_REFLECT_STRUCT(Config,

View File

@ -114,7 +114,8 @@ TEST_SUITE("FindIncludeLine") {
REQUIRE(parse_correct("Content-Length: 4\r\n\r\nabcd") == "abcd"); REQUIRE(parse_correct("Content-Length: 4\r\n\r\nabcd") == "abcd");
REQUIRE(parse_incorrect("ggg") == optional<std::string>()); REQUIRE(parse_incorrect("ggg") == optional<std::string>());
REQUIRE(parse_incorrect("Content-Length: 0\r\n") == optional<std::string>()); REQUIRE(parse_incorrect("Content-Length: 0\r\n") ==
optional<std::string>());
REQUIRE(parse_incorrect("Content-Length: 5\r\n\r\nab") == REQUIRE(parse_incorrect("Content-Length: 5\r\n\r\nab") ==
optional<std::string>()); optional<std::string>());
} }
@ -217,7 +218,7 @@ void lsDocumentUri::SetPath(const std::string& path) {
raw_uri = ReplaceAll(raw_uri, "(", "%28"); raw_uri = ReplaceAll(raw_uri, "(", "%28");
raw_uri = ReplaceAll(raw_uri, ")", "%29"); raw_uri = ReplaceAll(raw_uri, ")", "%29");
// TODO: proper fix // TODO: proper fix
#if defined(_WIN32) #if defined(_WIN32)
raw_uri = "file:///" + raw_uri; raw_uri = "file:///" + raw_uri;
#else #else
@ -255,7 +256,7 @@ std::string lsDocumentUri::GetPath() const {
std::replace(result.begin(), result.end(), '\\', '/'); std::replace(result.begin(), result.end(), '\\', '/');
#if defined(_WIN32) #if defined(_WIN32)
// std::transform(result.begin(), result.end(), result.begin(), ::tolower); // std::transform(result.begin(), result.end(), result.begin(), ::tolower);
#endif #endif
return result; return result;

View File

@ -28,7 +28,8 @@ std::vector<std::string> Split(const std::string& s, char delim) {
return elems; return elems;
} }
std::string Join(const std::vector<std::string>& entries, char delim, std::string Join(const std::vector<std::string>& entries,
char delim,
size_t end) { size_t end) {
std::string result; std::string result;
bool first = true; bool first = true;

View File

@ -157,7 +157,7 @@ std::string GetWorkingDirectory() {
std::string NormalizePath(const std::string& path) { std::string NormalizePath(const std::string& path) {
errno = 0; errno = 0;
char name[PATH_MAX + 1]; char name[PATH_MAX + 1];
(void) realpath(path.c_str(), name); (void)realpath(path.c_str(), name);
if (errno) if (errno)
return path; return path;
return name; return name;

View File

@ -52,15 +52,10 @@ static std::vector<std::string> kBlacklistMulti = {
// Blacklisted flags which are always removed from the command line. // Blacklisted flags which are always removed from the command line.
static std::vector<std::string> kBlacklist = { static std::vector<std::string> kBlacklist = {
"-c", "-c", "-MP", "-MD", "-MMD", "--fcolor-diagnostics",
"-MP",
"-MD",
"-MMD",
"--fcolor-diagnostics",
// This strips path-like args but is a bit hacky. // This strips path-like args but is a bit hacky.
"/", "/", "..",
"..",
}; };
// Arguments which are followed by a potentially relative path. We need to make // Arguments which are followed by a potentially relative path. We need to make
@ -412,8 +407,7 @@ void Project::ForAllFilteredFiles(
} }
TEST_SUITE("Project") { TEST_SUITE("Project") {
void CheckFlags(const std::string& directory, void CheckFlags(const std::string& directory, const std::string& file,
const std::string& file,
std::vector<std::string> raw, std::vector<std::string> raw,
std::vector<std::string> expected) { std::vector<std::string> expected) {
g_disable_normalize_path_for_test = true; g_disable_normalize_path_for_test = true;
@ -795,7 +789,8 @@ TEST_SUITE("Project") {
"-std=gnu++14", "-std=gnu++14",
"-fno-rtti", "-fno-rtti",
"-nostdinc++", "-nostdinc++",
"-isystem&/w/c/s/out/Release/../../buildtools/third_party/libc++/trunk/" "-isystem&/w/c/s/out/Release/../../buildtools/third_party/libc++/"
"trunk/"
"include", "include",
"-isystem&/w/c/s/out/Release/../../buildtools/third_party/libc++abi/" "-isystem&/w/c/s/out/Release/../../buildtools/third_party/libc++abi/"
"trunk/" "trunk/"
@ -1113,7 +1108,8 @@ TEST_SUITE("Project") {
"-std=gnu++14", "-std=gnu++14",
"-fno-rtti", "-fno-rtti",
"-nostdinc++", "-nostdinc++",
"-isystem&/w/c/s/out/Release/../../buildtools/third_party/libc++/trunk/" "-isystem&/w/c/s/out/Release/../../buildtools/third_party/libc++/"
"trunk/"
"include", "include",
"-isystem&/w/c/s/out/Release/../../buildtools/third_party/libc++abi/" "-isystem&/w/c/s/out/Release/../../buildtools/third_party/libc++abi/"
"trunk/" "trunk/"

View File

@ -603,7 +603,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
} }
void IndexUpdate::Merge(const IndexUpdate& update) { void IndexUpdate::Merge(const IndexUpdate& update) {
// This function runs on an indexer thread. // This function runs on an indexer thread.
#define INDEX_UPDATE_APPEND(name) AddRange(&name, update.name); #define INDEX_UPDATE_APPEND(name) AddRange(&name, update.name);
#define INDEX_UPDATE_MERGE(name) AddMergeableRange(&name, update.name); #define INDEX_UPDATE_MERGE(name) AddMergeableRange(&name, update.name);
@ -890,7 +890,8 @@ TEST_SUITE("query") {
REQUIRE(update.funcs_callers[0].to_remove[0].loc.range == REQUIRE(update.funcs_callers[0].to_remove[0].loc.range ==
Range(Position(1, 0))); Range(Position(1, 0)));
REQUIRE(update.funcs_callers[0].to_add.size() == 1); REQUIRE(update.funcs_callers[0].to_add.size() == 1);
REQUIRE(update.funcs_callers[0].to_add[0].loc.range == Range(Position(2, 0))); REQUIRE(update.funcs_callers[0].to_add[0].loc.range ==
Range(Position(2, 0)));
} }
TEST_CASE("type usages") { TEST_CASE("type usages") {