mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 11:01:57 +00:00
code dedup
This commit is contained in:
parent
82596abc51
commit
5b734e4c64
@ -26,12 +26,6 @@ unsigned Flags() {
|
|||||||
CXTranslationUnit_DetailedPreprocessingRecord;
|
CXTranslationUnit_DetailedPreprocessingRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartsWith(const std::string& value, const std::string& start) {
|
|
||||||
if (start.size() > value.size())
|
|
||||||
return false;
|
|
||||||
return std::equal(start.begin(), start.end(), value.begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
||||||
switch (cursor_kind) {
|
switch (cursor_kind) {
|
||||||
|
|
||||||
|
@ -8,20 +8,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
// See http://stackoverflow.com/a/2072890
|
|
||||||
bool EndsWith(const std::string& value, const std::string& ending) {
|
|
||||||
if (ending.size() > value.size())
|
|
||||||
return false;
|
|
||||||
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartsWith(const std::string& value, const std::string& start) {
|
|
||||||
if (start.size() > value.size())
|
|
||||||
return false;
|
|
||||||
return std::equal(start.begin(), start.end(), value.begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<CompilationEntry> LoadFromDirectoryListing(const std::string& project_directory) {
|
std::vector<CompilationEntry> LoadFromDirectoryListing(const std::string& project_directory) {
|
||||||
std::vector<CompilationEntry> result;
|
std::vector<CompilationEntry> result;
|
||||||
|
|
||||||
|
13
src/utils.cc
13
src/utils.cc
@ -6,6 +6,19 @@
|
|||||||
|
|
||||||
#include <tinydir.h>
|
#include <tinydir.h>
|
||||||
|
|
||||||
|
// See http://stackoverflow.com/a/2072890
|
||||||
|
bool EndsWith(const std::string& value, const std::string& ending) {
|
||||||
|
if (ending.size() > value.size())
|
||||||
|
return false;
|
||||||
|
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StartsWith(const std::string& value, const std::string& start) {
|
||||||
|
if (start.size() > value.size())
|
||||||
|
return false;
|
||||||
|
return std::equal(start.begin(), start.end(), value.begin());
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<std::string> GetFilesInFolderHelper(std::string folder, bool recursive, std::string output_prefix) {
|
static std::vector<std::string> GetFilesInFolderHelper(std::string folder, bool recursive, std::string output_prefix) {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
|
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
// Returns true if |value| starts/ends with |start| or |ending|.
|
||||||
|
bool StartsWith(const std::string& value, const std::string& start);
|
||||||
|
bool EndsWith(const std::string& value, const std::string& ending);
|
||||||
|
|
||||||
// Finds all files in the given folder. This is recursive.
|
// Finds all files in the given folder. This is recursive.
|
||||||
std::vector<std::string> GetFilesInFolder(std::string folder, bool recursive, bool add_folder_to_path);
|
std::vector<std::string> GetFilesInFolder(std::string folder, bool recursive, bool add_folder_to_path);
|
||||||
std::vector<std::string> ReadLines(std::string filename);
|
std::vector<std::string> ReadLines(std::string filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user