2018-10-01 07:57:24 +00:00
|
|
|
/* Copyright 2017-2018 ccls Authors
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==============================================================================*/
|
|
|
|
|
2018-10-28 17:49:31 +00:00
|
|
|
#include "message_handler.hh"
|
2018-10-01 07:57:24 +00:00
|
|
|
#include "pipeline.hh"
|
2018-10-28 17:49:31 +00:00
|
|
|
#include "project.hh"
|
2018-10-01 07:57:24 +00:00
|
|
|
#include "query_utils.h"
|
|
|
|
|
2018-10-28 17:49:31 +00:00
|
|
|
namespace ccls {
|
2018-10-01 07:57:24 +00:00
|
|
|
MAKE_REFLECT_STRUCT(QueryFile::Def, path, args, language, skipped_ranges,
|
|
|
|
dependencies);
|
|
|
|
|
|
|
|
namespace {
|
2019-01-09 07:19:17 +00:00
|
|
|
struct Out_cclsInfo {
|
|
|
|
struct DB {
|
|
|
|
int files, funcs, types, vars;
|
|
|
|
} db;
|
|
|
|
struct Pipeline {
|
|
|
|
int pendingIndexRequests;
|
|
|
|
} pipeline;
|
|
|
|
struct Project {
|
|
|
|
int entries;
|
|
|
|
} project;
|
2018-10-01 07:57:24 +00:00
|
|
|
};
|
2019-01-09 07:19:17 +00:00
|
|
|
MAKE_REFLECT_STRUCT(Out_cclsInfo::DB, files, funcs, types, vars);
|
|
|
|
MAKE_REFLECT_STRUCT(Out_cclsInfo::Pipeline, pendingIndexRequests);
|
|
|
|
MAKE_REFLECT_STRUCT(Out_cclsInfo::Project, entries);
|
|
|
|
MAKE_REFLECT_STRUCT(Out_cclsInfo, db, pipeline, project);
|
2018-10-28 17:49:31 +00:00
|
|
|
} // namespace
|
2018-10-01 07:57:24 +00:00
|
|
|
|
2018-10-28 17:49:31 +00:00
|
|
|
void MessageHandler::ccls_info(EmptyParam &, ReplyOnce &reply) {
|
|
|
|
Out_cclsInfo result;
|
|
|
|
result.db.files = db->files.size();
|
|
|
|
result.db.funcs = db->funcs.size();
|
|
|
|
result.db.types = db->types.size();
|
|
|
|
result.db.vars = db->vars.size();
|
|
|
|
result.pipeline.pendingIndexRequests = pipeline::pending_index_requests;
|
|
|
|
result.project.entries = 0;
|
|
|
|
for (auto &[_, folder] : project->root2folder)
|
|
|
|
result.project.entries += folder.entries.size();
|
|
|
|
reply(result);
|
|
|
|
}
|
2018-10-01 07:57:24 +00:00
|
|
|
|
2018-10-28 17:49:31 +00:00
|
|
|
void MessageHandler::ccls_fileInfo(TextDocumentParam ¶m, ReplyOnce &reply) {
|
|
|
|
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath());
|
|
|
|
if (!file)
|
|
|
|
return;
|
2018-10-01 07:57:24 +00:00
|
|
|
|
2018-10-28 17:49:31 +00:00
|
|
|
QueryFile::Def result;
|
|
|
|
// Expose some fields of |QueryFile::Def|.
|
|
|
|
result.path = file->def->path;
|
|
|
|
result.args = file->def->args;
|
|
|
|
result.language = file->def->language;
|
|
|
|
result.includes = file->def->includes;
|
|
|
|
result.skipped_ranges = file->def->skipped_ranges;
|
|
|
|
reply(result);
|
|
|
|
}
|
|
|
|
} // namespace ccls
|