From 5670ec2d9bc1bc71337a6d214c6cd58f1dc2c1ff Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sat, 6 Apr 2024 19:13:45 +0200 Subject: [PATCH 1/2] analyzer: add `pub` access modifier to publicly used struct fields --- src/analyzer/psi/ReferenceImpl.v | 1 + src/analyzer/psi/StubbedElementTypeImpl.v | 2 ++ src/analyzer/psi/search/ReferencesSearch.v | 1 + src/jsonrpc/jsonrpc.v | 1 + src/jsonrpc/server.v | 1 + src/lsp/document_highlight.v | 1 + src/lsp/signature_help.v | 2 ++ src/lsp/window.v | 3 +++ src/main.v | 8 +++----- .../completion/providers/ReferenceCompletionProcessor.v | 1 + src/server/hints/InlayHintsVisitor.v | 1 + src/server/inspections/compiler/CompilerReportsSource.v | 1 + src/testing/BenchmarkRunner.v | 5 +++-- tree_sitter_v/bindings/bindings.v | 1 + 14 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/analyzer/psi/ReferenceImpl.v b/src/analyzer/psi/ReferenceImpl.v index 2d0f5ee7..9a9c84ef 100644 --- a/src/analyzer/psi/ReferenceImpl.v +++ b/src/analyzer/psi/ReferenceImpl.v @@ -58,6 +58,7 @@ pub fn (r &ReferenceImpl) resolve() ?PsiElement { } pub struct SubResolver { +pub: containing_file &PsiFile element ReferenceExpressionBase for_types bool diff --git a/src/analyzer/psi/StubbedElementTypeImpl.v b/src/analyzer/psi/StubbedElementTypeImpl.v index b8940c83..c49f8e91 100644 --- a/src/analyzer/psi/StubbedElementTypeImpl.v +++ b/src/analyzer/psi/StubbedElementTypeImpl.v @@ -600,6 +600,7 @@ pub fn (s &StubbedElementType) create_stub(psi PsiElement, parent_stub &StubBase @[params] struct StubParams { +pub: include_text bool additional string } @@ -617,6 +618,7 @@ pub fn declaration_stub(psi PsiNamedElement, parent_stub &StubElement, stub_type @[params] struct TestStubParams { +pub: include_text bool = true } diff --git a/src/analyzer/psi/search/ReferencesSearch.v b/src/analyzer/psi/search/ReferencesSearch.v index 994042d1..1a7e3ac5 100644 --- a/src/analyzer/psi/search/ReferencesSearch.v +++ b/src/analyzer/psi/search/ReferencesSearch.v @@ -9,6 +9,7 @@ import loglib @[params] pub struct SearchParams { +pub: // include_declaration indicates whether to include the declaration // of the symbol in the search results // This is useful when we want to find all usages of a symbol for diff --git a/src/jsonrpc/jsonrpc.v b/src/jsonrpc/jsonrpc.v index cd5e6945..81f0987f 100644 --- a/src/jsonrpc/jsonrpc.v +++ b/src/jsonrpc/jsonrpc.v @@ -192,6 +192,7 @@ pub fn (e ResponseError) err() IError { @[params] pub struct ResponseErrorGeneratorParams { +pub: error IError @[required] data string } diff --git a/src/jsonrpc/server.v b/src/jsonrpc/server.v index c7db1e85..e2ed5340 100644 --- a/src/jsonrpc/server.v +++ b/src/jsonrpc/server.v @@ -116,6 +116,7 @@ fn (mut s Server) internal_respond(mut base_rw ResponseWriter) ! { @[params] pub struct NewWriterConfig { +pub: own_buffer bool } diff --git a/src/lsp/document_highlight.v b/src/lsp/document_highlight.v index b63a93f4..4c0cfbc3 100644 --- a/src/lsp/document_highlight.v +++ b/src/lsp/document_highlight.v @@ -4,6 +4,7 @@ module lsp // response: []DocumentHighlight | none // request: TextDocumentPositionParams pub struct DocumentHighlight { +pub: range Range kind DocumentHighlightKind } diff --git a/src/lsp/signature_help.v b/src/lsp/signature_help.v index 1bc1b74b..08c5a0ad 100644 --- a/src/lsp/signature_help.v +++ b/src/lsp/signature_help.v @@ -1,6 +1,7 @@ module lsp pub struct SignatureHelpOptions { +pub: trigger_characters []string @[json: triggerCharacters] retrigger_characters []string @[json: retriggerCharacters] } @@ -47,6 +48,7 @@ pub mut: } pub struct ParameterInformation { +pub: label string } diff --git a/src/lsp/window.v b/src/lsp/window.v index c49f5504..a048205d 100644 --- a/src/lsp/window.v +++ b/src/lsp/window.v @@ -3,6 +3,7 @@ module lsp // method: ‘window/showMessage’ // notification pub struct ShowMessageParams { +pub: @type MessageType // @type int message string @@ -19,6 +20,7 @@ pub enum MessageType { // method: ‘window/showMessageRequest’ // response: MessageActionItem | none / null pub struct ShowMessageRequestParams { +pub: @type MessageType message string actions []MessageActionItem @@ -31,6 +33,7 @@ pub struct MessageActionItem { // method: ‘window/logMessage’ // notification pub struct LogMessageParams { +pub: @type MessageType message string } diff --git a/src/main.v b/src/main.v index 8b195347..3303f14d 100644 --- a/src/main.v +++ b/src/main.v @@ -46,13 +46,11 @@ fn run(cmd cli.Command) ! { mut ls := server.LanguageServer.new(analyzer.IndexingManager.new()) mut jrpc_server := &jsonrpc.Server{ stream: stream - interceptors: [ - &log.LogRecorder{ - enabled: true - }, - ] handler: ls } + mut lr := log.LogRecorder{} + lr.enable() + jrpc_server.interceptors = [&lr] defer { mut out := loglib.get_output() diff --git a/src/server/completion/providers/ReferenceCompletionProcessor.v b/src/server/completion/providers/ReferenceCompletionProcessor.v index ab085ad3..5bf1fc71 100644 --- a/src/server/completion/providers/ReferenceCompletionProcessor.v +++ b/src/server/completion/providers/ReferenceCompletionProcessor.v @@ -7,6 +7,7 @@ import analyzer.lang import server.completion pub struct ReferenceCompletionProcessor { +pub: file &psi.PsiFile module_fqn string root string diff --git a/src/server/hints/InlayHintsVisitor.v b/src/server/hints/InlayHintsVisitor.v index 24996eb9..16f4dd51 100644 --- a/src/server/hints/InlayHintsVisitor.v +++ b/src/server/hints/InlayHintsVisitor.v @@ -6,6 +6,7 @@ import analyzer.psi import analyzer.psi.types pub struct InlayHintsVisitor { +pub: cfg config.InlayHintsConfig pub mut: lines int diff --git a/src/server/inspections/compiler/CompilerReportsSource.v b/src/server/inspections/compiler/CompilerReportsSource.v index daf6c191..356d4575 100644 --- a/src/server/inspections/compiler/CompilerReportsSource.v +++ b/src/server/inspections/compiler/CompilerReportsSource.v @@ -4,6 +4,7 @@ import lsp import server.inspections pub struct CompilerReportsSource { +pub: compiler_path string } diff --git a/src/testing/BenchmarkRunner.v b/src/testing/BenchmarkRunner.v index 3e19d875..36e027f3 100644 --- a/src/testing/BenchmarkRunner.v +++ b/src/testing/BenchmarkRunner.v @@ -1,9 +1,10 @@ module testing pub struct BenchmarkRunner { -mut: - benchmarks []&Benchmark +pub mut: last_fixture &Fixture +mut: + benchmarks []&Benchmark } pub fn (mut b BenchmarkRunner) create_or_reuse_fixture() &Fixture { diff --git a/tree_sitter_v/bindings/bindings.v b/tree_sitter_v/bindings/bindings.v index 8b6f85f3..7bfe5dac 100644 --- a/tree_sitter_v/bindings/bindings.v +++ b/tree_sitter_v/bindings/bindings.v @@ -31,6 +31,7 @@ pub fn (mut p Parser[T]) reset() { @[params] pub struct ParseConfig { +pub: source string @[required] tree &TSTree = &TSTree(unsafe { nil }) } From cc8e98d9c24f23c5d0b90fc88d7d4ba41cb6fcef Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sat, 6 Apr 2024 19:18:07 +0200 Subject: [PATCH 2/2] sort --- src/testing/BenchmarkRunner.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/testing/BenchmarkRunner.v b/src/testing/BenchmarkRunner.v index 36e027f3..95af3845 100644 --- a/src/testing/BenchmarkRunner.v +++ b/src/testing/BenchmarkRunner.v @@ -1,10 +1,10 @@ module testing pub struct BenchmarkRunner { -pub mut: - last_fixture &Fixture mut: benchmarks []&Benchmark +pub mut: + last_fixture &Fixture } pub fn (mut b BenchmarkRunner) create_or_reuse_fixture() &Fixture {