rust-analyzer/syntax/index.html
github-merge-queue[bot] cddc2a952f deploy: 9923b0085c
2025-01-11 06:35:13 +00:00

20 lines
No EOL
13 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Syntax Tree library used throughout the rust-analyzer."><title>syntax - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="syntax" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../syntax/index.html">syntax</a><span class="version">0.0.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#reexports">Crate Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>syntax</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/syntax/lib.rs.html#1-407">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Syntax Tree library used throughout the rust-analyzer.</p>
<p>Properties:</p>
<ul>
<li>easy and fast incremental re-parsing</li>
<li>graceful handling of errors</li>
<li>full-fidelity representation (<em>any</em> text can be precisely represented as
a syntax tree)</li>
</ul>
<p>For more information, see the <a href="https://github.com/rust-lang/rfcs/pull/2256">RFC</a>. Current implementation is inspired by
the <a href="https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md">Swift</a> one.</p>
<p>The most interesting modules here are <code>syntax_node</code> (which defines concrete
syntax tree) and <code>ast</code> (which defines abstract syntax tree on top of the
CST). The actual parser live in a separate <code>parser</code> crate, though the
lexer lives in this crate.</p>
<p>See <code>api_walkthrough</code> test in this file for a quick API tour!</p>
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.AstNode"><code>pub use crate::ast::<a class="trait" href="ast/trait.AstNode.html" title="trait syntax::ast::AstNode">AstNode</a>;</code></div></li><li><div class="item-name" id="reexport.AstToken"><code>pub use crate::ast::<a class="trait" href="ast/trait.AstToken.html" title="trait syntax::ast::AstToken">AstToken</a>;</code></div></li><li><div class="item-name" id="reexport.SourceFile"><code>pub use crate::ast::<a class="struct" href="ast/struct.SourceFile.html" title="struct syntax::ast::SourceFile">SourceFile</a>;</code></div></li></ul><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="algo/index.html" title="mod syntax::algo">algo</a></div><div class="desc docblock-short">Collection of assorted algorithms for syntax trees.</div></li><li><div class="item-name"><a class="mod" href="ast/index.html" title="mod syntax::ast">ast</a></div><div class="desc docblock-short">Abstract Syntax Tree, layered on top of untyped <code>SyntaxNode</code>s</div></li><li><div class="item-name"><a class="mod" href="hacks/index.html" title="mod syntax::hacks">hacks</a></div><div class="desc docblock-short">Things which exist to solve practical issues, but which shouldnt exist.</div></li><li><div class="item-name"><a class="mod" href="syntax_editor/index.html" title="mod syntax::syntax_editor">syntax_<wbr>editor</a></div><div class="desc docblock-short">Syntax Tree editor</div></li><li><div class="item-name"><a class="mod" href="ted/index.html" title="mod syntax::ted">ted</a></div><div class="desc docblock-short">Primitive tree editor, ed for trees.</div></li><li><div class="item-name"><a class="mod" href="unescape/index.html" title="mod syntax::unescape">unescape</a></div><div class="desc docblock-short">Utilities for validating string and char literals and turning them into
values they represent.</div></li><li><div class="item-name"><a class="mod" href="utils/index.html" title="mod syntax::utils">utils</a></div><div class="desc docblock-short">A set of utils methods to reuse on other abstraction levels</div></li></ul><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.T.html" title="macro syntax::T">T</a></div></li><li><div class="item-name"><a class="macro" href="macro.format_smolstr.html" title="macro syntax::format_smolstr">format_<wbr>smolstr</a></div><div class="desc docblock-short">Formats arguments to a <a href="struct.SmolStr.html" title="struct syntax::SmolStr"><code>SmolStr</code></a>, potentially without allocating.</div></li><li><div class="item-name"><a class="macro" href="macro.match_ast.html" title="macro syntax::match_ast">match_<wbr>ast</a></div><div class="desc docblock-short">Matches a <code>SyntaxNode</code> against an <code>ast</code> type.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.AstPtr.html" title="struct syntax::AstPtr">AstPtr</a></div><div class="desc docblock-short">Like <code>SyntaxNodePtr</code>, but remembers the type of node.</div></li><li><div class="item-name"><a class="struct" href="struct.GreenNode.html" title="struct syntax::GreenNode">Green<wbr>Node</a></div><div class="desc docblock-short">Internal node in the immutable tree.
It has other nodes and tokens as children.</div></li><li><div class="item-name"><a class="struct" href="struct.Parse.html" title="struct syntax::Parse">Parse</a></div><div class="desc docblock-short"><code>Parse</code> is the result of the parsing: a syntax tree and a collection of
errors.</div></li><li><div class="item-name"><a class="struct" href="struct.Preorder.html" title="struct syntax::Preorder">Preorder</a></div></li><li><div class="item-name"><a class="struct" href="struct.SmolStr.html" title="struct syntax::SmolStr">SmolStr</a></div><div class="desc docblock-short">A <code>SmolStr</code> is a string type that has the following properties:</div></li><li><div class="item-name"><a class="struct" href="struct.SmolStrBuilder.html" title="struct syntax::SmolStrBuilder">Smol<wbr>StrBuilder</a></div><div class="desc docblock-short">A builder that can be used to efficiently build a <a href="struct.SmolStr.html" title="struct syntax::SmolStr"><code>SmolStr</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.SyntaxError.html" title="struct syntax::SyntaxError">Syntax<wbr>Error</a></div><div class="desc docblock-short">Represents the result of unsuccessful tokenization, parsing
or tree validation.</div></li><li><div class="item-name"><a class="struct" href="struct.SyntaxText.html" title="struct syntax::SyntaxText">Syntax<wbr>Text</a></div></li><li><div class="item-name"><a class="struct" href="struct.SyntaxTreeBuilder.html" title="struct syntax::SyntaxTreeBuilder">Syntax<wbr>Tree<wbr>Builder</a></div></li><li><div class="item-name"><a class="struct" href="struct.TextRange.html" title="struct syntax::TextRange">Text<wbr>Range</a></div><div class="desc docblock-short">A range in text, represented as a pair of <a href="struct.TextSize.html" title="struct syntax::TextSize"><code>TextSize</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.TextSize.html" title="struct syntax::TextSize">Text<wbr>Size</a></div><div class="desc docblock-short">A measure of text length. Also, equivalently, an index into text.</div></li><li><div class="item-name"><a class="struct" href="struct.TokenText.html" title="struct syntax::TokenText">Token<wbr>Text</a></div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.Direction.html" title="enum syntax::Direction">Direction</a></div></li><li><div class="item-name"><a class="enum" href="enum.Edition.html" title="enum syntax::Edition">Edition</a></div></li><li><div class="item-name"><a class="enum" href="enum.NodeOrToken.html" title="enum syntax::NodeOrToken">Node<wbr>OrToken</a></div></li><li><div class="item-name"><a class="enum" href="enum.RustLanguage.html" title="enum syntax::RustLanguage">Rust<wbr>Language</a></div></li><li><div class="item-name"><a class="enum" href="enum.SyntaxKind.html" title="enum syntax::SyntaxKind">Syntax<wbr>Kind</a></div><div class="desc docblock-short">The kind of syntax node, e.g. <code>IDENT</code>, <code>USE_KW</code>, or <code>STRUCT</code>.</div></li><li><div class="item-name"><a class="enum" href="enum.TokenAtOffset.html" title="enum syntax::TokenAtOffset">Token<wbr>AtOffset</a></div><div class="desc docblock-short">There might be zero, one or two leaves at a given offset.</div></li><li><div class="item-name"><a class="enum" href="enum.WalkEvent.html" title="enum syntax::WalkEvent">Walk<wbr>Event</a></div><div class="desc docblock-short"><code>WalkEvent</code> describes tree walking process.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.ToSmolStr.html" title="trait syntax::ToSmolStr">ToSmol<wbr>Str</a></div><div class="desc docblock-short">Convert value to <a href="struct.SmolStr.html" title="struct syntax::SmolStr"><code>SmolStr</code></a> using <a href="https://doc.rust-lang.org/1.84.0/core/fmt/trait.Display.html" title="trait core::fmt::Display"><code>fmt::Display</code></a>, potentially without allocating.</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.PreorderWithTokens.html" title="type syntax::PreorderWithTokens">Preorder<wbr>With<wbr>Tokens</a></div></li><li><div class="item-name"><a class="type" href="type.SyntaxElement.html" title="type syntax::SyntaxElement">Syntax<wbr>Element</a></div></li><li><div class="item-name"><a class="type" href="type.SyntaxElementChildren.html" title="type syntax::SyntaxElementChildren">Syntax<wbr>Element<wbr>Children</a></div></li><li><div class="item-name"><a class="type" href="type.SyntaxNode.html" title="type syntax::SyntaxNode">Syntax<wbr>Node</a></div></li><li><div class="item-name"><a class="type" href="type.SyntaxNodeChildren.html" title="type syntax::SyntaxNodeChildren">Syntax<wbr>Node<wbr>Children</a></div></li><li><div class="item-name"><a class="type" href="type.SyntaxNodePtr.html" title="type syntax::SyntaxNodePtr">Syntax<wbr>Node<wbr>Ptr</a></div><div class="desc docblock-short">A “pointer” to a <a href="type.SyntaxNode.html" title="type syntax::SyntaxNode"><code>SyntaxNode</code></a>, via location in the source code.</div></li><li><div class="item-name"><a class="type" href="type.SyntaxToken.html" title="type syntax::SyntaxToken">Syntax<wbr>Token</a></div></li></ul></section></div></main></body></html>