atularen / ngx-monaco-editor

Monaco Editor component for Angular 2 and Above
https://www.npmjs.com/package/ngx-monaco-editor
MIT License
428 stars 155 forks source link

How to implement java intellisense for monaco editor #148

Open datavisorfrankhe opened 4 years ago

datavisorfrankhe commented 4 years ago

We are doing online code editor using monaco editor. One of the requirement is to provide intellisense, or code auto-complete for java/python language. I searched so many resources, and can not find any useful resource on introduction how to make auto-complete working. some said using language server, but it is really difficult to make it work. May I ask what is the best way to make auto-complete working for java language? Are there any good material that I can refer? Or can we just use some json files to make auto-complete work as well? Thanks

Tumao727 commented 4 years ago

@datavisorfrankhe Hello, have you worked it out now? I have a similar requirement to provide Python intellisense on online code editor. Really gratefull if you are willing to help. Thank you.

abner commented 4 years ago

We are doing online code editor using monaco editor. One of the requirement is to provide intellisense, or code auto-complete for java/python language. I searched so many resources, and can not find any useful resource on introduction how to make auto-complete working. some said using language server, but it is really difficult to make it work. May I ask what is the best way to make auto-complete working for java language? Are there any good material that I can refer? Or can we just use some json files to make auto-complete work as well? Thanks

Hi, i recommend you to try out the Theia Ide: https://theia-ide.org/ Definitely it is a more heavy approach, but it goes at the right direction to what you want to accomplish, since it has a client-side part (the editor) and the background service implementing the environment with the language-service (to provide the intellisense).

suneethar commented 3 years ago

Eclipse Theia is very heavy to use and there is no proper guideline on how to use theia inside angular/react. How can I add support for java using monaco editor. Is there support to add custom language/java with intelligence?

liuyike98 commented 2 years ago

well, this is not difficult to simplely realize it. you know vscode use LSP to provide language intellisense, we can also emunate this. first we can start a socket to communicate with monaco editor, the backend service accordding to the document of jdk to provide items for monaco. for example when user input ".", we can call editor.getModel().getWordsUntilPosition to get the prefix, then find methods in this Class

alfu32 commented 1 year ago

I’m developing an extension that provides a code editor for Nashorn. I have the same problem … providing code completion. In my case LSP is out of the question because everything should be self contained in the extension.

for Monaco, the completion provider is quite simple ( have a look in the source code ). It requires some sort of a backend that will respond with suggestions. The provider receives as input the entire text before the cursor.

My strategy is to just extract the name, kind and signature from all java classes I need to provide completions for and query them with a background worker ( the bkg worker of the extension).

In my case one big problem is scanning .jars and extracting signatures. It would be nice to find the information readily extracted somewhere.

chaitanya71998 commented 1 year ago

@liuyike98 can you share any working example for java language server with monaco editor