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(¶ms);
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
impl RainLanguageServices
Sourcepub fn js_meta_store(&self) -> MetaStore
pub fn js_meta_store(&self) -> MetaStore
The meta Store associated with this RainLanguageServices instance
Sourcepub fn js_new(meta_store: &MetaStore) -> RainLanguageServices
pub fn js_new(meta_store: &MetaStore) -> RainLanguageServices
Instantiates with the given MetaStore
Sourcepub fn js_new_rain_document(
&self,
text_document: TextDocumentItem,
rebinds: Option<Vec<Rebind>>,
) -> RainDocument
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
Sourcepub async fn js_new_rain_document_async(
&self,
text_document: TextDocumentItem,
rebinds: Option<Vec<Rebind>>,
) -> RainDocument
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
Sourcepub fn js_do_validate(
&self,
text_document: TextDocumentItem,
related_information: bool,
rebinds: Option<Vec<Rebind>>,
) -> Vec<Diagnostic>
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
Sourcepub fn js_do_validate_rain_document(
&self,
rain_document: &RainDocument,
uri: &str,
related_information: bool,
) -> Vec<Diagnostic>
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
Sourcepub async fn js_do_validate_async(
&self,
text_document: TextDocumentItem,
related_information: bool,
rebinds: Option<Vec<Rebind>>,
) -> JsValue
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
Sourcepub fn js_do_complete(
&self,
text_document: TextDocumentItem,
position: Position,
documentation_format: Option<MarkupKind>,
rebinds: Option<Vec<Rebind>>,
) -> Option<Vec<CompletionItem>>
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
Sourcepub fn js_do_complete_rain_document(
&self,
rain_document: &RainDocument,
uri: &str,
position: Position,
documentation_format: Option<MarkupKind>,
) -> Option<Vec<CompletionItem>>
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
Sourcepub fn js_do_hover(
&self,
text_document: TextDocumentItem,
position: Position,
content_format: Option<MarkupKind>,
rebinds: Option<Vec<Rebind>>,
) -> Option<Hover>
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
Sourcepub fn js_do_hover_rain_document(
&self,
rain_document: &RainDocument,
position: Position,
content_format: Option<MarkupKind>,
) -> Option<Hover>
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
Sourcepub fn js_semantic_tokens(
&self,
text_document: TextDocumentItem,
semantic_token_types_index: u32,
semantic_token_modifiers_len: usize,
rebinds: Option<Vec<Rebind>>,
) -> SemanticTokensPartialResult
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
Sourcepub fn js_rain_document_semantic_tokens(
&self,
rain_document: &RainDocument,
semantic_token_types_index: u32,
semantic_token_modifiers_len: usize,
) -> SemanticTokensPartialResult
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
impl RainLanguageServices
Sourcepub fn meta_store(&self) -> Arc<RwLock<Store>>
pub fn meta_store(&self) -> Arc<RwLock<Store>>
The meta Store associated with this RainLanguageServices instance
Sourcepub fn new(language_params: &LanguageServiceParams) -> RainLanguageServices
pub fn new(language_params: &LanguageServiceParams) -> RainLanguageServices
Instantiates from the given params
Sourcepub fn new_rain_document(
&self,
text_document: &TextDocumentItem,
rebinds: Option<Vec<Rebind>>,
) -> RainDocument
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
Sourcepub async fn new_rain_document_async(
&self,
text_document: &TextDocumentItem,
rebinds: Option<Vec<Rebind>>,
) -> RainDocument
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
Sourcepub fn do_validate(
&self,
text_document: &TextDocumentItem,
related_information: bool,
rebinds: Option<Vec<Rebind>>,
) -> Vec<Diagnostic>
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
Sourcepub async fn do_validate_async(
&self,
text_document: &TextDocumentItem,
related_information: bool,
rebinds: Option<Vec<Rebind>>,
) -> Vec<Diagnostic>
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
Sourcepub fn do_validate_rain_document(
&self,
rain_document: &RainDocument,
uri: &Url,
related_information: bool,
) -> Vec<Diagnostic>
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
Sourcepub fn do_complete(
&self,
text_document: &TextDocumentItem,
position: Position,
documentation_format: Option<MarkupKind>,
rebinds: Option<Vec<Rebind>>,
) -> Option<Vec<CompletionItem>>
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
Sourcepub fn do_complete_rain_document(
&self,
rain_document: &RainDocument,
uri: &Url,
position: Position,
documentation_format: Option<MarkupKind>,
) -> Option<Vec<CompletionItem>>
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
Sourcepub fn do_hover(
&self,
text_document: &TextDocumentItem,
position: Position,
content_format: Option<MarkupKind>,
rebinds: Option<Vec<Rebind>>,
) -> Option<Hover>
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
Sourcepub fn do_hover_rain_document(
&self,
rain_document: &RainDocument,
position: Position,
content_format: Option<MarkupKind>,
) -> Option<Hover>
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
Sourcepub fn semantic_tokens(
&self,
text_document: &TextDocumentItem,
semantic_token_types_index: u32,
semantic_token_modifiers_len: usize,
rebinds: Option<Vec<Rebind>>,
) -> SemanticTokensPartialResult
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
Sourcepub fn rain_document_semantic_tokens(
&self,
rain_document: &RainDocument,
semantic_token_types_index: u32,
semantic_token_modifiers_len: usize,
) -> SemanticTokensPartialResult
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
impl Default for RainLanguageServices
Source§impl From<RainLanguageServices> for JsValue
impl From<RainLanguageServices> for JsValue
Source§fn from(value: RainLanguageServices) -> Self
fn from(value: RainLanguageServices) -> Self
Source§impl FromWasmAbi for RainLanguageServices
impl FromWasmAbi for RainLanguageServices
Source§impl IntoWasmAbi for RainLanguageServices
impl IntoWasmAbi for RainLanguageServices
Source§impl RefFromWasmAbi for RainLanguageServices
impl RefFromWasmAbi for RainLanguageServices
Source§type Anchor = RcRef<RainLanguageServices>
type Anchor = RcRef<RainLanguageServices>
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§impl VectorFromWasmAbi for RainLanguageServices
impl VectorFromWasmAbi for RainLanguageServices
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[RainLanguageServices]>
Source§impl VectorIntoJsValue for RainLanguageServices
impl VectorIntoJsValue for RainLanguageServices
fn vector_into_jsvalue(vector: Box<[RainLanguageServices]>) -> JsValue
Source§impl VectorIntoWasmAbi for RainLanguageServices
impl VectorIntoWasmAbi for RainLanguageServices
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[RainLanguageServices]>) -> Self::Abi
Source§impl WasmDescribeVector for RainLanguageServices
impl WasmDescribeVector for RainLanguageServices
impl SupportsConstructor for RainLanguageServices
impl SupportsInstanceProperty for RainLanguageServices
impl SupportsStaticProperty for RainLanguageServices
Auto Trait Implementations§
impl Freeze for RainLanguageServices
impl RefUnwindSafe for RainLanguageServices
impl Send for RainLanguageServices
impl Sync for RainLanguageServices
impl Unpin for RainLanguageServices
impl UnwindSafe for RainLanguageServices
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.