Skip to content

Commit 0cc6538

Browse files
committed
Try to find and fix broken blank node parsing
1 parent de1086f commit 0cc6538

18 files changed

Lines changed: 416 additions & 187 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,22 @@ lov = { path = "../lov/" }
3232

3333
oxigraph = { version = "0.5.3", features = ["rdf-12", "js"], default-features=false }
3434

35-
shacl_rdf = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
36-
shacl_ir = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
37-
srdf = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
38-
shacl_ast = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
39-
prefixmap = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
40-
iri_s = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
41-
shacl_validation = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
42-
4335
oxrdf = "0.3.2"
4436

37+
# shacl_rdf = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
38+
# shacl_ir = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
39+
# srdf = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
40+
# shacl_ast = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
41+
# prefixmap = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
42+
# iri_s = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
43+
# shacl_validation = { git = "https://github.com/ajuvercr/rudof", branch = "feat/wasm-2" }
44+
#
45+
46+
# [patch."https://github.com/ajuvercr/rudof"]
47+
shacl_rdf = { path = "../../rudof/shacl_rdf" }
48+
shacl_ir = { path = "../../rudof/shacl_ir" }
49+
srdf = { path = "../../rudof/srdf" }
50+
shacl_ast = { path = "../../rudof/shacl_ast" }
51+
prefixmap = { path = "../../rudof/prefixmap" }
52+
iri_s = { path = "../../rudof/iri_s" }
53+
shacl_validation = { path = "../../rudof/shacl_validation", default-features = false }

core/src/components.rs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,110 @@ pub struct LocalConfig {
280280
pub shapes: HashSet<String>,
281281
/// Features to disable
282282
pub disabled: HashSet<Disabled>,
283+
/// disable which prefices from prefix.cc to show
283284
pub prefix_disabled: HashSet<String>,
285+
/// confiure completion behavior
286+
pub completion: CompletionConfig,
287+
}
288+
289+
/// Lets the user configure how the property completion should happen.
290+
/// There are two main modes: strict and loose (default)
291+
/// On loose, the editor will suggest anything, not caring about the domain.
292+
/// On strict, the editor will only suggest property that have a matching domain or anything if the
293+
/// type could not be determined.
294+
///
295+
/// Both options can be specialized, ie only strict on these properties or only loose on these
296+
/// properties.
297+
///
298+
/// For example { loose: ["http://www.w3.org/2000/01/rdf-schema#"] }, here the editor will be strict, and show properties
299+
/// from rdfs
300+
/// On the other hand { strict: ["http://www.w3.org/ns/shacl#"] }, here the editor will be loose,
301+
/// and only show shacl properties if the objects is the correct type
302+
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
303+
#[serde(untagged)]
304+
pub enum CompletionConfig {
305+
// "strict" | "loose" | "none"
306+
Mode(CompletionMode),
307+
308+
// { "except": [...] }
309+
Except(ExceptRules),
310+
311+
// { "strict": [...] }
312+
Strict(StrictRules),
313+
}
314+
315+
impl Default for CompletionConfig {
316+
fn default() -> Self {
317+
Self::Mode(CompletionMode::None)
318+
}
319+
}
320+
321+
impl CompletionConfig {
322+
fn combine(&mut self, other: CompletionConfig) {
323+
use CompletionConfig::*;
324+
325+
if matches!(other, Mode(CompletionMode::None)) {
326+
return;
327+
}
328+
329+
if matches!(self, Mode(CompletionMode::None)) {
330+
*self = other;
331+
return;
332+
}
333+
334+
if let Strict(r) = self {
335+
if let Strict(r2) = other {
336+
r.strict.extend(r2.strict);
337+
return;
338+
}
339+
}
340+
341+
if let Except(r) = self {
342+
if let Except(r2) = other {
343+
r.loose.extend(r2.loose);
344+
return;
345+
}
346+
}
347+
348+
*self = other;
349+
}
350+
pub fn correct_domain_required(&self, property: &str) -> bool {
351+
match self {
352+
CompletionConfig::Mode(CompletionMode::Loose)
353+
| CompletionConfig::Mode(CompletionMode::None) => false,
354+
CompletionConfig::Mode(CompletionMode::Strict) => true,
355+
CompletionConfig::Except(completion_rules) => !completion_rules
356+
.loose
357+
.iter()
358+
.any(|x| property.starts_with(x)),
359+
CompletionConfig::Strict(completion_rules) => completion_rules
360+
.strict
361+
.iter()
362+
.any(|x| property.starts_with(x)),
363+
}
364+
}
365+
}
366+
367+
#[derive(Debug, Clone, PartialEq, Eq, Default, Deserialize)]
368+
#[serde(rename_all = "lowercase")]
369+
pub enum CompletionMode {
370+
#[default]
371+
None,
372+
Loose,
373+
Strict,
374+
}
375+
376+
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Default)]
377+
#[serde(deny_unknown_fields)]
378+
pub struct ExceptRules {
379+
#[serde(default)]
380+
pub loose: Vec<String>,
381+
}
382+
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Default)]
383+
#[serde(deny_unknown_fields)]
384+
pub struct StrictRules {
385+
#[serde(default)]
386+
pub strict: Vec<String>,
284387
}
285388

286389
impl LocalConfig {
@@ -290,11 +393,13 @@ impl LocalConfig {
290393
self.shapes.extend(other.shapes);
291394
self.disabled.extend(other.disabled);
292395
self.prefix_disabled.extend(other.prefix_disabled);
396+
self.completion.combine(other.completion);
293397
}
294398
#[cfg(target_arch = "wasm32")]
295399
pub async fn global(_: &Fs) -> Option<Self> {
296400
None
297401
}
402+
298403
#[cfg(not(target_arch = "wasm32"))]
299404
pub async fn global(fs: &Fs) -> Option<Self> {
300405
let global_path = dirs::config_dir()

0 commit comments

Comments
 (0)