Implement DocumentLink (#107)

This commit is contained in:
ykiko
2025-03-16 16:43:35 +08:00
committed by GitHub
parent c332c93433
commit c54baf5590
18 changed files with 386 additions and 76 deletions

View File

@@ -98,6 +98,8 @@ public:
async::Task<std::vector<feature::FoldingRange>> foldingRanges(llvm::StringRef file) const;
async::Task<std::vector<feature::DocumentLink>> documentLinks(llvm::StringRef file) const;
private:
async::Task<> index(std::string file);

View File

@@ -7,6 +7,7 @@
#include "Feature/FoldingRange.h"
#include "Feature/DocumentSymbol.h"
#include "Feature/SemanticTokens.h"
#include "Feature/DocumentLink.h"
#include "Server/Protocol.h"
namespace clice {
@@ -36,10 +37,15 @@ public:
std::vector<proto::FoldingRange> transform(llvm::StringRef content,
llvm::ArrayRef<feature::FoldingRange> foldings);
std::vector<proto::DocumentLink> transform(llvm::StringRef content,
llvm::ArrayRef<feature::DocumentLink> links);
Result convert(llvm::StringRef path, llvm::ArrayRef<feature::SemanticToken> tokens);
Result convert(llvm::StringRef path, llvm::ArrayRef<feature::FoldingRange> foldings);
Result convert(llvm::StringRef path, llvm::ArrayRef<feature::DocumentLink> links);
Result convert(const feature::Hover& hover);
private:

View File

@@ -289,6 +289,11 @@ enum class FoldingRangeKind {
Region,
};
struct DocumentLink {
Range range;
URI target;
};
/// Represents a folding range. To be valid, start and end line must be bigger
/// than zero and smaller than the number of lines in the document. Clients
/// are free to ignore invalid ranges.
@@ -366,6 +371,14 @@ struct ServerCapabilities {
/// The server provides semantic tokens support.
SemanticTokensOptions semanticTokensProvider;
struct DocumentLinkOptions {
/// Document links have a resolve provider as well.
bool resolveProvider = false;
};
/// The server provides document link support.
DocumentLinkOptions documentLinkProvider;
/// The server provides folding provider support.
bool foldingRangeProvider = true;
};
@@ -425,6 +438,8 @@ using SemanticTokensParams = TextDocumentParams;
using FoldingRangeParams = TextDocumentParams;
using DocumentLinkParams = TextDocumentParams;
struct HeaderContext {
/// The path of context file.
std::string file;