ontocore-refactor 0.11.1

Workspace refactoring for OntoCore (ontocore-*) (rename, migrate, move, extract)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::error::Result;
use ontocore_core::{read_to_string_capped, MAX_FILE_BYTES};
use std::collections::HashMap;
use std::path::{Path, PathBuf};

/// Read Turtle source for a document, preferring unsaved LSP buffer overrides.
pub fn read_source_text(path: &Path, overrides: &HashMap<PathBuf, String>) -> Result<String> {
    if let Some(text) = overrides.get(path) {
        return Ok(text.clone());
    }
    if let Ok(canonical) = path.canonicalize() {
        if let Some(text) = overrides.get(&canonical) {
            return Ok(text.clone());
        }
    }
    read_to_string_capped(path, MAX_FILE_BYTES).map_err(Into::into)
}