From 162f1b2fbe88e18f47bd7a1b7b9e3c320e24fd3f Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Sat, 10 Oct 2020 12:25:50 +0300 Subject: [PATCH] Opaque type support --- src/analysis.zig | 4 ++++ src/main.zig | 2 +- src/semantic_tokens.zig | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/analysis.zig b/src/analysis.zig index 5247a6a..3f51bc5 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -914,6 +914,10 @@ pub const TypeWithHandle = struct { return self.isContainer(.Keyword_union); } + pub fn isOpaqueType(self: TypeWithHandle) bool { + return self.isContainer(.Keyword_opaque); + } + pub fn isTypeFunc(self: TypeWithHandle) bool { switch (self.type.data) { .other => |n| { diff --git a/src/main.zig b/src/main.zig index fe9a0c5..af760b4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -92,7 +92,7 @@ var client_capabilities = ClientCapabilities{}; var offset_encoding = offsets.Encoding.utf16; const initialize_capabilities = - \\"capabilities": {"signatureHelpProvider": {"triggerCharacters": ["(",","]},"textDocumentSync": 1,"renameProvider":true,"completionProvider": {"resolveProvider": false,"triggerCharacters": [".",":","@"]},"documentHighlightProvider": false,"hoverProvider": true,"codeActionProvider": false,"declarationProvider": true,"definitionProvider": true,"typeDefinitionProvider": true,"implementationProvider": false,"referencesProvider": true,"documentSymbolProvider": true,"colorProvider": false,"documentFormattingProvider": true,"documentRangeFormattingProvider": false,"foldingRangeProvider": false,"selectionRangeProvider": false,"workspaceSymbolProvider": false,"rangeProvider": false,"documentProvider": true,"workspace": {"workspaceFolders": {"supported": true,"changeNotifications": true}},"semanticTokensProvider": {"documentProvider": true,"legend": {"tokenTypes": ["namespace","type","struct","enum","union","parameter","variable","tagField","field","errorTag","function","keyword","comment","string","number","operator","builtin","label","keywordLiteral"],"tokenModifiers": ["definition","async","documentation", "generic"]}}}}} + \\"capabilities": {"signatureHelpProvider": {"triggerCharacters": ["(",","]},"textDocumentSync": 1,"renameProvider":true,"completionProvider": {"resolveProvider": false,"triggerCharacters": [".",":","@"]},"documentHighlightProvider": false,"hoverProvider": true,"codeActionProvider": false,"declarationProvider": true,"definitionProvider": true,"typeDefinitionProvider": true,"implementationProvider": false,"referencesProvider": true,"documentSymbolProvider": true,"colorProvider": false,"documentFormattingProvider": true,"documentRangeFormattingProvider": false,"foldingRangeProvider": false,"selectionRangeProvider": false,"workspaceSymbolProvider": false,"rangeProvider": false,"documentProvider": true,"workspace": {"workspaceFolders": {"supported": true,"changeNotifications": true}},"semanticTokensProvider": {"documentProvider": true,"legend": {"tokenTypes": ["namespace","type","struct","enum","union","opaque","parameter","variable","tagField","field","errorTag","function","keyword","comment","string","number","operator","builtin","label","keywordLiteral"],"tokenModifiers": ["definition","async","documentation", "generic"]}}}}} ; const initialize_response = ",\"result\": {" ++ initialize_capabilities; diff --git a/src/semantic_tokens.zig b/src/semantic_tokens.zig index c4b0ece..9486efd 100644 --- a/src/semantic_tokens.zig +++ b/src/semantic_tokens.zig @@ -10,6 +10,7 @@ const TokenType = enum(u32) { @"struct", @"enum", @"union", + @"opaque", parameter, variable, tagField, @@ -195,6 +196,8 @@ fn colorIdentifierBasedOnType(builder: *Builder, type_node: analysis.TypeWithHan .@"enum" else if (type_node.isUnionType()) .@"union" + else if (type_node.isOpaqueType()) + .@"opaque" else TokenType.type;