![]() Its content can be derived from your current source code (with the help of a parser + a parse listener). Providing them is usually the task of a symbol table. A Code Completion Breakdownįor showing possible symbols in source code you obviously need a source for all available symbols at the given position. Still, a full code completion implementation requires some support code that we need to discuss first before we can come to the actual usage of the c3 engine. In the simplest setup you only give it a parser instance and a caret position and it will return the candidates for it. With the Code Completion Core implementation things become a lot easier. The ANTLR4 runtime even provides the LL1Analyzer class, which helps with retrieving follow sets for a given ATN state, but has a few shortcomings and is in general not easy to use. With ANTLR4 we no longer need to load a grammar, because the grammar structure is now available as part of a parser (via the ATN - Augmented Transition Network). There a grammar was loaded into a memory structure so that it can be walked through with the current input to find a specific location (usually the caret position) and then collect all possible tokens and special rules, which then describe the possible set of code completion candidates for that position. The c3 engine implementation is based on an idea presented a while ago under Universal Code Completion using ANTLR3. This library aims to provide a common infrastructure for code completion implementations in a more general way, so that people can share their solutions and provide others with ideas to solve specific problems related to that. There have been quite a number of requests over the past years for getting support from ANTLR to create a code completion implementation, but so far that turned out as an isolated task with only custom solutions. Implementations under the ports folder might not be up to date compared to the Typescript version. A port to Java is available under ports/java. The original implementation is provided as a node module (works in both, Node.js and browsers), and is written in TypeScript. ![]() The c3 engine is able to provide code completion candidates useful for editors with ANTLR generated parsers, independent of the actual language/grammar used for the generation. ![]() This project contains a grammar agnostic code completion engine for ANTLR4 based parsers. Antlr4-c3 The ANTLR4 Code Completion Core ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |