eclipse-corrosion / corrosion

Eclipse Corrosion - Rust edition in Eclipse IDE
Eclipse Public License 2.0
223 stars 31 forks source link

[regression?] Code folding gutter disappeared? #137

Closed norru closed 1 year ago

norru commented 6 years ago

Hi,

I'm running latest snapshot of Eclipse 2018-09, tm4e, lsp4e and corrosion to test progress (a life on the edge, I know!).

After an "upgrade all", the code folding feature, which was working on the previous update, has disappeared again.

norru commented 6 years ago

Oddly, I don't think that the "update all" had anyting new from Corrosion snaps or tm4e itself, so there must be some sort of API oddity after upgrading the platform.

norru commented 6 years ago

This is low priority for me.

norru commented 5 years ago

@mickaelistria the code folding functionality disappeared a while ago after a short stint of actually working fine. Just FMY, is it something that would be addressed in 2018-12?

mickaelistria commented 5 years ago

I don't know what caused this to disappear, I don't even know which component was providing the functionality. As 2018-12 was released some time ago, it's definitely not addressed if you're still seeing the issue. I personally cannot place this issue high in my priority todo-list, it's very unlikely I work on it soon (or even any time). You'll need to have a look at this issue or to recruit someone else to do it. Good luck!

norru commented 5 years ago

I thought it might be a case of configuring the TM4E plugin "descriptor". It's too low priority for me to worry, thanks anyway :)

norru commented 5 years ago

I am still seeing this. I have also tried to edit language-configuration.json and add some folding markers but nothing happens. Folding seems to be active in the TextMate configuration.

norru commented 5 years ago

@angelozerr do you have any advice? How do we enable the folding gutter in our plugin.xml?

angelozerr commented 5 years ago

language-configuration.json

TM4E doesn't support code folding and ignores the folding declaration from language-configuration.json (VSCode supports it). Code folding is managed by the language server. Perhaps it's an issue from LSP4E?

norru commented 5 years ago

Code folding is managed by the language server.

This is not possible as LSP has not a complete spec for code folding yet.

Perhaps it's an issue from LSP4E?

I think LSP4E assumes TM4E manages code folding. @mickaelistria ?

RLS doesn't have code folding implemented yet, I think they're blocked by the LSP project https://github.com/rust-lang/rls/issues/986

It seems like VSCode supports folding natively without the LSP as LSP folding specification is still in draft/proposal state and won't be ready any time soon.

@angelozerr Just FYI Code Folding was working in Corrosion in the release prior to 2018-09 (Photon IIRC)

mickaelistria commented 5 years ago

I think LSP4E assumes TM4E manages code folding. @mickaelistria ?

LSP4E doesn't know nor assume anything about TM4E. If documentFolding is supported by LSP, it should be supported by LSP4E and work for any LS that provides folding.

angelozerr commented 5 years ago

I don't know what caused this to disappear, I don't even know which component was providing the functionality.

The first step to do is to debug https://git.eclipse.org/c/lsp4e/lsp4e.git/tree/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/folding/LSPFoldingReconcilingStrategy.java

norru commented 5 years ago

If documentFolding is supported by LSP, it should be supported by LSP4E and work for any LS that provides folding

I've left the VSCode guys a comment asking for pointers - see if something bites.

norru commented 5 years ago

I've done a quick check and I could not find any instances of foldingRange in my RLS logs.

It kind of confirms that RLS doesn't implement it yet. There would be a foldingProvider in the response of initialize otherwise.

LSP4E to org.eclipse.corrosion.rls:{"jsonrpc":"2.0","id":"1","method":"initialize","params":{"processId":13979,"rootPath":"/home/norru/Projects/ivt/parallax_testbed/","rootUri":"file:///home/norru/Projects/ivt/parallax_testbed/","initializationOptions":{"settings":{"rust":{"clippy_preference":"on","goto_def_racer_fallback":true}}},"capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","delete","rename"],"failureHandling":"undo"},"symbol":{},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"completionItem":{"snippetSupport":true}},"hover":{},"signatureHelp":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{"valueSet":[18,17,5,14,9,10,22,24,8,1,12,11,20,6,2,3,21,16,19,25,4,7,15,23,26,13]},"hierarchicalDocumentSymbolSupport":true},"formatting":{},"rangeFormatting":{},"definition":{},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"codeLens":{},"documentLink":{},"colorProvider":{},"rename":{}}},"clientName":"Eclipse IDE","trace":"off"}}
org.eclipse.corrosion.rls to LSP4E:{"jsonrpc":"2.0","id":"1","result":{"capabilities":{"textDocumentSync":2,"hoverProvider":true,"completionProvider":{"resolveProvider":true,"triggerCharacters":[".",":"]},"definitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":true,"codeLensProvider":{"resolveProvider":false},"documentFormattingProvider":true,"documentRangeFormattingProvider":false,"renameProvider":true,"executeCommandProvider":{"commands":["rls.applySuggestion-14086","rls.deglobImports-14086"]}}}}
LSP4E to org.eclipse.corrosion.rls:Content-Length: 52

Although we're probably not asking for it from the client, as the request doesn't contain a foldingRange capability @mickaelistria @angelozerr.

    /**
     * Capabilities specific to `textDocument/foldingRange` requests.
     *
     * Since 3.10.0
     */
    foldingRange?: {
        /**
         * Whether implementation supports dynamic registration for folding range providers. If this is set to `true`
         * the client supports the new `(FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)`
         * return value for the corresponding server capability as well.
         */
        dynamicRegistration?: boolean;
        /**
         * The maximum number of folding ranges that the client prefers to receive per document. The value serves as a
         * hint, servers are free to follow the limit.
         */
        rangeLimit?: number;
        /**
         * If set, the client signals that it only supports folding complete lines. If set, client will
         * ignore specified `startCharacter` and `endCharacter` properties in a FoldingRange.
         */
        lineFoldingOnly?: boolean;
    };

https://microsoft.github.io/language-server-protocol/specification

angelozerr commented 5 years ago

Ok I suspect the following problem : by default Generic Editor uses indentation folding strategies (so I think you have that before). And after LSP4E has implemented folding strategies.

I think the main problem is in LSP4E https://git.eclipse.org/c/lsp4e/lsp4e.git/tree/org.eclipse.lsp4e/plugin.xml#n470 :

<extension
         point="org.eclipse.ui.genericeditor.foldingReconcilers">
      <foldingReconciler
            class="org.eclipse.lsp4e.operations.folding.LSPFoldingReconciler"
            contentType="org.eclipse.core.runtime.text">
         <enabledWhen>
            <with
                  variable="editorInput">
               <test
                     property="org.eclipse.lsp4e.hasLanguageServer">
               </test>
            </with>
         </enabledWhen>
      </foldingReconciler>
   </extension>

I mean org.eclipse.lsp4e.hasLanguageServer checks just if the editor is bound in the editor which have LSP (in yoru case). In this case default indent strategy is disabled and you loose folding (in your case). The best mean is to improve this condition with org.eclipse.lsp4e.cansSupportFolding but it requires the start of the language server which could freeze the editor when it is opened.

norru commented 5 years ago

For reference https://bugs.eclipse.org/bugs/show_bug.cgi?id=537706

norru commented 5 years ago

The best mean is to improve this condition with org.eclipse.lsp4e.cansSupportFolding

@angelozerr Does this property need to be implemented?

angelozerr commented 5 years ago

@angelozerr Does this property need to be implemented?

Yes, but it's hard I think since we cannot start the server when editor is created (I had tried it, but I failed it). Any PR ar ewelcome!

norru commented 5 years ago

Could not we find a way to let LS-specific plugins decide in a static way via plugin.xmlrather than letting lsp4e guess?

mickaelistria commented 5 years ago

@norru Is this still an issue with 2019-06 RC2 ?

norru commented 5 years ago

Still open on 2019-06 RC1 as it's what the IDE thinks it's latest. and it is still the case. Is RC2 not on the /updates Eclipse repository?

norru commented 5 years ago

Still open in Version: 2019-06 (4.12.0) Build id: 20190614-1200

mickaelistria commented 4 years ago

Could it be caused by https://bugs.eclipse.org/bugs/show_bug.cgi?id=547879 ?

cplir-c commented 3 years ago

Code folding is still not showing up in my eclipse version 4.20.0.v20210611-1600 installation with corrosion v1.2.1.202106081156. Should I open a new issue?

akurtakov commented 2 years ago

Do you still face the issue with latest version?

norru commented 1 year ago

Looks fixed.