Enum cstree::NodeOrToken[][src]

pub enum NodeOrToken<N, T> {
    Node(N),
    Token(T),
}

Convenience type to represent tree elements which may either be a node or a token.

Used for both red and green tree, references to elements, …

Variants

Node(N)
Token(T)

Implementations

impl NodeOrToken<GreenNode, GreenToken>[src]

pub fn kind(&self) -> SyntaxKind[src]

Returns kind of this element.

pub fn text_len(&self) -> TextSize[src]

Returns the length of the text covered by this element.

impl NodeOrToken<&'_ GreenNode, &'_ GreenToken>[src]

pub fn kind(&self) -> SyntaxKind[src]

Returns kind of this element.

pub fn text_len(self) -> TextSize[src]

Returns the length of the text covered by this element.

impl<L: Language, D> NodeOrToken<SyntaxNode<L, D>, SyntaxToken<L, D>>[src]

pub fn display(&self, resolver: &impl Resolver) -> String[src]

impl<'a, L: Language, D> NodeOrToken<&'a SyntaxNode<L, D>, &'a SyntaxToken<L, D>>[src]

pub fn display(&self, resolver: &impl Resolver) -> String[src]

impl<L: Language, D> NodeOrToken<SyntaxNode<L, D>, SyntaxToken<L, D>>[src]

pub fn text_range(&self) -> TextRange[src]

The range this element covers in the source text, in bytes.

pub fn syntax_kind(&self) -> SyntaxKind[src]

The internal representation of the kind of this element.

pub fn kind(&self) -> L::Kind[src]

The kind of this element in terms of your language.

pub fn parent(&self) -> Option<&SyntaxNode<L, D>>[src]

The parent node of this element, except if this element is the root.

pub fn ancestors(&self) -> impl Iterator<Item = &SyntaxNode<L, D>>[src]

Returns an iterator along the chain of parents of this node.

pub fn first_token(&self) -> Option<&SyntaxToken<L, D>>[src]

Return the leftmost token in the subtree of this element.

pub fn last_token(&self) -> Option<&SyntaxToken<L, D>>[src]

Return the rightmost token in the subtree of this element.

pub fn next_sibling_or_token(&self) -> Option<SyntaxElementRef<'_, L, D>>[src]

The tree element to the right of this one, i.e. the next child of this element’s parent after this element.

pub fn prev_sibling_or_token(&self) -> Option<SyntaxElementRef<'_, L, D>>[src]

The tree element to the left of this one, i.e. the previous child of this element’s parent after this element.

impl<'a, L: Language, D> NodeOrToken<&'a SyntaxNode<L, D>, &'a SyntaxToken<L, D>>[src]

pub fn text_range(&self) -> TextRange[src]

The range this element covers in the source text, in bytes.

pub fn syntax_kind(&self) -> SyntaxKind[src]

The internal representation of the kind of this element.

pub fn kind(&self) -> L::Kind[src]

The kind of this element in terms of your language.

pub fn parent(&self) -> Option<&'a SyntaxNode<L, D>>[src]

The parent node of this element, except if this element is the root.

pub fn ancestors(&self) -> impl Iterator<Item = &'a SyntaxNode<L, D>>[src]

Returns an iterator along the chain of parents of this node.

pub fn first_token(&self) -> Option<&'a SyntaxToken<L, D>>[src]

Return the leftmost token in the subtree of this element.

pub fn last_token(&self) -> Option<&'a SyntaxToken<L, D>>[src]

Return the rightmost token in the subtree of this element.

pub fn next_sibling_or_token(&self) -> Option<SyntaxElementRef<'a, L, D>>[src]

The tree element to the right of this one, i.e. the next child of this element’s parent after this element.

pub fn prev_sibling_or_token(&self) -> Option<SyntaxElementRef<'a, L, D>>[src]

The tree element to the left of this one, i.e. the previous child of this element’s parent after this element.

impl<L: Language, D> NodeOrToken<ResolvedNode<L, D>, ResolvedToken<L, D>>[src]

pub fn display(&self, resolver: &impl Resolver) -> String[src]

impl<L: Language, D> NodeOrToken<ResolvedNode<L, D>, ResolvedToken<L, D>>[src]

pub fn text_range(&self) -> TextRange[src]

The range this element covers in the source text, in bytes.

pub fn syntax_kind(&self) -> SyntaxKind[src]

The internal representation of the kind of this element.

pub fn kind(&self) -> L::Kind[src]

The kind of this element in terms of your language.

pub fn parent(&self) -> Option<&ResolvedNode<L, D>>[src]

The parent node of this element, except if this element is the root.

pub fn ancestors(&self) -> impl Iterator<Item = &ResolvedNode<L, D>>[src]

Returns an iterator along the chain of parents of this node.

pub fn first_token(&self) -> Option<&ResolvedToken<L, D>>[src]

Return the leftmost token in the subtree of this element.

pub fn last_token(&self) -> Option<&ResolvedToken<L, D>>[src]

Return the rightmost token in the subtree of this element.

pub fn next_sibling_or_token(&self) -> Option<ResolvedElementRef<'_, L, D>>[src]

The tree element to the right of this one, i.e. the next child of this element’s parent after this element.

pub fn prev_sibling_or_token(&self) -> Option<ResolvedElementRef<'_, L, D>>[src]

The tree element to the left of this one, i.e. the previous child of this element’s parent after this element.

impl<'a, L: Language, D> NodeOrToken<&'a ResolvedNode<L, D>, &'a ResolvedToken<L, D>>[src]

pub fn text_range(&self) -> TextRange[src]

The range this element covers in the source text, in bytes.

pub fn syntax_kind(&self) -> SyntaxKind[src]

The internal representation of the kind of this element.

pub fn kind(&self) -> L::Kind[src]

The kind of this element in terms of your language.

pub fn parent(&self) -> Option<&'a ResolvedNode<L, D>>[src]

The parent node of this element, except if this element is the root.

pub fn ancestors(&self) -> impl Iterator<Item = &'a ResolvedNode<L, D>>[src]

Returns an iterator along the chain of parents of this node.

pub fn first_token(&self) -> Option<&'a ResolvedToken<L, D>>[src]

Return the leftmost token in the subtree of this element.

pub fn last_token(&self) -> Option<&'a ResolvedToken<L, D>>[src]

Return the rightmost token in the subtree of this element.

pub fn next_sibling_or_token(&self) -> Option<ResolvedElementRef<'a, L, D>>[src]

The tree element to the right of this one, i.e. the next child of this element’s parent after this element.

pub fn prev_sibling_or_token(&self) -> Option<ResolvedElementRef<'a, L, D>>[src]

The tree element to the left of this one, i.e. the previous child of this element’s parent after this element.

impl<N, T> NodeOrToken<N, T>[src]

pub fn into_node(self) -> Option<N>[src]

pub fn into_token(self) -> Option<T>[src]

pub fn as_node(&self) -> Option<&N>[src]

pub fn as_token(&self) -> Option<&T>[src]

Trait Implementations

impl<N: Clone, T: Clone> Clone for NodeOrToken<N, T>[src]

impl<N: Copy, T: Copy> Copy for NodeOrToken<N, T>[src]

impl<N: Debug, T: Debug> Debug for NodeOrToken<N, T>[src]

impl<N: Display, T: Display> Display for NodeOrToken<N, T>[src]

impl<N: Eq, T: Eq> Eq for NodeOrToken<N, T>[src]

impl<'a> From<&'a GreenNode> for NodeOrToken<&'a GreenNode, &'a GreenToken>[src]

impl<'a> From<&'a GreenToken> for NodeOrToken<&'a GreenNode, &'a GreenToken>[src]

impl<'a, L: Language, D> From<&'a NodeOrToken<ResolvedNode<L, D>, ResolvedToken<L, D>>> for ResolvedElementRef<'a, L, D>[src]

impl<'a, L: Language, D> From<&'a NodeOrToken<SyntaxNode<L, D>, SyntaxToken<L, D>>> for SyntaxElementRef<'a, L, D>[src]

impl From<GreenNode> for NodeOrToken<GreenNode, GreenToken>[src]

impl From<GreenToken> for NodeOrToken<GreenNode, GreenToken>[src]

impl<N: Hash, T: Hash> Hash for NodeOrToken<N, T>[src]

impl<N: Ord, T: Ord> Ord for NodeOrToken<N, T>[src]

impl<N: PartialEq, T: PartialEq> PartialEq<NodeOrToken<N, T>> for NodeOrToken<N, T>[src]

impl<N: PartialOrd, T: PartialOrd> PartialOrd<NodeOrToken<N, T>> for NodeOrToken<N, T>[src]

impl<N, T> StructuralEq for NodeOrToken<N, T>[src]

impl<N, T> StructuralPartialEq for NodeOrToken<N, T>[src]

Auto Trait Implementations

impl<N, T> RefUnwindSafe for NodeOrToken<N, T> where
    N: RefUnwindSafe,
    T: RefUnwindSafe

impl<N, T> Send for NodeOrToken<N, T> where
    N: Send,
    T: Send

impl<N, T> Sync for NodeOrToken<N, T> where
    N: Sync,
    T: Sync

impl<N, T> Unpin for NodeOrToken<N, T> where
    N: Unpin,
    T: Unpin

impl<N, T> UnwindSafe for NodeOrToken<N, T> where
    N: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CallHasher for T where
    T: Hash

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.