mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 21:25:25 +00:00 
			
		
		
		
	Merge pull request #19015 from Wilfred/mdbook
manual: Convert to mdbook
This commit is contained in:
		
						commit
						07a09c154e
					
				
					 70 changed files with 2836 additions and 2686 deletions
				
			
		| 
						 | 
				
			
			@ -21,7 +21,7 @@ mod fn_references;
 | 
			
		|||
// Provides user with annotations above items for looking up references or impl blocks
 | 
			
		||||
// and running/debugging binaries.
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020672-b7c34f00-917a-11eb-8f6e-858735660a0e.png[]
 | 
			
		||||
// 
 | 
			
		||||
#[derive(Debug, Hash, PartialEq, Eq)]
 | 
			
		||||
pub struct Annotation {
 | 
			
		||||
    pub range: TextRange,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -122,11 +122,9 @@ pub(crate) fn remove_links(markdown: &str) -> String {
 | 
			
		|||
// The simplest way to use this feature is via the context menu. Right-click on
 | 
			
		||||
// the selected item. The context menu opens. Select **Open Docs**.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Open Docs**
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Open Docs** |
 | 
			
		||||
pub(crate) fn external_docs(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    FilePosition { file_id, offset }: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,13 +19,11 @@ pub struct ExpandedMacro {
 | 
			
		|||
//
 | 
			
		||||
// Shows the full macro expansion of the macro at the current caret position.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Expand macro recursively at caret** |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Expand macro recursively at caret**
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020648-b3973180-917a-11eb-84a9-ecb921293dc5.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<ExpandedMacro> {
 | 
			
		||||
    let sema = Semantics::new(db);
 | 
			
		||||
    let file = sema.parse_guess_edition(position.file_id);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,13 +17,11 @@ use crate::FileRange;
 | 
			
		|||
// Extends or shrinks the current selection to the encompassing syntactic construct
 | 
			
		||||
// (expression, statement, item, module, etc). It works with multiple cursors.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Shortcut
 | 
			
		||||
// | Editor  | Shortcut |
 | 
			
		||||
// |---------|----------|
 | 
			
		||||
// | VS Code | <kbd>Alt+Shift+→</kbd>, <kbd>Alt+Shift+←</kbd> |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | kbd:[Alt+Shift+→], kbd:[Alt+Shift+←]
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020651-b42fc800-917a-11eb-8a4f-cf1a07859fac.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
 | 
			
		||||
    let sema = Semantics::new(db);
 | 
			
		||||
    let src = sema.parse_guess_edition(frange.file_id);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,13 +14,11 @@ pub struct CrateInfo {
 | 
			
		|||
//
 | 
			
		||||
// Shows a view tree with all the dependencies of this project
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Panel Name
 | 
			
		||||
// | Editor  | Panel Name |
 | 
			
		||||
// |---------|------------|
 | 
			
		||||
// | VS Code | **Rust Dependencies** |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **Rust Dependencies**
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/5748995/229394139-2625beab-f4c9-484b-84ed-ad5dee0b1e1a.png[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn fetch_crates(db: &RootDatabase) -> FxIndexSet<CrateInfo> {
 | 
			
		||||
    let crate_graph = db.crate_graph();
 | 
			
		||||
    crate_graph
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,14 +31,11 @@ pub enum StructureNodeKind {
 | 
			
		|||
// * draw breadcrumbs to describe the context around the cursor
 | 
			
		||||
// * draw outline of the file
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Shortcut
 | 
			
		||||
// | Editor  | Shortcut |
 | 
			
		||||
// |---------|----------|
 | 
			
		||||
// | VS Code | <kbd>Ctrl+Shift+O</kbd> |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | kbd:[Ctrl+Shift+O]
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020654-b42fc800-917a-11eb-8388-e7dc4d92b02e.gif[]
 | 
			
		||||
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
 | 
			
		||||
    let mut res = Vec::new();
 | 
			
		||||
    let mut stack = Vec::new();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,13 +31,11 @@ use syntax::{
 | 
			
		|||
//
 | 
			
		||||
// For outline modules, this will navigate to the source file of the module.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Shortcut
 | 
			
		||||
// | Editor  | Shortcut |
 | 
			
		||||
// |---------|----------|
 | 
			
		||||
// | VS Code | <kbd>F12</kbd> |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | kbd:[F12]
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065563-025fbe00-91b1-11eb-83e4-a5a703610b23.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn goto_definition(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    FilePosition { file_id, offset }: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,13 +12,11 @@ use crate::{FilePosition, NavigationTarget, RangeInfo, TryToNav};
 | 
			
		|||
//
 | 
			
		||||
// Navigates to the impl items of types.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Shortcut
 | 
			
		||||
// | Editor  | Shortcut |
 | 
			
		||||
// |---------|----------|
 | 
			
		||||
// | VS Code | <kbd>Ctrl+F12</kbd>
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | kbd:[Ctrl+F12]
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065566-02f85480-91b1-11eb-9288-aaad8abd8841.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn goto_implementation(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    FilePosition { file_id, offset }: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,13 +8,11 @@ use crate::{FilePosition, NavigationTarget, RangeInfo, TryToNav};
 | 
			
		|||
//
 | 
			
		||||
// Navigates to the type of an identifier.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **Go to Type Definition** |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **Go to Type Definition**
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020657-b560f500-917a-11eb-9007-0f809733a338.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn goto_type_definition(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    FilePosition { file_id, offset }: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,12 +43,12 @@ pub struct HighlightRelatedConfig {
 | 
			
		|||
//
 | 
			
		||||
// Highlights constructs related to the thing under the cursor:
 | 
			
		||||
//
 | 
			
		||||
// . if on an identifier, highlights all references to that identifier in the current file
 | 
			
		||||
// .. additionally, if the identifier is a trait in a where clause, type parameter trait bound or use item, highlights all references to that trait's assoc items in the corresponding scope
 | 
			
		||||
// . if on an `async` or `await` token, highlights all yield points for that async context
 | 
			
		||||
// . if on a `return` or `fn` keyword, `?` character or `->` return type arrow, highlights all exit points for that context
 | 
			
		||||
// . if on a `break`, `loop`, `while` or `for` token, highlights all break points for that loop or block context
 | 
			
		||||
// . if on a `move` or `|` token that belongs to a closure, highlights all captures of the closure.
 | 
			
		||||
// 1. if on an identifier, highlights all references to that identifier in the current file
 | 
			
		||||
//      * additionally, if the identifier is a trait in a where clause, type parameter trait bound or use item, highlights all references to that trait's assoc items in the corresponding scope
 | 
			
		||||
// 1. if on an `async` or `await` token, highlights all yield points for that async context
 | 
			
		||||
// 1. if on a `return` or `fn` keyword, `?` character or `->` return type arrow, highlights all exit points for that context
 | 
			
		||||
// 1. if on a `break`, `loop`, `while` or `for` token, highlights all break points for that loop or block context
 | 
			
		||||
// 1. if on a `move` or `|` token that belongs to a closure, highlights all captures of the closure.
 | 
			
		||||
//
 | 
			
		||||
// Note: `?`, `|` and `->` do not currently trigger this behavior in the VSCode editor.
 | 
			
		||||
pub(crate) fn highlight_related(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -118,7 +118,7 @@ pub struct HoverResult {
 | 
			
		|||
// Shows additional information, like the type of an expression or the documentation for a definition when "focusing" code.
 | 
			
		||||
// Focusing is usually hovering with a mouse, but can also be triggered with a shortcut.
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020658-b5f98b80-917a-11eb-9f88-3dbc27320c95.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn hover(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    frange @ FileRange { file_id, range }: FileRange,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ mod range_exclusive;
 | 
			
		|||
//
 | 
			
		||||
// Note: inlay hints for function argument names are heuristically omitted to reduce noise and will not appear if
 | 
			
		||||
// any of the
 | 
			
		||||
// link:https://github.com/rust-lang/rust-analyzer/blob/6b8b8ff4c56118ddee6c531cde06add1aad4a6af/crates/ide/src/inlay_hints/param_name.rs#L92-L99[following criteria]
 | 
			
		||||
// [following criteria](https://github.com/rust-lang/rust-analyzer/blob/6b8b8ff4c56118ddee6c531cde06add1aad4a6af/crates/ide/src/inlay_hints/param_name.rs#L92-L99)
 | 
			
		||||
// are met:
 | 
			
		||||
//
 | 
			
		||||
// * the parameter name is a suffix of the function's name
 | 
			
		||||
| 
						 | 
				
			
			@ -68,13 +68,13 @@ mod range_exclusive;
 | 
			
		|||
//   of argument with _ splitting it off
 | 
			
		||||
// * the parameter name starts with `ra_fixture`
 | 
			
		||||
// * the parameter name is a
 | 
			
		||||
// link:https://github.com/rust-lang/rust-analyzer/blob/6b8b8ff4c56118ddee6c531cde06add1aad4a6af/crates/ide/src/inlay_hints/param_name.rs#L200[well known name]
 | 
			
		||||
// [well known name](https://github.com/rust-lang/rust-analyzer/blob/6b8b8ff4c56118ddee6c531cde06add1aad4a6af/crates/ide/src/inlay_hints/param_name.rs#L200)
 | 
			
		||||
// in a unary function
 | 
			
		||||
// * the parameter name is a
 | 
			
		||||
// link:https://github.com/rust-lang/rust-analyzer/blob/6b8b8ff4c56118ddee6c531cde06add1aad4a6af/crates/ide/src/inlay_hints/param_name.rs#L201[single character]
 | 
			
		||||
// [single character](https://github.com/rust-lang/rust-analyzer/blob/6b8b8ff4c56118ddee6c531cde06add1aad4a6af/crates/ide/src/inlay_hints/param_name.rs#L201)
 | 
			
		||||
// in a unary function
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020660-b5f98b80-917a-11eb-8d70-3be3fd558cdd.png[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn inlay_hints(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    file_id: FileId,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,11 +7,9 @@ use syntax::{algo::ancestors_at_offset, ast, AstNode, TextRange};
 | 
			
		|||
 | 
			
		||||
// Feature: Interpret A Function, Static Or Const.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Interpret**
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Interpret** |
 | 
			
		||||
pub(crate) fn interpret(db: &RootDatabase, position: FilePosition) -> String {
 | 
			
		||||
    match find_and_interpret(db, position) {
 | 
			
		||||
        Some((duration, mut result)) => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,17 +21,13 @@ pub struct JoinLinesConfig {
 | 
			
		|||
//
 | 
			
		||||
// Join selected lines into one, smartly fixing up whitespace, trailing commas, and braces.
 | 
			
		||||
//
 | 
			
		||||
// See
 | 
			
		||||
// https://user-images.githubusercontent.com/1711539/124515923-4504e800-dde9-11eb-8d58-d97945a1a785.gif[this gif]
 | 
			
		||||
// for the cases handled specially by joined lines.
 | 
			
		||||
// See [this gif](https://user-images.githubusercontent.com/1711539/124515923-4504e800-dde9-11eb-8d58-d97945a1a785.gif) for the cases handled specially by joined lines.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Join lines** |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Join lines**
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020661-b6922200-917a-11eb-87c4-b75acc028f11.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn join_lines(
 | 
			
		||||
    config: &JoinLinesConfig,
 | 
			
		||||
    file: &SourceFile,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,13 +9,11 @@ use syntax::{
 | 
			
		|||
// moves cursor to the matching brace. It uses the actual parser to determine
 | 
			
		||||
// braces, so it won't confuse generics with comparisons.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Find matching brace** |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Find matching brace**
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065573-04298180-91b1-11eb-8dec-d4e2a202f304.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> {
 | 
			
		||||
    const BRACES: &[SyntaxKind] =
 | 
			
		||||
        &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>], T![|], T![|]];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,14 +17,12 @@ pub enum Direction {
 | 
			
		|||
//
 | 
			
		||||
// Move item under cursor or selection up and down.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Move item up**
 | 
			
		||||
// | VS Code | **rust-analyzer: Move item down**
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065576-04298180-91b1-11eb-91ce-4505e99ed598.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn move_item(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    range: FileRange,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,13 +15,11 @@ use crate::NavigationTarget;
 | 
			
		|||
//
 | 
			
		||||
// Navigates to the parent module of the current module.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Locate parent module** |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Locate parent module**
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065580-04c21800-91b1-11eb-9a32-00086161c0bd.gif[]
 | 
			
		||||
// 
 | 
			
		||||
 | 
			
		||||
/// This returns `Vec` because a module may be included from several places.
 | 
			
		||||
pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<NavigationTarget> {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,13 +43,11 @@ pub struct Declaration {
 | 
			
		|||
//
 | 
			
		||||
// Shows all references of the item at the cursor location
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Shortcut
 | 
			
		||||
// | Editor  | Shortcut |
 | 
			
		||||
// |---------|----------|
 | 
			
		||||
// | VS Code | <kbd>Shift+Alt+F12</kbd> |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | kbd:[Shift+Alt+F12]
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113020670-b7c34f00-917a-11eb-8003-370ac5f2b3cb.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn find_all_refs(
 | 
			
		||||
    sema: &Semantics<'_, RootDatabase>,
 | 
			
		||||
    position: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,13 +71,11 @@ pub(crate) fn prepare_rename(
 | 
			
		|||
//
 | 
			
		||||
// Renames the item below the cursor and all of its references
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Shortcut
 | 
			
		||||
// | Editor  | Shortcut |
 | 
			
		||||
// |---------|----------|
 | 
			
		||||
// | VS Code | <kbd>F2</kbd> |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | kbd:[F2]
 | 
			
		||||
// |===
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065582-055aae80-91b1-11eb-8ade-2b58e6d81883.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn rename(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    position: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -119,12 +119,11 @@ impl Runnable {
 | 
			
		|||
// location**. Super useful for repeatedly running just a single test. Do bind this
 | 
			
		||||
// to a shortcut!
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Run** |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Run**
 | 
			
		||||
// |===
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065583-055aae80-91b1-11eb-958f-d67efcaf6a2f.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
 | 
			
		||||
    let sema = Semantics::new(db);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -207,11 +206,9 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
 | 
			
		|||
// The simplest way to use this feature is via the context menu. Right-click on
 | 
			
		||||
// the selected item. The context menu opens. Select **Peek Related Tests**.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Peek Related Tests**
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Peek Related Tests** |
 | 
			
		||||
pub(crate) fn related_tests(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    position: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,12 +29,11 @@ use triomphe::Arc;
 | 
			
		|||
//
 | 
			
		||||
// Shows internal statistic about memory usage of rust-analyzer.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Status** |
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Status**
 | 
			
		||||
// |===
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065584-05f34500-91b1-11eb-98cc-5c196f76be7f.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn status(db: &RootDatabase, file_id: Option<FileId>) -> String {
 | 
			
		||||
    let mut buf = String::new();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,113 +76,118 @@ pub struct HighlightConfig {
 | 
			
		|||
// We also give special modifier for `mut` and `&mut` local variables.
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
// .Token Tags
 | 
			
		||||
// #### Token Tags
 | 
			
		||||
//
 | 
			
		||||
// Rust-analyzer currently emits the following token tags:
 | 
			
		||||
//
 | 
			
		||||
// - For items:
 | 
			
		||||
// +
 | 
			
		||||
// [horizontal]
 | 
			
		||||
// attribute:: Emitted for attribute macros.
 | 
			
		||||
// enum:: Emitted for enums.
 | 
			
		||||
// function:: Emitted for free-standing functions.
 | 
			
		||||
// derive:: Emitted for derive macros.
 | 
			
		||||
// macro:: Emitted for function-like macros.
 | 
			
		||||
// method:: Emitted for associated functions, also knowns as methods.
 | 
			
		||||
// namespace:: Emitted for modules.
 | 
			
		||||
// struct:: Emitted for structs.
 | 
			
		||||
// trait:: Emitted for traits.
 | 
			
		||||
// typeAlias:: Emitted for type aliases and `Self` in `impl`s.
 | 
			
		||||
// union:: Emitted for unions.
 | 
			
		||||
//
 | 
			
		||||
// |           |                                |
 | 
			
		||||
// |-----------|--------------------------------|
 | 
			
		||||
// | attribute |  Emitted for attribute macros. |
 | 
			
		||||
// |enum| Emitted for enums. |
 | 
			
		||||
// |function| Emitted for free-standing functions. |
 | 
			
		||||
// |derive| Emitted for derive macros. |
 | 
			
		||||
// |macro| Emitted for function-like macros. |
 | 
			
		||||
// |method| Emitted for associated functions, also knowns as methods. |
 | 
			
		||||
// |namespace| Emitted for modules. |
 | 
			
		||||
// |struct| Emitted for structs.|
 | 
			
		||||
// |trait| Emitted for traits.|
 | 
			
		||||
// |typeAlias| Emitted for type aliases and `Self` in `impl`s.|
 | 
			
		||||
// |union| Emitted for unions.|
 | 
			
		||||
//
 | 
			
		||||
// - For literals:
 | 
			
		||||
// +
 | 
			
		||||
// [horizontal]
 | 
			
		||||
// boolean:: Emitted for the boolean literals `true` and `false`.
 | 
			
		||||
// character:: Emitted for character literals.
 | 
			
		||||
// number:: Emitted for numeric literals.
 | 
			
		||||
// string:: Emitted for string literals.
 | 
			
		||||
// escapeSequence:: Emitted for escaped sequences inside strings like `\n`.
 | 
			
		||||
// formatSpecifier:: Emitted for format specifiers `{:?}` in `format!`-like macros.
 | 
			
		||||
//
 | 
			
		||||
// |           |                                |
 | 
			
		||||
// |-----------|--------------------------------|
 | 
			
		||||
// | boolean|  Emitted for the boolean literals `true` and `false`.|
 | 
			
		||||
// | character| Emitted for character literals.|
 | 
			
		||||
// | number| Emitted for numeric literals.|
 | 
			
		||||
// | string| Emitted for string literals.|
 | 
			
		||||
// | escapeSequence| Emitted for escaped sequences inside strings like `\n`.|
 | 
			
		||||
// | formatSpecifier| Emitted for format specifiers `{:?}` in `format!`-like macros.|
 | 
			
		||||
//
 | 
			
		||||
// - For operators:
 | 
			
		||||
// +
 | 
			
		||||
// [horizontal]
 | 
			
		||||
// operator:: Emitted for general operators.
 | 
			
		||||
// arithmetic:: Emitted for the arithmetic operators `+`, `-`, `*`, `/`, `+=`, `-=`, `*=`, `/=`.
 | 
			
		||||
// bitwise:: Emitted for the bitwise operators `|`, `&`, `!`, `^`, `|=`, `&=`, `^=`.
 | 
			
		||||
// comparison:: Emitted for the comparison operators `>`, `<`, `==`, `>=`, `<=`, `!=`.
 | 
			
		||||
// logical:: Emitted for the logical operators `||`, `&&`, `!`.
 | 
			
		||||
//
 | 
			
		||||
// |           |                                |
 | 
			
		||||
// |-----------|--------------------------------|
 | 
			
		||||
// |operator| Emitted for general operators.|
 | 
			
		||||
// |arithmetic| Emitted for the arithmetic operators `+`, `-`, `*`, `/`, `+=`, `-=`, `*=`, `/=`.|
 | 
			
		||||
// |bitwise| Emitted for the bitwise operators `|`, `&`, `!`, `^`, `|=`, `&=`, `^=`.|
 | 
			
		||||
// |comparison| Emitted for the comparison oerators `>`, `<`, `==`, `>=`, `<=`, `!=`.|
 | 
			
		||||
// |logical| Emitted for the logical operatos `||`, `&&`, `!`.|
 | 
			
		||||
//
 | 
			
		||||
// - For punctuation:
 | 
			
		||||
// +
 | 
			
		||||
// [horizontal]
 | 
			
		||||
// punctuation:: Emitted for general punctuation.
 | 
			
		||||
// attributeBracket:: Emitted for attribute invocation brackets, that is the `#[` and `]` tokens.
 | 
			
		||||
// angle:: Emitted for `<>` angle brackets.
 | 
			
		||||
// brace:: Emitted for `{}` braces.
 | 
			
		||||
// bracket:: Emitted for `[]` brackets.
 | 
			
		||||
// parenthesis:: Emitted for `()` parentheses.
 | 
			
		||||
// colon:: Emitted for the `:` token.
 | 
			
		||||
// comma:: Emitted for the `,` token.
 | 
			
		||||
// dot:: Emitted for the `.` token.
 | 
			
		||||
// semi:: Emitted for the `;` token.
 | 
			
		||||
// macroBang:: Emitted for the `!` token in macro calls.
 | 
			
		||||
//
 | 
			
		||||
// //-
 | 
			
		||||
// |           |                                |
 | 
			
		||||
// |-----------|--------------------------------|
 | 
			
		||||
// |punctuation| Emitted for general punctuation.|
 | 
			
		||||
// |attributeBracket| Emitted for attribute invocation brackets, that is the `#[` and `]` tokens.|
 | 
			
		||||
// |angle| Emitted for `<>` angle brackets.|
 | 
			
		||||
// |brace| Emitted for `{}` braces.|
 | 
			
		||||
// |bracket| Emitted for `[]` brackets.|
 | 
			
		||||
// |parenthesis| Emitted for `()` parentheses.|
 | 
			
		||||
// |colon| Emitted for the `:` token.|
 | 
			
		||||
// |comma| Emitted for the `,` token.|
 | 
			
		||||
// |dot| Emitted for the `.` token.|
 | 
			
		||||
// |semi| Emitted for the `;` token.|
 | 
			
		||||
// |macroBang| Emitted for the `!` token in macro calls.|
 | 
			
		||||
//
 | 
			
		||||
// [horizontal]
 | 
			
		||||
// builtinAttribute:: Emitted for names to builtin attributes in attribute path, the `repr` in `#[repr(u8)]` for example.
 | 
			
		||||
// builtinType:: Emitted for builtin types like `u32`, `str` and `f32`.
 | 
			
		||||
// comment:: Emitted for comments.
 | 
			
		||||
// constParameter:: Emitted for const parameters.
 | 
			
		||||
// deriveHelper:: Emitted for derive helper attributes.
 | 
			
		||||
// enumMember:: Emitted for enum variants.
 | 
			
		||||
// generic:: Emitted for generic tokens that have no mapping.
 | 
			
		||||
// keyword:: Emitted for keywords.
 | 
			
		||||
// label:: Emitted for labels.
 | 
			
		||||
// lifetime:: Emitted for lifetimes.
 | 
			
		||||
// parameter:: Emitted for non-self function parameters.
 | 
			
		||||
// property:: Emitted for struct and union fields.
 | 
			
		||||
// selfKeyword:: Emitted for the self function parameter and self path-specifier.
 | 
			
		||||
// selfTypeKeyword:: Emitted for the Self type parameter.
 | 
			
		||||
// toolModule:: Emitted for tool modules.
 | 
			
		||||
// typeParameter:: Emitted for type parameters.
 | 
			
		||||
// unresolvedReference:: Emitted for unresolved references, names that rust-analyzer can't find the definition of.
 | 
			
		||||
// variable:: Emitted for locals, constants and statics.
 | 
			
		||||
//-
 | 
			
		||||
//
 | 
			
		||||
// |           |                                |
 | 
			
		||||
// |-----------|--------------------------------|
 | 
			
		||||
// |builtinAttribute| Emitted for names to builtin attributes in attribute path, the `repr` in `#[repr(u8)]` for example.|
 | 
			
		||||
// |builtinType| Emitted for builtin types like `u32`, `str` and `f32`.|
 | 
			
		||||
// |comment| Emitted for comments.|
 | 
			
		||||
// |constParameter| Emitted for const parameters.|
 | 
			
		||||
// |deriveHelper| Emitted for derive helper attributes.|
 | 
			
		||||
// |enumMember| Emitted for enum variants.|
 | 
			
		||||
// |generic| Emitted for generic tokens that have no mapping.|
 | 
			
		||||
// |keyword| Emitted for keywords.|
 | 
			
		||||
// |label| Emitted for labels.|
 | 
			
		||||
// |lifetime| Emitted for lifetimes.|
 | 
			
		||||
// |parameter| Emitted for non-self function parameters.|
 | 
			
		||||
// |property| Emitted for struct and union fields.|
 | 
			
		||||
// |selfKeyword| Emitted for the self function parameter and self path-specifier.|
 | 
			
		||||
// |selfTypeKeyword| Emitted for the Self type parameter.|
 | 
			
		||||
// |toolModule| Emitted for tool modules.|
 | 
			
		||||
// |typeParameter| Emitted for type parameters.|
 | 
			
		||||
// |unresolvedReference| Emitted for unresolved references, names that rust-analyzer can't find the definition of.|
 | 
			
		||||
// |variable| Emitted for locals, constants and statics.|
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
// .Token Modifiers
 | 
			
		||||
// #### Token Modifiers
 | 
			
		||||
//
 | 
			
		||||
// Token modifiers allow to style some elements in the source code more precisely.
 | 
			
		||||
//
 | 
			
		||||
// Rust-analyzer currently emits the following token modifiers:
 | 
			
		||||
//
 | 
			
		||||
// [horizontal]
 | 
			
		||||
// async:: Emitted for async functions and the `async` and `await` keywords.
 | 
			
		||||
// attribute:: Emitted for tokens inside attributes.
 | 
			
		||||
// callable:: Emitted for locals whose types implements one of the `Fn*` traits.
 | 
			
		||||
// constant:: Emitted for consts.
 | 
			
		||||
// consuming:: Emitted for locals that are being consumed when use in a function call.
 | 
			
		||||
// controlFlow:: Emitted for control-flow related tokens, this includes the `?` operator.
 | 
			
		||||
// crateRoot:: Emitted for crate names, like `serde` and `crate`.
 | 
			
		||||
// declaration:: Emitted for names of definitions, like `foo` in `fn foo() {}`.
 | 
			
		||||
// defaultLibrary:: Emitted for items from built-in crates (std, core, alloc, test and proc_macro).
 | 
			
		||||
// documentation:: Emitted for documentation comments.
 | 
			
		||||
// injected:: Emitted for doc-string injected highlighting like rust source blocks in documentation.
 | 
			
		||||
// intraDocLink:: Emitted for intra doc links in doc-strings.
 | 
			
		||||
// library:: Emitted for items that are defined outside of the current crate.
 | 
			
		||||
// macro::  Emitted for tokens inside macro calls.
 | 
			
		||||
// mutable:: Emitted for mutable locals and statics as well as functions taking `&mut self`.
 | 
			
		||||
// public:: Emitted for items that are from the current crate and are `pub`.
 | 
			
		||||
// reference:: Emitted for locals behind a reference and functions taking `self` by reference.
 | 
			
		||||
// static:: Emitted for "static" functions, also known as functions that do not take a `self` param, as well as statics and consts.
 | 
			
		||||
// trait:: Emitted for associated trait items.
 | 
			
		||||
// unsafe:: Emitted for unsafe operations, like unsafe function calls, as well as the `unsafe` token.
 | 
			
		||||
// |           |                                |
 | 
			
		||||
// |-----------|--------------------------------|
 | 
			
		||||
// |async| Emitted for async functions and the `async` and `await` keywords.|
 | 
			
		||||
// |attribute| Emitted for tokens inside attributes.|
 | 
			
		||||
// |callable| Emitted for locals whose types implements one of the `Fn*` traits.|
 | 
			
		||||
// |constant| Emitted for const.|
 | 
			
		||||
// |consuming| Emitted for locals that are being consumed when use in a function call.|
 | 
			
		||||
// |controlFlow| Emitted for control-flow related tokens, this includes th `?` operator.|
 | 
			
		||||
// |crateRoot| Emitted for crate names, like `serde` and `crate.|
 | 
			
		||||
// |declaration| Emitted for names of definitions, like `foo` in `fn foo(){}`.|
 | 
			
		||||
// |defaultLibrary| Emitted for items from built-in crates (std, core, allc, test and proc_macro).|
 | 
			
		||||
// |documentation| Emitted for documentation comment.|
 | 
			
		||||
// |injected| Emitted for doc-string injected highlighting like rust source blocks in documentation.|
 | 
			
		||||
// |intraDocLink| Emitted for intra doc links in doc-string.|
 | 
			
		||||
// |library| Emitted for items that are defined outside of the current crae.|
 | 
			
		||||
// |macro|  Emitted for tokens inside macro call.|
 | 
			
		||||
// |mutable| Emitted for mutable locals and statics as well as functions taking `&mut self`.|
 | 
			
		||||
// |public| Emitted for items that are from the current crate and are `pub.|
 | 
			
		||||
// |reference| Emitted for locals behind a reference and functions taking self` by reference.|
 | 
			
		||||
// |static| Emitted for "static" functions, also known as functions that d not take a `self` param, as well as statics and consts.|
 | 
			
		||||
// |trait| Emitted for associated trait item.|
 | 
			
		||||
// |unsafe| Emitted for unsafe operations, like unsafe function calls, as ell as the `unsafe` token.|
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113164457-06cfb980-9239-11eb-819b-0f93e646acf8.png[]
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113187625-f7f50100-9250-11eb-825e-91c58f236071.png[]
 | 
			
		||||
// 
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn highlight(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    config: HighlightConfig,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,16 +51,15 @@ struct ExtendedTextEdit {
 | 
			
		|||
// - typing `{` in a use item adds a closing `}` in the right place
 | 
			
		||||
// - typing `>` to complete a return type `->` will insert a whitespace after it
 | 
			
		||||
//
 | 
			
		||||
// VS Code::
 | 
			
		||||
// #### VS Code
 | 
			
		||||
//
 | 
			
		||||
// Add the following to `settings.json`:
 | 
			
		||||
// [source,json]
 | 
			
		||||
// ----
 | 
			
		||||
// ```json
 | 
			
		||||
// "editor.formatOnType": true,
 | 
			
		||||
// ----
 | 
			
		||||
// ```
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113166163-69758500-923a-11eb-81ee-eb33ec380399.gif[]
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113171066-105c2000-923f-11eb-87ab-f4a263346567.gif[]
 | 
			
		||||
// 
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn on_char_typed(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    position: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,12 @@ use ide_db::text_edit::TextEdit;
 | 
			
		|||
 | 
			
		||||
// Feature: On Enter
 | 
			
		||||
//
 | 
			
		||||
// rust-analyzer can override kbd:[Enter] key to make it smarter:
 | 
			
		||||
// rust-analyzer can override <kbd>Enter</kbd> key to make it smarter:
 | 
			
		||||
//
 | 
			
		||||
// - kbd:[Enter] inside triple-slash comments automatically inserts `///`
 | 
			
		||||
// - kbd:[Enter] in the middle or after a trailing space in `//` inserts `//`
 | 
			
		||||
// - kbd:[Enter] inside `//!` doc comments automatically inserts `//!`
 | 
			
		||||
// - kbd:[Enter] after `{` indents contents and closing `}` of single-line block
 | 
			
		||||
// - <kbd>Enter</kbd> inside triple-slash comments automatically inserts `///`
 | 
			
		||||
// - <kbd>Enter</kbd> in the middle or after a trailing space in `//` inserts `//`
 | 
			
		||||
// - <kbd>Enter</kbd> inside `//!` doc comments automatically inserts `//!`
 | 
			
		||||
// - <kbd>Enter</kbd> after `{` indents contents and closing `}` of single-line block
 | 
			
		||||
//
 | 
			
		||||
// This action needs to be assigned to shortcut explicitly.
 | 
			
		||||
//
 | 
			
		||||
| 
						 | 
				
			
			@ -29,29 +29,27 @@ use ide_db::text_edit::TextEdit;
 | 
			
		|||
// Similarly, if rust-analyzer crashes or stops responding, `Enter` might not work.
 | 
			
		||||
// In that case, you can still press `Shift-Enter` to insert a newline.
 | 
			
		||||
//
 | 
			
		||||
// VS Code::
 | 
			
		||||
// #### VS Code
 | 
			
		||||
//
 | 
			
		||||
// Add the following to `keybindings.json`:
 | 
			
		||||
// [source,json]
 | 
			
		||||
// ----
 | 
			
		||||
// ```json
 | 
			
		||||
// {
 | 
			
		||||
//   "key": "Enter",
 | 
			
		||||
//   "command": "rust-analyzer.onEnter",
 | 
			
		||||
//   "when": "editorTextFocus && !suggestWidgetVisible && editorLangId == rust"
 | 
			
		||||
// }
 | 
			
		||||
// ----
 | 
			
		||||
// ````
 | 
			
		||||
//
 | 
			
		||||
// When using the Vim plugin:
 | 
			
		||||
// [source,json]
 | 
			
		||||
// ----
 | 
			
		||||
// ```json
 | 
			
		||||
// {
 | 
			
		||||
//   "key": "Enter",
 | 
			
		||||
//   "command": "rust-analyzer.onEnter",
 | 
			
		||||
//   "when": "editorTextFocus && !suggestWidgetVisible && editorLangId == rust && vim.mode == 'Insert'"
 | 
			
		||||
// }
 | 
			
		||||
// ----
 | 
			
		||||
// ````
 | 
			
		||||
//
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065578-04c21800-91b1-11eb-82b8-22b8c481e645.gif[]
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<TextEdit> {
 | 
			
		||||
    let parse = db.parse(EditionedFileId::current_edition(position.file_id));
 | 
			
		||||
    let file = parse.tree();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,11 +12,9 @@ use triomphe::Arc;
 | 
			
		|||
//
 | 
			
		||||
// Only workspace crates are included, no crates.io dependencies or sysroot crates.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: View Crate Graph**
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: View Crate Graph** |
 | 
			
		||||
pub(crate) fn view_crate_graph(db: &RootDatabase, full: bool) -> Result<String, String> {
 | 
			
		||||
    let crate_graph = db.crate_graph();
 | 
			
		||||
    let crates_to_render = crate_graph
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,12 +4,11 @@ use syntax::{algo::ancestors_at_offset, ast, AstNode};
 | 
			
		|||
 | 
			
		||||
// Feature: View Hir
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|--------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: View Hir**
 | 
			
		||||
// |===
 | 
			
		||||
// image::https://user-images.githubusercontent.com/48062697/113065588-068bdb80-91b1-11eb-9a78-0b4ef1e972fb.gif[]
 | 
			
		||||
//
 | 
			
		||||
// 
 | 
			
		||||
pub(crate) fn view_hir(db: &RootDatabase, position: FilePosition) -> String {
 | 
			
		||||
    body_hir(db, position).unwrap_or_else(|| "Not inside a function body".to_owned())
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,11 +6,9 @@ use span::EditionedFileId;
 | 
			
		|||
//
 | 
			
		||||
// Displays the ItemTree of the currently open file, for debugging.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: Debug ItemTree**
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: Debug ItemTree** |
 | 
			
		||||
pub(crate) fn view_item_tree(db: &RootDatabase, file_id: FileId) -> String {
 | 
			
		||||
    let sema = Semantics::new(db);
 | 
			
		||||
    let file_id = sema
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,11 +75,9 @@ impl FieldOrTupleIdx {
 | 
			
		|||
//
 | 
			
		||||
// Displays the recursive memory layout of a datatype.
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **rust-analyzer: View Memory Layout**
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: View Memory Layout** |
 | 
			
		||||
pub(crate) fn view_memory_layout(
 | 
			
		||||
    db: &RootDatabase,
 | 
			
		||||
    position: FilePosition,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,11 +4,9 @@ use syntax::{algo::ancestors_at_offset, ast, AstNode};
 | 
			
		|||
 | 
			
		||||
// Feature: View Mir
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Action Name
 | 
			
		||||
//
 | 
			
		||||
// | Editor  | Action Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **rust-analyzer: View Mir**
 | 
			
		||||
// |===
 | 
			
		||||
pub(crate) fn view_mir(db: &RootDatabase, position: FilePosition) -> String {
 | 
			
		||||
    body_mir(db, position).unwrap_or_else(|| "Not inside a function body".to_owned())
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,11 +15,9 @@ use triomphe::Arc;
 | 
			
		|||
//
 | 
			
		||||
// Shows a tree view with the syntax tree of the current file
 | 
			
		||||
//
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Panel Name
 | 
			
		||||
//
 | 
			
		||||
// | VS Code | **Rust Syntax Tree**
 | 
			
		||||
// |===
 | 
			
		||||
// | Editor  | Panel Name |
 | 
			
		||||
// |---------|-------------|
 | 
			
		||||
// | VS Code | **Rust Syntax Tree** |
 | 
			
		||||
pub(crate) fn view_syntax_tree(db: &RootDatabase, file_id: FileId) -> String {
 | 
			
		||||
    let sema = Semantics::new(db);
 | 
			
		||||
    let line_index = db.line_index(file_id);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue