Skip to content

Commit

Permalink
Update FoldingRange to support index.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guo-Shiyu committed Jan 24, 2025
1 parent 1a298a3 commit 13119ff
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 77 deletions.
48 changes: 40 additions & 8 deletions include/Feature/DocumentSymbol.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "Basic/Document.h"
#include "Basic/SourceCode.h"
#include "Index/Shared.h"
#include "Support/JSON.h"

namespace clice {
Expand Down Expand Up @@ -75,9 +77,6 @@ struct DocumentSymbol {
/// The kind of this symbol.
SymbolKind kind;

/// Indicates if this symbol is deprecated.
bool deprecated = false;

/// Tags for this symbol.
std::vector<SymbolTag> tags;

Expand All @@ -101,13 +100,46 @@ using DocumentSymbolResult = std::vector<DocumentSymbol>;
class ASTInfo;
class SourceConverter;

namespace feature {
namespace feature::document_symbol {

json::Value capability(json::Value clientCapabilities);

struct DocumentSymbol {
/// The kind of this symbol.
proto::SymbolKind kind;

/// The name of this symbol.
std::string name;

/// More detail for this symbol, e.g the signature of a function.
std::string detail;

/// Tags for this symbol.
std::vector<proto::SymbolTag> tags;

/// Children of this symbol, e.g. properties of a class.
std::vector<DocumentSymbol> children;

/// The range enclosing the symbol not including leading/trailing whitespace but everything
/// else.
LocalSourceRange range;

/// Must be contained by the `range`.
LocalSourceRange selectionRange;
};

using Result = std::vector<DocumentSymbol>;

/// Get all document symbols in each file.
index::Shared<Result> documentSymbol(ASTInfo& info, const SourceConverter& SC);

json::Value documentSymbolCapability(json::Value clientCapabilities);
/// Get document symbols in the main file.
Result documentSymbolInMainFile(ASTInfo& info, const SourceConverter& SC);

/// Run document symbol in given file.
proto::DocumentSymbolResult documentSymbol(ASTInfo& info, const SourceConverter& converter);
/// Convert the result to LSP format.
proto::DocumentSymbolResult toLspResult(llvm::ArrayRef<DocumentSymbol> result,
llvm::StringRef content, const SourceConverter& SC);

} // namespace feature
} // namespace feature::document_symbol

} // namespace clice
Loading

0 comments on commit 13119ff

Please sign in to comment.