mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-16 21:58:08 +00:00
objc
This commit is contained in:
parent
ea5c89e956
commit
5238c50027
@ -85,6 +85,7 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
|||||||
|
|
||||||
case CXCursor_ObjCInstanceMethodDecl:
|
case CXCursor_ObjCInstanceMethodDecl:
|
||||||
case CXCursor_CXXMethod:
|
case CXCursor_CXXMethod:
|
||||||
|
case CXCursor_ObjCClassMethodDecl:
|
||||||
return lsCompletionItemKind::Method;
|
return lsCompletionItemKind::Method;
|
||||||
|
|
||||||
case CXCursor_FunctionTemplate:
|
case CXCursor_FunctionTemplate:
|
||||||
@ -101,6 +102,7 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
|||||||
|
|
||||||
case CXCursor_VarDecl:
|
case CXCursor_VarDecl:
|
||||||
case CXCursor_ParmDecl:
|
case CXCursor_ParmDecl:
|
||||||
|
case CXCursor_ObjCIvarDecl:
|
||||||
return lsCompletionItemKind::Variable;
|
return lsCompletionItemKind::Variable;
|
||||||
|
|
||||||
case CXCursor_UnionDecl:
|
case CXCursor_UnionDecl:
|
||||||
@ -112,6 +114,11 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
|||||||
case CXCursor_TypedefDecl:
|
case CXCursor_TypedefDecl:
|
||||||
case CXCursor_TypeAliasDecl:
|
case CXCursor_TypeAliasDecl:
|
||||||
case CXCursor_TypeAliasTemplateDecl:
|
case CXCursor_TypeAliasTemplateDecl:
|
||||||
|
case CXCursor_ObjCCategoryDecl:
|
||||||
|
case CXCursor_ObjCProtocolDecl:
|
||||||
|
case CXCursor_ObjCPropertyDecl:
|
||||||
|
case CXCursor_ObjCImplementationDecl:
|
||||||
|
case CXCursor_ObjCCategoryImplDecl:
|
||||||
return lsCompletionItemKind::Class;
|
return lsCompletionItemKind::Class;
|
||||||
|
|
||||||
case CXCursor_EnumConstantDecl:
|
case CXCursor_EnumConstantDecl:
|
||||||
@ -120,6 +127,7 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
|||||||
|
|
||||||
case CXCursor_MacroInstantiation:
|
case CXCursor_MacroInstantiation:
|
||||||
case CXCursor_MacroDefinition:
|
case CXCursor_MacroDefinition:
|
||||||
|
case CXCursor_ObjCInterfaceDecl:
|
||||||
return lsCompletionItemKind::Interface;
|
return lsCompletionItemKind::Interface;
|
||||||
|
|
||||||
case CXCursor_Namespace:
|
case CXCursor_Namespace:
|
||||||
@ -129,6 +137,9 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
|||||||
|
|
||||||
case CXCursor_MemberRef:
|
case CXCursor_MemberRef:
|
||||||
case CXCursor_TypeRef:
|
case CXCursor_TypeRef:
|
||||||
|
case CXCursor_ObjCSuperClassRef:
|
||||||
|
case CXCursor_ObjCProtocolRef:
|
||||||
|
case CXCursor_ObjCClassRef:
|
||||||
return lsCompletionItemKind::Reference;
|
return lsCompletionItemKind::Reference;
|
||||||
|
|
||||||
// return lsCompletionItemKind::Property;
|
// return lsCompletionItemKind::Property;
|
||||||
|
@ -1048,7 +1048,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (print_help) {
|
if (print_help) {
|
||||||
std::cout << R"help(cquery is a low-latency C++ language server.
|
std::cout << R"help(cquery is a low-latency C/C++/Objective-C language server.
|
||||||
|
|
||||||
Command line options:
|
Command line options:
|
||||||
--language-server
|
--language-server
|
||||||
|
@ -956,8 +956,6 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
param->ctors.NotifyConstructor(decl->cursor);
|
param->ctors.NotifyConstructor(decl->cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(AreEqualLocations(decl->loc, decl->cursor));
|
|
||||||
|
|
||||||
CXFile file;
|
CXFile file;
|
||||||
clang_getSpellingLocation(clang_indexLoc_getCXSourceLocation(decl->loc),
|
clang_getSpellingLocation(clang_indexLoc_getCXSourceLocation(decl->loc),
|
||||||
&file, nullptr, nullptr, nullptr);
|
&file, nullptr, nullptr, nullptr);
|
||||||
|
@ -84,8 +84,16 @@ bool ShouldAddToAngleIncludes(const std::string& arg) {
|
|||||||
|
|
||||||
// Returns true if we should use the C, not C++, language spec for the given
|
// Returns true if we should use the C, not C++, language spec for the given
|
||||||
// file.
|
// file.
|
||||||
bool IsCFile(const std::string& path) {
|
optional<std::string> SourceFileType(const std::string& path) {
|
||||||
return EndsWith(path, ".c");
|
if (EndsWith(path, ".c"))
|
||||||
|
return std::string("c");
|
||||||
|
else if (EndsWith(path, ".cpp") || EndsWith(path, ".cc"))
|
||||||
|
return std::string("c++");
|
||||||
|
else if (EndsWith(path, ".mm"))
|
||||||
|
return std::string("objective-c++");
|
||||||
|
else if (EndsWith(path, ".m"))
|
||||||
|
return std::string("objective-c");
|
||||||
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
||||||
@ -181,17 +189,17 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
|
|
||||||
// Clang does not have good hueristics for determining source language, we
|
// Clang does not have good hueristics for determining source language, we
|
||||||
// should explicitly specify it.
|
// should explicitly specify it.
|
||||||
if (!AnyStartsWith(result.args, "-x")) {
|
if (auto source_file_type = SourceFileType(entry.file)) {
|
||||||
if (IsCFile(entry.file))
|
if (AnyStartsWith(result.args, "-x")) {
|
||||||
result.args.push_back("-xc");
|
result.args.push_back("-x" + *source_file_type);
|
||||||
else
|
}
|
||||||
result.args.push_back("-xc++");
|
if (!AnyStartsWith(result.args, "-std=")) {
|
||||||
}
|
if (*source_file_type == "c")
|
||||||
if (!AnyStartsWith(result.args, "-std=")) {
|
result.args.push_back("-std=c11");
|
||||||
if (IsCFile(entry.file))
|
else if (*source_file_type == "c++")
|
||||||
result.args.push_back("-std=c11");
|
result.args.push_back("-std=c++11");
|
||||||
else
|
}
|
||||||
result.args.push_back("-std=c++11");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add -resource-dir so clang can correctly resolve system includes like
|
// Add -resource-dir so clang can correctly resolve system includes like
|
||||||
@ -227,8 +235,7 @@ std::vector<Project::Entry> LoadFromDirectoryListing(ProjectConfig* config) {
|
|||||||
std::vector<std::string> files = GetFilesInFolder(
|
std::vector<std::string> files = GetFilesInFolder(
|
||||||
config->project_dir, true /*recursive*/, true /*add_folder_to_path*/);
|
config->project_dir, true /*recursive*/, true /*add_folder_to_path*/);
|
||||||
for (const std::string& file : files) {
|
for (const std::string& file : files) {
|
||||||
if (EndsWith(file, ".cc") || EndsWith(file, ".cpp") ||
|
if (SourceFileType(file)) {
|
||||||
EndsWith(file, ".c")) {
|
|
||||||
CompileCommandsEntry e;
|
CompileCommandsEntry e;
|
||||||
e.file = NormalizePathWithTestOptOut(file);
|
e.file = NormalizePathWithTestOptOut(file);
|
||||||
e.args = args;
|
e.args = args;
|
||||||
|
Loading…
Reference in New Issue
Block a user