Library / tool for creating common code

I am trying to set the correct code completion in my favorite editor, let him use AnEditor to avoid answering specific requests that are filled on the network. (And the Alanguage language, you know.) The editor has two functions that I like: it works in the console as well as in the GUI, so I can use it over the network, and it is significantly extensible. Therefore, I do not want to use a full-blown IDE. But the editor does not have reliable code completion, although it can be connected if I find a decent solution.

I put together a whole bunch of questions and solutions for completing [language X] in [editor / IDE Y]. "It seems that each new IDE performs its code completion for each language from scratch, the parser and all. And each simpler editor (including AnEditor) does one of the following:

  • fill in only standard library function names,
  • or use ctags, which offers delayed regular expression-based analysis (for non-C programs) and should not indicate the type of variable that you typed now, so itโ€™s not very useful for real code completion,
  • There are other ways when the editor is expanded using plugins, but usually they come down to a more or less perverse combination above, with lots of custom regular expressions.

Now the question is: why can't we have a sound code completion library that I can connect to AnEditor and someone else to ABIGIDE? As far as I can tell (decrypting the C-pointer joystick is not my goal), the answer should look something like this:

  • a general yacc / lex / bison-style parser (or static parser), somehow relaxed to tolerate code in the writing process, capable of accepting JavaDoc-style comments. And quickly, it is desirable that it can be used "on the fly"
  • an index that can report the signatures of class members, methods and their position in files (ctags do it now), return values โ€‹โ€‹and other documentation from JavaDoc comments
  • another index that knows the type of the variable, and a function that tells the type based on the position in the file or code that is currently written

So, in order to get the completion of work in any language, you make up the parser rules for the language, create indexes on the standard library and your project, call the type indicating function and look at the class members and documentation. Or just list the classes and members if you are dealing with object construction or static calls.

If Eclipse, Netbeans and JetBrains have successfully done this in Java (so I have to connect Eclipse to AnEditor ), why does โ€œSomeone do it in a less bloated and more universal way? Or am I missing something and the future is already somewhere hiding?

+8
autocomplete code-completion
source share
1 answer

So: to date, this is the problem that has been solved by Microsoft, of all people. 'Language servers provide a protocol for connecting to various editors and IDE add-ons, taking into account semantics, language-dependent, and other functions.

It is noteworthy that language servers, as a rule, are developed in the same languages โ€‹โ€‹that they analyze. This might be a dubious solution for slower languages โ€‹โ€‹like Python.

For some languages, similar solutions were available for some time independently of Langservers servers, for example Krachka for JS , Scion and ghc-mod for Haskell, etc. They mainly serve Emacs and Vim. As expected, such solutions mostly appear for non-core languages, such as all compiled in JS, which seem to pop up faster than required to develop separate plugins for each editor / IDE.

0
source share

All Articles