oak-javascript 0.0.11

JavaScript frontend for Oak (reuses TypeScript implementation)
Documentation
#![doc = include_str!("readme.md")]

#[cfg(feature = "oak-highlight")]
pub mod highlighter;

#[cfg(feature = "lsp")]
use {futures::Future, oak_lsp::service::LanguageService, oak_lsp::types::Hover as LspHover, oak_vfs::Vfs};
#[cfg(feature = "oak-pretty-print")]
pub mod formatter;
use crate::language::JavaScriptLanguage;
use core::range::Range;
use oak_core::tree::RedNode;

/// JavaScript language service.
#[cfg(feature = "lsp")]
pub struct JavaScriptLanguageService<V: Vfs> {
    /// The virtual file system.
    vfs: V,
    /// The workspace manager.
    workspace: oak_lsp::workspace::WorkspaceManager,
}
impl<V: Vfs> JavaScriptLanguageService<V> {
    /// Creates a new JavaScript language service.
    pub fn new(vfs: V) -> Self {
        Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::default() }
    }
}
impl<V: Vfs + Send + Sync + 'static + oak_vfs::WritableVfs> LanguageService for JavaScriptLanguageService<V> {
    type Lang = JavaScriptLanguage;
    type Vfs = V;
    fn vfs(&self) -> &Self::Vfs {
        &self.vfs
    }
    fn workspace(&self) -> &oak_lsp::workspace::WorkspaceManager {
        &self.workspace
    }
    fn get_root(&self, _uri: &str) -> impl Future<Output = Option<RedNode<'_, JavaScriptLanguage>>> + Send + '_ {
        async move { None }
    }
    fn hover(&self, _uri: &str, _range: Range<usize>) -> impl Future<Output = Option<LspHover>> + Send + '_ {
        async move { None }
    }
}