mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Use clang_File_tryGetRealPathName
This commit is contained in:
parent
b51347960c
commit
3fbfb99e1b
@ -5,7 +5,7 @@ a C/C++/Objective-C language server.
|
|||||||
|
|
||||||
* code completion (with both signature help and snippets)
|
* code completion (with both signature help and snippets)
|
||||||
* finding [definition](src/messages/text_document_definition.cc)/[references](src/messages/text_document_references.cc)
|
* finding [definition](src/messages/text_document_definition.cc)/[references](src/messages/text_document_references.cc)
|
||||||
* [call (caller/callee) hierarchy](src/messages/cquery_call_hierarchy.cc), [inheritance (base/derived) hierarchy](src/messages/cquery_inheritance_hierarchy.cc), [member hierarchy](src/messages/cquery_member_hierarchy.cc)
|
* [call (caller/callee) hierarchy](src/messages/ccls_call_hierarchy.cc), [inheritance (base/derived) hierarchy](src/messages/ccls_inheritance_hierarchy.cc), [member hierarchy](src/messages/ccls_member_hierarchy.cc)
|
||||||
* [symbol rename](src/messages/text_document_rename.cc)
|
* [symbol rename](src/messages/text_document_rename.cc)
|
||||||
* [document symbols](src/messages/text_document_document_symbol.cc) and approximate search of [workspace symbol](src/messages/workspace_symbol.cc)
|
* [document symbols](src/messages/text_document_document_symbol.cc) and approximate search of [workspace symbol](src/messages/workspace_symbol.cc)
|
||||||
* [hover information](src/messages/text_document_hover.cc)
|
* [hover information](src/messages/text_document_hover.cc)
|
||||||
|
@ -7,15 +7,15 @@ case $(uname -s) in
|
|||||||
Darwin)
|
Darwin)
|
||||||
libclang=(lib/clang+llvm-*/lib/libclang.dylib)
|
libclang=(lib/clang+llvm-*/lib/libclang.dylib)
|
||||||
strip_option="-x"
|
strip_option="-x"
|
||||||
name=cquery-$version-x86_64-apple-darwin ;;
|
name=ccls-$version-x86_64-apple-darwin ;;
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
libclang=(lib/clang+llvm-*/lib/libclang.so.?)
|
libclang=(lib/clang+llvm-*/lib/libclang.so.?)
|
||||||
strip_option="-s"
|
strip_option="-s"
|
||||||
name=cquery-$version-x86_64-unknown-freebsd10 ;;
|
name=ccls-$version-x86_64-unknown-freebsd10 ;;
|
||||||
Linux)
|
Linux)
|
||||||
libclang=(lib/clang+llvm-*/lib/libclang.so.?)
|
libclang=(lib/clang+llvm-*/lib/libclang.so.?)
|
||||||
strip_option="-s"
|
strip_option="-s"
|
||||||
name=cquery-$version-x86_64-unknown-linux-gnu ;;
|
name=ccls-$version-x86_64-unknown-linux-gnu ;;
|
||||||
*)
|
*)
|
||||||
echo Unsupported >&2
|
echo Unsupported >&2
|
||||||
exit 1 ;;
|
exit 1 ;;
|
||||||
@ -26,7 +26,7 @@ mkdir "$pkg/$name"
|
|||||||
rsync -rtLR bin "./${libclang[-1]}" ./lib/clang+llvm-*/lib/clang/*/include "$pkg/$name"
|
rsync -rtLR bin "./${libclang[-1]}" ./lib/clang+llvm-*/lib/clang/*/include "$pkg/$name"
|
||||||
|
|
||||||
cd "$pkg"
|
cd "$pkg"
|
||||||
strip "$strip_option" "$name/bin/cquery" "$name/${libclang[-1]}"
|
strip "$strip_option" "$name/bin/ccls" "$name/${libclang[-1]}"
|
||||||
case $(uname -s) in
|
case $(uname -s) in
|
||||||
Darwin)
|
Darwin)
|
||||||
# https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/tar.1.html
|
# https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/tar.1.html
|
||||||
|
@ -106,8 +106,13 @@ std::optional<lsDiagnostic> BuildAndDisposeDiagnostic(CXDiagnostic diagnostic,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string FileName(CXFile file) {
|
std::string FileName(CXFile file) {
|
||||||
CXString cx_name = clang_getFileName(file);
|
std::string ret;
|
||||||
std::string ret = NormalizePath(ToString(cx_name));
|
// clang > 6
|
||||||
|
#if CINDEX_VERSION >= 48
|
||||||
|
ret = ToString(clang_File_tryGetRealPathName(file));
|
||||||
|
#endif
|
||||||
|
if (ret.empty())
|
||||||
|
ret = ToString(clang_getFileName(file));
|
||||||
// Resolve /usr/include/c++/7.3.0 symlink.
|
// Resolve /usr/include/c++/7.3.0 symlink.
|
||||||
if (!StartsWith(ret, g_config->projectRoot))
|
if (!StartsWith(ret, g_config->projectRoot))
|
||||||
ret = fs::canonical(ret);
|
ret = fs::canonical(ret);
|
||||||
|
@ -77,7 +77,7 @@ bool ShouldDisplayMethodTiming(MethodType type) {
|
|||||||
|
|
||||||
void PrintHelp() {
|
void PrintHelp() {
|
||||||
std::cout
|
std::cout
|
||||||
<< R"help(ccls is a low-latency C/C++/Objective-C language server.
|
<< R"help(ccls is a C/C++/Objective-C language server.
|
||||||
|
|
||||||
Mode:
|
Mode:
|
||||||
--test-unit Run unit tests.
|
--test-unit Run unit tests.
|
||||||
@ -91,7 +91,7 @@ Mode:
|
|||||||
Other command line options:
|
Other command line options:
|
||||||
--init <initializationOptions>
|
--init <initializationOptions>
|
||||||
Override client provided initialization options
|
Override client provided initialization options
|
||||||
https://github.com/cquery-project/cquery/wiki/Initialization-options
|
https://github.com/MaskRay/ccls/wiki/Initialization-options
|
||||||
--log-file <path> Logging file for diagnostics
|
--log-file <path> Logging file for diagnostics
|
||||||
--log-file-append <path> Like --log-file, but appending
|
--log-file-append <path> Like --log-file, but appending
|
||||||
--log-all-to-stderr Write all log messages to STDERR.
|
--log-all-to-stderr Write all log messages to STDERR.
|
||||||
|
@ -80,8 +80,8 @@ std::vector<std::string> kNormalizePathArgs = {"--sysroot="};
|
|||||||
|
|
||||||
// Arguments whose path arguments should be injected into include dir lookup
|
// Arguments whose path arguments should be injected into include dir lookup
|
||||||
// for #include completion.
|
// for #include completion.
|
||||||
std::vector<std::string> kQuoteIncludeArgs = {"-iquote"};
|
std::vector<std::string> kQuoteIncludeArgs = {"-iquote", "-I", "/I"};
|
||||||
std::vector<std::string> kAngleIncludeArgs = {"-I", "/I", "-isystem"};
|
std::vector<std::string> kAngleIncludeArgs = {"-isystem", "-I", "/I"};
|
||||||
|
|
||||||
bool ShouldAddToQuoteIncludes(const std::string& arg) {
|
bool ShouldAddToQuoteIncludes(const std::string& arg) {
|
||||||
return StartsWithAny(arg, kQuoteIncludeArgs);
|
return StartsWithAny(arg, kQuoteIncludeArgs);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -248,7 +249,7 @@ std::string TextReplacer::Apply(const std::string& content) {
|
|||||||
void WriteToFile(const std::string& filename, const std::string& content) {
|
void WriteToFile(const std::string& filename, const std::string& content) {
|
||||||
FILE* f = fopen(filename.c_str(), "wb");
|
FILE* f = fopen(filename.c_str(), "wb");
|
||||||
if (!f || fwrite(content.c_str(), content.size(), 1, f) != 1) {
|
if (!f || fwrite(content.c_str(), content.size(), 1, f) != 1) {
|
||||||
LOG_S(ERROR) << "Cannot write to " << filename;
|
LOG_S(ERROR) << "Failed to write to " << filename << ' ' << strerror(errno);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
Loading…
Reference in New Issue
Block a user