Skip to content
Oleg Shilo edited this page Jun 9, 2019 · 5 revisions

Syntaxer Protocol

Overview

Server

Starting syntax server (syntaxer.exe) is as simple as below:

syntaxer.exe -listen -port:<port> -timeout:<timeout> -cscs_path:<cscsFile> 

Where:

  • port - port the server needs to listen to. Below is the list of already used ports:
    • 18000 - Sublime Text 3
    • 18001 - Notepad++
    • 18002 - VSCode.CodeMap
    • 18003 - VSCode.CS-Script
  • timeout - inactivity timeout in millisecond, after which the server process will terminate itself.
  • cscs_path - is a path to CS-Script engine executable. It is needed for discovering all script dependencies required by the majority of the Intellisense operations. This parameter is mandatory. Specify special value ./cscs.exe if you prefer to use the default engine file included in the Syntaxer distributables.

Client

Syntaxer client can simply open the socked at the desired port and simply send request strings and receive string responses from the server.

If the client is not capable of operating socket or for whatever reason it is not desired it can use special CLI client syntaxer.cli.exe instead. This executable takes the request string as a set if CLI attributes, communicates with the server over the TCP connection and prints to the server response to the standard output. This way the Syntaxer client (e.g. IDE) instead of exercising the socket simply starts the syntaxer.cli.exe and reads it output. Making it an ultimately portable option.

Windows vs Linux

Both syntaxer.exe and syntaxer.cli.exe are .NET applications and if used on Linux you will need to run them against Mono:

mono syntaxer.exe -listen -port:18000 . . .

Request command

Format:

-client:<procId>\n-op:<operation>\n-script:<file>[\n-pos:<caret>][\n-rich][\n-doc]

Where:

  • -client
    client process id. Can be an IDE like Notepad++, Sublime Text, VSCode.
  • -op
    requested syntax operation:
    • completion
    • resolve
    • references
    • memberinfo
    • signaturehelp
    • format
    • codemap
    • codemap_vscode
    • suggest_usings:{word}
    • tooltip:{hint}
  • file
    location of the script (source) file
  • pos
    an optional parameter with caret position within the script (source) file
  • -rich
    an optional flag that indicates that the client is capable of processing response with rich data serialization (e.g. Notepad++ deserializes response data to .NET types)
  • -doc
    an optional flag that indicates if the completion data should include documentation (e.g. method documentation for for VSCode). This flag is only to be used with -op:complete

Response data

The response data format is always request specific. See use cases below.


Use cases

Get completion

A typical request for completion suggestions.

Request

Format:

-client:<procId>\n-op:completion\n-script:<file>\n-pos:<caret>[\n<-rich>[\n<-doc>]

Where: procId - client process id. file - location of the source file with the code to generate completion suggestions for. caret - caret position (within the code) at which the completion suggestions should be generated.

Sample:

-client:25780
-op:completion
-script:C:\Users\user\AppData\Local\Temp\Roslyn.Intellisense\sources\5beb71c9-5458-4320-bac7-47205edfde36.cs
-pos:626
-rich

Response

Format:

<display>\t<type>|<completion>[|<doc>]
  • display - suggestion text
  • type - type of suggestion (e.g. 'method')
  • completion - text that is to be inserted in the source code if completion suggestion item is accepted.
  • doc - documentation associated with the completion item. It is only present if the request contained -doc parameter.

Sample:

BackgroundColor property|BackgroundColor
Beep(...)   method|Beep
BufferHeight    property|BufferHeight
BufferWidth property|BufferWidth
WindowTop   property|WindowTop
WindowWidth property|WindowWidth
Write(...)  method|Write
WriteLine(...)  method|WriteLine

below content is still in progress

Resolve Symbol

Request

Sample:

-client:25780
-op:memberinfo
-script:C:\Users\user\AppData\Local\Temp\Roslyn.Intellisense\sources\17af7d9b-a54c-46d6-ace2-19e0fa3e3abb.cs
-pos:630
-rich
-collapseOverloads

Response

Format

"{MemberStartPosition}\n" +
"{Info}"

Sample:

631
Method: void Console.WriteLine(string value) (+ 18 overloads)${r}${n}Writes the specified string value, followed by the current line terminator, to the standard output stream.${r}${n}${r}${n}value: The value to write.${r}${n}${r}${n}Exceptions: ${r}${n}  System.IO.IOException

Find definition

Request

Sample:

-client:25780
-op:resolve
-script:C:\Users\user\AppData\Local\Temp\Roslyn.Intellisense\sources\bad30c0b-fae5-463d-9b9f-1bc7f399885a.cs
-pos:627
-rich

Response

Format

"{BeginColumn}\n" +
"{BeginLine}\n" +
"{EndLine}\n" +
"{FileName}\n" +
"{Hint}\n" +
"{IsEmpty}"

Sample:

0
635
635
C:\Users\user\AppData\Local\Temp\Roslyn.Intellisense\ReflctedTypes\System.Console.-1344442983.r.cs

False

Find references

References: -client:25780 -op:references -script:C:\Users\user\AppData\Local\Temp\Roslyn.Intellisense\sources\18357e2d-bcb4-4b33-964a-f84c11af0486.cs -pos:627 -rich


C:\Users\user\Documents\C# Scripts\New Script11\New Script11.cs(21,17): WriteLine(new CultureInfo("cs").DisplayName); C:\Users\user\Documents\C# Scripts\New Script11\New Script11.cs(22,17): WriteLine($"Hello from - {Process.GetCurrentProcess().Id}"); C:\Users\user\Documents\C# Scripts\New Script11\New Script11.cs(23,17): WriteLine($"{System.Reflection.Assembly.GetEntryAssembly().Location}"); C:\Users\user\Documents\C# Scripts\New Script11\New Script11.cs(32,17): WriteLine("test!! 33333333");