From a18d695ec105f0cda1903d1974f493207e122b35 Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 27 Aug 2024 14:39:51 +0800 Subject: [PATCH] format all the files with the new vfmt (#117) --- build.vsh | 20 +-- install.vsh | 36 ++--- src/analyzer/index/IndexDeserializer.v | 36 ++--- src/analyzer/index/IndexingRoot.v | 16 +-- src/analyzer/index/StubTree.v | 4 +- src/analyzer/parser/parser.v | 2 +- src/analyzer/psi/PsiElement.v | 6 +- src/analyzer/psi/PsiElementImpl.v | 16 +-- src/analyzer/psi/PsiFile.v | 16 +-- src/analyzer/psi/PsiTreeWalker.v | 2 +- src/analyzer/psi/ReferenceImpl.v | 18 +-- src/analyzer/psi/StubBase.v | 20 +-- src/analyzer/psi/StubIndex.v | 12 +- src/analyzer/psi/StubbedElementTypeImpl.v | 10 +- src/analyzer/psi/element_factory.v | 2 +- src/analyzer/psi/search/ReferencesSearch.v | 2 +- src/analyzer/psi/types/AliasType.v | 4 +- src/analyzer/psi/types/EnumType.v | 2 +- src/analyzer/psi/types/FixedArrayType.v | 2 +- src/analyzer/psi/types/FunctionType.v | 6 +- .../psi/types/GenericInstantiationType.v | 2 +- src/analyzer/psi/types/InterfaceType.v | 2 +- src/analyzer/psi/types/MapType.v | 4 +- src/analyzer/psi/types/OptionType.v | 2 +- src/analyzer/psi/types/ResultType.v | 2 +- src/analyzer/psi/types/StructType.v | 2 +- src/bytes/serialization_test.v | 34 ++--- src/jsonrpc/jsonrpc.v | 4 +- src/jsonrpc/server.v | 8 +- src/jsonrpc/server_test.v | 6 +- .../server_test_utils/server_test_utils.v | 8 +- src/loglib/Entry.v | 16 +-- src/loglib/Logger.v | 2 +- src/lsp/capabilities.v | 42 +++--- src/lsp/completion.v | 2 +- src/lsp/diagnostics.v | 2 +- src/lsp/document_link.v | 2 +- src/lsp/document_symbol.v | 4 +- src/lsp/file_resource.v | 4 +- src/lsp/hover.v | 4 +- src/lsp/initialize.v | 14 +- src/lsp/log/log.v | 4 +- src/lsp/rename.v | 2 +- src/lsp/text_document.v | 2 +- src/main.v | 58 ++++---- src/metadata/stubs/attributes/Attribute.v | 6 +- src/server/ResponseWriter.v | 2 +- src/server/code_lens/CodeLensVisitor.v | 38 ++--- .../providers/AssertCompletionProvider.v | 12 +- .../providers/AttributesCompletionProvider.v | 10 +- .../CompileTimeConstantCompletionProvider.v | 6 +- .../FunctionLikeCompletionProvider.v | 6 +- .../providers/ImportsCompletionProvider.v | 4 +- .../providers/InitsCompletionProvider.v | 24 ++-- .../JsonAttributeCompletionProvider.v | 6 +- .../providers/KeywordsCompletionProvider.v | 4 +- .../LoopKeywordsCompletionProvider.v | 8 +- .../providers/ModuleNameCompletionProvider.v | 10 +- .../providers/ModulesImportProvider.v | 10 +- .../providers/NilKeywordCompletionProvider.v | 4 +- .../OrBlockExpressionCompletionProvider.v | 10 +- .../PureBlockExpressionCompletionProvider.v | 8 +- .../PureBlockStatementCompletionProvider.v | 8 +- .../providers/ReferenceCompletionProcessor.v | 132 +++++++++--------- .../providers/ReferenceCompletionProvider.v | 4 +- .../providers/ReturnCompletionProvider.v | 8 +- .../providers/TopLevelCompletionProvider.v | 20 +-- src/server/diagnostics.v | 8 +- src/server/features_code_actions.v | 16 +-- src/server/features_completion.v | 12 +- src/server/features_definition.v | 8 +- src/server/features_did_change.v | 4 +- src/server/features_did_open.v | 4 +- src/server/features_document_highlight.v | 2 +- src/server/features_document_symbol.v | 10 +- src/server/features_folding_range.v | 8 +- src/server/features_formatting.v | 2 +- src/server/features_hover.v | 4 +- src/server/features_prepare_rename.v | 2 +- src/server/features_semantic_tokens.v | 4 +- src/server/features_signature_help.v | 4 +- src/server/features_workspace_symbol.v | 6 +- src/server/file_diff/Diff.v | 12 +- src/server/general.v | 40 +++--- src/server/hints/InlayHintsVisitor.v | 28 ++-- src/server/inspections/compiler/utils.v | 10 +- src/server/intentions/Intention.v | 2 +- src/server/language_server.v | 6 +- src/server/progress/progress.v | 18 +-- src/server/protocol/Client.v | 6 +- .../semantic/DumbAwareSemanticVisitor.v | 4 +- .../semantic/ResolvingSemanticVisitor.v | 4 +- src/server/semantic/SemanticToken.v | 8 +- src/server/tform/tform.v | 12 +- src/streams/streams.v | 16 +-- src/testing/TestFixture.v | 44 +++--- src/testing/Tester.v | 16 +-- src/testing/client/TestClient.v | 8 +- src/utils.v | 2 +- tree_sitter_v/bindings/bindings.c.v | 16 +-- tree_sitter_v/bindings/bindings.v | 12 +- tree_sitter_v/bindings/generate_types.vsh | 2 +- 102 files changed, 582 insertions(+), 582 deletions(-) diff --git a/build.vsh b/build.vsh index a1e57cb4..e552669f 100644 --- a/build.vsh +++ b/build.vsh @@ -93,11 +93,11 @@ os.setenv('BUILD_DATETIME', build_datetime, true) os.setenv('BUILD_COMMIT', build_commit, true) mut cmd := cli.Command{ - name: 'v-analyzer-builder' - version: metadata.manifest.version + name: 'v-analyzer-builder' + version: metadata.manifest.version description: 'Builds the v-analyzer binary.' - posix_mode: true - execute: fn (_ cli.Command) ! { + posix_mode: true + execute: fn (_ cli.Command) ! { build(.debug, false) } } @@ -107,9 +107,9 @@ mut cmd := cli.Command{ // Thanks to -d use_libbacktrace, the binary will print beautiful stack traces, // which is very useful for debugging. cmd.add_command(cli.Command{ - name: 'debug' + name: 'debug' description: 'Builds the v-analyzer binary in debug mode.' - execute: fn (_ cli.Command) ! { + execute: fn (_ cli.Command) ! { build(.debug, true) } }) @@ -117,9 +117,9 @@ cmd.add_command(cli.Command{ // dev builds the v-analyzer binary in development mode. // In this mode, additional development features are enabled. cmd.add_command(cli.Command{ - name: 'dev' + name: 'dev' description: 'Builds the v-analyzer binary in development mode.' - execute: fn (_ cli.Command) ! { + execute: fn (_ cli.Command) ! { build(.dev, false) } }) @@ -128,9 +128,9 @@ cmd.add_command(cli.Command{ // This is the recommended mode for production use. // It is about 30-40% faster than debug mode. cmd.add_command(cli.Command{ - name: 'release' + name: 'release' description: 'Builds the v-analyzer binary in release mode.' - execute: fn (_ cli.Command) ! { + execute: fn (_ cli.Command) ! { build(.release, false) } }) diff --git a/install.vsh b/install.vsh index b28a1311..a8b8bf63 100644 --- a/install.vsh +++ b/install.vsh @@ -447,7 +447,7 @@ fn run_command(cmd string) !int { } mut command := os.Command{ - path: cmd + path: cmd redirect_stdout: true } @@ -481,47 +481,47 @@ pub fn get_release_type(cmd cli.Command) string { } mut cmd := cli.Command{ - name: 'v-analyzer-installer-updated' - version: installer_version + name: 'v-analyzer-installer-updated' + version: installer_version description: 'Install and update v-analyzer' - posix_mode: true - execute: fn (cmd cli.Command) ! { + posix_mode: true + execute: fn (cmd cli.Command) ! { no_interaction := cmd.flags.get_bool('no-interaction') or { os.getenv('GITHUB_JOB') != '' } release_type := get_release_type(cmd) install(no_interaction, release_type)! } flags: [ cli.Flag{ - flag: .bool - name: 'no-interaction' // Used primarily for VS Code extension, to install v-analyzer from sources + flag: .bool + name: 'no-interaction' // Used primarily for VS Code extension, to install v-analyzer from sources description: 'Do not ask any questions, use default values' }, ] } cmd.add_command(cli.Command{ - name: 'up' + name: 'up' description: 'Update v-analyzer to the latest version' - posix_mode: true - execute: fn (cmd cli.Command) ! { + posix_mode: true + execute: fn (cmd cli.Command) ! { nightly := cmd.flags.get_bool('nightly') or { false } release_type := get_release_type(cmd) update(nightly, release_type)! } flags: [ cli.Flag{ - flag: .bool - name: 'nightly' + flag: .bool + name: 'nightly' description: 'Install the latest nightly build' }, ] }) cmd.add_command(cli.Command{ - name: 'check-availability' + name: 'check-availability' description: 'Check if v-analyzer binary is available for the current platform (service command for editors)' - posix_mode: true - execute: fn (cmd cli.Command) ! { + posix_mode: true + execute: fn (cmd cli.Command) ! { release_type := get_release_type(cmd) find_latest_asset(release_type) or { println('Prebuild v-analyzer binary is not available for your platform') @@ -533,10 +533,10 @@ cmd.add_command(cli.Command{ }) cmd.add_command(cli.Command{ - name: 'check-updates' + name: 'check-updates' description: 'Checks for v-analyzer updates.' - posix_mode: true - execute: fn (cmd cli.Command) ! { + posix_mode: true + execute: fn (cmd cli.Command) ! { release_type := get_release_type(cmd) check_updates(release_type)! } diff --git a/src/analyzer/index/IndexDeserializer.v b/src/analyzer/index/IndexDeserializer.v index 8f930f57..ae14506d 100644 --- a/src/analyzer/index/IndexDeserializer.v +++ b/src/analyzer/index/IndexDeserializer.v @@ -27,9 +27,9 @@ pub fn (mut d IndexDeserializer) deserialize_index(expected_version string) !Ind file_indexes := d.deserialize_file_indexes() return Index{ - version: version + version: version updated_at: time.unix(updated_at_unix) - per_file: PerFileIndex{ + per_file: PerFileIndex{ data: file_indexes } } @@ -53,10 +53,10 @@ pub fn (mut d IndexDeserializer) deserialize_file_index() FileIndex { stub_index_sink := d.deserialize_stub_index_sink(stub_list, kind) return FileIndex{ - kind: kind + kind: kind file_last_modified: file_last_modified - stub_list: stub_list - sink: stub_index_sink + stub_list: stub_list + sink: stub_index_sink } } @@ -64,7 +64,7 @@ pub fn (mut d IndexDeserializer) deserialize_stub_index_sink(stub_list &psi.Stub len := d.d.read_int() mut sink := &psi.StubIndexSink{ stub_list: stub_list - kind: unsafe { psi.StubIndexLocationKind(u8(kind)) } + kind: unsafe { psi.StubIndexLocationKind(u8(kind)) } } for _ in 0 .. len { key := d.d.read_int() @@ -156,26 +156,26 @@ pub fn (mut d IndexDeserializer) deserialize_stub() &psi.StubBase { id := d.d.read_int() return &psi.StubBase{ - text: text - comment: comment - receiver: receiver - additional: additional - name: name + text: text + comment: comment + receiver: receiver + additional: additional + name: name identifier_text_range: psi.TextRange{ - line: identifier_line - column: identifier_column - end_line: identifier_end_line + line: identifier_line + column: identifier_column + end_line: identifier_end_line end_column: identifier_end_column } text_range: psi.TextRange{ - line: line - column: column - end_line: end_line + line: line + column: column + end_line: end_line end_column: end_column } parent_id: parent_id stub_list: unsafe { nil } // will be set later stub_type: stub_type - id: id + id: id } } diff --git a/src/analyzer/index/IndexingRoot.v b/src/analyzer/index/IndexingRoot.v index 3b487e06..d295d96c 100644 --- a/src/analyzer/index/IndexingRoot.v +++ b/src/analyzer/index/IndexingRoot.v @@ -13,7 +13,7 @@ import analyzer.parser // BuiltIndexStatus describes the status of the built index. pub enum BuiltIndexStatus { - from_cache // index was loaded from cache + from_cache // index was loaded from cache from_scratch // index was built from scratch } @@ -41,7 +41,7 @@ pub fn (k IndexingRootKind) readable_name() string { @[noinit] pub struct IndexingRoot { pub: - root string // root that is indexed + root string // root that is indexed kind IndexingRootKind // type of root that is indexed pub mut: cache_dir string // path to the directory where the index is stored @@ -56,9 +56,9 @@ pub mut: pub fn new_indexing_root(root string, kind IndexingRootKind, cache_dir string) &IndexingRoot { cache_file := 'v_analyzer_index_${md5.hexhash(root)}' return &IndexingRoot{ - root: root - kind: kind - cache_dir: cache_dir + root: root + kind: kind + cache_dir: cache_dir cache_file: cache_file } } @@ -185,10 +185,10 @@ pub fn (mut i IndexingRoot) index_file(path string, content string) !FileIndex { module_fqn := psi.module_qualified_name(psi_file, i.root) mut cache := FileIndex{ - kind: i.kind + kind: i.kind file_last_modified: last_modified - sink: &psi.StubIndexSink{ - kind: unsafe { psi.StubIndexLocationKind(u8(i.kind)) } + sink: &psi.StubIndexSink{ + kind: unsafe { psi.StubIndexLocationKind(u8(i.kind)) } stub_list: unsafe { nil } } stub_list: unsafe { nil } diff --git a/src/analyzer/index/StubTree.v b/src/analyzer/index/StubTree.v index 6c22d18b..e2960cda 100644 --- a/src/analyzer/index/StubTree.v +++ b/src/analyzer/index/StubTree.v @@ -98,7 +98,7 @@ pub fn build_stub_tree_iterative(file &psi.PsiFile, mut nodes []NodeInfo) &StubT nodes = nodes[..0].clone() nodes << NodeInfo{ - node: root + node: root parent: stub_root } @@ -122,7 +122,7 @@ pub fn build_stub_tree_iterative(file &psi.PsiFile, mut nodes []NodeInfo) &StubT for child in node.node.children() { nodes << NodeInfo{ - node: child + node: child parent: parent_stub } } diff --git a/src/analyzer/parser/parser.v b/src/analyzer/parser/parser.v index 9fd0c400..93fe62e3 100644 --- a/src/analyzer/parser/parser.v +++ b/src/analyzer/parser/parser.v @@ -100,7 +100,7 @@ pub fn parse_code_with_tree(code string, old_tree &bindings.Tree[bindings.NodeTy raw_tree := if isnil(old_tree) { unsafe { nil } } else { old_tree.raw_tree } tree := parser.parse_string(source: code, tree: raw_tree) return ParseResult{ - tree: tree + tree: tree source_text: code } } diff --git a/src/analyzer/psi/PsiElement.v b/src/analyzer/psi/PsiElement.v index fa21d6c9..7a8f7924 100644 --- a/src/analyzer/psi/PsiElement.v +++ b/src/analyzer/psi/PsiElement.v @@ -7,14 +7,14 @@ pub type ID = int pub type AstNode = bindings.Node[bindings.NodeType] pub interface PsiElement { - node AstNode // base node from Tree Sitter + node AstNode // base node from Tree Sitter containing_file &PsiFile // file where the element is located stub_id StubId get_stub() ?&StubBase stub_list() &StubList element_type() bindings.NodeType - node() AstNode // return base node from Tree Sitter - containing_file() &PsiFile // return file where the element is located + node() AstNode // return base node from Tree Sitter + containing_file() &PsiFile // return file where the element is located is_equal(other PsiElement) bool // return true if the element is equal to the other element // find_element_at returns the leaf node at the specified position relative to the start of the node. // If the node is not found, none is returned. diff --git a/src/analyzer/psi/PsiElementImpl.v b/src/analyzer/psi/PsiElementImpl.v index 6c1b30a4..03e9245b 100644 --- a/src/analyzer/psi/PsiElementImpl.v +++ b/src/analyzer/psi/PsiElementImpl.v @@ -13,18 +13,18 @@ pub: pub fn new_psi_node(containing_file &PsiFile, node AstNode) PsiElementImpl { return PsiElementImpl{ - node: node + node: node containing_file: containing_file - stubs_list: unsafe { nil } + stubs_list: unsafe { nil } } } fn new_psi_node_from_stub(id StubId, stubs_list &StubList) PsiElementImpl { return PsiElementImpl{ - node: AstNode{} + node: AstNode{} containing_file: new_stub_psi_file(stubs_list.path, stubs_list) - stub_id: id - stubs_list: stubs_list + stub_id: id + stubs_list: stubs_list } } @@ -422,9 +422,9 @@ pub fn (n &PsiElementImpl) text_range() TextRange { } return TextRange{ - line: int(n.node.start_point().row) - column: int(n.node.start_point().column) - end_line: int(n.node.end_point().row) + line: int(n.node.start_point().row) + column: int(n.node.start_point().column) + end_line: int(n.node.end_point().row) end_column: int(n.node.end_point().column) } } diff --git a/src/analyzer/psi/PsiFile.v b/src/analyzer/psi/PsiFile.v index 992aff70..d1274014 100644 --- a/src/analyzer/psi/PsiFile.v +++ b/src/analyzer/psi/PsiFile.v @@ -20,11 +20,11 @@ pub mut: pub fn new_psi_file(path string, tree &bindings.Tree[bindings.NodeType], source_text string) &PsiFile { mut file := &PsiFile{ - path: path - tree: unsafe { tree } + path: path + tree: unsafe { tree } source_text: source_text - stub_list: unsafe { nil } - root: unsafe { nil } + stub_list: unsafe { nil } + root: unsafe { nil } } file.root = create_element(AstNode(tree.root_node()), file) return file @@ -32,11 +32,11 @@ pub fn new_psi_file(path string, tree &bindings.Tree[bindings.NodeType], source_ pub fn new_stub_psi_file(path string, stub_list &StubList) &PsiFile { return &PsiFile{ - path: path - tree: unsafe { nil } + path: path + tree: unsafe { nil } source_text: '' - stub_list: stub_list - root: unsafe { nil } + stub_list: stub_list + root: unsafe { nil } } } diff --git a/src/analyzer/psi/PsiTreeWalker.v b/src/analyzer/psi/PsiTreeWalker.v index 7f162c4c..0d23d4a3 100644 --- a/src/analyzer/psi/PsiTreeWalker.v +++ b/src/analyzer/psi/PsiTreeWalker.v @@ -13,7 +13,7 @@ pub fn (mut tw PsiTreeWalker) next() ?PsiElement { pub fn new_psi_tree_walker(root_node PsiElement) PsiTreeWalker { return PsiTreeWalker{ - tree_walker: new_tree_walker(root_node.node) + tree_walker: new_tree_walker(root_node.node) containing_file: root_node.containing_file } } diff --git a/src/analyzer/psi/ReferenceImpl.v b/src/analyzer/psi/ReferenceImpl.v index 9a9c84ef..549676bd 100644 --- a/src/analyzer/psi/ReferenceImpl.v +++ b/src/analyzer/psi/ReferenceImpl.v @@ -12,16 +12,16 @@ pub struct ReferenceImpl { pub fn new_reference(file &PsiFile, element ReferenceExpressionBase, for_types bool) &ReferenceImpl { return &ReferenceImpl{ - element: element - file: file + element: element + file: file for_types: for_types } } pub fn new_attribute_reference(file &PsiFile, element ReferenceExpressionBase) &ReferenceImpl { return &ReferenceImpl{ - element: element - file: file + element: element + file: file for_attributes: true } } @@ -33,14 +33,14 @@ fn (r &ReferenceImpl) element() PsiElement { pub fn (r &ReferenceImpl) resolve() ?PsiElement { sub := SubResolver{ containing_file: r.file - element: r.element - for_types: r.for_types - for_attributes: r.for_attributes + element: r.element + for_types: r.for_types + for_attributes: r.for_attributes } mut processor := ResolveProcessor{ containing_file: r.file - ref: r.element - ref_name: r.element.name() + ref: r.element + ref_name: r.element.name() } if from_cache := resolve_cache.get(r.element()) { diff --git a/src/analyzer/psi/StubBase.v b/src/analyzer/psi/StubBase.v index e4c68078..9d950064 100644 --- a/src/analyzer/psi/StubBase.v +++ b/src/analyzer/psi/StubBase.v @@ -38,16 +38,16 @@ pub fn new_stub_base(parent &StubElement, stub_type StubType, name string, ident } parent_id := if !isnil(parent) { parent.id() } else { psi.non_stubbed_element } mut stub := &StubBase{ - name: name - text: data.text - comment: data.comment - receiver: data.receiver - additional: data.additional + name: name + text: data.text + comment: data.comment + receiver: data.receiver + additional: data.additional identifier_text_range: identifier_text_range - text_range: text_range - stub_list: stub_list - parent_id: parent_id - stub_type: stub_type + text_range: text_range + stub_list: stub_list + parent_id: parent_id + stub_type: stub_type } stub_list.add_stub(mut stub, parent) return stub @@ -58,7 +58,7 @@ pub fn new_root_stub(path string) &StubBase { path: path } mut stub := &StubBase{ - name: '' + name: '' stub_list: stub_list parent_id: -1 stub_type: .root diff --git a/src/analyzer/psi/StubIndex.v b/src/analyzer/psi/StubIndex.v index 03cf6c79..9fe4c041 100644 --- a/src/analyzer/psi/StubIndex.v +++ b/src/analyzer/psi/StubIndex.v @@ -31,19 +31,19 @@ pub mut: file_to_module map[string]string // data defines the index data that allows you to get the description of the element // in 2 accesses to the array elements and one lookup by key. - data [count_stub_index_location_keys][count_index_keys]map[string]StubResult + data [psi.count_stub_index_location_keys][psi.count_index_keys]map[string]StubResult // all_elements_by_modules contains all top-level elements in the module. - all_elements_by_modules [count_stub_index_location_keys]map[string][]PsiElement + all_elements_by_modules [psi.count_stub_index_location_keys]map[string][]PsiElement // types_by_modules contains all top-level types in the module. - types_by_modules [count_stub_index_location_keys]map[string][]PsiElement + types_by_modules [psi.count_stub_index_location_keys]map[string][]PsiElement } pub fn new_stubs_index(sinks []StubIndexSink) &StubIndex { mut index := &StubIndex{ - sinks: sinks - module_to_files: map[string][]StubIndexSink{} + sinks: sinks + module_to_files: map[string][]StubIndexSink{} all_elements_by_modules: unsafe { [psi.count_stub_index_location_keys]map[string][]PsiElement{} } - types_by_modules: unsafe { [psi.count_stub_index_location_keys]map[string][]PsiElement{} } + types_by_modules: unsafe { [psi.count_stub_index_location_keys]map[string][]PsiElement{} } } for i in 0 .. psi.count_stub_index_location_keys { diff --git a/src/analyzer/psi/StubbedElementTypeImpl.v b/src/analyzer/psi/StubbedElementTypeImpl.v index c49f8e91..1fea9966 100644 --- a/src/analyzer/psi/StubbedElementTypeImpl.v +++ b/src/analyzer/psi/StubbedElementTypeImpl.v @@ -428,8 +428,8 @@ pub fn (s &StubbedElementType) create_stub(psi PsiElement, parent_stub &StubBase return new_stub_base(parent_stub, stub_type, psi.name(), identifier_text_range, text_range, - comment: comment - receiver: receiver_type + comment: comment + receiver: receiver_type additional: fingerprint ) } @@ -448,7 +448,7 @@ pub fn (s &StubbedElementType) create_stub(psi PsiElement, parent_stub &StubBase return new_stub_base(parent_stub, .static_method_declaration, psi.name(), identifier_text_range, text_range, - comment: comment + comment: comment receiver: receiver_type ) } @@ -610,8 +610,8 @@ pub fn declaration_stub(psi PsiNamedElement, parent_stub &StubElement, stub_type text_range := (psi as PsiElement).text_range() identifier_text_range := psi.identifier_text_range() return new_stub_base(parent_stub, stub_type, psi.name(), identifier_text_range, text_range, - comment: if psi is PsiDocCommentOwner { psi.doc_comment() } else { '' } - text: if params.include_text { (psi as PsiElement).get_text() } else { '' } + comment: if psi is PsiDocCommentOwner { psi.doc_comment() } else { '' } + text: if params.include_text { (psi as PsiElement).get_text() } else { '' } additional: params.additional ) } diff --git a/src/analyzer/psi/element_factory.v b/src/analyzer/psi/element_factory.v index 7e9f3c5f..4031f187 100644 --- a/src/analyzer/psi/element_factory.v +++ b/src/analyzer/psi/element_factory.v @@ -269,7 +269,7 @@ pub fn create_element(node AstNode, containing_file &PsiFile) PsiElement { if node.type_name == .fixed_array_creation { return ArrayCreation{ PsiElementImpl: base_node - is_fixed: true + is_fixed: true } } diff --git a/src/analyzer/psi/search/ReferencesSearch.v b/src/analyzer/psi/search/ReferencesSearch.v index 1a7e3ac5..6cc913ac 100644 --- a/src/analyzer/psi/search/ReferencesSearch.v +++ b/src/analyzer/psi/search/ReferencesSearch.v @@ -29,7 +29,7 @@ pub: pub fn references(element psi.PsiElement, params SearchParams) []psi.PsiElement { containing_file := element.containing_file return ReferencesSearch{ - params: params + params: params containing_file: containing_file }.search(element) } diff --git a/src/analyzer/psi/types/AliasType.v b/src/analyzer/psi/types/AliasType.v index 736f2d1d..49bbbe5e 100644 --- a/src/analyzer/psi/types/AliasType.v +++ b/src/analyzer/psi/types/AliasType.v @@ -8,9 +8,9 @@ pub: pub fn new_alias_type(name string, module_name string, inner Type) &AliasType { return &AliasType{ - name: name + name: name module_name: module_name - inner: inner + inner: inner } } diff --git a/src/analyzer/psi/types/EnumType.v b/src/analyzer/psi/types/EnumType.v index f02b7369..f004a18d 100644 --- a/src/analyzer/psi/types/EnumType.v +++ b/src/analyzer/psi/types/EnumType.v @@ -6,7 +6,7 @@ pub struct EnumType { pub fn new_enum_type(name string, module_name string) &EnumType { return &EnumType{ - name: name + name: name module_name: module_name } } diff --git a/src/analyzer/psi/types/FixedArrayType.v b/src/analyzer/psi/types/FixedArrayType.v index 04228164..f01a8659 100644 --- a/src/analyzer/psi/types/FixedArrayType.v +++ b/src/analyzer/psi/types/FixedArrayType.v @@ -9,7 +9,7 @@ pub: pub fn new_fixed_array_type(inner Type, size int) &FixedArrayType { return &FixedArrayType{ inner: inner - size: size + size: size } } diff --git a/src/analyzer/psi/types/FunctionType.v b/src/analyzer/psi/types/FunctionType.v index a3e6eebf..1b534313 100644 --- a/src/analyzer/psi/types/FunctionType.v +++ b/src/analyzer/psi/types/FunctionType.v @@ -12,9 +12,9 @@ pub: pub fn new_function_type(module_name string, params []Type, result Type, no_result bool) &FunctionType { return &FunctionType{ - params: params - result: result - no_result: no_result + params: params + result: result + no_result: no_result module_name: module_name } } diff --git a/src/analyzer/psi/types/GenericInstantiationType.v b/src/analyzer/psi/types/GenericInstantiationType.v index e77e1ec7..2e9e0ee9 100644 --- a/src/analyzer/psi/types/GenericInstantiationType.v +++ b/src/analyzer/psi/types/GenericInstantiationType.v @@ -8,7 +8,7 @@ pub: pub fn new_generic_instantiation_type(inner Type, specialization []Type) &GenericInstantiationType { return &GenericInstantiationType{ - inner: inner + inner: inner specialization: specialization } } diff --git a/src/analyzer/psi/types/InterfaceType.v b/src/analyzer/psi/types/InterfaceType.v index 0ac20015..63f21343 100644 --- a/src/analyzer/psi/types/InterfaceType.v +++ b/src/analyzer/psi/types/InterfaceType.v @@ -6,7 +6,7 @@ pub struct InterfaceType { pub fn new_interface_type(name string, module_name string) &InterfaceType { return &InterfaceType{ - name: name + name: name module_name: module_name } } diff --git a/src/analyzer/psi/types/MapType.v b/src/analyzer/psi/types/MapType.v index 05a50d41..bdc3c5b6 100644 --- a/src/analyzer/psi/types/MapType.v +++ b/src/analyzer/psi/types/MapType.v @@ -9,8 +9,8 @@ pub: pub fn new_map_type(module_name string, key Type, value Type) &MapType { return &MapType{ - key: key - value: value + key: key + value: value module_name: module_name } } diff --git a/src/analyzer/psi/types/OptionType.v b/src/analyzer/psi/types/OptionType.v index ac827ddd..d7586974 100644 --- a/src/analyzer/psi/types/OptionType.v +++ b/src/analyzer/psi/types/OptionType.v @@ -8,7 +8,7 @@ pub: pub fn new_option_type(inner Type, no_inner bool) &OptionType { return &OptionType{ - inner: inner + inner: inner no_inner: no_inner } } diff --git a/src/analyzer/psi/types/ResultType.v b/src/analyzer/psi/types/ResultType.v index 9d033744..0bd9009f 100644 --- a/src/analyzer/psi/types/ResultType.v +++ b/src/analyzer/psi/types/ResultType.v @@ -8,7 +8,7 @@ pub: pub fn new_result_type(inner Type, no_inner bool) &ResultType { return &ResultType{ - inner: inner + inner: inner no_inner: no_inner } } diff --git a/src/analyzer/psi/types/StructType.v b/src/analyzer/psi/types/StructType.v index c9e5adb1..029eb08c 100644 --- a/src/analyzer/psi/types/StructType.v +++ b/src/analyzer/psi/types/StructType.v @@ -14,7 +14,7 @@ pub struct StructType { pub fn new_struct_type(name string, module_name string) &StructType { return &StructType{ - name: name + name: name module_name: module_name } } diff --git a/src/bytes/serialization_test.v b/src/bytes/serialization_test.v index 92c57097..8d335063 100644 --- a/src/bytes/serialization_test.v +++ b/src/bytes/serialization_test.v @@ -27,18 +27,18 @@ fn test_serialize_deserialize_several_strings() { fn test_serialize_deserialize_stub_element() { mut s := Serializer{} data := StubBase{ - name: 'test' + name: 'test' text_range: TextRange{ - line: 1 - column: 2 - end_line: 3 + line: 1 + column: 2 + end_line: 3 end_column: 4 } stub_type: .function_declaration - id: 123456 - text: 'some text with spaces' - comment: '// comment data' - receiver: 'Foo' + id: 123456 + text: 'some text with spaces' + comment: '// comment data' + receiver: 'Foo' } serialize_stub_element(mut s, data) @@ -78,9 +78,9 @@ fn serialize_stub_element(mut s Serializer, stub StubBase) { fn deserialize_stub_element(mut s Deserializer) StubBase { name := s.read_string() text_range := TextRange{ - line: s.read_int() - column: s.read_int() - end_line: s.read_int() + line: s.read_int() + column: s.read_int() + end_line: s.read_int() end_column: s.read_int() } stub_type := unsafe { StubType(s.read_u8()) } @@ -90,13 +90,13 @@ fn deserialize_stub_element(mut s Deserializer) StubBase { receiver := s.read_string() return StubBase{ - name: name + name: name text_range: text_range - stub_type: stub_type - id: id - text: text - comment: comment - receiver: receiver + stub_type: stub_type + id: id + text: text + comment: comment + receiver: receiver } } diff --git a/src/jsonrpc/jsonrpc.v b/src/jsonrpc/jsonrpc.v index 81f0987f..ddf83188 100644 --- a/src/jsonrpc/jsonrpc.v +++ b/src/jsonrpc/jsonrpc.v @@ -201,8 +201,8 @@ pub: @[inline] pub fn response_error(params ResponseErrorGeneratorParams) ResponseError { return ResponseError{ - code: params.error.code() + code: params.error.code() message: params.error.msg() - data: params.data + data: params.data } } diff --git a/src/jsonrpc/server.v b/src/jsonrpc/server.v index e2ed5340..8891de66 100644 --- a/src/jsonrpc/server.v +++ b/src/jsonrpc/server.v @@ -93,7 +93,7 @@ fn (mut s Server) internal_respond(mut base_rw ResponseWriter) ! { mut rw := ResponseWriter{ server: s writer: base_rw.writer - sb: base_rw.sb + sb: base_rw.sb req_id: req.id } @@ -134,7 +134,7 @@ pub fn (s &Server) writer(cfg NewWriterConfig) &ResponseWriter { // passthrough between processes and does not need a // "repackaging" of the outgoing data Writer{ - clen_sb: if cfg.own_buffer { s.conlen_buf.clone() } else { s.conlen_buf } + clen_sb: if cfg.own_buffer { s.conlen_buf.clone() } else { s.conlen_buf } read_writer: s.stream }, ] @@ -197,7 +197,7 @@ pub fn (mut rw ResponseWriter) write[T](payload T) { } final_resp := Response[T]{ - id: rw.req_id + id: rw.req_id result: payload } encode_response[T](final_resp, mut rw.sb) @@ -246,7 +246,7 @@ pub fn (mut rw ResponseWriter) write_error(err &ResponseError) { } final_resp := Response[string]{ - id: rw.req_id + id: rw.req_id error: err } encode_response[string](final_resp, mut rw.sb) diff --git a/src/jsonrpc/server_test.v b/src/jsonrpc/server_test.v index 03b0b3a9..bcb33572 100644 --- a/src/jsonrpc/server_test.v +++ b/src/jsonrpc/server_test.v @@ -46,7 +46,7 @@ fn test_server() { mut stream := &TestStream{} mut server := &jsonrpc.Server{ handler: &TestHandler{} - stream: stream + stream: stream } mut client := TestClient{ @@ -98,9 +98,9 @@ fn test_interceptor() { mut stream := &TestStream{} mut server := &jsonrpc.Server{ - handler: &TestHandler{} + handler: &TestHandler{} interceptors: [test_inter] - stream: stream + stream: stream } mut client := TestClient{ diff --git a/src/jsonrpc/server_test_utils/server_test_utils.v b/src/jsonrpc/server_test_utils/server_test_utils.v index 3367abf6..31d0e4ff 100644 --- a/src/jsonrpc/server_test_utils/server_test_utils.v +++ b/src/jsonrpc/server_test_utils/server_test_utils.v @@ -13,9 +13,9 @@ import datatypes pub fn new_test_client(handler jsonrpc.Handler, interceptors ...jsonrpc.Interceptor) &TestClient { mut stream := &TestStream{} mut server := &jsonrpc.Server{ - handler: handler + handler: handler interceptors: interceptors - stream: stream + stream: stream } return &TestClient{ @@ -46,7 +46,7 @@ pub mut: pub fn (mut tc TestClient) send[T, U](method string, params T) !U { params_json := json.encode(params) req := jsonrpc.Request{ - id: '${tc.id}' + id: '${tc.id}' method: method params: params_json } @@ -67,7 +67,7 @@ pub fn (mut tc TestClient) send[T, U](method string, params T) !U { pub fn (mut tc TestClient) notify[T](method string, params T) ! { params_json := json.encode(params) req := jsonrpc.Request{ - id: '' + id: '' method: method params: params_json } diff --git a/src/loglib/Entry.v b/src/loglib/Entry.v index 7d718929..7e928194 100644 --- a/src/loglib/Entry.v +++ b/src/loglib/Entry.v @@ -22,10 +22,10 @@ pub fn new_entry(logger &Logger) &Entry { pub fn (entry &Entry) clone() &Entry { return &Entry{ - logger: entry.logger - fields: entry.fields.clone() - time: entry.time - level: entry.level + logger: entry.logger + fields: entry.fields.clone() + time: entry.time + level: entry.level message: entry.message } } @@ -37,10 +37,10 @@ pub fn (entry &Entry) with_fields(fields Fields) &Entry { } return &Entry{ - logger: entry.logger - fields: own_fields - time: entry.time - level: entry.level + logger: entry.logger + fields: own_fields + time: entry.time + level: entry.level message: entry.message } } diff --git a/src/loglib/Logger.v b/src/loglib/Logger.v index fc1ae330..bc040f6b 100644 --- a/src/loglib/Logger.v +++ b/src/loglib/Logger.v @@ -8,7 +8,7 @@ import time __global logger = Logger{ formatter: TextFormatter{} - out: os.stderr() + out: os.stderr() } pub const support_colors = term.can_show_color_on_stderr() && term.can_show_color_on_stdout() diff --git a/src/lsp/capabilities.v b/src/lsp/capabilities.v index 10065da6..f26f26fb 100644 --- a/src/lsp/capabilities.v +++ b/src/lsp/capabilities.v @@ -2,13 +2,13 @@ module lsp pub struct WorkspaceClientCapabilities { pub mut: - apply_edit bool @[json: applyEdit] - workspace_edit WorkspaceEdit @[json: workspaceEdit] - did_change_configuration DidChange @[json: didChangeConfiguration] - did_change_watched_files DidChange @[json: didChangeWatchedFiles] + apply_edit bool @[json: applyEdit] + workspace_edit WorkspaceEdit @[json: workspaceEdit] + did_change_configuration DidChange @[json: didChangeConfiguration] + did_change_watched_files DidChange @[json: didChangeWatchedFiles] symbol WorkspaceSymbolCapabilities - execute_command DidChange @[json: executeCommand] - workspace_folders bool @[json: workspaceFolders] + execute_command DidChange @[json: executeCommand] + workspace_folders bool @[json: workspaceFolders] configuration bool } @@ -30,15 +30,15 @@ pub mut: pub struct TextDocumentClientCapabilities { pub mut: - code_lens Capability @[json: codeLens] - color_provider Capability @[json: colorProvider] + code_lens Capability @[json: codeLens] + color_provider Capability @[json: colorProvider] completion CompletionCapability declaration LinkCapability definition LinkCapability - document_highlight Capability @[json: documentHighlight] - document_link Capability @[json: documentLink] - document_symbol DocumentSymbolCapability @[json: documentSymbol] - folding_range FoldingRangeCapabilities @[json: foldingRange] + document_highlight Capability @[json: documentHighlight] + document_link Capability @[json: documentLink] + document_symbol DocumentSymbolCapability @[json: documentSymbol] + folding_range FoldingRangeCapabilities @[json: foldingRange] formatting Capability hover HoverCapability implementation LinkCapability @@ -47,10 +47,10 @@ pub mut: range_formatting Capability @[json: rangeFormatting] references Capability rename RenameCapability - selection_range Capability @[json: selectionRange] + selection_range Capability @[json: selectionRange] signature_help SignatureHelpCapability synchronization TextDocumentSyncCapability - type_definition LinkCapability @[json: typeDefinition] + type_definition LinkCapability @[json: typeDefinition] } pub struct DocumentLinkSupport { @@ -82,7 +82,7 @@ pub mut: pub struct SignatureHelpCapability { pub mut: - dynamic_registration bool @[json: dynamicRegistration] + dynamic_registration bool @[json: dynamicRegistration] signature_information SignatureInformationCapability @[json: signatureInformation] } @@ -151,7 +151,7 @@ pub mut: workspace WorkspaceClientCapabilities @[skip] text_document TextDocumentClientCapabilities @[json: 'textDocument'] window WindowCapability - experimental string @[raw] + experimental string @[raw] } pub struct WindowCapability { @@ -186,11 +186,11 @@ pub mut: document_on_type_formatting_provider DocumentOnTypeFormattingOptions @[json: documentOnTypeFormattingProvider] rename_provider RenameOptions @[json: renameProvider] document_link_provider DocumentLinkOptions @[json: documentLinkProvider] - color_provider bool @[json: colorProvider] - declaration_provider bool @[json: declarationProvider] - execute_command_provider ExecuteCommandOptions @[json: executeCommandProvider] - folding_range_provider bool @[json: foldingRangeProvider] - semantic_tokens_provider SemanticTokensOptions @[json: semanticTokensProvider; omitempty] + color_provider bool @[json: colorProvider] + declaration_provider bool @[json: declarationProvider] + execute_command_provider ExecuteCommandOptions @[json: executeCommandProvider] + folding_range_provider bool @[json: foldingRangeProvider] + semantic_tokens_provider SemanticTokensOptions @[json: semanticTokensProvider; omitempty] experimental map[string]bool } diff --git a/src/lsp/completion.v b/src/lsp/completion.v index fb9441e1..a3134970 100644 --- a/src/lsp/completion.v +++ b/src/lsp/completion.v @@ -40,7 +40,7 @@ pub: pub struct CompletionList { pub: - is_incomplete bool @[json: isIncomplete] + is_incomplete bool @[json: isIncomplete] items []CompletionItem } diff --git a/src/lsp/diagnostics.v b/src/lsp/diagnostics.v index 18225f8f..6ad2b09d 100644 --- a/src/lsp/diagnostics.v +++ b/src/lsp/diagnostics.v @@ -44,7 +44,7 @@ pub mut: @[json_as_number] pub enum DiagnosticSeverity { - error = 1 + error = 1 warning information hint diff --git a/src/lsp/document_link.v b/src/lsp/document_link.v index c1693edd..82c879d0 100644 --- a/src/lsp/document_link.v +++ b/src/lsp/document_link.v @@ -13,7 +13,7 @@ pub struct DocumentLinkParams { pub struct DocumentLink { range Range target DocumentUri - data string @[raw] + data string @[raw] } pub struct DocumentLinkRegistrationOptions { diff --git a/src/lsp/document_symbol.v b/src/lsp/document_symbol.v index 1b2c617b..aeec5aa0 100644 --- a/src/lsp/document_symbol.v +++ b/src/lsp/document_symbol.v @@ -44,9 +44,9 @@ pub mut: // white spaces. name string // More detail for this symbol, e.g the signature of a function. - detail string @[omitempty] + detail string @[omitempty] kind SymbolKind - deprecated bool @[omitempty] + deprecated bool @[omitempty] // The range enclosing this symbol not including leading/trailing whitespace // but everything else like comments. This information is typically used to // determine if the clients cursor is inside the symbol to reveal in the diff --git a/src/lsp/file_resource.v b/src/lsp/file_resource.v index d87a87c7..8653edc0 100644 --- a/src/lsp/file_resource.v +++ b/src/lsp/file_resource.v @@ -18,8 +18,8 @@ pub struct RenameFileOptions { pub struct RenameFile { kind string = 'rename' - old_uri DocumentUri @[json: oldUri] - new_uri DocumentUri @[json: newUri] + old_uri DocumentUri @[json: oldUri] + new_uri DocumentUri @[json: newUri] options RenameFileOptions } diff --git a/src/lsp/hover.v b/src/lsp/hover.v index f7b3fa13..ff3a86b3 100644 --- a/src/lsp/hover.v +++ b/src/lsp/hover.v @@ -31,13 +31,13 @@ pub struct MarkedString { pub fn hover_v_marked_string(text string) HoverResponseContent { return HoverResponseContent(MarkedString{ language: 'v' - value: text + value: text }) } pub fn hover_markdown_string(text string) HoverResponseContent { return HoverResponseContent(MarkupContent{ - kind: markup_kind_markdown + kind: markup_kind_markdown value: text }) } diff --git a/src/lsp/initialize.v b/src/lsp/initialize.v index 18e11e36..a501124e 100644 --- a/src/lsp/initialize.v +++ b/src/lsp/initialize.v @@ -4,14 +4,14 @@ module lsp // response: InitializeResult pub struct InitializeParams { pub mut: - process_id int = -2 @[json: processId] - client_info ClientInfo @[json: clientInfo] - root_uri DocumentUri @[json: rootUri] - root_path DocumentUri @[json: rootPath] - initialization_options string @[json: initializationOptions] + process_id int = -2 @[json: processId] + client_info ClientInfo @[json: clientInfo] + root_uri DocumentUri @[json: rootUri] + root_path DocumentUri @[json: rootPath] + initialization_options string @[json: initializationOptions] capabilities ClientCapabilities trace string - workspace_folders []WorkspaceFolder @[skip] + workspace_folders []WorkspaceFolder @[skip] } pub struct ClientInfo { @@ -29,7 +29,7 @@ pub mut: pub struct InitializeResult { pub: capabilities ServerCapabilities - server_info ServerInfo @[json: 'serverInfo'; omitempty] + server_info ServerInfo @[json: 'serverInfo'; omitempty] } // method: ‘initialized’ diff --git a/src/lsp/log/log.v b/src/lsp/log/log.v index da00d782..f62d69ac 100644 --- a/src/lsp/log/log.v +++ b/src/lsp/log/log.v @@ -62,8 +62,8 @@ pub fn (li LogItem) encode_json(mut wr io.Writer) ! { pub fn new() &LogRecorder { return &LogRecorder{ file_opened: false - enabled: true - buffer: strings.new_builder(4096) + enabled: true + buffer: strings.new_builder(4096) } } diff --git a/src/lsp/rename.v b/src/lsp/rename.v index f7b7317b..8f618bbf 100644 --- a/src/lsp/rename.v +++ b/src/lsp/rename.v @@ -11,7 +11,7 @@ pub struct RenameParams { pub: text_document TextDocumentIdentifier @[json: textDocument] position Position - new_name string @[json: newName] + new_name string @[json: newName] } pub struct RenameRegistrationOptions { diff --git a/src/lsp/text_document.v b/src/lsp/text_document.v index 9a8ea51a..bbe4fb5d 100644 --- a/src/lsp/text_document.v +++ b/src/lsp/text_document.v @@ -35,7 +35,7 @@ pub struct TextDocumentEdit { pub struct TextDocumentItem { pub: uri DocumentUri - language_id string @[json: languageId] + language_id string @[json: languageId] version int text string } diff --git a/src/main.v b/src/main.v index 3303f14d..286176b5 100644 --- a/src/main.v +++ b/src/main.v @@ -45,7 +45,7 @@ fn run(cmd cli.Command) ! { mut ls := server.LanguageServer.new(analyzer.IndexingManager.new()) mut jrpc_server := &jsonrpc.Server{ - stream: stream + stream: stream handler: ls } mut lr := log.LogRecorder{} @@ -84,70 +84,70 @@ fn setup_logger(to_file bool) { fn main() { mut cmd := cli.Command{ - name: metadata.manifest.name - version: metadata.full_version + name: metadata.manifest.name + version: metadata.full_version description: metadata.manifest.description - execute: run - posix_mode: true + execute: run + posix_mode: true } cmd.add_command(cli.Command{ - name: 'init' + name: 'init' description: 'Initialize a configuration file inside the current directory.' - execute: init_cmd + execute: init_cmd }) cmd.add_command(cli.Command{ - name: 'clear-cache' + name: 'clear-cache' description: 'Clears the analyzer cache.' - execute: clear_cache_cmd + execute: clear_cache_cmd }) cmd.add_command(cli.Command{ - name: 'up' + name: 'up' description: 'Updates the analyzer to the latest version.' - execute: up_cmd - posix_mode: true - flags: [ + execute: up_cmd + posix_mode: true + flags: [ cli.Flag{ - flag: .bool - name: 'nightly' + flag: .bool + name: 'nightly' description: 'Install the latest nightly build' }, ] }) cmd.add_command(cli.Command{ - name: 'check-updates' + name: 'check-updates' description: 'Checks for v-analyzer updates.' - execute: check_updates_cmd - posix_mode: true - version: metadata.full_version + execute: check_updates_cmd + posix_mode: true + version: metadata.full_version }) cmd.add_flags([ cli.Flag{ - flag: .bool - name: 'stdio' - description: 'Use stdio for communication.' + flag: .bool + name: 'stdio' + description: 'Use stdio for communication.' default_value: [ 'true', ] }, cli.Flag{ - flag: .bool - name: 'socket' + flag: .bool + name: 'socket' description: 'Use TCP connection for communication.' }, cli.Flag{ - flag: .bool - name: 'log-to-stdout' + flag: .bool + name: 'log-to-stdout' description: 'Use stdout for logs, can be used only with --socket flag (Only for debug purposes).' }, cli.Flag{ - flag: .int - name: 'port' - description: 'Port to use for socket communication. (Default: 5007)' + flag: .int + name: 'port' + description: 'Port to use for socket communication. (Default: 5007)' default_value: [ '${default_tcp_port}', ] diff --git a/src/metadata/stubs/attributes/Attribute.v b/src/metadata/stubs/attributes/Attribute.v index 7ae3766b..20f95144 100644 --- a/src/metadata/stubs/attributes/Attribute.v +++ b/src/metadata/stubs/attributes/Attribute.v @@ -20,8 +20,8 @@ enum Target { // Attribute is base interface that describes the // information and behavior of any attribute. interface Attribute { - name string // name of the attribute - with_arg bool // whether the attribute has an argument - arg_is_optional bool // if with_arg is true, this field is used to indicate whether the argument is optional + name string // name of the attribute + with_arg bool // whether the attribute has an argument + arg_is_optional bool // if with_arg is true, this field is used to indicate whether the argument is optional target []Target // places where the attribute is allowed } diff --git a/src/server/ResponseWriter.v b/src/server/ResponseWriter.v index 7516047f..3d3d1735 100644 --- a/src/server/ResponseWriter.v +++ b/src/server/ResponseWriter.v @@ -16,7 +16,7 @@ fn (mut wr ResponseWriter) wrap_error(err IError) IError { // log_message sends a window/logMessage notification to the client pub fn (mut wr ResponseWriter) log_message(message string, typ lsp.MessageType) { wr.write_notify('window/logMessage', lsp.LogMessageParams{ - @type: typ + @type: typ message: message }) } diff --git a/src/server/code_lens/CodeLensVisitor.v b/src/server/code_lens/CodeLensVisitor.v index 02b14000..d5d660ae 100644 --- a/src/server/code_lens/CodeLensVisitor.v +++ b/src/server/code_lens/CodeLensVisitor.v @@ -21,10 +21,10 @@ mut: pub fn new_visitor(cfg config.CodeLensConfig, uri lsp.DocumentUri, containing_file &psi.PsiFile) CodeLensVisitor { return CodeLensVisitor{ - cfg: cfg - uri: uri + cfg: cfg + uri: uri containing_file: containing_file - is_test_file: containing_file.is_test_file() + is_test_file: containing_file.is_test_file() } } @@ -67,8 +67,8 @@ pub fn (mut v CodeLensVisitor) add_run_test_lens(node psi.AstNode) { } v.add_lens(node, lsp.Command{ - title: '▶ Run test' - command: 'v-analyzer.runTests' + title: '▶ Run test' + command: 'v-analyzer.runTests' arguments: [ v.uri.path(), name, @@ -77,8 +77,8 @@ pub fn (mut v CodeLensVisitor) add_run_test_lens(node psi.AstNode) { if !v.first_test_seen { v.add_lens(node, lsp.Command{ - title: 'all file tests' - command: 'v-analyzer.runTests' + title: 'all file tests' + command: 'v-analyzer.runTests' arguments: [ v.uri.path(), ] @@ -102,15 +102,15 @@ pub fn (mut v CodeLensVisitor) add_run_lens(node psi.AstNode) { } v.add_lens(node, lsp.Command{ - title: '▶ Run workspace' - command: 'v-analyzer.runWorkspace' + title: '▶ Run workspace' + command: 'v-analyzer.runWorkspace' arguments: [ v.uri.path(), ] }) v.add_lens(node, lsp.Command{ - title: 'single file' - command: 'v-analyzer.runFile' + title: 'single file' + command: 'v-analyzer.runFile' arguments: [ v.uri.path(), ] @@ -137,12 +137,12 @@ pub fn (mut v CodeLensVisitor) add_interface_implementations_lens(node psi.AstNo if implementations.len == 1 { ' implementation' } else { ' implementations' } v.add_lens(node, lsp.Command{ - title: lens_title - command: 'v-analyzer.showReferences' + title: lens_title + command: 'v-analyzer.showReferences' arguments: [ v.uri.path(), json.encode(lsp.Position{ - line: identifier_text_range.line + line: identifier_text_range.line character: identifier_text_range.column }), json.encode(locations), @@ -170,12 +170,12 @@ pub fn (mut v CodeLensVisitor) add_super_interfaces_lens(node psi.AstNode) { if supers.len == 1 { ' interface' } else { ' interfaces' } v.add_lens(node, lsp.Command{ - title: lens_title - command: 'v-analyzer.showReferences' + title: lens_title + command: 'v-analyzer.showReferences' arguments: [ v.uri.path(), json.encode(lsp.Position{ - line: identifier_text_range.line + line: identifier_text_range.line character: identifier_text_range.column }), json.encode(locations), @@ -188,13 +188,13 @@ pub fn (mut v CodeLensVisitor) add_super_interfaces_lens(node psi.AstNode) { pub fn (mut v CodeLensVisitor) add_lens(node psi.AstNode, cmd lsp.Command) { start_point := node.start_point() start := lsp.Position{ - line: int(start_point.row) + line: int(start_point.row) character: int(start_point.column) } v.result << lsp.CodeLens{ range: lsp.Range{ start: start - end: start + end: start } command: cmd } diff --git a/src/server/completion/providers/AssertCompletionProvider.v b/src/server/completion/providers/AssertCompletionProvider.v index fcefe09f..746b8620 100644 --- a/src/server/completion/providers/AssertCompletionProvider.v +++ b/src/server/completion/providers/AssertCompletionProvider.v @@ -14,16 +14,16 @@ fn (_ &AssertCompletionProvider) is_available(ctx &completion.CompletionContext) fn (mut _ AssertCompletionProvider) add_completion(ctx &completion.CompletionContext, mut result completion.CompletionResultSet) { result.add_element(lsp.CompletionItem{ - label: 'assert expr' - kind: .keyword + label: 'assert expr' + kind: .keyword insert_text_format: .snippet - insert_text: 'assert \${1:expr}' + insert_text: 'assert \${1:expr}' }) result.add_element(lsp.CompletionItem{ - label: 'assert expr, message' - kind: .keyword + label: 'assert expr, message' + kind: .keyword insert_text_format: .snippet - insert_text: "assert \${1:expr}, '\${2:message}'$0" + insert_text: "assert \${1:expr}, '\${2:message}'$0" }) } diff --git a/src/server/completion/providers/AttributesCompletionProvider.v b/src/server/completion/providers/AttributesCompletionProvider.v index 04ca6133..4a22269e 100644 --- a/src/server/completion/providers/AttributesCompletionProvider.v +++ b/src/server/completion/providers/AttributesCompletionProvider.v @@ -45,17 +45,17 @@ fn (k &AttributesCompletionProvider) is_available(ctx &completion.CompletionCont fn (mut k AttributesCompletionProvider) add_completion(ctx &completion.CompletionContext, mut result completion.CompletionResultSet) { for attribute in providers.attributes { result.add_element(lsp.CompletionItem{ - label: attribute - kind: .struct_ + label: attribute + kind: .struct_ insert_text: attribute }) } for attribute in providers.attributes_with_colon { result.add_element(lsp.CompletionItem{ - label: "${attribute}: 'value'" - kind: .struct_ - insert_text: "${attribute}: '$1'$0" + label: "${attribute}: 'value'" + kind: .struct_ + insert_text: "${attribute}: '$1'$0" insert_text_format: .snippet }) } diff --git a/src/server/completion/providers/CompileTimeConstantCompletionProvider.v b/src/server/completion/providers/CompileTimeConstantCompletionProvider.v index e8c1d81c..48e058df 100644 --- a/src/server/completion/providers/CompileTimeConstantCompletionProvider.v +++ b/src/server/completion/providers/CompileTimeConstantCompletionProvider.v @@ -28,9 +28,9 @@ fn (_ &CompileTimeConstantCompletionProvider) is_available(ctx &completion.Compl fn (mut _ CompileTimeConstantCompletionProvider) add_completion(ctx &completion.CompletionContext, mut result completion.CompletionResultSet) { for constant, description in providers.compile_time_constant { result.add_element(lsp.CompletionItem{ - label: '@${constant}' - kind: .constant - detail: description + label: '@${constant}' + kind: .constant + detail: description insert_text: constant }) } diff --git a/src/server/completion/providers/FunctionLikeCompletionProvider.v b/src/server/completion/providers/FunctionLikeCompletionProvider.v index db5c89c9..7c84c4d2 100644 --- a/src/server/completion/providers/FunctionLikeCompletionProvider.v +++ b/src/server/completion/providers/FunctionLikeCompletionProvider.v @@ -20,9 +20,9 @@ fn (k &FunctionLikeCompletionProvider) is_available(ctx &completion.CompletionCo fn (mut k FunctionLikeCompletionProvider) add_completion(ctx &completion.CompletionContext, mut result completion.CompletionResultSet) { for keyword in providers.function_like_keywords { result.add_element(lsp.CompletionItem{ - label: '${keyword}()' - kind: .keyword - insert_text: '${keyword}($1)$0' + label: '${keyword}()' + kind: .keyword + insert_text: '${keyword}($1)$0' insert_text_format: .snippet }) } diff --git a/src/server/completion/providers/ImportsCompletionProvider.v b/src/server/completion/providers/ImportsCompletionProvider.v index f5d56b13..22ec8b7e 100644 --- a/src/server/completion/providers/ImportsCompletionProvider.v +++ b/src/server/completion/providers/ImportsCompletionProvider.v @@ -18,8 +18,8 @@ fn (mut _ ImportsCompletionProvider) add_completion(ctx &completion.CompletionCo for import_name in imports_names { result.add_element(lsp.CompletionItem{ - label: import_name - kind: .module_ + label: import_name + kind: .module_ insert_text: import_name }) } diff --git a/src/server/completion/providers/InitsCompletionProvider.v b/src/server/completion/providers/InitsCompletionProvider.v index d7c4ec57..172f6567 100644 --- a/src/server/completion/providers/InitsCompletionProvider.v +++ b/src/server/completion/providers/InitsCompletionProvider.v @@ -11,26 +11,26 @@ fn (_ &InitsCompletionProvider) is_available(ctx &completion.CompletionContext) fn (mut _ InitsCompletionProvider) add_completion(ctx &completion.CompletionContext, mut result completion.CompletionResultSet) { result.add_element(lsp.CompletionItem{ - label: 'chan int{}' - kind: .snippet - detail: '' - insert_text: 'chan \${1:int}{}$0' + label: 'chan int{}' + kind: .snippet + detail: '' + insert_text: 'chan \${1:int}{}$0' insert_text_format: .snippet }) result.add_element(lsp.CompletionItem{ - label: 'map[string]int{}' - kind: .snippet - detail: '' - insert_text: 'map[\${1:string}]\${2:int}{}$0' + label: 'map[string]int{}' + kind: .snippet + detail: '' + insert_text: 'map[\${1:string}]\${2:int}{}$0' insert_text_format: .snippet }) result.add_element(lsp.CompletionItem{ - label: 'thread int{}' - kind: .snippet - detail: '' - insert_text: 'thread \${1:int}{}$0' + label: 'thread int{}' + kind: .snippet + detail: '' + insert_text: 'thread \${1:int}{}$0' insert_text_format: .snippet }) } diff --git a/src/server/completion/providers/JsonAttributeCompletionProvider.v b/src/server/completion/providers/JsonAttributeCompletionProvider.v index 1fe810fa..8b33b308 100644 --- a/src/server/completion/providers/JsonAttributeCompletionProvider.v +++ b/src/server/completion/providers/JsonAttributeCompletionProvider.v @@ -26,9 +26,9 @@ fn (mut p JsonAttributeCompletionProvider) add_completion(ctx &completion.Comple json_name := p.json_name(name) result.add_element(lsp.CompletionItem{ - label: "json: '${json_name}'" - kind: .keyword - insert_text: "json: '\${1:${json_name}}'$0" + label: "json: '${json_name}'" + kind: .keyword + insert_text: "json: '\${1:${json_name}}'$0" insert_text_format: .snippet }) } diff --git a/src/server/completion/providers/KeywordsCompletionProvider.v b/src/server/completion/providers/KeywordsCompletionProvider.v index 920eabab..9712717c 100644 --- a/src/server/completion/providers/KeywordsCompletionProvider.v +++ b/src/server/completion/providers/KeywordsCompletionProvider.v @@ -21,8 +21,8 @@ fn (mut k KeywordsCompletionProvider) add_completion(ctx &completion.CompletionC fn (mut k KeywordsCompletionProvider) no_space_keywords(keywords []string, mut result completion.CompletionResultSet) { for keyword in keywords { result.add_element(lsp.CompletionItem{ - label: keyword - kind: .keyword + label: keyword + kind: .keyword insert_text: keyword }) } diff --git a/src/server/completion/providers/LoopKeywordsCompletionProvider.v b/src/server/completion/providers/LoopKeywordsCompletionProvider.v index 5e1ae029..fde657c7 100644 --- a/src/server/completion/providers/LoopKeywordsCompletionProvider.v +++ b/src/server/completion/providers/LoopKeywordsCompletionProvider.v @@ -11,13 +11,13 @@ fn (k &LoopKeywordsCompletionProvider) is_available(ctx &completion.CompletionCo fn (mut k LoopKeywordsCompletionProvider) add_completion(ctx &completion.CompletionContext, mut result completion.CompletionResultSet) { result.add_element(lsp.CompletionItem{ - label: 'break' - kind: .keyword + label: 'break' + kind: .keyword insert_text: 'break' }) result.add_element(lsp.CompletionItem{ - label: 'continue' - kind: .keyword + label: 'continue' + kind: .keyword insert_text: 'continue' }) } diff --git a/src/server/completion/providers/ModuleNameCompletionProvider.v b/src/server/completion/providers/ModuleNameCompletionProvider.v index 5af522b0..744eb72b 100644 --- a/src/server/completion/providers/ModuleNameCompletionProvider.v +++ b/src/server/completion/providers/ModuleNameCompletionProvider.v @@ -20,15 +20,15 @@ fn (mut p ModuleNameCompletionProvider) add_completion(ctx &completion.Completio dir_name := p.transform_module_name(os.file_name(dir)) result.add_element(lsp.CompletionItem{ - label: 'module ${dir_name}' - kind: .keyword + label: 'module ${dir_name}' + kind: .keyword insert_text_format: .snippet - insert_text: 'module ${dir_name}' + insert_text: 'module ${dir_name}' }) result.add_element(lsp.CompletionItem{ - label: 'module main' - kind: .keyword + label: 'module main' + kind: .keyword insert_text: 'module main' }) } diff --git a/src/server/completion/providers/ModulesImportProvider.v b/src/server/completion/providers/ModulesImportProvider.v index a952c11a..38b54d50 100644 --- a/src/server/completion/providers/ModulesImportProvider.v +++ b/src/server/completion/providers/ModulesImportProvider.v @@ -28,11 +28,11 @@ fn (mut m ModulesImportProvider) add_completion(ctx &completion.CompletionContex name_without_prefix := module_.trim_string_left(before_path) result.add_element(lsp.CompletionItem{ - label: name_without_prefix - kind: .module_ - detail: '' - documentation: '' - insert_text: name_without_prefix + label: name_without_prefix + kind: .module_ + detail: '' + documentation: '' + insert_text: name_without_prefix insert_text_format: .plain_text }) } diff --git a/src/server/completion/providers/NilKeywordCompletionProvider.v b/src/server/completion/providers/NilKeywordCompletionProvider.v index 98a6b75b..3c676f63 100644 --- a/src/server/completion/providers/NilKeywordCompletionProvider.v +++ b/src/server/completion/providers/NilKeywordCompletionProvider.v @@ -19,8 +19,8 @@ fn (mut k NilKeywordCompletionProvider) add_completion(ctx &completion.Completio } result.add_element(lsp.CompletionItem{ - label: 'nil' - kind: .keyword + label: 'nil' + kind: .keyword insert_text: insert_text }) } diff --git a/src/server/completion/providers/OrBlockExpressionCompletionProvider.v b/src/server/completion/providers/OrBlockExpressionCompletionProvider.v index 1d3d14ab..eeefac2e 100644 --- a/src/server/completion/providers/OrBlockExpressionCompletionProvider.v +++ b/src/server/completion/providers/OrBlockExpressionCompletionProvider.v @@ -11,15 +11,15 @@ fn (k &OrBlockExpressionCompletionProvider) is_available(ctx &completion.Complet fn (mut k OrBlockExpressionCompletionProvider) add_completion(ctx &completion.CompletionContext, mut result completion.CompletionResultSet) { result.add_element(lsp.CompletionItem{ - label: 'or { ... }' - kind: .keyword - insert_text: 'or { $0 }' + label: 'or { ... }' + kind: .keyword + insert_text: 'or { $0 }' insert_text_format: .snippet }) result.add_element(lsp.CompletionItem{ - label: 'or { panic(err) }' - kind: .keyword + label: 'or { panic(err) }' + kind: .keyword insert_text: 'or { panic(err) }' }) } diff --git a/src/server/completion/providers/PureBlockExpressionCompletionProvider.v b/src/server/completion/providers/PureBlockExpressionCompletionProvider.v index 07819ae5..b523255d 100644 --- a/src/server/completion/providers/PureBlockExpressionCompletionProvider.v +++ b/src/server/completion/providers/PureBlockExpressionCompletionProvider.v @@ -27,10 +27,10 @@ fn (mut k PureBlockExpressionCompletionProvider) add_completion(ctx &completion. } result.add_element(lsp.CompletionItem{ - label: 'unsafe { ... }' - kind: .keyword - insert_text: insert_text + label: 'unsafe { ... }' + kind: .keyword + insert_text: insert_text insert_text_format: .snippet - insert_text_mode: .adjust_indentation + insert_text_mode: .adjust_indentation }) } diff --git a/src/server/completion/providers/PureBlockStatementCompletionProvider.v b/src/server/completion/providers/PureBlockStatementCompletionProvider.v index 228d00d4..8d24546e 100644 --- a/src/server/completion/providers/PureBlockStatementCompletionProvider.v +++ b/src/server/completion/providers/PureBlockStatementCompletionProvider.v @@ -11,10 +11,10 @@ fn (k &PureBlockStatementCompletionProvider) is_available(ctx &completion.Comple fn (mut k PureBlockStatementCompletionProvider) add_completion(ctx &completion.CompletionContext, mut result completion.CompletionResultSet) { result.add_element(lsp.CompletionItem{ - label: 'defer { ... }' - kind: .keyword - insert_text: 'defer {\n\t$0\n}' + label: 'defer { ... }' + kind: .keyword + insert_text: 'defer {\n\t$0\n}' insert_text_format: .snippet - insert_text_mode: .adjust_indentation + insert_text_mode: .adjust_indentation }) } diff --git a/src/server/completion/providers/ReferenceCompletionProcessor.v b/src/server/completion/providers/ReferenceCompletionProcessor.v index 5bf1fc71..04e6c85b 100644 --- a/src/server/completion/providers/ReferenceCompletionProcessor.v +++ b/src/server/completion/providers/ReferenceCompletionProcessor.v @@ -45,44 +45,44 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { if element is psi.VarDefinition { c.add_item( - label: name - kind: .variable - detail: element.get_type().readable_name() + label: name + kind: .variable + detail: element.get_type().readable_name() label_details: lsp.CompletionItemLabelDetails{ description: element.get_type().readable_name() } - documentation: '' - insert_text: name + documentation: '' + insert_text: name insert_text_format: .plain_text - sort_text: '0${name}' // variables should go first + sort_text: '0${name}' // variables should go first ) } if element is psi.ParameterDeclaration { c.add_item( - label: name - kind: .variable - detail: element.get_type().readable_name() + label: name + kind: .variable + detail: element.get_type().readable_name() label_details: lsp.CompletionItemLabelDetails{ description: element.get_type().readable_name() } - documentation: '' - insert_text: name + documentation: '' + insert_text: name insert_text_format: .plain_text - sort_text: '0${name}' // parameters should go first + sort_text: '0${name}' // parameters should go first ) } if element is psi.Receiver { c.add_item( - label: element.name() - kind: .variable - detail: element.get_type().readable_name() + label: element.name() + kind: .variable + detail: element.get_type().readable_name() label_details: lsp.CompletionItemLabelDetails{ description: element.get_type().readable_name() } - documentation: '' - insert_text: element.name() + documentation: '' + insert_text: element.name() insert_text_format: .plain_text ) } @@ -110,7 +110,7 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { text_ranga := c.ctx.element.text_range() symbol := c.ctx.element.containing_file.symbol_at(psi.TextRange{ - line: text_ranga.line + line: text_ranga.line column: text_ranga.end_column + 1 }) paren_after_cursor := symbol == `(` @@ -134,16 +134,16 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { insert_text_builder.write_string('$0') c.add_item( - label: '${name}' - kind: if receiver_text == '' { .function } else { .method } + label: '${name}' + kind: if receiver_text == '' { .function } else { .method } label_details: lsp.CompletionItemLabelDetails{ detail: signature.get_text() } - detail: 'fn ${receiver_text}${element.name()}${generic_parameters_text}${signature.get_text()}' - documentation: element.doc_comment() - insert_text: insert_text_builder.str() + detail: 'fn ${receiver_text}${element.name()}${generic_parameters_text}${signature.get_text()}' + documentation: element.doc_comment() + insert_text: insert_text_builder.str() insert_text_format: .snippet - sort_text: '1${name}' // functions should go second + sort_text: '1${name}' // functions should go second ) } @@ -170,7 +170,7 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { text_ranga := c.ctx.element.text_range() symbol := c.ctx.element.containing_file.symbol_at(psi.TextRange{ - line: text_ranga.line + line: text_ranga.line column: text_ranga.end_column + 1 }) paren_after_cursor := symbol == `(` @@ -194,16 +194,16 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { insert_text_builder.write_string('$0') c.add_item( - label: '${name}' - kind: .method + label: '${name}' + kind: .method label_details: lsp.CompletionItemLabelDetails{ detail: signature.get_text() } - detail: 'fn ${receiver_text}${element.name()}${generic_parameters_text}${signature.get_text()}' - documentation: element.doc_comment() - insert_text: insert_text_builder.str() + detail: 'fn ${receiver_text}${element.name()}${generic_parameters_text}${signature.get_text()}' + documentation: element.doc_comment() + insert_text: insert_text_builder.str() insert_text_format: .snippet - sort_text: '1${name}' // functions should go second + sort_text: '1${name}' // functions should go second ) } @@ -215,7 +215,7 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { text_ranga := c.ctx.element.text_range() symbol := c.ctx.element.containing_file.symbol_at(psi.TextRange{ - line: text_ranga.line + line: text_ranga.line column: text_ranga.end_column + 1 }) paren_after_cursor := symbol == `{` @@ -227,25 +227,25 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { } c.add_item( - label: name - kind: .struct_ - detail: '' - documentation: element.doc_comment() - insert_text: insert_text + label: name + kind: .struct_ + detail: '' + documentation: element.doc_comment() + insert_text: insert_text insert_text_format: .snippet ) } if element is psi.ConstantDefinition { c.add_item( - label: element.name() - kind: .constant - detail: element.get_type().readable_name() + label: element.name() + kind: .constant + detail: element.get_type().readable_name() label_details: lsp.CompletionItemLabelDetails{ description: element.get_type().readable_name() } - documentation: element.doc_comment() - insert_text: element.name() + documentation: element.doc_comment() + insert_text: element.name() insert_text_format: .plain_text ) } @@ -260,14 +260,14 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { } c.add_item( - label: element.name() - kind: .field - detail: element.get_type().readable_name() + label: element.name() + kind: .field + detail: element.get_type().readable_name() label_details: lsp.CompletionItemLabelDetails{ description: element.get_type().readable_name() } - documentation: element.doc_comment() - insert_text: insert_text + documentation: element.doc_comment() + insert_text: insert_text insert_text_format: .snippet ) } @@ -290,37 +290,37 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { '' } c.add_item( - label: element.name() - kind: .method - detail: 'fn ${element.name()}${signature.get_text()}' + label: element.name() + kind: .method + detail: 'fn ${element.name()}${signature.get_text()}' label_details: lsp.CompletionItemLabelDetails{ - detail: signature.get_text() + detail: signature.get_text() description: owner_name } - documentation: element.doc_comment() - insert_text: insert_text_builder.str() + documentation: element.doc_comment() + insert_text: insert_text_builder.str() insert_text_format: .snippet ) } if element is psi.EnumDeclaration { c.add_item( - label: element.name() - kind: .enum_ - detail: '' - documentation: element.doc_comment() - insert_text: element.name() + label: element.name() + kind: .enum_ + detail: '' + documentation: element.doc_comment() + insert_text: element.name() insert_text_format: .plain_text ) } if element is psi.EnumFieldDeclaration { c.add_item( - label: element.name() - kind: .enum_member - detail: '' - documentation: element.doc_comment() - insert_text: element.name() + label: element.name() + kind: .enum_member + detail: '' + documentation: element.doc_comment() + insert_text: element.name() insert_text_format: .plain_text ) } @@ -328,18 +328,18 @@ fn (mut c ReferenceCompletionProcessor) execute(element psi.PsiElement) bool { if element is psi.GenericParameter { c.add_item( label: element.name() - kind: .type_parameter + kind: .type_parameter ) } if element is psi.GlobalVarDefinition { module_name := element.containing_file.module_fqn() c.add_item( - label: element.name() + label: element.name() label_details: lsp.CompletionItemLabelDetails{ detail: ' (global defined in ${module_name})' } - kind: .variable + kind: .variable insert_text: element.name() ) } diff --git a/src/server/completion/providers/ReferenceCompletionProvider.v b/src/server/completion/providers/ReferenceCompletionProvider.v index ca0ece8d..c8561446 100644 --- a/src/server/completion/providers/ReferenceCompletionProvider.v +++ b/src/server/completion/providers/ReferenceCompletionProvider.v @@ -28,8 +28,8 @@ fn (mut r ReferenceCompletionProvider) add_completion(ctx &completion.Completion if parent is psi.ReferenceExpressionBase { sub := psi.SubResolver{ containing_file: containing_file - element: parent - for_types: parent is psi.TypeReferenceExpression + element: parent + for_types: parent is psi.TypeReferenceExpression } variants := StructLiteralCompletion{}.allowed_variants(ctx, parent) diff --git a/src/server/completion/providers/ReturnCompletionProvider.v b/src/server/completion/providers/ReturnCompletionProvider.v index c7df267e..28ef2767 100644 --- a/src/server/completion/providers/ReturnCompletionProvider.v +++ b/src/server/completion/providers/ReturnCompletionProvider.v @@ -32,11 +32,11 @@ fn (mut _ ReturnCompletionProvider) add_completion(ctx &completion.CompletionCon if result_type.name == 'bool' { result.add_element(lsp.CompletionItem{ label: 'return true' - kind: .text + kind: .text }) result.add_element(lsp.CompletionItem{ label: 'return false' - kind: .text + kind: .text }) } } @@ -45,7 +45,7 @@ fn (mut _ ReturnCompletionProvider) add_completion(ctx &completion.CompletionCon zero_value := lang.get_zero_value_for(result_type) result.add_element(lsp.CompletionItem{ label: 'return ${zero_value}' - kind: .text + kind: .text }) } @@ -57,7 +57,7 @@ fn (mut _ ReturnCompletionProvider) add_completion(ctx &completion.CompletionCon result.add_element(lsp.CompletionItem{ label: label - kind: .text + kind: .text }) } } diff --git a/src/server/completion/providers/TopLevelCompletionProvider.v b/src/server/completion/providers/TopLevelCompletionProvider.v index 40915ac3..8d0a0406 100644 --- a/src/server/completion/providers/TopLevelCompletionProvider.v +++ b/src/server/completion/providers/TopLevelCompletionProvider.v @@ -30,27 +30,27 @@ fn (mut k TopLevelCompletionProvider) add_completion(ctx &completion.CompletionC fn (mut k TopLevelCompletionProvider) pub_keyword(mut result completion.CompletionResultSet) { for label, variant in providers.top_level_map { result.add_element(lsp.CompletionItem{ - label: label - kind: .keyword - filter_text: variant.search_text - insert_text: variant.insert_text + label: label + kind: .keyword + filter_text: variant.search_text + insert_text: variant.insert_text insert_text_format: .snippet }) } for label, variant in providers.top_level_map { result.add_element(lsp.CompletionItem{ - label: 'pub ${label}' - kind: .keyword - filter_text: 'pub ${variant.search_text}' - insert_text: 'pub ${variant.insert_text}' + label: 'pub ${label}' + kind: .keyword + filter_text: 'pub ${variant.search_text}' + insert_text: 'pub ${variant.insert_text}' insert_text_format: .snippet }) } result.add_element(lsp.CompletionItem{ - label: 'import' - kind: .keyword + label: 'import' + kind: .keyword insert_text: 'import ' }) } diff --git a/src/server/diagnostics.v b/src/server/diagnostics.v index 5010ab0a..6fc99561 100644 --- a/src/server/diagnostics.v +++ b/src/server/diagnostics.v @@ -45,7 +45,7 @@ fn (mut d DiagnosticReporter) clear(uri lsp.DocumentUri) { fn (mut d DiagnosticReporter) publish(mut wr ResponseWriter, uri lsp.DocumentUri) { reports := d.reports[uri] or { return } wr.publish_diagnostics(lsp.PublishDiagnosticsParams{ - uri: uri + uri: uri diagnostics: reports.map(d.convert_report(it)) }) } @@ -62,15 +62,15 @@ fn (_ &DiagnosticReporter) convert_report(report inspections.Report) lsp.Diagnos } return lsp.Diagnostic{ - range: tform.text_range_to_lsp_range(report.range) + range: tform.text_range_to_lsp_range(report.range) severity: match report.kind { .error { lsp.DiagnosticSeverity.error } .warning { lsp.DiagnosticSeverity.warning } .notice { lsp.DiagnosticSeverity.information } } - source: 'compiler' + source: 'compiler' message: report.message - tags: tags + tags: tags } } diff --git a/src/server/features_code_actions.v b/src/server/features_code_actions.v index cc4a2792..cdda6fb3 100644 --- a/src/server/features_code_actions.v +++ b/src/server/features_code_actions.v @@ -18,11 +18,11 @@ pub fn (mut ls LanguageServer) code_actions(params lsp.CodeActionParams) ?[]lsp. } actions << lsp.CodeAction{ - title: intention.name - kind: lsp.refactor + title: intention.name + kind: lsp.refactor command: lsp.Command{ - title: intention.name - command: intention.id + title: intention.name + command: intention.id arguments: [ json.encode(IntentionData{ file_uri: uri @@ -43,11 +43,11 @@ pub fn (mut ls LanguageServer) code_actions(params lsp.CodeActionParams) ?[]lsp. } actions << lsp.CodeAction{ - title: intention.name - kind: lsp.quick_fix + title: intention.name + kind: lsp.quick_fix command: lsp.Command{ - title: intention.name - command: intention.id + title: intention.name + command: intention.id arguments: [ json.encode(IntentionData{ file_uri: uri diff --git a/src/server/features_completion.v b/src/server/features_completion.v index 4e982178..19151d95 100644 --- a/src/server/features_completion.v +++ b/src/server/features_completion.v @@ -45,9 +45,9 @@ pub fn (mut ls LanguageServer) completion(params lsp.CompletionParams) ![]lsp.Co // We use CompletionContext in order not to calculate the current partial context // in each provider, but to calculate it once and pass it to all providers. mut ctx := &completion.CompletionContext{ - element: element - position: params.position - offset: offset + element: element + position: params.position + offset: offset trigger_kind: params.context.trigger_kind } ctx.compute() @@ -55,10 +55,10 @@ pub fn (mut ls LanguageServer) completion(params lsp.CompletionParams) ![]lsp.Co mut result_set := &completion.CompletionResultSet{} mut processor := &providers.ReferenceCompletionProcessor{ - file: file.psi_file + file: file.psi_file module_fqn: file.psi_file.module_fqn() - root: ls.root_uri.path() - ctx: ctx + root: ls.root_uri.path() + ctx: ctx } mut completion_providers := []completion.CompletionProvider{} diff --git a/src/server/features_definition.v b/src/server/features_definition.v index 4435fafa..fa097926 100644 --- a/src/server/features_definition.v +++ b/src/server/features_definition.v @@ -42,9 +42,9 @@ pub fn new_resolve_result(containing_file &psi.PsiFile, element psi.PsiElement) if element is psi.PsiNamedElement { text_range := element.identifier_text_range() return ResolveResult{ - range: text_range + range: text_range filepath: containing_file.path() - name: element.name() + name: element.name() } } @@ -54,9 +54,9 @@ pub fn new_resolve_result(containing_file &psi.PsiFile, element psi.PsiElement) fn (r &ResolveResult) to_location_link(origin_selection_range psi.TextRange) lsp.LocationLink { range := tform.text_range_to_lsp_range(r.range) return lsp.LocationLink{ - target_uri: lsp.document_uri_from_path(r.filepath) + target_uri: lsp.document_uri_from_path(r.filepath) origin_selection_range: tform.text_range_to_lsp_range(origin_selection_range) - target_range: range + target_range: range target_selection_range: range } } diff --git a/src/server/features_did_change.v b/src/server/features_did_change.v index 693964bb..186496d7 100644 --- a/src/server/features_did_change.v +++ b/src/server/features_did_change.v @@ -18,8 +18,8 @@ pub fn (mut ls LanguageServer) did_change(params lsp.DidChangeTextDocumentParams new_content := params.content_changes[0].text file.psi_file.reparse(new_content) ls.opened_files[uri] = analyzer.OpenedFile{ - uri: uri - version: file.version++ + uri: uri + version: file.version++ psi_file: file.psi_file } diff --git a/src/server/features_did_open.v b/src/server/features_did_open.v index 8e54b3ba..390e5b37 100644 --- a/src/server/features_did_open.v +++ b/src/server/features_did_open.v @@ -14,8 +14,8 @@ pub fn (mut ls LanguageServer) did_open(params lsp.DidOpenTextDocumentParams) { psi_file := psi.new_psi_file(uri.path(), res.tree, res.source_text) ls.opened_files[uri] = analyzer.OpenedFile{ - uri: uri - version: 0 + uri: uri + version: 0 psi_file: psi_file } diff --git a/src/server/features_document_highlight.v b/src/server/features_document_highlight.v index 386ae575..6d9d7e23 100644 --- a/src/server/features_document_highlight.v +++ b/src/server/features_document_highlight.v @@ -30,7 +30,7 @@ pub fn (mut ls LanguageServer) document_highlight(params lsp.TextDocumentPositio } highlights << lsp.DocumentHighlight{ range: tform.text_range_to_lsp_range(range) - kind: read_write_kind(reference) + kind: read_write_kind(reference) } } diff --git a/src/server/features_document_symbol.v b/src/server/features_document_symbol.v index e7072bc3..ed1e810e 100644 --- a/src/server/features_document_symbol.v +++ b/src/server/features_document_symbol.v @@ -26,12 +26,12 @@ fn document_symbol_presentation(element psi.PsiElement) ?lsp.DocumentSymbol { identifier_text_range := element.identifier_text_range() children := symbol_children(element) return lsp.DocumentSymbol{ - name: name_presentation(element) - detail: detail_presentation(element) - kind: symbol_kind(element as psi.PsiElement)? - range: tform.text_range_to_lsp_range(full_text_range) + name: name_presentation(element) + detail: detail_presentation(element) + kind: symbol_kind(element as psi.PsiElement)? + range: tform.text_range_to_lsp_range(full_text_range) selection_range: tform.text_range_to_lsp_range(identifier_text_range) - children: children + children: children } } diff --git a/src/server/features_folding_range.v b/src/server/features_folding_range.v index 097326ef..caf7547c 100644 --- a/src/server/features_folding_range.v +++ b/src/server/features_folding_range.v @@ -28,11 +28,11 @@ pub fn (mut ls LanguageServer) folding_range(params lsp.FoldingRangeParams) ?[]l } result << lsp.FoldingRange{ - start_line: first_range.line + start_line: first_range.line start_character: first_range.column - end_line: range.end_line - 2 - end_character: range.end_column - kind: lsp.folding_range_kind_imports + end_line: range.end_line - 2 + end_character: range.end_column + kind: lsp.folding_range_kind_imports } } } diff --git a/src/server/features_formatting.v b/src/server/features_formatting.v index 4b84463a..3b33ec6c 100644 --- a/src/server/features_formatting.v +++ b/src/server/features_formatting.v @@ -33,7 +33,7 @@ pub fn (mut ls LanguageServer) formatting(params lsp.DocumentFormattingParams) ! return [ lsp.TextEdit{ - range: tform.text_range_to_lsp_range(file.psi_file.root().text_range()) + range: tform.text_range_to_lsp_range(file.psi_file.root().text_range()) new_text: output }, ] diff --git a/src/server/features_hover.v b/src/server/features_hover.v index af76386a..ec644e35 100644 --- a/src/server/features_hover.v +++ b/src/server/features_hover.v @@ -27,7 +27,7 @@ pub fn (mut ls LanguageServer) hover(params lsp.HoverParams) ?lsp.Hover { if content := provider.documentation(element) { return lsp.Hover{ contents: lsp.hover_markdown_string(content) - range: tform.text_range_to_lsp_range(element.text_range()) + range: tform.text_range_to_lsp_range(element.text_range()) } } } @@ -37,7 +37,7 @@ pub fn (mut ls LanguageServer) hover(params lsp.HoverParams) ?lsp.Hover { if content := provider.documentation(doc_element) { return lsp.Hover{ contents: lsp.hover_markdown_string(content) - range: tform.text_range_to_lsp_range(element.text_range()) + range: tform.text_range_to_lsp_range(element.text_range()) } } diff --git a/src/server/features_prepare_rename.v b/src/server/features_prepare_rename.v index 40f4a8b8..4dfac845 100644 --- a/src/server/features_prepare_rename.v +++ b/src/server/features_prepare_rename.v @@ -30,7 +30,7 @@ pub fn (mut ls LanguageServer) prepare_rename(params lsp.PrepareRenameParams) !l element_text_range := resolved.identifier_text_range() return lsp.PrepareRenameResult{ - range: tform.text_range_to_lsp_range(element_text_range) + range: tform.text_range_to_lsp_range(element_text_range) placeholder: '' } } diff --git a/src/server/features_semantic_tokens.v b/src/server/features_semantic_tokens.v index e2377796..0b3a4c99 100644 --- a/src/server/features_semantic_tokens.v +++ b/src/server/features_semantic_tokens.v @@ -30,7 +30,7 @@ pub fn (mut ls LanguageServer) semantic_tokens(text_document lsp.TextDocumentIde tokens := dumb_aware_visitor.accept(file.psi_file.root) return lsp.SemanticTokens{ result_id: time.now().unix().str() - data: semantic.encode(tokens) + data: semantic.encode(tokens) } } @@ -43,6 +43,6 @@ pub fn (mut ls LanguageServer) semantic_tokens(text_document lsp.TextDocumentIde return lsp.SemanticTokens{ result_id: time.now().unix().str() - data: semantic.encode(result) + data: semantic.encode(result) } } diff --git a/src/server/features_signature_help.v b/src/server/features_signature_help.v index cb86adc0..54be4581 100644 --- a/src/server/features_signature_help.v +++ b/src/server/features_signature_help.v @@ -53,9 +53,9 @@ pub fn (mut ls LanguageServer) signature_help(params lsp.SignatureHelpParams) ?l return lsp.SignatureHelp{ active_parameter: active_parameter - signatures: [ + signatures: [ lsp.SignatureInformation{ - label: 'fn ${resolved.name()}${signature.get_text()}' + label: 'fn ${resolved.name()}${signature.get_text()}' parameters: param_infos }, ] diff --git a/src/server/features_workspace_symbol.v b/src/server/features_workspace_symbol.v index 9fd50c45..77a948c0 100644 --- a/src/server/features_workspace_symbol.v +++ b/src/server/features_workspace_symbol.v @@ -23,10 +23,10 @@ pub fn (mut ls LanguageServer) workspace_symbol(_ lsp.WorkspaceSymbolParams) ?[] text_range := elem.identifier_text_range() workspace_symbols << lsp.WorkspaceSymbol{ - name: fqn - kind: symbol_kind(elem as psi.PsiElement) or { continue } + name: fqn + kind: symbol_kind(elem as psi.PsiElement) or { continue } location: lsp.Location{ - uri: uri + uri: uri range: tform.text_range_to_lsp_range(text_range) } } diff --git a/src/server/file_diff/Diff.v b/src/server/file_diff/Diff.v index 684f89c0..873220bc 100644 --- a/src/server/file_diff/Diff.v +++ b/src/server/file_diff/Diff.v @@ -28,7 +28,7 @@ pub fn (mut diff Diff) append_to(line int, col int, text string) { diff.edits << Edit{ range: lsp.Range{ start: pos - end: pos + end: pos } new_text: text } @@ -39,7 +39,7 @@ pub fn (mut diff Diff) append_as_prev_line(line int, text string) { diff.edits << Edit{ range: lsp.Range{ start: pos - end: pos + end: pos } new_text: '${text}\n' } @@ -50,7 +50,7 @@ pub fn (mut diff Diff) append_as_next_line(line int, text string) { diff.edits << Edit{ range: lsp.Range{ start: pos - end: pos + end: pos } new_text: '\n${text}' } @@ -60,7 +60,7 @@ pub fn (mut diff Diff) to_workspace_edit() lsp.WorkspaceEdit { return lsp.WorkspaceEdit{ changes: { diff.uri: diff.edits.map(lsp.TextEdit{ - range: it.range + range: it.range new_text: it.new_text }) } @@ -69,14 +69,14 @@ pub fn (mut diff Diff) to_workspace_edit() lsp.WorkspaceEdit { fn Diff.line_begin_pos(line int) lsp.Position { return lsp.Position{ - line: line + line: line character: 0 } } fn Diff.line_pos(line int, col int) lsp.Position { return lsp.Position{ - line: line + line: line character: col } } diff --git a/src/server/general.v b/src/server/general.v index 18a7e827..2689f8a5 100644 --- a/src/server/general.v +++ b/src/server/general.v @@ -41,50 +41,50 @@ pub fn (mut ls LanguageServer) initialize(params lsp.InitializeParams, mut wr Re capabilities: lsp.ServerCapabilities{ text_document_sync: lsp.TextDocumentSyncOptions{ open_close: true - change: .full - will_save: true - save: lsp.SaveOptions{} + change: .full + will_save: true + save: lsp.SaveOptions{} } - hover_provider: true - definition_provider: true - type_definition_provider: true - references_provider: lsp.ReferencesOptions{} + hover_provider: true + definition_provider: true + type_definition_provider: true + references_provider: lsp.ReferencesOptions{} document_formatting_provider: true - completion_provider: lsp.CompletionOptions{ - resolve_provider: false + completion_provider: lsp.CompletionOptions{ + resolve_provider: false trigger_characters: ['.', ':', '(', '@'] } signature_help_provider: lsp.SignatureHelpOptions{ - trigger_characters: ['(', ','] + trigger_characters: ['(', ','] retrigger_characters: [',', ' '] } - code_lens_provider: lsp.CodeLensOptions{} - inlay_hint_provider: lsp.InlayHintOptions{} + code_lens_provider: lsp.CodeLensOptions{} + inlay_hint_provider: lsp.InlayHintOptions{} semantic_tokens_provider: lsp.SemanticTokensOptions{ legend: lsp.SemanticTokensLegend{ - token_types: semantic.semantic_types + token_types: semantic.semantic_types token_modifiers: semantic.semantic_modifiers } range: true - full: true + full: true } rename_provider: lsp.RenameOptions{ prepare_provider: false } - document_symbol_provider: true - workspace_symbol_provider: true - implementation_provider: true + document_symbol_provider: true + workspace_symbol_provider: true + implementation_provider: true document_highlight_provider: true - code_action_provider: lsp.CodeActionOptions{ + code_action_provider: lsp.CodeActionOptions{ code_action_kinds: [lsp.quick_fix] } - folding_range_provider: true + folding_range_provider: true execute_command_provider: lsp.ExecuteCommandOptions{ commands: arrays.concat(ls.intentions.values().map(it.id), ...ls.compiler_quick_fixes.values().map(it.id)) } } server_info: lsp.ServerInfo{ - name: metadata.manifest.name + name: metadata.manifest.name version: metadata.manifest.version } } diff --git a/src/server/hints/InlayHintsVisitor.v b/src/server/hints/InlayHintsVisitor.v index 16f4dd51..908fc0ae 100644 --- a/src/server/hints/InlayHintsVisitor.v +++ b/src/server/hints/InlayHintsVisitor.v @@ -33,21 +33,21 @@ pub fn (mut v InlayHintsVisitor) process_node(node psi.AstNode, containing_file if need_left { v.result << lsp.InlayHint{ position: lsp.Position{ - line: int(start_point.row) + line: int(start_point.row) character: int(start_point.column) } label: '≤' - kind: .type_ + kind: .type_ } } if need_right { v.result << lsp.InlayHint{ position: lsp.Position{ - line: int(end_point.row) + line: int(end_point.row) character: int(end_point.column) } label: '<' - kind: .type_ + kind: .type_ } } return @@ -64,11 +64,11 @@ pub fn (mut v InlayHintsVisitor) process_node(node psi.AstNode, containing_file v.result << lsp.InlayHint{ position: lsp.Position{ - line: range.line + line: range.line character: range.end_column } label: ': ' + element.get_type().readable_name() - kind: .type_ + kind: .type_ } } } @@ -81,11 +81,11 @@ pub fn (mut v InlayHintsVisitor) process_node(node psi.AstNode, containing_file v.result << lsp.InlayHint{ position: lsp.Position{ - line: range.line + line: range.line character: range.end_column } label: ': ' + typ.readable_name() - kind: .type_ + kind: .type_ } } } @@ -130,11 +130,11 @@ pub fn (mut v InlayHintsVisitor) handle_enum_field(enum_field psi.AstNode, conta text_range := element.text_range() v.result << lsp.InlayHint{ position: lsp.Position{ - line: int(text_range.line) + line: int(text_range.line) character: int(text_range.end_column) } label: ' = ${value_presentation}' - kind: .type_ + kind: .type_ } } } @@ -176,11 +176,11 @@ pub fn (mut v InlayHintsVisitor) handle_call_expression(call psi.AstNode, contai arg_range := arg.text_range() v.result << lsp.InlayHint{ position: lsp.Position{ - line: arg_range.line + line: arg_range.line character: arg_range.column } label: '${name}: ' - kind: .parameter + kind: .parameter } } } @@ -215,10 +215,10 @@ pub fn (mut v InlayHintsVisitor) handle_implicit_error_variable(block psi.AstNod v.result << lsp.InlayHint{ position: lsp.Position{ - line: int(start_point.row) + line: int(start_point.row) character: int(start_point.column + 1) } label: ' err →' - kind: .parameter + kind: .parameter } } diff --git a/src/server/inspections/compiler/utils.v b/src/server/inspections/compiler/utils.v index e8cb1eba..04c19b67 100644 --- a/src/server/inspections/compiler/utils.v +++ b/src/server/inspections/compiler/utils.v @@ -52,13 +52,13 @@ fn parse_compiler_diagnostic(msg string) ?inspections.Report { return inspections.Report{ range: psi.TextRange{ - line: line_nr - column: col_nr - end_line: line_nr + line: line_nr + column: col_nr + end_line: line_nr end_column: col_nr + underline_width } - kind: diag_kind - message: msg_content + kind: diag_kind + message: msg_content filepath: filepath } } diff --git a/src/server/intentions/Intention.v b/src/server/intentions/Intention.v index ab372d74..5718b594 100644 --- a/src/server/intentions/Intention.v +++ b/src/server/intentions/Intention.v @@ -13,7 +13,7 @@ pub struct IntentionContext { pub fn IntentionContext.from(containing_file &psi.PsiFile, position lsp.Position) IntentionContext { return IntentionContext{ containing_file: containing_file - position: position + position: position } } diff --git a/src/server/language_server.v b/src/server/language_server.v index 1d34b159..52a6380e 100644 --- a/src/server/language_server.v +++ b/src/server/language_server.v @@ -82,9 +82,9 @@ pub mut: pub fn LanguageServer.new(indexing analyzer.IndexingManager) &LanguageServer { return &LanguageServer{ indexing_mng: indexing - writer: unsafe { nil } // will be initialized in `initialize` - client: unsafe { nil } // will be initialized in `initialize` - progress: unsafe { nil } // will be initialized in `initialize` + writer: unsafe { nil } // will be initialized in `initialize` + client: unsafe { nil } // will be initialized in `initialize` + progress: unsafe { nil } // will be initialized in `initialize` } } diff --git a/src/server/progress/progress.v b/src/server/progress/progress.v index 8f86d072..b9826ef4 100644 --- a/src/server/progress/progress.v +++ b/src/server/progress/progress.v @@ -17,7 +17,7 @@ pub fn new_tracker(mut client protocol.Client) &Tracker { pub fn (mut t Tracker) start(title string, message string, token lsp.ProgressToken) &WorkDone { mut wd := &WorkDone{ - token: token + token: token client: t.client } @@ -35,10 +35,10 @@ pub fn (mut t Tracker) start(title string, message string, token lsp.ProgressTok t.client.progress( token: wd.token value: lsp.WorkDoneProgressPayload{ - kind: 'begin' - title: title - message: message - percentage: 0 + kind: 'begin' + title: title + message: message + percentage: 0 cancellable: false } ) @@ -61,8 +61,8 @@ pub fn (mut wd WorkDone) progress(message string, percentage u32) { wd.client.progress( token: wd.token value: lsp.WorkDoneProgressPayload{ - kind: 'report' - message: message.trim_string_right('\n') + kind: 'report' + message: message.trim_string_right('\n') percentage: percentage } ) @@ -77,8 +77,8 @@ pub fn (mut wd WorkDone) end(message string) { wd.client.progress( token: wd.token value: lsp.WorkDoneProgressPayload{ - kind: 'end' - message: message + kind: 'end' + message: message percentage: 100 } ) diff --git a/src/server/protocol/Client.v b/src/server/protocol/Client.v index 58b116d2..ae8e5f86 100644 --- a/src/server/protocol/Client.v +++ b/src/server/protocol/Client.v @@ -31,7 +31,7 @@ pub fn (mut c Client) log_message(message string, typ lsp.MessageType) { } } c.wr.write_notify('window/logMessage', lsp.LogMessageParams{ - @type: typ + @type: typ message: message }) } @@ -39,14 +39,14 @@ pub fn (mut c Client) log_message(message string, typ lsp.MessageType) { // show_message sends a window/showMessage notification to the client pub fn (mut c Client) show_message(message string, typ lsp.MessageType) { c.wr.write_notify('window/showMessage', lsp.ShowMessageParams{ - @type: typ + @type: typ message: message }) } pub fn (mut c Client) show_message_request(message string, actions []lsp.MessageActionItem, typ lsp.MessageType) { c.wr.write_notify('window/showMessageRequest', lsp.ShowMessageRequestParams{ - @type: typ + @type: typ message: message actions: actions }) diff --git a/src/server/semantic/DumbAwareSemanticVisitor.v b/src/server/semantic/DumbAwareSemanticVisitor.v index a65e01a0..38b39bd4 100644 --- a/src/server/semantic/DumbAwareSemanticVisitor.v +++ b/src/server/semantic/DumbAwareSemanticVisitor.v @@ -19,8 +19,8 @@ pub fn new_dumb_aware_semantic_visitor(range lsp.Range, containing_file &psi.Psi return DumbAwareSemanticVisitor{ with_range: !range.is_empty() - start: u32(start) - end: u32(end) + start: u32(start) + end: u32(end) } } diff --git a/src/server/semantic/ResolvingSemanticVisitor.v b/src/server/semantic/ResolvingSemanticVisitor.v index a0b91f1b..f18170d6 100644 --- a/src/server/semantic/ResolvingSemanticVisitor.v +++ b/src/server/semantic/ResolvingSemanticVisitor.v @@ -16,8 +16,8 @@ pub fn new_resolve_semantic_visitor(range lsp.Range, containing_file &psi.PsiFil return ResolveSemanticVisitor{ with_range: !range.is_empty() - start: u32(start) - end: u32(end) + start: u32(start) + end: u32(end) } } diff --git a/src/server/semantic/SemanticToken.v b/src/server/semantic/SemanticToken.v index 873395a9..e5c566f9 100644 --- a/src/server/semantic/SemanticToken.v +++ b/src/server/semantic/SemanticToken.v @@ -41,10 +41,10 @@ pub struct SemanticToken { fn element_to_semantic(element psi.AstNode, typ SemanticTypes, modifiers ...string) SemanticToken { start_point := element.start_point() return SemanticToken{ - line: start_point.row + line: start_point.row start: start_point.column - len: element.text_length() - typ: typ - mods: modifiers + len: element.text_length() + typ: typ + mods: modifiers } } diff --git a/src/server/tform/tform.v b/src/server/tform/tform.v index c90e2722..6489f924 100644 --- a/src/server/tform/tform.v +++ b/src/server/tform/tform.v @@ -12,7 +12,7 @@ pub fn elements_to_locations(elements []psi.PsiElement) []lsp.Location { element.text_range() } return lsp.Location{ - uri: element.containing_file.uri() + uri: element.containing_file.uri() range: text_range_to_lsp_range(range) } }) @@ -22,11 +22,11 @@ pub fn elements_to_locations(elements []psi.PsiElement) []lsp.Location { pub fn text_range_to_lsp_range(pos psi.TextRange) lsp.Range { return lsp.Range{ start: lsp.Position{ - line: pos.line + line: pos.line character: pos.column } end: lsp.Position{ - line: pos.end_line + line: pos.end_line character: pos.end_column } } @@ -45,7 +45,7 @@ pub fn elements_to_text_edits(elements []psi.PsiElement, new_name string) []lsp. element.text_range() } result << lsp.TextEdit{ - range: text_range_to_lsp_range(range) + range: text_range_to_lsp_range(range) new_text: new_name } } @@ -55,14 +55,14 @@ pub fn elements_to_text_edits(elements []psi.PsiElement, new_name string) []lsp. pub fn position_to_lsp_position(pos psi.Position) lsp.Position { return lsp.Position{ - line: pos.line + line: pos.line character: pos.character } } pub fn lsp_position_to_position(pos lsp.Position) psi.Position { return psi.Position{ - line: pos.line + line: pos.line character: pos.character } } diff --git a/src/streams/streams.v b/src/streams/streams.v index fac4bf14..66dc08e4 100644 --- a/src/streams/streams.v +++ b/src/streams/streams.v @@ -115,10 +115,10 @@ pub fn new_socket_stream_server(port int, log bool) !io.ReaderWriter { mut stream := &SocketStream{ log_label: server_label - log: log - port: port - conn: conn - reader: reader + log: log + port: port + conn: conn + reader: reader } return stream @@ -132,10 +132,10 @@ fn new_socket_stream_client(port int) !io.ReaderWriter { mut stream := &SocketStream{ log_label: 'v-analyzer-client' - log: false - port: port - conn: conn - reader: reader + log: false + port: port + conn: conn + reader: reader } return stream } diff --git a/src/testing/TestFixture.v b/src/testing/TestFixture.v index 5237d90a..49f65922 100644 --- a/src/testing/TestFixture.v +++ b/src/testing/TestFixture.v @@ -37,7 +37,7 @@ pub fn new_fixture() &Fixture { mut stream := &client.TestStream{} mut jsonprc_server := &jsonrpc.Server{ - stream: stream + stream: stream handler: ls } @@ -47,9 +47,9 @@ pub fn new_fixture() &Fixture { } return &Fixture{ - ls: ls - stream: stream - server: jsonprc_server + ls: ls + stream: stream + server: jsonprc_server test_client: test_client } } @@ -64,17 +64,17 @@ pub fn (mut t Fixture) initialize(with_stdlib bool) !lsp.InitializeResult { result := t.test_client.send[lsp.InitializeParams, lsp.InitializeResult]('initialize', lsp.InitializeParams{ - process_id: 75556 + process_id: 75556 client_info: lsp.ClientInfo{ - name: 'Testing' + name: 'Testing' version: '0.0.1' } - root_uri: lsp.document_uri_from_path(testing.temp_path) - root_path: testing.temp_path + root_uri: lsp.document_uri_from_path(testing.temp_path) + root_path: testing.temp_path initialization_options: options.join(' ') - capabilities: lsp.ClientCapabilities{} - trace: '' - workspace_folders: [] + capabilities: lsp.ClientCapabilities{} + trace: '' + workspace_folders: [] })! return result @@ -99,9 +99,9 @@ pub fn (mut t Fixture) configure_by_file(path string) ! { } t.current_file = TestFile{ - path: abs_path + path: abs_path content: prepared_content.split_into_lines() - caret: t.caret_pos(prepared_text) + caret: t.caret_pos(prepared_text) } t.send_open_current_file_request()! @@ -120,9 +120,9 @@ pub fn (mut t Fixture) configure_by_text(filename string, text string) ! { } t.current_file = TestFile{ - path: abs_path + path: abs_path content: content.split_into_lines() - caret: t.caret_pos(prepared_text) + caret: t.caret_pos(prepared_text) } t.send_open_current_file_request()! @@ -132,17 +132,17 @@ fn (mut t Fixture) send_open_current_file_request() ! { t.test_client.send[lsp.DidOpenTextDocumentParams, jsonrpc.Null]('textDocument/didOpen', lsp.DidOpenTextDocumentParams{ text_document: lsp.TextDocumentItem{ - uri: lsp.document_uri_from_path(t.current_file.path) + uri: lsp.document_uri_from_path(t.current_file.path) language_id: 'v' - version: 1 - text: t.current_file.content.join('\n') + version: 1 + text: t.current_file.content.join('\n') } }) or {} t.test_client.send[lsp.DidChangeTextDocumentParams, jsonrpc.Null]('textDocument/didChange', lsp.DidChangeTextDocumentParams{ text_document: lsp.VersionedTextDocumentIdentifier{ - uri: lsp.document_uri_from_path(t.current_file.path) + uri: lsp.document_uri_from_path(t.current_file.path) version: 1 } content_changes: [ @@ -190,7 +190,7 @@ pub fn (mut t Fixture) complete(pos lsp.Position) []lsp.CompletionItem { uri: lsp.document_uri_from_path(t.current_file.path) } position: pos - context: lsp.CompletionContext{ + context: lsp.CompletionContext{ trigger_kind: .invoked } }) or { []lsp.CompletionItem{} } @@ -300,14 +300,14 @@ pub fn (mut t Fixture) caret_pos(file string) lsp.Position { for index, line in file.split_into_lines() { if line.contains('/*caret*/') { return lsp.Position{ - line: index + line: index character: line.index('/*caret*/') or { 0 } } } } return lsp.Position{ - line: 0 + line: 0 character: 0 } } diff --git a/src/testing/Tester.v b/src/testing/Tester.v index 31f26e28..a755ca38 100644 --- a/src/testing/Tester.v +++ b/src/testing/Tester.v @@ -22,9 +22,9 @@ pub fn (s TesterStats) print() { pub fn (s TesterStats) merge(other TesterStats) TesterStats { return TesterStats{ - passed: s.passed + other.passed - failed: s.failed + other.failed - skipped: s.skipped + other.skipped + passed: s.passed + other.passed + failed: s.failed + other.failed + skipped: s.skipped + other.skipped duration: s.duration + other.duration } } @@ -117,9 +117,9 @@ pub fn (t Tester) stats() TesterStats { } return TesterStats{ - passed: passed - failed: failed - skipped: skipped + passed: passed + failed: failed + skipped: skipped duration: duration } } @@ -134,8 +134,8 @@ pub fn (mut t Tester) test(name string, test_func TestFunc) { pub fn (mut t Tester) slow_test(name string, test_func TestFunc) { mut test := &Test{ - name: name - func: test_func + name: name + func: test_func with_stdlib: true } t.tests << test diff --git a/src/testing/client/TestClient.v b/src/testing/client/TestClient.v index 0481b38d..fefe1f2a 100644 --- a/src/testing/client/TestClient.v +++ b/src/testing/client/TestClient.v @@ -10,9 +10,9 @@ import datatypes pub fn new_test_client(handler jsonrpc.Handler, interceptors ...jsonrpc.Interceptor) &TestClient { mut stream := &TestStream{} mut server := &jsonrpc.Server{ - handler: handler + handler: handler interceptors: interceptors - stream: stream + stream: stream } return &TestClient{ @@ -43,7 +43,7 @@ pub mut: pub fn (mut tc TestClient) send[T, U](method string, params T) !U { params_json := json.encode(params) req := jsonrpc.Request{ - id: '${tc.id}' + id: '${tc.id}' method: method params: params_json } @@ -64,7 +64,7 @@ pub fn (mut tc TestClient) send[T, U](method string, params T) !U { pub fn (mut tc TestClient) notify[T](method string, params T) ! { params_json := json.encode(params) req := jsonrpc.Request{ - id: '' + id: '' method: method params: params_json } diff --git a/src/utils.v b/src/utils.v index d1dec9d2..f684e5d9 100644 --- a/src/utils.v +++ b/src/utils.v @@ -35,7 +35,7 @@ pub fn call_install_vsh(cmd string) !int { } mut command := os.Command{ - path: 'v ${analyzer_install_script_path} ${cmd}' + path: 'v ${analyzer_install_script_path} ${cmd}' redirect_stdout: true } diff --git a/tree_sitter_v/bindings/bindings.c.v b/tree_sitter_v/bindings/bindings.c.v index 1bb114a1..2348accd 100644 --- a/tree_sitter_v/bindings/bindings.c.v +++ b/tree_sitter_v/bindings/bindings.c.v @@ -103,8 +103,8 @@ fn byte_array_input_read(pl voidptr, byte_index u32, position C.TSPoint, bytes_r fn (mut p C.TSParser) parse_bytes_with_old_tree(content []u8, old_tree &TSTree) &TSTree { return p.parse(old_tree, - payload: &content - read: byte_array_input_read + payload: &content + read: byte_array_input_read encoding: int(TSVInputEncoding.utf8) ) } @@ -157,9 +157,9 @@ fn (tree &TSTree) get_changed_ranges(new_tree &TSTree) []C.TSRange { return unsafe { array{ element_size: element_size - len: int(len) - cap: int(len) - data: buf + len: int(len) + cap: int(len) + data: buf } } } @@ -275,9 +275,9 @@ fn (node C.TSNode) end_byte() u32 { fn (node C.TSNode) range() C.TSRange { return C.TSRange{ start_point: node.start_point() - end_point: node.end_point() - start_byte: node.start_byte() - end_byte: node.end_byte() + end_point: node.end_point() + start_byte: node.start_byte() + end_byte: node.end_byte() } } diff --git a/tree_sitter_v/bindings/bindings.v b/tree_sitter_v/bindings/bindings.v index 7bfe5dac..ffbf10c5 100644 --- a/tree_sitter_v/bindings/bindings.v +++ b/tree_sitter_v/bindings/bindings.v @@ -14,7 +14,7 @@ mut: pub fn new_parser[T](type_factory NodeTypeFactory[T]) &Parser[T] { mut parser := new_ts_parser() return &Parser[T]{ - raw_parser: parser + raw_parser: parser type_factory: type_factory } } @@ -32,14 +32,14 @@ pub fn (mut p Parser[T]) reset() { @[params] pub struct ParseConfig { pub: - source string @[required] + source string @[required] tree &TSTree = &TSTree(unsafe { nil }) } pub fn (mut p Parser[T]) parse_string(cfg ParseConfig) &Tree[T] { tree := p.raw_parser.parse_string_with_old_tree(cfg.source, cfg.tree) return &Tree[T]{ - raw_tree: tree + raw_tree: tree type_factory: p.type_factory } } @@ -65,9 +65,9 @@ pub fn (tree Tree[T]) root_node() Node[T] { pub fn new_tsnode[T](factory NodeTypeFactory[T], node TSNode) Node[T] { return Node[T]{ - raw_node: node + raw_node: node type_factory: factory - type_name: factory.get_type(node.type_name()) + type_name: factory.get_type(node.type_name()) } } @@ -337,7 +337,7 @@ pub fn (node Node[T]) equal(other_node Node[T]) bool { pub fn (node Node[T]) tree_cursor() TreeCursor[T] { return TreeCursor[T]{ type_factory: node.type_factory - raw_cursor: node.raw_node.tree_cursor() + raw_cursor: node.raw_node.tree_cursor() } } diff --git a/tree_sitter_v/bindings/generate_types.vsh b/tree_sitter_v/bindings/generate_types.vsh index 92ce91ac..f691250e 100644 --- a/tree_sitter_v/bindings/generate_types.vsh +++ b/tree_sitter_v/bindings/generate_types.vsh @@ -48,7 +48,7 @@ fn write_const_enum_array(mut wr strings.Builder, var_name string, enum_type_nam } struct TSNodeType { - name string @[json: 'type'] + name string @[json: 'type'] named bool subtypes []TSNodeType }