Sarrus1 / sourcepawn-studio

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

Request textDocument/documentSymbol failed #330

Open Dragonisser opened 1 year ago

Dragonisser commented 1 year ago

Basic informations

Further Information

Error below keeps popping up from time to time

Afterwards i cant ctrl+leftclick on functions to jump to its declaration I need to restart the sourcepawn-lsp server to make it work again

To Reproduce

  1. Open project
  2. Write code
  3. Wait patiently for the error
  4. Error

Code to reproduce the behaviour

https://github.com/tf2td/towerdefense

Expected behaviour

No error

Error messages

[2023-08-09T21:00:12.986Z INFO] Telemetry is enabled. To disable it, use the --disable-telemetry flag.
[2023-08-09T21:00:12.987Z INFO] Starting sourcepawn-lsp version 0.10.19
[2023-08-09T21:00:14.577Z INFO] Received config [
    Object {
        "disableSyntaxLinter": Bool(false),
        "includesDirectories": Array [],
        "linterArguments": Array [],
        "mainPath": String("c:\\Users\\Dragonisser\\vscode\\towerdefense\\addons\\sourcemod\\scripting\\towerdefense.sp"),
        "spcompPath": String("E:\\sourcemod-1.11.0-git6936-windows\\addons\\sourcemod\\scripting\\spcomp.exe"),
    },
]
[2023-08-09T21:00:15.406Z INFO] Scanned all the files in 828.76ms:
    - 108 file(s) were scanned.
    - Parsing took 557.04ms.
    - Analysis took 271.72ms.
        - Analysis took 256.77ms.
        - Getting all items 14.95ms.
            - Getting includes took 3.43ms.
            - Cloning items took 11.52ms.

[Error - 11:00:15 PM] Request textDocument/documentSymbol failed.
Error: name must not be falsy
    at n.validate (c:\Users\Dragonisser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:16862)
    at new n (c:\Users\Dragonisser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:17157)
    at ye (c:\Users\Dragonisser\.vscode\extensions\sarrus.sourcepawn-vscode-5.5.5-win32-x64\dist\spIndex.js:430:73787)
    at ye (c:\Users\Dragonisser\.vscode\extensions\sarrus.sourcepawn-vscode-5.5.5-win32-x64\dist\spIndex.js:430:73968)
    at o (c:\Users\Dragonisser\.vscode\extensions\sarrus.sourcepawn-vscode-5.5.5-win32-x64\dist\spIndex.js:430:48842)
    at Object.Kse [as map] (c:\Users\Dragonisser\.vscode\extensions\sarrus.sourcepawn-vscode-5.5.5-win32-x64\dist\spIndex.js:430:48928)
    at Object.wr [as asDocumentSymbols] (c:\Users\Dragonisser\.vscode\extensions\sarrus.sourcepawn-vscode-5.5.5-win32-x64\dist\spIndex.js:430:73754)
    at c (c:\Users\Dragonisser\.vscode\extensions\sarrus.sourcepawn-vscode-5.5.5-win32-x64\dist\spIndex.js:434:56081)
    at async n.provideDocumentSymbols (c:\Users\Dragonisser\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:104:37143)
Sarrus1 commented 10 months ago

Are you able to reproduce this in the latest versions?

Dragonisser commented 10 months ago

I haven't encountered it yet, tho i wasn't really using it either lately. If i run into it again ill let you know.

Dragonisser commented 10 months ago

Still happens:

[2023-10-10T11:55:21.977Z WARN] Unknown notification: textDocument/didSave
[2023-10-10T11:55:26.594Z WARN] Unknown notification: textDocument/didSave
[2023-10-10T11:55:29.461Z WARN] Unknown notification: textDocument/didSave
[Error - 1:55:42 PM] Request textDocument/documentSymbol failed.
Error: name must not be falsy
    at r.validate (c:\Users\acks\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:121:16990)
    at new r (c:\Users\acks\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:121:17285)
    at ye (c:\Users\acks\.vscode\extensions\sarrus.sourcepawn-vscode-6.1.0-win32-x64\dist\spIndex.js:34:73456)
    at ye (c:\Users\acks\.vscode\extensions\sarrus.sourcepawn-vscode-6.1.0-win32-x64\dist\spIndex.js:34:73637)
    at o (c:\Users\acks\.vscode\extensions\sarrus.sourcepawn-vscode-6.1.0-win32-x64\dist\spIndex.js:34:48563)
    at Object.oj [as map] (c:\Users\acks\.vscode\extensions\sarrus.sourcepawn-vscode-6.1.0-win32-x64\dist\spIndex.js:34:48649)
    at Object.wr [as asDocumentSymbols] (c:\Users\acks\.vscode\extensions\sarrus.sourcepawn-vscode-6.1.0-win32-x64\dist\spIndex.js:34:73423)
    at c (c:\Users\acks\.vscode\extensions\sarrus.sourcepawn-vscode-6.1.0-win32-x64\dist\spIndex.js:38:56041)
    at async r.provideDocumentSymbols (c:\Users\acks\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:127:37581)
[2023-10-10T11:55:51.922Z WARN] Unknown notification: textDocument/didSave
[2023-10-10T11:55:53.431Z WARN] Unknown notification: textDocument/didSave
Phil25 commented 9 months ago

It's happening consistently for me in the TF2 RTD plugin, though its code is old and convoluted and I wasn't able to track it down to anything specific.

It only happens when you're editing the main scripting/rtd.sp file. If you go to scripting/rtd/perks/drugged.sp (or pretty much any other script file) then there aren't any issues.

Edit

A better repro is scripting/rtd/storage/precached.sp. It's smaller, relatively self-contained and doesn't include anything. Found the issue for that file, I had an empty enum like this:

enum TEParticleId
{
}

If I add ex. INVALID_PARTICLE_ID = -1 as a field it fixes the error. However, it's still popping up in the main rtd.sp file.

My issue is likely related to overabundant use of macros in methodmaps, ex. in scripting/rtd/classes/perk.sp. Which probably isn't OP's problem.

Logs

[2023-11-01T03:31:22.950Z INFO] Telemetry is enabled. To disable it, use the --disable-telemetry flag.
[2023-11-01T03:31:22.951Z INFO] Starting sourcepawn-lsp version 0.12.0
[2023-11-01T03:31:22.957Z INFO] Received config [
    Object {
        "disableSyntaxLinter": Bool(false),
        "includesDirectories": Array [],
        "linterArguments": Array [],
        "mainPath": String("U:\\Work\\Code\\RTD\\scripting\\rtd.sp"),
        "spcompPath": String("U:\\Work\\Code\\RTD\\scripting\\spcomp.exe"),
    },
]
[2023-11-01T03:31:23.746Z ERROR] Unknown token: Range {
    start: Position {
        line: 206,
        character: 54,
    },
    end: Position {
        line: 206,
        character: 55,
    },
}
[2023-11-01T03:31:23.832Z ERROR] Unknown token: Range {
    start: Position {
        line: 206,
        character: 54,
    },
    end: Position {
        line: 206,
        character: 55,
    },
}
[2023-11-01T03:31:24.014Z ERROR] Unknown token: Range {
    start: Position {
        line: 206,
        character: 54,
    },
    end: Position {
        line: 206,
        character: 55,
    },
}
[2023-11-01T03:31:24.164Z WARN] Unknown notification: $/setTrace
[2023-11-01T03:31:24.164Z WARN] Unknown notification: $/setTrace
[2023-11-01T03:31:24.164Z WARN] Unknown notification: $/setTrace
[2023-11-01T03:31:24.520Z WARN] Unknown notification: $/setTrace
[2023-11-01T03:31:24.520Z WARN] Unknown notification: $/setTrace
[2023-11-01T03:31:24.520Z WARN] Unknown notification: $/setTrace
[Error - 4:31:24 AM] Request textDocument/documentSymbol failed.
Error: name must not be falsy
    at r.validate (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:121:16990)
    at new r (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:121:17285)
    at ye (c:\Users\phil\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:73456)
    at ye (c:\Users\phil\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:73637)
    at o (c:\Users\phil\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:48563)
    at Object.oj [as map] (c:\Users\phil\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:48649)
    at Object.wr [as asDocumentSymbols] (c:\Users\phil\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:73423)
    at c (c:\Users\phil\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:38:56041)
    at async r.provideDocumentSymbols (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:127:37581)
Sarrus1 commented 9 months ago

Thanks for the details, will look into that!

Dragonisser commented 9 months ago

In my case its with this plugin, but i couldnt narrow it down. https://github.com/tf2td/towerdefense

Toyguna commented 9 months ago

I have the same problem as well, fortunately I have reproduced the bug. The bug only occurs when an EMPTY enum exists in a file, doesn't matter if an inc file or an sp file.


enum Test
{
   // This will result in "Request textDocument/documentSymbol failed."
   // L Error: name must not be falsy
}

But this will not:


enum Test
{
   TEST_ENUM1
}

However, sadly none of the files the OP and others commented on have empty enums in them, I guess I just encountered another producer of the bug.

( Also autocompletion seems to be broken in .inc files but that is another issue for another day :) )

Classes123 commented 7 months ago

the same error occurs when the extension tries to show an overview of the function, idk, maybe it's somehow related to enums.

enum UITaskMessage_Color {
    UITaskMessage_Fail,
    UITaskMessage_Success
}

void UITaskMessage_Display(WCPlayer pl, UITaskMessage_Color color, )
{

}

image

[Error - 11:43:06 PM] Request textDocument/documentSymbol failed.
Error: name must not be falsy
    at d.validate (c:\Users\*\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:137:17256)
    at new d (c:\Users\*\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:137:17551)
    at ye (c:\Users\*\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:73456)
    at ye (c:\Users\*\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:73637)
    at o (c:\Users\*\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:48563)
    at Object.oj [as map] (c:\Users\*\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:48649)
    at Object.wr [as asDocumentSymbols] (c:\Users\*\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:34:73423)
    at c (c:\Users\*\.vscode\extensions\sarrus.sourcepawn-vscode-6.2.0-win32-x64\dist\spIndex.js:38:56041)
    at async d.provideDocumentSymbols (c:\Users\*\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:143:39616)
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:49:37.021Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19044

Extension version: v6.2.0

Dragonisser commented 4 months ago

Sadly its still happening and i have no idea why.

stas11s11t commented 1 month ago

This is terrible, I just type "char" and this window immediately pops up and even the AI ​​can’t help turn off this annoying window. It's strange that there is no setting in VS Code to disable it. This is just spam that prevents you from writing code.

Sarrus1 commented 1 month ago

I will look into this again, it seems like the empty enum name error is back.