Sarrus1 / sourcepawn-studio

VSCode extension for SourcePawn scripting
https://sarrus1.github.io/sourcepawn-studio/
MIT License
139 stars 21 forks source link

Prerelease crashes if there is no workspace present #382

Closed chrb22 closed 1 month ago

chrb22 commented 2 months ago

Something simple like

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    PrintToServer("Hello, World!");
}

crashes with the prerelease version if there is no workspace that contains the sp file (which is the default in something like Sublime Text).

LSP log:

:: [19:23:54.033] --> sourcepawn initialize (1): {'processId': 50389, 'clientInfo': {'name': 'Sublime Text LSP', 'version': '2.0.0'}, 'rootUri': None, 'rootPath': None, 'workspaceFolders': None, 'capabilities': {'general': {'regularExpressions': {'engine': 'ECMAScript'}, 'markdown': {'parser': 'Python-Markdown', 'version': '3.2.2'}}, 'textDocument': {'synchronization': {'dynamicRegistration': True, 'didSave': True, 'willSave': True, 'willSaveWaitUntil': True}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}, 'completion': {'dynamicRegistration': True, 'completionItem': {'snippetSupport': True, 'deprecatedSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'tagSupport': {'valueSet': [1]}, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertReplaceSupport': True, 'insertTextModeSupport': {'valueSet': [2]}, 'labelDetailsSupport': True}, 'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, 'insertTextMode': 2, 'completionList': {'itemDefaults': ['editRange', 'insertTextFormat', 'data']}}, 'signatureHelp': {'dynamicRegistration': True, 'contextSupport': True, 'signatureInformation': {'activeParameterSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'parameterInformation': {'labelOffsetSupport': True}}}, 'references': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'documentSymbol': {'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': True, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, 'tagSupport': {'valueSet': [1]}}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'formatting': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True, 'rangesSupport': True}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'codeAction': {'dynamicRegistration': True, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}, 'dataSupport': True, 'isPreferredSupport': True, 'resolveSupport': {'properties': ['edit']}}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True, 'prepareSupportDefaultBehavior': 1}, 'colorProvider': {'dynamicRegistration': True}, 'publishDiagnostics': {'relatedInformation': True, 'tagSupport': {'valueSet': [1, 2]}, 'versionSupport': True, 'codeDescriptionSupport': True, 'dataSupport': True}, 'diagnostic': {'dynamicRegistration': True, 'relatedDocumentSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'foldingRange': {'dynamicRegistration': True, 'foldingRangeKind': {'valueSet': ['comment', 'imports', 'region']}}, 'codeLens': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'semanticTokens': {'dynamicRegistration': True, 'requests': {'range': True, 'full': {'delta': True}}, 'tokenTypes': ['namespace', 'type', 'class', 'enum', 'interface', 'struct', 'typeParameter', 'parameter', 'variable', 'property', 'enumMember', 'event', 'function', 'method', 'macro', 'keyword', 'modifier', 'comment', 'string', 'number', 'regexp', 'operator', 'decorator'], 'tokenModifiers': ['declaration', 'definition', 'readonly', 'static', 'deprecated', 'abstract', 'async', 'modification', 'documentation', 'defaultLibrary'], 'formats': ['relative'], 'overlappingTokenSupport': False, 'multilineTokenSupport': True, 'augmentsSyntaxTokens': True}, 'callHierarchy': {'dynamicRegistration': True}, 'typeHierarchy': {'dynamicRegistration': True}}, 'workspace': {'applyEdit': True, 'didChangeConfiguration': {'dynamicRegistration': True}, 'executeCommand': {}, 'workspaceEdit': {'documentChanges': True, 'failureHandling': 'abort'}, 'workspaceFolders': True, 'symbol': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['location.range']}, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}, 'tagSupport': {'valueSet': [1]}}, 'configuration': True, 'codeLens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'semanticTokens': {'refreshSupport': True}, 'diagnostics': {'refreshSupport': True}, 'didChangeWatchedFiles': {'dynamicRegistration': True}}, 'window': {'showDocument': {'support': True}, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'workDoneProgress': True}}, 'initializationOptions': {}}
:: [19:23:54.045] <<< sourcepawn (1) (duration: 11ms): {'capabilities': {'positionEncoding': 'utf-16', 'hoverProvider': True, 'completionProvider': {'resolveProvider': True, 'triggerCharacters': ['<', '"', "'", '/', '\\', '.', ':', ' ', '$', '*'], 'completionItem': {'labelDetailsSupport': True}}, 'definitionProvider': True, 'semanticTokensProvider': {'legend': {'tokenTypes': ['comment', 'decorator', 'enumMember', 'enum', 'function', 'interface', 'keyword', 'macro', 'method', 'namespace', 'number', 'operator', 'parameter', 'property', 'string', 'struct', 'typeParameter', 'variable', 'angle', 'arithmetic', 'attribute', 'attributeBracket', 'bitwise', 'boolean', 'brace', 'bracket', 'builtinAttribute', 'builtinType', 'character', 'colon', 'comma', 'comparison', 'constParameter', 'derive', 'deriveHelper', 'dot', 'escapeSequence', 'invalidEscapeSequence', 'formatSpecifier', 'generic', 'label', 'lifetime', 'logical', 'macroBang', 'parenthesis', 'punctuation', 'selfKeyword', 'selfTypeKeyword', 'semicolon', 'typeAlias', 'toolModule', 'union', 'unresolvedReference'], 'tokenModifiers': ['documentation', 'declaration', 'static', 'defaultLibrary', 'async', 'attribute', 'callable', 'constant', 'consuming', 'controlFlow', 'crateRoot', 'injected', 'intraDocLink', 'library', 'macro', 'mutable', 'public', 'reference', 'trait', 'unsafe']}, 'range': True, 'full': {'delta': True}}, 'textDocumentSync': {'didOpen': {}, 'save': {}, 'didClose': {}, 'change': {'syncKind': 2}}}, 'serverInfo': {'name': 'sourcepawn-lsp', 'version': '0.13.0'}}
:: [19:23:54.045]  -> sourcepawn initialized: {}
:: [19:23:54.045]  -> sourcepawn workspace/didChangeConfiguration: {'settings': {'SourcePawnLanguageServer': {'includesDirectories': ['/home/ildprut/Spil/TF2/Sourcemod/scripting/include/'], 'spcompPath': '/home/ildprut/Spil/TF2/Sourcemod/scripting/spcomp'}}}
:: [19:23:54.045] <-- sourcepawn workspace/configuration (initial_config_pull): {'items': [{'section': 'SourcePawnLanguageServer'}]}
:: [19:23:54.046] >>> sourcepawn (initial_config_pull) (duration: 0ms): [{'includesDirectories': ['/home/ildprut/Spil/TF2/Sourcemod/scripting/include/'], 'spcompPath': '/home/ildprut/Spil/TF2/Sourcemod/scripting/spcomp'}]
:: [19:23:54.048]  -> sourcepawn textDocument/didOpen: {'textDocument': {'uri': 'file:///home/ildprut/Spil/TF2/Sourcemod/scripting/lsp/lsp.sp', 'languageId': 'sp', 'version': 0, 'text': '#pragma semicolon 1\n#pragma newdecls required\n\npublic void OnPluginStart()\n{\n    PrintToServer("Hello, World!");\n}'}}
:: [19:23:54.050] <-- sourcepawn workspace/configuration (0): {'items': [{'section': 'SourcePawnLanguageServer'}]}
:: [19:23:54.051] >>> sourcepawn (0) (duration: 0ms): [{'includesDirectories': ['/home/ildprut/Spil/TF2/Sourcemod/scripting/include/'], 'spcompPath': '/home/ildprut/Spil/TF2/Sourcemod/scripting/spcomp'}]
:: [19:23:54.051] <?  sourcepawn sourcepawn-lsp/serverStatus: {'health': 'ok', 'quiescent': False, 'message': None}
:: [19:23:54.051] <-- sourcepawn window/workDoneProgress/create (1): {'token': 'rustAnalyzer/Roots Scanned'}
:: [19:23:54.051] >>> sourcepawn (1) (duration: 0ms): None
:: [19:23:54.051] <-  sourcepawn $/progress: {'token': 'rustAnalyzer/Roots Scanned', 'value': {'kind': 'begin', 'title': 'Roots Scanned', 'cancellable': False, 'message': '0/1', 'percentage': 0}}
:: [19:23:54.051] <-  sourcepawn $/progress: {'token': 'rustAnalyzer/Roots Scanned', 'value': {'kind': 'end', 'message': '1/1'}}
:: [19:23:54.051] <-- sourcepawn workspace/semanticTokens/refresh (2): None
:: [19:23:54.051] >>> sourcepawn (2) (duration: 0ms): None
:: [19:23:54.052] <?  sourcepawn sourcepawn-lsp/serverStatus: {'health': 'ok', 'quiescent': True, 'message': None}
:: [19:23:54.052] <-- sourcepawn window/workDoneProgress/create (3): {'token': 'rustAnalyzer/Indexing'}
:: [19:23:54.052] >>> sourcepawn (3) (duration: 0ms): None
:: [19:23:54.052] <-  sourcepawn $/progress: {'token': 'rustAnalyzer/Indexing', 'value': {'kind': 'begin', 'title': 'Indexing', 'cancellable': False, 'percentage': 0}}
:: [19:23:54.052] <-  sourcepawn $/progress: {'token': 'rustAnalyzer/Indexing', 'value': {'kind': 'end'}}

Crash stack trace:

sourcepawn: thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/salsa-0.17.0-pre.2/src/input.rs:106:32:
sourcepawn: no value set for FileSourceRootQuery(FileId(0))
sourcepawn: stack backtrace:
sourcepawn:    0:     0x56359ec48682 - std::backtrace_rs::backtrace::libunwind::trace::he4ee80166a02c846
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
sourcepawn:    1:     0x56359ec48682 - std::backtrace_rs::backtrace::trace_unsynchronized::h476faccf57e88641
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
sourcepawn:    2:     0x56359ec48682 - std::sys_common::backtrace::_print_fmt::h430c922a77e7a59c
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:68:5
sourcepawn:    3:     0x56359ec48682 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hffecb437d922f988
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:44:22
sourcepawn:    4:     0x56359ec763ec - core::fmt::rt::Argument::fmt::hf3df69369399bfa9
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/rt.rs:142:9
sourcepawn:    5:     0x56359ec763ec - core::fmt::write::hd9a8d7d029f9ea1a
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/mod.rs:1153:17
sourcepawn:    6:     0x56359ec44f8f - std::io::Write::write_fmt::h0e1226b2b8d973fe
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/io/mod.rs:1843:15
sourcepawn:    7:     0x56359ec48454 - std::sys_common::backtrace::_print::hd2df4a083f6e69b8
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:47:5
sourcepawn:    8:     0x56359ec48454 - std::sys_common::backtrace::print::he907f6ad7eee41cb
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:34:9
sourcepawn:    9:     0x56359ec49ffb - std::panicking::default_hook::{{closure}}::h3926193b61c9ca9b
sourcepawn:   10:     0x56359ec49d53 - std::panicking::default_hook::h25ba2457dea68e65
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:292:9
sourcepawn:   11:     0x56359ec4a630 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h022ca2c0d8c21c9e
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
sourcepawn:   12:     0x56359ec4a630 - std::panicking::rust_panic_with_hook::h0ad14d90dcf5224f
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13
sourcepawn:   13:     0x56359ec4a372 - std::panicking::begin_panic_handler::{{closure}}::h4a1838a06f542647
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:657:13
sourcepawn:   14:     0x56359ec48b56 - std::sys_common::backtrace::__rust_end_short_backtrace::h77cc4dc3567ca904
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18
sourcepawn:   15:     0x56359ec4a0a4 - rust_begin_unwind
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
sourcepawn:   16:     0x56359e208ef5 - core::panicking::panic_fmt::h940d4fd01a4b4fd1
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
sourcepawn:   17:     0x56359ea77607 - <salsa::input::InputStorage<Q> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch::{{closure}}::he5d1f612fd22d413
sourcepawn:                                at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/salsa-0.17.0-pre.2/src/input.rs:106:32
sourcepawn:   18:     0x56359ea77607 - core::option::Option<T>::unwrap_or_else::h6081d462706d2021
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:978:21
sourcepawn:   19:     0x56359ea77607 - <salsa::input::InputStorage<Q> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch::h204c24815dc4e251
sourcepawn:                                at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/salsa-0.17.0-pre.2/src/input.rs:106:14
sourcepawn:   20:     0x56359ea660ca - salsa::QueryTable<Q>::try_get::h103a9f58162bde5e
sourcepawn:                                at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/salsa-0.17.0-pre.2/src/lib.rs:426:9
sourcepawn:   21:     0x56359ea660ca - salsa::QueryTable<Q>::get::h103564b32a9fc94b
sourcepawn:                                at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/salsa-0.17.0-pre.2/src/lib.rs:421:9
sourcepawn:   22:     0x56359ea660ca - <DB as base_db::SourceDatabaseExt>::file_source_root::__shim::hc3d5437af6c0ec08
sourcepawn:                                at /home/runner/work/sourcepawn-vscode/sourcepawn-vscode/crates/base-db/src/lib.rs:128:1
sourcepawn:   23:     0x56359ea65039 - base_db::change::Change::apply::hb4f0fa1c12d35210
sourcepawn:                                at /home/runner/work/sourcepawn-vscode/sourcepawn-vscode/crates/base-db/src/change.rs:64:34
sourcepawn:   24:     0x56359e738ba0 - sourcepawn_lsp::global_state::GlobalState::process_changes::h9425724bcbab8559
sourcepawn:                                at /home/runner/work/sourcepawn-vscode/sourcepawn-vscode/crates/sourcepawn_lsp/src/global_state.rs:346:9
sourcepawn:   25:     0x56359e738ba0 - sourcepawn_lsp::main_loop::<impl sourcepawn_lsp::global_state::GlobalState>::handle_event::hb7ff32c6d96db435
sourcepawn:                                at /home/runner/work/sourcepawn-vscode/sourcepawn-vscode/crates/sourcepawn_lsp/src/main_loop.rs:652:29
sourcepawn:   26:     0x56359e734938 - sourcepawn_lsp::main_loop::<impl sourcepawn_lsp::global_state::GlobalState>::run::h10864b35f24b4c89
sourcepawn:                                at /home/runner/work/sourcepawn-vscode/sourcepawn-vscode/crates/sourcepawn_lsp/src/main_loop.rs:85:13
sourcepawn:   27:     0x56359e20ed15 - sourcepawn_lsp::main::hde4fc0c03ae6e731
sourcepawn:                                at /home/runner/work/sourcepawn-vscode/sourcepawn-vscode/crates/sourcepawn_lsp/src/main.rs:62:5
sourcepawn:   28:     0x56359e21d723 - core::ops::function::FnOnce::call_once::h5c3f0a398c75b028
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
sourcepawn:   29:     0x56359e21d723 - std::sys_common::backtrace::__rust_begin_short_backtrace::h3c1b4905571c53ca
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:155:18
sourcepawn:   30:     0x56359e21e6d1 - std::rt::lang_start::{{closure}}::haed130fbae745eb3
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:166:18
sourcepawn:   31:     0x56359ec3c023 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h52f5991f9ab8b369
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:284:13
sourcepawn:   32:     0x56359ec3c023 - std::panicking::try::do_call::h0ac4bee9a397a1bf
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:552:40
sourcepawn:   33:     0x56359ec3c023 - std::panicking::try::hc005decaf198d0ed
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:516:19
sourcepawn:   34:     0x56359ec3c023 - std::panic::catch_unwind::hb0f967d870b2a382
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panic.rs:146:14
sourcepawn:   35:     0x56359ec3c023 - std::rt::lang_start_internal::{{closure}}::hd140b84b0efe534b
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:148:48
sourcepawn:   36:     0x56359ec3c023 - std::panicking::try::do_call::h1ddfaf1d0d576c38
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:552:40
sourcepawn:   37:     0x56359ec3c023 - std::panicking::try::hdd4bdf855547659f
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:516:19
sourcepawn:   38:     0x56359ec3c023 - std::panic::catch_unwind::h276ba91c7706110c
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panic.rs:146:14
sourcepawn:   39:     0x56359ec3c023 - std::rt::lang_start_internal::h103c42a9c4e95084
sourcepawn:                                at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/rt.rs:148:20
sourcepawn:   40:     0x56359e21180c - main
sourcepawn:   41:     0x7fa80af83cd0 - <unknown>
sourcepawn:   42:     0x7fa80af83d8a - __libc_start_main
sourcepawn:   43:     0x56359e2095ae - _start
sourcepawn:   44:                0x0 - <unknown>
Sarrus1 commented 1 month ago

Fixed by https://github.com/Sarrus1/sourcepawn-vscode/pull/391