Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
503ac95
First attempt to include the semantic highlight feature, introduced i…
jlahoda Dec 25, 2020
013b655
Removing unnecessary include.
jlahoda Dec 26, 2020
a4de46b
name types for (trace|read)ability
FelipeLema Apr 12, 2021
ca51f9e
use tuple for lexicographical comparison
FelipeLema Apr 12, 2021
554833a
handle TODOs, imprve readbility
FelipeLema Apr 12, 2021
c986030
fix type
FelipeLema Apr 12, 2021
661870a
fix compilation
FelipeLema Apr 12, 2021
84a00f6
textDocument/semanticTokens/range
FelipeLema May 3, 2021
700c1ff
fix debug build
FelipeLema May 3, 2021
16d7ef6
use symbols that "intersect", rather than "begin" within range
FelipeLema May 10, 2021
ab53802
use SemanticTokensWithId internally
FelipeLema May 28, 2021
e702d33
indent fix
FelipeLema May 28, 2021
de89bae
use different container per gh review
FelipeLema Jun 16, 2021
1ff4931
comply with github review comments
FelipeLema Jun 16, 2021
79c0bee
omit copyright year per review
FelipeLema Jun 17, 2021
c9f36a3
remove $ccls/publishSemanticHighlight
FelipeLema Jun 18, 2021
5e2ea98
remove absctractions per github review
FelipeLema Jun 18, 2021
000fd75
remove another unnecessary abstraction per gh review
FelipeLema Jun 18, 2021
03324a1
correct usage of "empty (list) of params"
FelipeLema Jun 22, 2021
b07d39b
remove `using` per github review
FelipeLema Jun 23, 2021
20ef17c
clang-format file
FelipeLema Jun 23, 2021
dc9ba78
remove surrounding braces on single-if-statements
FelipeLema Jun 23, 2021
b27b1a6
fix build (no more `using ID`)
FelipeLema Aug 16, 2021
7c1d53b
improve log messages: add info
FelipeLema Aug 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ target_sources(ccls PRIVATE
src/messages/textDocument_hover.cc
src/messages/textDocument_references.cc
src/messages/textDocument_rename.cc
src/messages/textDocument_semanticToken.cc
src/messages/textDocument_signatureHelp.cc
src/messages/workspace.cc
)
Expand Down
2 changes: 2 additions & 0 deletions src/message_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ MessageHandler::MessageHandler() {
bind("textDocument/rename", &MessageHandler::textDocument_rename);
bind("textDocument/signatureHelp", &MessageHandler::textDocument_signatureHelp);
bind("textDocument/typeDefinition", &MessageHandler::textDocument_typeDefinition);
bind("textDocument/semanticTokens/full", &MessageHandler::textDocument_semanticTokensFull);
bind("textDocument/semanticTokens/range", &MessageHandler::textDocument_semanticTokensRange);
bind("workspace/didChangeConfiguration", &MessageHandler::workspace_didChangeConfiguration);
bind("workspace/didChangeWatchedFiles", &MessageHandler::workspace_didChangeWatchedFiles);
bind("workspace/didChangeWorkspaceFolders", &MessageHandler::workspace_didChangeWorkspaceFolders);
Expand Down
11 changes: 11 additions & 0 deletions src/message_handler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ struct TextDocumentPositionParam {
TextDocumentIdentifier textDocument;
Position position;
};
struct SemanticTokensParams {
TextDocumentIdentifier textDocument;
};
REFLECT_STRUCT(SemanticTokensParams, textDocument);
struct SemanticTokensRangeParams {
TextDocumentIdentifier textDocument;
lsRange range;
};
REFLECT_STRUCT(SemanticTokensRangeParams, textDocument, range);
struct TextDocumentEdit {
VersionedTextDocumentIdentifier textDocument;
std::vector<TextEdit> edits;
Expand Down Expand Up @@ -287,6 +296,8 @@ private:
void textDocument_rename(RenameParam &, ReplyOnce &);
void textDocument_signatureHelp(TextDocumentPositionParam &, ReplyOnce &);
void textDocument_typeDefinition(TextDocumentPositionParam &, ReplyOnce &);
void textDocument_semanticTokensFull(SemanticTokensParams &, ReplyOnce &);
void textDocument_semanticTokensRange(SemanticTokensRangeParams &, ReplyOnce &);
void workspace_didChangeConfiguration(EmptyParam &);
void workspace_didChangeWatchedFiles(DidChangeWatchedFilesParam &);
void workspace_didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParam &);
Expand Down
53 changes: 52 additions & 1 deletion src/messages/initialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,47 @@
namespace ccls {
using namespace llvm;

std::vector<const char *> SEMANTIC_TOKENS = {
"unknown",

"file",
"module",
"namespace",
"package",
"class",
"method",
"property",
"field",
"constructor",
"enum",
"interface",
"function",
"variable",
"constant",
"string",
"number",
"boolean",
"array",
"object",
"key",
"null",
"enumMember",
"struct",
"event",
"operator",
"typeParameter",
"typeAlias", //252 => 27
"parameter",
"staticMethod",
"macro"
};

std::vector<const char *> SEMANTIC_MODIFIERS = {
"declaration", //1
"definition", //2
"static" //4
};

extern std::vector<std::string> g_init_options;

namespace {
Expand Down Expand Up @@ -89,6 +130,14 @@ struct ServerCap {
std::vector<const char *> commands = {ccls_xref};
} executeCommandProvider;
Config::ServerCap::Workspace workspace;
struct SemanticTokenProvider {
struct SemanticTokensLegend {
std::vector<const char *> tokenTypes = SEMANTIC_TOKENS;
std::vector<const char *> tokenModifiers = SEMANTIC_MODIFIERS;
} legend;
bool range = true;
bool full = true;
} semanticTokensProvider;
};
REFLECT_STRUCT(ServerCap::CodeActionOptions, codeActionKinds);
REFLECT_STRUCT(ServerCap::CodeLensOptions, resolveProvider);
Expand All @@ -109,7 +158,9 @@ REFLECT_STRUCT(ServerCap, textDocumentSync, hoverProvider, completionProvider,
documentRangeFormattingProvider,
documentOnTypeFormattingProvider, renameProvider,
documentLinkProvider, foldingRangeProvider,
executeCommandProvider, workspace);
executeCommandProvider, workspace, semanticTokensProvider);
REFLECT_STRUCT(ServerCap::SemanticTokenProvider, legend, range, full);
REFLECT_STRUCT(ServerCap::SemanticTokenProvider::SemanticTokensLegend, tokenTypes, tokenModifiers);

struct DynamicReg {
bool dynamicRegistration = false;
Expand Down
Loading