mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Adaopt llvmorg-14-init-3863-g601102d282d5: refactor clang::isIdentifierBody
This commit is contained in:
parent
f21fd7e5a2
commit
3ce756e39a
@ -17,6 +17,10 @@ namespace vfs = clang::vfs;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LLVM_VERSION_MAJOR < 14 // llvmorg-14-init-3863-g601102d282d5
|
||||||
|
#define isAsciiIdentifierContinue isIdentifierBody
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ccls {
|
namespace ccls {
|
||||||
std::string pathFromFileEntry(const clang::FileEntry &file);
|
std::string pathFromFileEntry(const clang::FileEntry &file);
|
||||||
|
|
||||||
|
@ -527,8 +527,8 @@ public:
|
|||||||
auto i = name.find(short_name);
|
auto i = name.find(short_name);
|
||||||
if (short_name.size())
|
if (short_name.size())
|
||||||
while (i != std::string::npos &&
|
while (i != std::string::npos &&
|
||||||
((i && isIdentifierBody(name[i - 1])) ||
|
((i && isAsciiIdentifierContinue(name[i - 1])) ||
|
||||||
isIdentifierBody(name[i + short_name.size()])))
|
isAsciiIdentifierContinue(name[i + short_name.size()])))
|
||||||
i = name.find(short_name, i + short_name.size());
|
i = name.find(short_name, i + short_name.size());
|
||||||
if (i == std::string::npos) {
|
if (i == std::string::npos) {
|
||||||
// e.g. operator type-parameter-1
|
// e.g. operator type-parameter-1
|
||||||
@ -552,7 +552,7 @@ public:
|
|||||||
paren++;
|
paren++;
|
||||||
else if (name[i - 1] == '(')
|
else if (name[i - 1] == '(')
|
||||||
paren--;
|
paren--;
|
||||||
else if (!(paren > 0 || isIdentifierBody(name[i - 1]) ||
|
else if (!(paren > 0 || isAsciiIdentifierContinue(name[i - 1]) ||
|
||||||
name[i - 1] == ':'))
|
name[i - 1] == ':'))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,10 @@ std::optional<int> WorkingFile::getIndexPosFromBufferPos(int line, int *column,
|
|||||||
Position WorkingFile::getCompletionPosition(Position pos, std::string *filter) const {
|
Position WorkingFile::getCompletionPosition(Position pos, std::string *filter) const {
|
||||||
int start = getOffsetForPosition(pos, buffer_content);
|
int start = getOffsetForPosition(pos, buffer_content);
|
||||||
int i = start;
|
int i = start;
|
||||||
while (i > 0 && isIdentifierBody(buffer_content[i - 1]))
|
#if LLVM_VERSION_MAJOR < 14 // llvmorg-14-init-3863-g601102d282d5
|
||||||
|
#define isAsciiIdentifierContinue isIdentifierBody
|
||||||
|
#endif
|
||||||
|
while (i > 0 && isAsciiIdentifierContinue(buffer_content[i - 1]))
|
||||||
--i;
|
--i;
|
||||||
*filter = buffer_content.substr(i, start - i);
|
*filter = buffer_content.substr(i, start - i);
|
||||||
return getPositionForOffset(buffer_content, i);
|
return getPositionForOffset(buffer_content, i);
|
||||||
@ -455,10 +458,10 @@ std::string_view lexIdentifierAroundPos(Position position,
|
|||||||
c = content[start - 1];
|
c = content[start - 1];
|
||||||
if (c == ':' && start > 1 && content[start - 2] == ':')
|
if (c == ':' && start > 1 && content[start - 2] == ':')
|
||||||
start--;
|
start--;
|
||||||
else if (!isIdentifierBody(c))
|
else if (!isAsciiIdentifierContinue(c))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (; end < content.size() && isIdentifierBody(content[end]); end++)
|
for (; end < content.size() && isAsciiIdentifierContinue(content[end]); end++)
|
||||||
;
|
;
|
||||||
|
|
||||||
return content.substr(start, end - start);
|
return content.substr(start, end - start);
|
||||||
|
Loading…
Reference in New Issue
Block a user