mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	Add all to textDocument/documentSymbol
This commit is contained in:
		
							parent
							
								
									207e79ea98
								
							
						
					
					
						commit
						8a9640a56b
					
				@ -9,8 +9,9 @@ MethodType kMethodType = "textDocument/documentSymbol";
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct lsDocumentSymbolParams {
 | 
					struct lsDocumentSymbolParams {
 | 
				
			||||||
  lsTextDocumentIdentifier textDocument;
 | 
					  lsTextDocumentIdentifier textDocument;
 | 
				
			||||||
 | 
					  bool all = false;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
 | 
					MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument, all);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct In_TextDocumentDocumentSymbol : public RequestInMessage {
 | 
					struct In_TextDocumentDocumentSymbol : public RequestInMessage {
 | 
				
			||||||
  MethodType GetMethodType() const override { return kMethodType; }
 | 
					  MethodType GetMethodType() const override { return kMethodType; }
 | 
				
			||||||
@ -30,35 +31,44 @@ struct Handler_TextDocumentDocumentSymbol
 | 
				
			|||||||
    : BaseMessageHandler<In_TextDocumentDocumentSymbol> {
 | 
					    : BaseMessageHandler<In_TextDocumentDocumentSymbol> {
 | 
				
			||||||
  MethodType GetMethodType() const override { return kMethodType; }
 | 
					  MethodType GetMethodType() const override { return kMethodType; }
 | 
				
			||||||
  void Run(In_TextDocumentDocumentSymbol* request) override {
 | 
					  void Run(In_TextDocumentDocumentSymbol* request) override {
 | 
				
			||||||
 | 
					    auto& params = request->params;
 | 
				
			||||||
    Out_TextDocumentDocumentSymbol out;
 | 
					    Out_TextDocumentDocumentSymbol out;
 | 
				
			||||||
    out.id = request->id;
 | 
					    out.id = request->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QueryFile* file;
 | 
					    QueryFile* file;
 | 
				
			||||||
    int file_id;
 | 
					    int file_id;
 | 
				
			||||||
    if (!FindFileOrFail(db, project, request->id,
 | 
					    if (!FindFileOrFail(db, project, request->id,
 | 
				
			||||||
                        request->params.textDocument.uri.GetPath(), &file,
 | 
					                        params.textDocument.uri.GetPath(), &file, &file_id))
 | 
				
			||||||
                        &file_id)) {
 | 
					 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (SymbolRef sym : file->def->outline) {
 | 
					    if (params.all) {
 | 
				
			||||||
      std::optional<lsSymbolInformation> info =
 | 
					      for (SymbolRef sym : file->def->all_symbols)
 | 
				
			||||||
          GetSymbolInfo(db, working_files, sym, false);
 | 
					        if (std::optional<lsSymbolInformation> info =
 | 
				
			||||||
      if (!info)
 | 
					                GetSymbolInfo(db, working_files, sym, false)) {
 | 
				
			||||||
        continue;
 | 
					          if (std::optional<lsLocation> location = GetLsLocation(
 | 
				
			||||||
      if (sym.kind == SymbolKind::Var) {
 | 
					                  db, working_files,
 | 
				
			||||||
        QueryVar& var = db->GetVar(sym);
 | 
					                  Use{{sym.range, sym.usr, sym.kind, sym.role}, file_id})) {
 | 
				
			||||||
        auto* def = var.AnyDef();
 | 
					            info->location = *location;
 | 
				
			||||||
        if (!def || !def->spell || def->is_local())
 | 
					            out.result.push_back(*info);
 | 
				
			||||||
          continue;
 | 
					          }
 | 
				
			||||||
      }
 | 
					        }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
      if (std::optional<lsLocation> location = GetLsLocation(
 | 
					      for (SymbolRef sym : file->def->outline)
 | 
				
			||||||
              db, working_files,
 | 
					        if (std::optional<lsSymbolInformation> info =
 | 
				
			||||||
              Use{{sym.range, sym.usr, sym.kind, sym.role}, file_id})) {
 | 
					                GetSymbolInfo(db, working_files, sym, false)) {
 | 
				
			||||||
        info->location = *location;
 | 
					          if (sym.kind == SymbolKind::Var) {
 | 
				
			||||||
        out.result.push_back(*info);
 | 
					            QueryVar& var = db->GetVar(sym);
 | 
				
			||||||
      }
 | 
					            auto* def = var.AnyDef();
 | 
				
			||||||
 | 
					            if (!def || !def->spell || def->is_local())
 | 
				
			||||||
 | 
					              continue;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          if (std::optional<lsLocation> location = GetLsLocation(
 | 
				
			||||||
 | 
					                  db, working_files,
 | 
				
			||||||
 | 
					                  Use{{sym.range, sym.usr, sym.kind, sym.role}, file_id})) {
 | 
				
			||||||
 | 
					            info->location = *location;
 | 
				
			||||||
 | 
					            out.result.push_back(*info);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pipeline::WriteStdout(kMethodType, out);
 | 
					    pipeline::WriteStdout(kMethodType, out);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user