vknabel / vscode-swift-development-environment

New home of Swift Development Environment for VS Code
https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-swift-development-environment
Apache License 2.0
175 stars 14 forks source link

When editing a C/C++ file, the "output" tab at the bottom is always showing something. #78

Closed wantyapps closed 3 years ago

vknabel commented 4 years ago

Hi @wantyapps!

Thanks for opening an issue. As I currently don't have time to debug: what does it show? Can you provide the output or a screenshot?

This would be extremely helpful.

wantyapps commented 4 years ago
Screen Shot 2020-08-27 at 17 50 18

Here

wantyapps commented 4 years ago
I[16:58:54.155] <-- textDocument/didChange
I[16:58:54.659] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
I[16:58:54.672] --> textDocument/publishDiagnostics
I[16:58:55.161] <-- textDocument/documentColor(9)
I[16:58:55.161] --> reply:textDocument/documentColor(9) 0 ms, error: -32601: method not found
[Error - 4:58:55 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[16:58:55.892] <-- textDocument/documentSymbol(10)
I[16:58:55.892] --> reply:textDocument/documentSymbol(10) 0 ms
I[17:00:24.478] <-- textDocument/documentColor(11)
I[17:00:24.478] --> reply:textDocument/documentColor(11) 0 ms, error: -32601: method not found
[Error - 5:00:24 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[17:00:24.485] <-- textDocument/documentSymbol(12)
I[17:00:24.486] --> reply:textDocument/documentSymbol(12) 1 ms
I[17:00:32.059] <-- textDocument/didChange
I[17:00:32.302] <-- textDocument/codeAction(13)
I[17:00:32.303] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
I[17:00:32.316] --> textDocument/publishDiagnostics
I[17:00:32.316] --> reply:textDocument/codeAction(13) 13 ms
I[17:00:32.574] <-- textDocument/codeAction(14)
I[17:00:32.574] --> reply:textDocument/codeAction(14) 0 ms
I[17:00:33.054] <-- textDocument/documentColor(15)
I[17:00:33.054] --> reply:textDocument/documentColor(15) 0 ms, error: -32601: method not found
[Error - 5:00:33 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[17:00:33.373] <-- textDocument/documentSymbol(16)
I[17:00:33.373] --> reply:textDocument/documentSymbol(16) 0 ms
I[17:00:34.087] <-- textDocument/didChange
I[17:00:34.590] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
I[17:00:34.601] --> textDocument/publishDiagnostics
I[17:00:35.089] <-- textDocument/documentColor(17)
I[17:00:35.089] --> reply:textDocument/documentColor(17) 0 ms, error: -32601: method not found
[Error - 5:00:35 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[17:00:35.417] <-- textDocument/documentSymbol(18)
I[17:00:35.417] --> reply:textDocument/documentSymbol(18) 0 ms
I[17:00:35.886] <-- textDocument/didChange
I[17:00:35.903] <-- textDocument/completion(19)
I[17:00:35.909] Code complete: sema context TopLevel, query scopes [] (AnyScope=true), expected type <none>
I[17:00:35.909] Code complete: 1 results from Sema, 0 from Index, 0 matched, 0 from identifiers, 1 returned.
I[17:00:35.909] --> reply:textDocument/completion(19) 5 ms
I[17:00:36.134] <-- textDocument/codeAction(20)
I[17:00:36.134] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
I[17:00:36.149] --> textDocument/publishDiagnostics
I[17:00:36.149] --> reply:textDocument/codeAction(20) 15 ms
I[17:00:36.412] <-- textDocument/codeAction(21)
I[17:00:36.415] --> reply:textDocument/codeAction(21) 3 ms
I[17:00:36.883] <-- textDocument/documentColor(22)
I[17:00:36.883] --> reply:textDocument/documentColor(22) 0 ms, error: -32601: method not found
[Error - 5:00:36 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[17:00:37.056] <-- textDocument/codeAction(23)
I[17:00:37.057] --> reply:textDocument/codeAction(23) 0 ms
I[17:00:37.210] <-- textDocument/documentSymbol(24)
I[17:00:37.210] --> reply:textDocument/documentSymbol(24) 0 ms
I[17:00:38.695] <-- textDocument/codeAction(25)
I[17:00:38.695] --> reply:textDocument/codeAction(25) 0 ms
I[17:00:41.651] <-- textDocument/codeAction(26)
I[17:00:41.651] --> reply:textDocument/codeAction(26) 0 ms
I[17:00:44.109] <-- textDocument/didChange
I[17:00:44.609] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
I[17:00:44.624] --> textDocument/publishDiagnostics
I[17:00:45.113] <-- textDocument/documentColor(27)
I[17:00:45.113] --> reply:textDocument/documentColor(27) 0 ms, error: -32601: method not found
[Error - 5:00:45 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[17:00:47.778] <-- textDocument/documentSymbol(28)
I[17:00:47.778] --> reply:textDocument/documentSymbol(28) 0 ms
I[17:20:21.092] <-- textDocument/didChange
I[17:20:21.342] <-- textDocument/codeAction(29)
I[17:20:21.343] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
I[17:20:21.357] --> textDocument/publishDiagnostics
I[17:20:21.357] --> reply:textDocument/codeAction(29) 14 ms
I[17:20:22.093] <-- textDocument/documentColor(30)
I[17:20:22.093] --> reply:textDocument/documentColor(30) 0 ms, error: -32601: method not found
[Error - 5:20:22 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[17:20:23.542] <-- textDocument/documentSymbol(31)
I[17:20:23.542] --> reply:textDocument/documentSymbol(31) 0 ms
I[17:20:23.547] <-- textDocument/codeAction(32)
I[17:20:23.547] --> reply:textDocument/codeAction(32) 0 ms
I[17:20:24.609] <-- textDocument/codeAction(33)
I[17:20:24.610] --> reply:textDocument/codeAction(33) 0 ms
I[17:20:26.119] <-- textDocument/didChange
I[17:20:26.619] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
I[17:20:26.634] --> textDocument/publishDiagnostics
I[17:20:27.119] <-- textDocument/documentColor(34)
I[17:20:27.119] --> reply:textDocument/documentColor(34) 0 ms, error: -32601: method not found
[Error - 5:20:27 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[17:20:27.520] <-- textDocument/didClose
I[17:20:27.520] --> textDocument/publishDiagnostics
I[17:47:45.126] <-- workspace/didChangeConfiguration
I[17:47:45.126] <-- textDocument/didOpen
I[17:47:45.126] <-- textDocument/documentColor(35)
I[17:47:45.126] --> reply:textDocument/documentColor(35) 0 ms, error: -32601: method not found
I[17:47:45.126] <-- textDocument/documentSymbol(36)
I[17:47:45.126] <-- workspace/didChangeConfiguration
I[17:47:45.127] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
[Error - 5:47:45 PM] Request textDocument/colorPresentation failed.
  Message: method not found
  Code: -32601 
I[17:47:45.150] --> textDocument/publishDiagnostics
I[17:47:45.150] --> reply:textDocument/documentSymbol(36) 23 ms
could not open compilation database for /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c
I[17:47:45.627] Updating file /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c with command 
[]
/Library/Developer/CommandLineTools/usr/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c -fsyntax-only -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3
I[17:47:45.630] Skipping rebuild of the AST for /Users/uriarev/stuff/Programming/Projects/cr/swift/test.c, inputs are the same.
haifengkao commented 4 years ago

This output window is really annoying. How to get rid of it?

wantyapps commented 4 years ago

I don't know! I am working on a project with both C and Swift, and this is annoying. What is this? How can I disable the "Output" Tab?

vknabel commented 4 years ago

@wantyapps thanks for the details! Oh yes it's really annoying. You're using Apple's sourcekit-lsp not sourcekite as "driver", right?

As this extension does not control the output of sourcekit-lsp, we cannot silence the output itself, maybe we find a way to not focus the panel.

As a temporary workaround you might try to stop it from popping up until we found a solution:

https://stackoverflow.com/a/51025285

wantyapps commented 4 years ago

Can I switch to sourcekite?

wantyapps commented 4 years ago

SPECS: macOS Catalina 10.15.6 running on 13" 2017 MacBook Pro

vknabel commented 4 years ago

@wantyapps yes of course. You can easily switch between both drivers with this extension.

Here is how you set up sourcekite Using Sourcekite.

Depending on your project, it leads to different completions. Depending on your project, sourcekite and sourcekit-lsp have their pros and cons.

wantyapps commented 4 years ago

Trying to switch. Does it have this bug too?

vknabel commented 4 years ago

The panel might come up if there are more critical errors (on crashes, ...), but only in Swift files.

wantyapps commented 4 years ago

thank you! Trying...

wantyapps commented 4 years ago
$ swift build -Xswiftc -framework -Xswiftc sourcekitd -Xswiftc -F -Xswiftc /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib -Xlinker -rpath -Xlinker /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib -c release
/Users/uriarev/sourcekite: error: package at '/Users/uriarev/sourcekite' is using Swift tools version 3.1.0 which is no longer supported; consider using '// swift-tools-version:5.2' to specify the current tools version
make: *** [release] Error 1
vknabel commented 4 years ago

Did you use vknabel/sourcekite or jinmingjian/sourcekite? The latter is not supported anymore, please use vknabel/sourcekite.

When using Swift 5.2.4 everything worked fine for me, when cloning from master.

# using install instructions of readme
$ git clone https://github.com/vknabel/sourcekite
....
$ cd sourcekite
$ make install PREFIX=/usr/local
....
$ which sourcekite
/usr/local/bin/sourcekite
wantyapps commented 4 years ago

ok... trying

wantyapps commented 4 years ago

:D Worked!

wantyapps commented 4 years ago

is it supposed to debug?

vknabel commented 4 years ago

Great to hear! What do you mean with is it supposed to debug??

wantyapps commented 4 years ago

Is this extension supposed to show you the problems in your code?

vknabel commented 4 years ago

This is mostly about autocompletion, but it does show compile errors for Swift Package Manager projects.

If you wish to attach a debugger to your Swift Package Manager project, you can follow this blog post Debugging-Swift-in-VS-Code | vknabel.com.

wantyapps commented 4 years ago

Thank you! I love this extension!

vknabel commented 3 years ago

Sadly we cannot prevent the output panel from coming up when using sourcekit-lsp while still staying compatible.

CodingMarkus commented 3 years ago

The entire bug report and all follow up here is not even once talking about the actual issue itself, meaning the reason why the console is opening, since fixing that issue will prevent it from opening. The fact that it is opening is no issue at all, it is supported to open when it runs into an error. It is just not support to run into errors all the time.

The actual error is that the LSP client tries to use the methods textDocument/documentColor and textDocument/colorPresentation and that the server response with -32601, which means "Method not found" according to LSP spec.

This is strange and unexpected, as I checked the source code of sourcekit-lsp and it does support both methods since 2019-05-29. I can even show you the commit: https://github.com/apple/sourcekit-lsp/commit/9f9cc9a73466dbe3f65279d862f6af67e8203e15

Unfortunately I see now way to find out from which Git revision a specific sourcekit-lsp executable has been build, there is not even a version number available, so I don't know if the problem is caused by the fact that the sourcekit-lsp version that Apple ships withe the dev tools is maybe outdated.

Yet not even that is the actual issue. The actual issue is that an LSP client should not try to call a method again and again after it has already been told that this method is not available. It should never try to call it again after receiving this error once and if that would be fixed, the panel would open at most once per file/session and not again for the same cause when closed.

And I don't understand this comment:

Sadly we cannot prevent the output panel from coming up when using sourcekit-lsp while still staying compatible.

Compatible to what?

vknabel commented 3 years ago

Hey @CodingMarkus!

The entire bug report and all follow up here is not even once talking about the actual issue itself, meaning the reason why the console is opening, since fixing that issue will prevent it from opening. The fact that it is opening is no issue at all, it is supported to open when it runs into an error. It is just not support to run into errors all the time.

I agree on this: the actual error is that methods are being called, although they are not supported. Opening the panel is a feature, telling the users that something unexpected happened.

But from my perspective, this extension is not responsible for the bug itself. I did not explicitly mention it or explained why, due to the lack of time.

The actual error is that the LSP client tries to use the methods textDocument/documentColor and textDocument/colorPresentation and that the server response with -32601, which means "Method not found" according to LSP spec.

In general:

This extension here uses vscode-languageclient@7.0.0 for this. And in this case sourcekit-lsp is used as Language Server (this extension supports more servers).

Though back then I even tested if the same bug appeared in SourceKit-LSP for Visual Studio Code. Just to be sure and it did. If the behavior differs by now, feel free to open an issue.

As this extension never tells the Language Client about any specific requests or capabilities, I didn't see any reason to spend several hours more to investigate.

From my perspective there are two probable possibilities here:

  1. the Language Client Node implementation has a bug
  2. the Language Server pretends to support a specific capability, but does not respond correctly

And I don't understand this comment:

Sadly we cannot prevent the output panel from coming up when using sourcekit-lsp while still staying compatible.

Compatible to what?

Compatible to sourcekit-lsp and their reference VS Code extension, which needs to be built and installed by hand.

I hope you better understand why I didn't even try to fix the underlying issue. Somewhere I need to draw a line regarding responsibility, support, bug fixing or even new features. After all we are all enthusiasts, spending their free time on side projects.

If you have any questions or feedback left, don't hesitate!