From ee8dec5dc11cfecf219b6510b0eadd9691a82ba5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 8 Jun 2020 12:52:28 +0200 Subject: IDE API --- docs/dev/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/dev/README.md b/docs/dev/README.md index 903cb4055..64d595b68 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -268,6 +268,13 @@ IDE assumes that all information is available at all times. IDE should use only types from `ra_hir`, and should not depend on the underling compiler types. `ra_hir` is a facade. +## IDE API + +The main IDE crate (`ra_ide`) uses "Plain Old Data" for the API. +Rather than talking in definitions and references, it talks in Strings and textual offsets. +In general, API is centered around UI concerns -- the result of the call is what the user sees in the editor, and not what the compiler sees underneath. +The results are 100% Rust specific though. + # Logging Logging is done by both rust-analyzer and VS Code, so it might be tricky to -- cgit v1.2.3 From cc07c82fefb2affc1772e12b8357471cccc8d578 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 8 Jun 2020 12:54:48 +0200 Subject: Preconditions style --- docs/dev/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/dev/README.md b/docs/dev/README.md index 64d595b68..5a9c0a148 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -241,6 +241,26 @@ struct Foo { For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines. If the line is too long, you want to split the sentence in two :-) +## Preconditions + +Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee): + +```rust +// Good +fn frbonicate(walrus: Walrus) { + ... +} + +// Not as good +fn frobnicate(walrus: Option) { + let walrus = match walrus { + Some(it) => it, + None => return, + }; + ... +} +``` + # Architecture Invariants This section tries to document high-level design constraints, which are not -- cgit v1.2.3