-
Notifications
You must be signed in to change notification settings - Fork 0
ideas for rust ide
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.
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 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 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