Skip to content

(Sources-1) Teach SemanticIndex about NamespacedAccesses#1286

Open
DavisVaughan wants to merge 2 commits into
mainfrom
sources/1-namespaced-accesses
Open

(Sources-1) Teach SemanticIndex about NamespacedAccesses#1286
DavisVaughan wants to merge 2 commits into
mainfrom
sources/1-namespaced-accesses

Conversation

@DavisVaughan

@DavisVaughan DavisVaughan commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Progress towards #1234

The SemanticIndex now records instances of :: and ::: in its CST walk.

This is going to be useful as one of many ways to detect which packages are used by a workspace.

They are recorded as

pub struct NamespacedAccess {
    package: String,
    symbol: String,
    kind: NamespacedAccessKind,
    offset: TextSize,
}

Realllllly for package source requests we only need package, but my hypothesis is that the rest of this information is going to be useful in the future as well, and I think they should be pretty small. And if you take a step back, it also seems like it would be a bit weird for the SemanticIndex to expose the package list, but not where it originated from.

For tracking namespace accesses within a file, easing future lookup

Use accessors
/// Namespaced access recorded during indexing, i.e. `package::symbol` or
/// `package:::symbol`
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NamespacedAccess {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "d" in namespaced kind of trips me up.

Can this be NamespaceAccess instead?

Comment on lines +721 to +724
package: String,
symbol: String,
kind: NamespacedAccessKind,
offset: TextSize,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a pure data carrier without any invariants to uphold, so I'd just make these pub, but I know you and I have different defaults on this matter ;)

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