Skip to content

Commit

Permalink
Merge pull request #1021 from ipyffor/master
Browse files Browse the repository at this point in the history
修复clangd inlay hint不生效的问题
  • Loading branch information
manateelazycat authored Aug 17, 2024
2 parents 658f08e + db1935c commit 9265149
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
6 changes: 5 additions & 1 deletion core/lspserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,11 @@ def save_attribute_from_message(self, message):
("range_format_provider", ["result", "capabilities", "documentRangeFormattingProvider"]),
("signature_help_provider", ["result", "capabilities", "signatureHelpProvider"]),
("workspace_symbol_provider", ["result", "capabilities", "workspaceSymbolProvider"]),
("inlay_hint_provider", ["result", "capabilities", "inlayHintProvider", "resolveProvider"]),
# ("inlay_hint_provider", ["result", "capabilities", "inlayHintProvider", "resolveProvider"]),
("inlay_hint_provider", [
["result", "capabilities", "inlayHintProvider", "resolveProvider"],
["result", "capabilities", "clangdInlayHintsProvider"] # 兼容clangd
]),
("save_include_text", ["result", "capabilities", "textDocumentSync", "save", "includeText"]),
("text_document_sync", ["result", "capabilities", "textDocumentSync"]),
("semantic_tokens_provider", ["result", "capabilities", "semanticTokensProvider"])]
Expand Down
26 changes: 23 additions & 3 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,33 @@ def remove_duplicate_references(data):
result.append(item)
return result

# def get_nested_value(dct, keys):
# for key in keys:
# try:
# dct = dct[key]
# except (KeyError, TypeError):
# return None
# return dct

def get_nested_value(dct, keys):
'''
keys: ["k1", "k2", ...]匹配一组, [["k1", "k2", ...], [], ...]匹配多组情况
'''
value = None
for key in keys:
try:
dct = dct[key]
if isinstance(key, list):
value = get_nested_value(dct, key)
if value:
break
else:
dct = dct[key]
except (KeyError, TypeError):
return None
return dct
dct = None
break

return value if value else dct


class MessageSender(Thread):

Expand Down

0 comments on commit 9265149

Please sign in to comment.