Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit e28eb4a

Browse files
author
Rick Winfrey
committed
Add fully_qualified_name field to SourceInfo
1 parent 095c2af commit e28eb4a

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

stack-graphs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- New `Defines` and `Refers` assertions test for the presence of definitions and references, respectively, without resolution.
1313
- A method `StackGraph::get_file` to look up an existing file.
14+
- A field named `fully_qualified_name` was added to `SourceInfo`.
1415

1516
### Changed
1617

stack-graphs/include/stack-graphs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ struct sg_source_info {
259259
// If you need one of these to make the type checker happy, but you don't have one, just use
260260
// sg_span::default(), as this will correspond to the all-0s spans which mean "no definiens".
261261
struct sg_span definiens_span;
262+
// The fully qualified name is a representation of the symbol that captures its name and its
263+
// embedded context (e.g. `foo.bar` for the symbol `bar` defined in the module `foo`).
264+
sg_string_handle fully_qualified_name;
262265
};
263266

264267
// An array of all of the source information in a stack graph. Source information is associated

stack-graphs/src/c.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,12 +627,14 @@ pub struct sg_source_info {
627627
pub syntax_type: sg_string_handle,
628628
/// The full content of the line containing this node in its source file.
629629
pub containing_line: sg_string_handle,
630-
631630
/// The location in its containing file of the source code that this node's definiens represents.
632631
/// This is used for things like the bodies of functions, rather than the RHSes of equations.
633632
/// If you need one of these to make the type checker happy, but you don't have one, just use
634633
/// sg_span::default(), as this will correspond to the all-0s spans which mean "no definiens".
635634
pub definiens_span: sg_span,
635+
/// The fully qualified name is a representation of the symbol that captures its name and its
636+
/// embedded context (e.g. `foo.bar` for the symbol `bar` defined in the module `foo`).
637+
pub fully_qualified_name: sg_string_handle,
636638
}
637639

638640
/// All of the position information that we have about a range of content in a source file

stack-graphs/src/graph.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,9 @@ pub struct SourceInfo {
13451345
/// If you need one of these to make the type checker happy, but you don't have one, just use
13461346
/// lsp_positions::Span::default(), as this will correspond to the all-0s spans which mean "no definiens".
13471347
pub definiens_span: lsp_positions::Span,
1348+
/// The fully qualified name is a representation of the symbol that captures its name and its
1349+
/// embedded context (e.g. `foo.bar` for the symbol `bar` defined in the module `foo`).
1350+
pub fully_qualified_name: Option<Handle<InternedString>>,
13481351
}
13491352

13501353
impl StackGraph {
@@ -1572,6 +1575,7 @@ impl StackGraph {
15721575
.map(|cl| self.add_string(&other[cl]))
15731576
.into(),
15741577
definiens_span: source_info.definiens_span.clone(),
1578+
fully_qualified_name: None,
15751579
};
15761580
}
15771581
if let Some(debug_info) = other.node_debug_info(other_node) {

stack-graphs/tests/it/c/nodes.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ fn can_create_source_info() {
674674

675675
let syntax_type = add_string(graph, "function");
676676
let containing_line = add_string(graph, "def foo():");
677+
let fully_qualified_name = add_string(graph, "bar.foo");
677678

678679
let mut infos = [sg_node_source_info {
679680
node: handles[1],
@@ -682,6 +683,7 @@ fn can_create_source_info() {
682683
syntax_type,
683684
containing_line,
684685
definiens_span: sg_span::default(),
686+
fully_qualified_name,
685687
},
686688
}];
687689
infos[0].source_info.span.start.line = 17;

stack-graphs/tests/it/test_graphs/simple.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub fn new() -> StackGraph {
7777
syntax_type: str_var.into(),
7878
containing_line: str_line0.into(),
7979
definiens_span: Span::default(),
80+
fully_qualified_name: None,
8081
};
8182
*graph.source_info_mut(ref_x) = SourceInfo {
8283
span: Span {
@@ -104,6 +105,7 @@ pub fn new() -> StackGraph {
104105
syntax_type: str_var.into(),
105106
containing_line: str_line1.into(),
106107
definiens_span: Span::default(),
108+
fully_qualified_name: None,
107109
};
108110

109111
let str_dsl_var = graph.add_string("dsl_var");

0 commit comments

Comments
 (0)