Best way to represent language tokens for an autocomplete script

As some of you know, I am developing my own IDE. You might think "oh no, one more ?!" - do not worry, no one forces you to use it, and I doubt that it will be seriously published in any case.

So, to the main question. I am trying to implement an autocomplete system. An accurate user interface is not a concern. However, storing language and library tokens in a flexible way is my main problem.

Let's say we offer users CSS selector OR attributes. We would have something like:

- css/core
  - a                      // anchor tag
  - etc                    // all valid html tags
  - .stuff                 // class name parsed from user project
  - ?etc                   // more stuff parsed from user project (ids, classes...)
- css/properties
  - border                 // regular css properties - we also need to associate
                           // <border-style> and <color> value tokens
  - etc                    // the rest of them
- css/values/border-style  // property value tokens
  - solid
  - dotted
- css/values/color
  - red
  - green
  - fucshia

, , . BNF, subtokens, .

1. , , . 2. , , - -, , . , - ..

, , , . , IDE , .

, , , , , .

+5
4

IDE SharpDevelop. , .

, . IDE , , , , .

IDE , . , IDE, , :

getAutocompletionList(editor) {
  plugin = editor.languagePlugin;
  plugin.getAutocompletionList(editor.cursorPosition, editor.parsedDocument);
}

A CSSLanguagePlugin PHPLanguagePlugin getAutocompletionList - CSS, PHP.

, . , CSS:

h1 {
    text-align: <cursor>

:

[cssTopLevelContext] {
    [cssPropertyContext]: [cssPropertyValueContext]
}

CSS :

// CSSLanguageBinding
getAutocompletionList(cursorPosition, document) {
    completionContext = this.getCompletionContext(cursorPosition, document);
    // completionContext is { 
    //     'name': 'cssPropertyValueContext', 
    //     'propertyName': 'text-align' 
    // }
    return this.completionDatabase.getCompletionList(completionContext);
    // returns ['left', 'center', 'right'];
}

- . , (, , ) - PHP , (private, public, protected). CSS , .

, :

  • ,

SharpDevelop " " , , .

PHP , .

. PHP, , , , ( PHP) .

, . , ? SharpDevelop ( , , ..). 8000 , 8000 , , .

SharpDevelop , 700K SharpDevelop, - . . , ( , ..).

PHP. CSS , , , . IDE/ / CSS.


, CSS . PHP , - - 8000 , - . , Sublime Text, .

+8

.

, /​​ .

, , , PHP 8000 (= > ).

, PHP , IDE, . .

, , , .

+3

- ( , , ). , " " .

, , , , . , , - .

. , .

, , IDE , , , , " " : , , , , . IDE.

+1

, , . ( , , , .) ; .

, IDE, , , // .., . " ", " " " ". , , , ; , , , , . , , .

, , , : , '.' , CSS .. , . ; , . , "case SomeEnum.Foo:", IDE switch, , .

The practical consequence of all this is that you can never get a uniform idea of ​​what your autostart can offer; instead, you have a combination of language context-sensitive hacks, lists for different contexts, and more parsed lists. Many contexts combine multiple lists; for example, a CSS selector can have any HTML tag name or extract class name / identifier, and a list of HTML tag names is also used when entering HTML.

+1
source

All Articles