eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

How to disable autoimport

Open GNSubrahmanyam opened this issue 4 years ago • 13 comments

@fbricon @snjeza Editor: Monaco editor language client: Monaco language client In our use case we want to disable autoimport. How to stop sending completionItem/resolve image

GNSubrahmanyam avatar Jul 11 '20 13:07 GNSubrahmanyam

@GNSubrahmanyam you can try the following settings:

"java.completion.enabled": false,

snjeza avatar Jul 11 '20 15:07 snjeza

@snjeza In that case no auto complete is coming. We need autocomplete. We want to disable auto import statements

image

GNSubrahmanyam avatar Jul 11 '20 16:07 GNSubrahmanyam

It's not possible to disable automatic type import at that point. Can you explain how auto import is a problem in monaco?

fbricon avatar Jul 11 '20 16:07 fbricon

image In our use case we locked few lines in code editor. Where candidates or learners will write code in editable part. While typing candidates or learners selects method from the codeCompleteItem (Example: StreamDecoder from com.oracle.webservices.internal.impl.internalspi.encoding.* it automatically imports com.oracle.webservices.internal.impl.internalspi.encoding.) image

It mess up the whole codelock feature.

GNSubrahmanyam avatar Jul 11 '20 17:07 GNSubrahmanyam

@fbricon Is there any way to suggest method autocomplete for imported packages only?

GNSubrahmanyam avatar Jul 11 '20 17:07 GNSubrahmanyam

@fbricon Any updates how we can achieve this?

GNSubrahmanyam avatar Jul 13 '20 05:07 GNSubrahmanyam

@fbricon Found a solution

import { has, get, map, omit, set} from "lodash";
import * as rpc from "vscode-ws-jsonrpc";
export const launch = (request: http.IncomingMessage, socket: rpc.IWebSocket) => {
if (rpc.isResponseMessage(message)) {
          if (typeof message.result === 'object' && has(message.result, 'isIncomplete')) {
            let items = map(get(message.result, 'items'), (item) => {
              if (has(item, 'additionalTextEdits')) {
                item = omit(item, 'additionalTextEdits')
                return item;
              }
              return item;
            })

            set(message.result, 'items', items)

          }
        }

GNSubrahmanyam avatar Jul 13 '20 13:07 GNSubrahmanyam

interesting, where do you put that code?

fbricon avatar Jul 13 '20 13:07 fbricon

https://github.com/TypeFox/monaco-languageclient/blob/master/example/src/json-server-launcher.ts#L20 inside forward

GNSubrahmanyam avatar Jul 13 '20 13:07 GNSubrahmanyam

Am i doing right ? By omitting additionalTextEdits

GNSubrahmanyam avatar Jul 13 '20 13:07 GNSubrahmanyam

that's very, very hacky. I'm not sure but other things than import statements might be sent as additional textedits.

fbricon avatar Jul 13 '20 13:07 fbricon

True, In our case we don't want auto import. What are other alternative to achieve this ?

GNSubrahmanyam avatar Jul 13 '20 13:07 GNSubrahmanyam

@GNSubrahmanyam Hi can you please help me with the configs used to make it work with monaco-languageclient? To ve more specific - How to modify this line --https://github.com/TypeFox/monaco-languageclient/blob/69f41d2c2d9b37bcbb9a080d86ec2eed838d6885/example/src/json-server-launcher.ts#L19

to make it work with -- this java lsp.

And do we need any other chnages?

pawansingh00 avatar Nov 08 '21 05:11 pawansingh00