Skip to content

Introduce dedicated SignatureDocumentation message type#385

Open
jupblb wants to merge 3 commits intomainfrom
michal/signature-doc
Open

Introduce dedicated SignatureDocumentation message type#385
jupblb wants to merge 3 commits intomainfrom
michal/signature-doc

Conversation

@jupblb
Copy link
Copy Markdown
Collaborator

@jupblb jupblb commented Apr 3, 2026

SymbolInformation.signature_documentation previously reused the Document message type, even though Document is designed to represent a source file on disk (with a "required" relative_path, etc.). This PR introduces a dedicated SignatureDocumentation message with a subset of Document fields.

The new message preserves the same protobuf field numbers as Document for the shared fields, so old and new indexes are binary wire-compatible in both directions. The Document-only field numbers are reserved in SignatureDocumentation to prevent accidental reuse.

This change is not compliant with Protobuf best practices (shouldn't change the type of an existing field) but we're also pre-1.0.

Supersedes #299

jupblb added 2 commits April 3, 2026 17:29
Replace the reuse of Document for SymbolInformation.signature_documentation
with a dedicated SignatureDocumentation message. The new message contains only
the relevant fields (language, text, occurrences) and reserves Document's
field numbers (1, 3, 6) to maintain wire compatibility with older indexes.
@jupblb jupblb force-pushed the michal/signature-doc branch from d3d2e5c to 9073268 Compare April 3, 2026 15:43
Copy link
Copy Markdown
Collaborator

@CatherineGasnier CatherineGasnier left a comment

Choose a reason for hiding this comment

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

Welcome change!

// 4. The path must use '/' as the separator, including on Windows.
// 5. The path must be canonical; it cannot include empty components ('//'),
// or '.' or '..'.
string relative_path = 1;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if some indexers were abusing this field to link a symbol to its containing file? In general, do we usually do bidirectional linking between messages? Right now a Document has a symbols field, but SymbolInformation does not point to its containing Document. Should it? Not super concerned by this but just raising.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm against having bidirectional linking and I think this convention fits the rest of the protocol definition. SCIP format is intended to be an intermediate form that is to be processed further. I know about only a single indexer that sets this field - but we mark it as reserved so it should not be a problem.

scip.proto Outdated
// encoded signatures using the Document message type.
message SignatureDocumentation {
// The language of the signature, e.g. "java", "go", "python".
string language = 4;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if this should be a field for Document only, to avoid the possibility of creating inconsistent data. But just nitpicking.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There were two reasons I've left it here:

  1. When we render hovers with signature in the Sourcegraph UI, we support syntax highlighting. It's easy to just get information about the language from this field. But it's not a problem at all to source it from the Document context.
  2. Within boundary of a single language this is not a useful field, which is always the case right now. But if we were to support cross-language references then it would make more sense, maybe.

I am fully ok with removing this field if you think there is no point in keeping it.

@jupblb jupblb requested a review from CatherineGasnier April 9, 2026 15:23
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