Skip to content
This repository has been archived by the owner on Nov 14, 2021. It is now read-only.

ideas for rust ide

dobkeratops edited this page Oct 11, 2013 · 3 revisions

Home

Rust IDE protocol

Overview

IDE (for example, JetBrains IDEA) launches rust-ided process. rust-ided protocol is a sequence of request/response pairs.

Requests are written to stdin, and responses are written to stdout. If anything is written to stderr, then it is internal error, that should be displayed to user, and rust-ided process must be restarted.

Serialization

Requests and responses have to be serialized and deserialized.

I think protocol message serialization should not be written by hands (it is boring and error-prone).

I think protobuf is a perfect choise for protocol description, because it is supported by virtually all environments, including rust.

First version, needed to implement simple, proof-of-concept IDE

First version should have only one request/response pair (written in protobuf syntax):

message File {
    optional string name = 1;
    optional string content = 2;
}

message AnalyzeRequest {
     repeated File files = 1;
}

message Location { ... }
message Ast { ... }
message Error {
    optional string message = 1;
    optional Location location = 2;
}
message JumpTarget {
    // jump source and targets should operate node ids, not file and line positions
    // because IDE engine works with AST
    optional int32 source_node_id = 1;
    optional int32 target_node_id = 2;
}

message AnalyzeResponse {
    optional Ast ast = 1;
    repeated Error errors = 2;
    repeated JumpTarget jump_targets = 3;
}

Proper version

Proper version of rust IDE should support incremental compilation, completion and lots of stuff. In proper version, rust-ided process mirrors IDE state, and IDE sends only updates to rust-ided. Possible commands are:

message InitialRequest { /* files */ }
message FileChangedRequest { /* send file delta to rust-ided process */ }
message CompleteRequest { /* send current position and return completion results */ }
message FindCallersRequest { /* IDE sends function node id, and rust-ided returns set of nodes that call it */ }
/// and so on