MCPcopy Create free account
hub / github.com/MaskRay/ccls / workspace_executeCommand

Method workspace_executeCommand

src/messages/textDocument_code.cc:146–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void MessageHandler::workspace_executeCommand(JsonReader &reader, ReplyOnce &reply) {
147 Command param;
148 reflect(reader, param);
149 if (param.arguments.empty()) {
150 return;
151 }
152 rapidjson::Document reader1;
153 reader1.Parse(param.arguments[0].c_str());
154 JsonReader json_reader{&reader1};
155 if (param.command == ccls_xref) {
156 Cmd_xref cmd;
157 reflect(json_reader, cmd);
158 std::vector<Location> result;
159 auto map = [&](auto &&uses) {
160 for (auto &use : uses)
161 if (auto loc = getLsLocation(db, wfiles, use))
162 result.push_back(std::move(*loc));
163 };
164 switch (cmd.kind) {
165 case Kind::Func: {
166 QueryFunc &func = db->getFunc(cmd.usr);
167 if (cmd.field == "bases") {
168 if (auto *def = func.anyDef())
169 map(getFuncDeclarations(db, def->bases));
170 } else if (cmd.field == "bases uses") {
171 map(getUsesForAllBases(db, func));
172 } else if (cmd.field == "derived") {
173 map(getFuncDeclarations(db, func.derived));
174 } else if (cmd.field == "derived uses") {
175 map(getUsesForAllDerived(db, func));
176 } else if (cmd.field == "uses") {
177 map(func.uses);
178 }
179 break;
180 }
181 case Kind::Type: {
182 QueryType &type = db->getType(cmd.usr);
183 if (cmd.field == "derived") {
184 map(getTypeDeclarations(db, type.derived));
185 } else if (cmd.field == "instances") {
186 map(getVarDeclarations(db, type.instances, 7));
187 } else if (cmd.field == "uses") {
188 map(type.uses);
189 }
190 break;
191 }
192 case Kind::Var: {
193 QueryVar &var = db->getVar(cmd.usr);
194 if (cmd.field == "uses")
195 map(var.uses);
196 break;
197 }
198 default:
199 break;
200 }
201 reply(result);
202 }
203}

Callers

nothing calls this directly

Calls 9

getLsLocationFunction · 0.85
getFuncDeclarationsFunction · 0.85
getUsesForAllBasesFunction · 0.85
getUsesForAllDerivedFunction · 0.85
getTypeDeclarationsFunction · 0.85
getVarDeclarationsFunction · 0.85
replyFunction · 0.85
anyDefMethod · 0.80
reflectFunction · 0.70

Tested by

no test coverage detected