Skip to content

Suggest predicates that shapes require first - #40

Merged
ajuvercr merged 1 commit into
mainfrom
claude/required-first
Nov 18, 2026
Merged

ajuvercr merged 1 commit into
mainfrom
claude/required-first

Conversation

@ajuvercr

@ajuvercr ajuvercr commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

At a predicate position, predicates that SHACL shapes require and the subject does not have yet are now at the top of the suggestions.

Ranking

  • Required: a predicate that a property shape requires (sh:minCount >= 1) and the subject does not have yet comes first.
  • One of required: next come the alternatives of a required sh:alternativePath when the subject has none of them.
  • Shape templates, keywords and other properties keep their order after these.
  • This works whether the suggestion comes from the shapes or from an ontology. Items are marked "required by shape" or "one of required by shape"; an ontology suggestion keeps its title after the marker.
  • Predicates the subject already has are not promoted.

Before, required predicates only got a "required by shape" label and were sorted alphabetically among the domain-matching properties. Required predicates that an ontology also defined were not ranked at all.

Sorting

Completions are now sorted the way LSP clients sort them: by sort text, or by label when an item has none (completion::sort_completions, used by the server). Sorting by Option<sort_text> put every item without a sort text first, e.g. the prefix suggestions foaf, owl, rdfs, rdf.

Testing

  • New e2e/tests/required_first.rs:
    • required predicates come first, both shape-only ones and ones an ontology also defines;
    • alternatives of a required group come next;
    • optional predicates are not promoted;
    • predicates the subject already has (or an alternative it already satisfies) are not promoted;
    • required predicates come before templates and keywords.
  • cargo test --workspace (579 tests), cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings (Rust 1.100) pass.
  • Ran the real binary with the RML shapes. In an empty predicate position of a rml:TriplesMap, the first suggestions are now rml:logicalSource (required), then rml:quotedTriplesMap, rml:subject and rml:subjectMap (one of required), then the two shape templates.

At a predicate position, a predicate that a SHACL property shape requires
(`sh:minCount >= 1`) and that the subject does not have yet is now the first
suggestion, followed by the alternatives of a required `sh:alternativePath`
none of which the subject has. This holds whether the suggestion comes from
the shapes or from an ontology. Such items are marked "required by shape" or
"one of required by shape"; an ontology suggestion keeps its title after the
marker. Predicates the subject already has are not promoted.

Before, required predicates only got a "required by shape" label and were
sorted alphabetically among the domain-matching properties, and required
predicates that an ontology also defined were not ranked at all.

Completions are now sorted the way LSP clients sort them, by sort text or
else by label (`completion::sort_completions`, used by the server). Sorting
by `Option<sort_text>` put every item without a sort text, such as prefix
suggestions, first.
@ajuvercr
ajuvercr merged commit a1dc471 into main Nov 18, 2026
2 checks passed
@ajuvercr
ajuvercr deleted the claude/required-first branch November 18, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants