Struct RainLanguageServices

Source
pub struct RainLanguageServices { /* private fields */ }
Expand description

Provides methods for getting language services (such as diagnostics, completion, etc) for a given TextDocumentItem or a RainDocument. Each instance is linked to a shared locked Store instance Arc<RwLock<Store>> that holds all the required metadata/functionalities that are required during parsing a text.

Position encodings provided by the client are irrevelant as RainDocument/Rainlang supports only ASCII characters (parsing will stop at very first encountered non-ASCII character), so any position encodings will result in the same LSP provided Position value which is 1 for each char.

§Example

use std::sync::{Arc, RwLock};
use dotrain_lsp::{
    RainLanguageServices, 
    LanguageServiceParams, 
    dotrain::Store, 
    lsp_types::{TextDocumentItem, MarkupKind, Position, Url}
};

// instaniate a shared locked Store
let meta_store = Arc::new(RwLock::new(Store::default()));

// create instatiation params
let params = LanguageServiceParams {
    meta_store: Some(meta_store)
};

// create a new instane with a shared locked Store that is used for all
// parsings that are triggered through available methods of this instance
let lang_services = RainLanguageServices::new(&params);

let text_document = TextDocumentItem {
    uri: Url::parse("file:///example.rain").unwrap(),
    text: "some .rain text content".to_string(),
    version: 0,
    language_id: "rainlang".to_string()
};

// create a new RainDocument instance
let rain_document = lang_services.new_rain_document(&text_document, None);

// get LSP Diagnostics for a given TextDocumentItem
let diagnostics_related_information = true;
let diagnostics = lang_services.do_validate(&text_document, diagnostics_related_information, None);

let position = Position {
    line: 0,
    character: 10
};
let content_format = Some(MarkupKind::PlainText);
let hover = lang_services.do_hover(&text_document, position, content_format, None);

Implementations§

Source§

impl RainLanguageServices

Source

pub fn js_meta_store(&self) -> MetaStore

The meta Store associated with this RainLanguageServices instance

Source

pub fn js_new(meta_store: &MetaStore) -> RainLanguageServices

Instantiates with the given MetaStore

Source

pub fn js_new_rain_document( &self, text_document: TextDocumentItem, rebinds: Option<Vec<Rebind>>, ) -> RainDocument

Instantiates a RainDocument with remote meta search disabled when parsing from the given TextDocumentItem

Source

pub async fn js_new_rain_document_async( &self, text_document: TextDocumentItem, rebinds: Option<Vec<Rebind>>, ) -> RainDocument

Instantiates a RainDocument with remote meta search enabled when parsing from the given TextDocumentItem

Source

pub fn js_do_validate( &self, text_document: TextDocumentItem, related_information: bool, rebinds: Option<Vec<Rebind>>, ) -> Vec<Diagnostic>

Validates the document with remote meta search disabled when parsing and reports LSP diagnostics

Source

pub fn js_do_validate_rain_document( &self, rain_document: &RainDocument, uri: &str, related_information: bool, ) -> Vec<Diagnostic>

Reports LSP diagnostics from RainDocument’s all problems

Source

pub async fn js_do_validate_async( &self, text_document: TextDocumentItem, related_information: bool, rebinds: Option<Vec<Rebind>>, ) -> JsValue

Validates the document with remote meta search enabled when parsing and reports LSP diagnostics

Source

pub fn js_do_complete( &self, text_document: TextDocumentItem, position: Position, documentation_format: Option<MarkupKind>, rebinds: Option<Vec<Rebind>>, ) -> Option<Vec<CompletionItem>>

Provides completion items at the given position

Source

pub fn js_do_complete_rain_document( &self, rain_document: &RainDocument, uri: &str, position: Position, documentation_format: Option<MarkupKind>, ) -> Option<Vec<CompletionItem>>

Provides completion items at the given position

Source

pub fn js_do_hover( &self, text_document: TextDocumentItem, position: Position, content_format: Option<MarkupKind>, rebinds: Option<Vec<Rebind>>, ) -> Option<Hover>

Provides hover for a fragment at the given position

Source

pub fn js_do_hover_rain_document( &self, rain_document: &RainDocument, position: Position, content_format: Option<MarkupKind>, ) -> Option<Hover>

Provides hover for a RainDocument fragment at the given position

Source

pub fn js_semantic_tokens( &self, text_document: TextDocumentItem, semantic_token_types_index: u32, semantic_token_modifiers_len: usize, rebinds: Option<Vec<Rebind>>, ) -> SemanticTokensPartialResult

Provides semantic tokens for elided fragments

Source

pub fn js_rain_document_semantic_tokens( &self, rain_document: &RainDocument, semantic_token_types_index: u32, semantic_token_modifiers_len: usize, ) -> SemanticTokensPartialResult

Provides semantic tokens for RainDocument’s elided fragments

Source§

impl RainLanguageServices

Source

pub fn meta_store(&self) -> Arc<RwLock<Store>>

The meta Store associated with this RainLanguageServices instance

Source

pub fn new(language_params: &LanguageServiceParams) -> RainLanguageServices

Instantiates from the given params

Source

pub fn new_rain_document( &self, text_document: &TextDocumentItem, rebinds: Option<Vec<Rebind>>, ) -> RainDocument

Instantiates a RainDocument with remote meta search disabled when parsing from the given TextDocumentItem

Source

pub async fn new_rain_document_async( &self, text_document: &TextDocumentItem, rebinds: Option<Vec<Rebind>>, ) -> RainDocument

Instantiates a RainDocument with remote meta search enabled when parsing from the given TextDocumentItem

Source

pub fn do_validate( &self, text_document: &TextDocumentItem, related_information: bool, rebinds: Option<Vec<Rebind>>, ) -> Vec<Diagnostic>

Validates the document with remote meta search disabled when parsing and reports LSP diagnostics

Source

pub async fn do_validate_async( &self, text_document: &TextDocumentItem, related_information: bool, rebinds: Option<Vec<Rebind>>, ) -> Vec<Diagnostic>

Validates the document with remote meta search enabled when parsing and reports LSP diagnostics

Source

pub fn do_validate_rain_document( &self, rain_document: &RainDocument, uri: &Url, related_information: bool, ) -> Vec<Diagnostic>

Reports LSP diagnostics from RainDocument’s all problems

Source

pub fn do_complete( &self, text_document: &TextDocumentItem, position: Position, documentation_format: Option<MarkupKind>, rebinds: Option<Vec<Rebind>>, ) -> Option<Vec<CompletionItem>>

Provides completion items at the given position

Source

pub fn do_complete_rain_document( &self, rain_document: &RainDocument, uri: &Url, position: Position, documentation_format: Option<MarkupKind>, ) -> Option<Vec<CompletionItem>>

Provides completion items at the given position

Source

pub fn do_hover( &self, text_document: &TextDocumentItem, position: Position, content_format: Option<MarkupKind>, rebinds: Option<Vec<Rebind>>, ) -> Option<Hover>

Provides hover for a fragment at the given position

Source

pub fn do_hover_rain_document( &self, rain_document: &RainDocument, position: Position, content_format: Option<MarkupKind>, ) -> Option<Hover>

Provides hover for a RainDocument fragment at the given position

Source

pub fn semantic_tokens( &self, text_document: &TextDocumentItem, semantic_token_types_index: u32, semantic_token_modifiers_len: usize, rebinds: Option<Vec<Rebind>>, ) -> SemanticTokensPartialResult

Provides semantic tokens for elided fragments

Source

pub fn rain_document_semantic_tokens( &self, rain_document: &RainDocument, semantic_token_types_index: u32, semantic_token_modifiers_len: usize, ) -> SemanticTokensPartialResult

Provides semantic tokens for RainDocument’s elided fragments

Trait Implementations§

Source§

impl Default for RainLanguageServices

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<RainLanguageServices> for JsValue

Source§

fn from(value: RainLanguageServices) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for RainLanguageServices

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for RainLanguageServices

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for RainLanguageServices

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<RainLanguageServices>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for RainLanguageServices

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for RainLanguageServices

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for RainLanguageServices

Source§

type Abi = u32

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<RainLanguageServices>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for RainLanguageServices

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<RainLanguageServices>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for RainLanguageServices

Source§

type Error = JsValue

The type returned in the event of a conversion error.
Source§

fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl VectorFromWasmAbi for RainLanguageServices

Source§

impl VectorIntoJsValue for RainLanguageServices

Source§

impl VectorIntoWasmAbi for RainLanguageServices

Source§

impl WasmDescribe for RainLanguageServices

Source§

impl WasmDescribeVector for RainLanguageServices

Source§

impl SupportsConstructor for RainLanguageServices

Source§

impl SupportsInstanceProperty for RainLanguageServices

Source§

impl SupportsStaticProperty for RainLanguageServices

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,