Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analysis server not sending requests when onlyAnalyzeProjectsWithOpenFiles is enabled #3638

Closed
rlch opened this issue Oct 28, 2021 · 6 comments
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is bug
Milestone

Comments

@rlch
Copy link
Contributor

rlch commented Oct 28, 2021

Hey!

Describe the bug

I've recently been working in a monorepo, and have noticed that enabling onlyAnalyzeProjectsWithOpenFiles drastically improves performance using Neovim. On VSCode, textDocument/publishDiagnostics is called for packages adjacent to the currently opened one, resulting in duplicate code actions, auto-completion items etc.

On enabling onlyAnalyzeProjectsWithOpenFiles in the analyzer LSP, I don't get any textDocument/publishDiagnostics or textDocument/didOpen etc as expected; despite the analyzer being initialized.

Any advice on how to resolve this is appreciated - I'm happy to continue developing on my fork and will push when fixed.

To Reproduce
Steps to reproduce the behavior:

  1. Set onlyAnalyzeProjectsWithOpenFiles to true in initializationOptions
  2. Open a Dart project

Expected behavior
LSP should send requests for project folders of open files in VSC.

Logs

Here's my instrumentation log:

1635396407949:Req:{"jsonrpc"::"2.0","id"::0,"method"::"initialize","params"::{"processId"::6416,"clientInfo"::{"name"::"Visual Studio Code","version"::"1.61.2"},"locale"::"en-gb","rootPath"::"/Users/rjm/Coding/Tutero/app","rootUri"::"file::///Users/rjm/Coding/Tutero/app","capabilities"::{"workspace"::{"applyEdit"::true,"workspaceEdit"::{"documentChanges"::true,"resourceOperations"::["create","rename","delete"],"failureHandling"::"textOnlyTransactional","normalizesLineEndings"::true,"changeAnnotationSupport"::{"groupsOnLabel"::true}},"didChangeConfiguration"::{"dynamicRegistration"::true},"didChangeWatchedFiles"::{"dynamicRegistration"::true},"symbol"::{"dynamicRegistration"::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]}},"codeLens"::{"refreshSupport"::true},"executeCommand"::{"dynamicRegistration"::true},"configuration"::true,"workspaceFolders"::true,"semanticTokens"::{"refreshSupport"::true},"fileOperations"::{"dynamicRegistration"::true,"didCreate"::true,"didRename"::true,"didDelete"::true,"willCreate"::true,"willRename"::true,"willDelete"::true}},"textDocument"::{"publishDiagnostics"::{"relatedInformation"::true,"versionSupport"::false,"tagSupport"::{"valueSet"::[1,2]},"codeDescriptionSupport"::true,"dataSupport"::true},"synchronization"::{"dynamicRegistration"::true,"willSave"::true,"willSaveWaitUntil"::true,"didSave"::true},"completion"::{"dynamicRegistration"::true,"contextSupport"::true,"completionItem"::{"snippetSupport"::true,"commitCharactersSupport"::true,"documentationFormat"::["markdown","plaintext"],"deprecatedSupport"::true,"preselectSupport"::true,"tagSupport"::{"valueSet"::[1]},"insertReplaceSupport"::true,"resolveSupport"::{"properties"::["documentation","detail","additionalTextEdits"]},"insertTextModeSupport"::{"valueSet"::[1,2]}},"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]}},"hover"::{"dynamicRegistration"::true,"contentFormat"::["markdown","plaintext"]},"signatureHelp"::{"dynamicRegistration"::true,"signatureInformation"::{"documentationFormat"::["markdown","plaintext"],"parameterInformation"::{"labelOffsetSupport"::true},"activeParameterSupport"::true},"contextSupport"::true},"definition"::{"dynamicRegistration"::true,"linkSupport"::true},"references"::{"dynamicRegistration"::true},"documentHighlight"::{"dynamicRegistration"::true},"documentSymbol"::{"dynamicRegistration"::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]},"hierarchicalDocumentSymbolSupport"::true,"tagSupport"::{"valueSet"::[1]},"labelSupport"::true},"codeAction"::{"dynamicRegistration"::true,"isPreferredSupport"::true,"disabledSupport"::true,"dataSupport"::true,"resolveSupport"::{"properties"::["edit"]},"codeActionLiteralSupport"::{"codeActionKind"::{"valueSet"::["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"honorsChangeAnnotations"::false},"codeLens"::{"dynamicRegistration"::true},"formatting"::{"dynamicRegistration"::true},"rangeFormatting"::{"dynamicRegistration"::true},"onTypeFormatting"::{"dynamicRegistration"::true},"rename"::{"dynamicRegistration"::true,"prepareSupport"::true,"prepareSupportDefaultBehavior"::1,"honorsChangeAnnotations"::true},"documentLink"::{"dynamicRegistration"::true,"tooltipSupport"::true},"typeDefinition"::{"dynamicRegistration"::true,"linkSupport"::true},"implementation"::{"dynamicRegistration"::true,"linkSupport"::true},"colorProvider"::{"dynamicRegistration"::true},"foldingRange"::{"dynamicRegistration"::true,"rangeLimit"::5000,"lineFoldingOnly"::true},"declaration"::{"dynamicRegistration"::true,"linkSupport"::true},"selectionRange"::{"dynamicRegistration"::true},"callHierarchy"::{"dynamicRegistration"::true},"semanticTokens"::{"dynamicRegistration"::true,"tokenTypes"::["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers"::["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats"::["relative"],"requests"::{"range"::true,"full"::{"delta"::true}},"multilineTokenSupport"::false,"overlappingTokenSupport"::false},"linkedEditingRange"::{"dynamicRegistration"::true}},"window"::{"showMessage"::{"messageActionItem"::{"additionalPropertiesSupport"::true}},"showDocument"::{"support"::true},"workDoneProgress"::true},"general"::{"regularExpressions"::{"engine"::"ECMAScript","version"::"ES2020"},"markdown"::{"parser"::"marked","version"::"1.1.0"}},"experimental"::{"snippetTextEdit"::true}},"initializationOptions"::{"onlyAnalyzeProjectsWithOpenFiles"::true,"closingLabels"::true,"flutterOutline"::true,"outline"::true,"suggestFromUnimportedLibraries"::true},"trace"::"off","workspaceFolders"::[{"uri"::"file::///Users/rjm/Coding/Tutero/app","name"::"app"}]}}
1635396408134:Res:{"id"::0,"jsonrpc"::"2.0","result"::{"capabilities"::{"executeCommandProvider"::{"commands"::["edit.sortMembers","edit.organizeImports","edit.fixAll","edit.sendWorkspaceEdit","refactor.perform"],"workDoneProgress"::true},"workspaceSymbolProvider"::true,"workspace"::{"workspaceFolders"::{"supported"::true,"changeNotifications"::true}}},"serverInfo"::{"name"::"Dart SDK LSP Analysis Server","version"::"2.14.3"}}}
1635396408154:Req:{"jsonrpc"::"2.0","method"::"initialized","params"::{}}

I should note that this is the full log; and that I attempted to load multiple Dart files in a valid workspace.

Versions (please complete the following information):

  • VS Code version: 1.61.2
  • Dart extension version: master
  • Dart/Flutter SDK version: 2.5.2
@rlch rlch added the is bug label Oct 28, 2021
@DanTup DanTup added this to the v3.28.0 milestone Oct 28, 2021
@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server labels Oct 28, 2021
@DanTup
Copy link
Member

DanTup commented Oct 28, 2021

Seems like this may have become broken with the removal of this line here:

dart-lang/sdk@c881935#diff-c38cbadb02f1d80c826a2837bb846088759465f15243bc681045784148764561L31

Without it, the server is not registering any capabilities with the client when onlyAnalyzeProjectsWithOpenFiles=true. I'm not sure why I did this (or how it went unnoticed by tests or others using this). Will get a fix w/ some additional tests.

@rlch
Copy link
Contributor Author

rlch commented Oct 28, 2021

Thanks!

Also just submitted a PR #3640 for adding onlyAnalyzeProjectsWithOpenFiles to config. 😄

@DanTup
Copy link
Member

DanTup commented Oct 28, 2021

I've a fix open at https://dart-review.googlesource.com/c/sdk/+/218441/. It's an SDK change, so after merging will require an updated SDK to take effect unfortunately.

@DanTup
Copy link
Member

DanTup commented Oct 28, 2021

btw:

On VSCode, textDocument/publishDiagnostics is called for packages adjacent to the currently opened one, resulting in duplicate code actions, auto-completion items etc.

Nothing should be duplicated without setting onlyAnalyzeProjectsWithOpenFiles so if you're seeing bad behaviour (besides it being a little slower because it's analyzing the whole workspace), please do file an issue with an example so I can take a look.

@rlch
Copy link
Contributor Author

rlch commented Oct 28, 2021

Gotcha, thanks.

I'll do some more digging and let you know if it's a separate issue.

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Oct 28, 2021
…alyzeProjectsWithOpenFiles=true

Fixes Dart-Code/Dart-Code#3638.

Change-Id: I2749210a209fb0321f4833cf39c4d5fea55b579b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Oct 28, 2021

The change above has landed in the SDK (and will be included in a future release).

@DanTup DanTup closed this as completed Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is bug
Projects
None yet
Development

No branches or pull requests

2 participants