Reflect the forward declaration and the single-line function definition to the selected symbol
Categories
(Webtools :: Searchfox, enhancement)
Tracking
(Not tracked)
People
(Reporter: arai, Assigned: arai)
Details
Attachments
(1 file)
Currently the "Symbol Link" feature uses the DocumentTitler.selectedSymbol, which uses the nesting container's symbol.
This means the symbol is not used for the following cases:
- the function definition is single line
- the forward declaration
I often use the "Symbol Link" feature to create a link to the function while explanation, but sometimes hit the above case, where I need to manually copy the function name.
It would be nice if those cases are also reflected to the selected symbol, so that the "Symbol Link" works for more cases.
| Assignee | ||
Comment 1•1 year ago
|
||
The current design is the following:
- given a set of lines, find the deepest nesting container
- in the nesting container, find the corresponding source line
- return a symbol in the line
processLineSelection(selectedLines) {
...
const nestingContainer = this._findNestingContainerFor(selectedLines);
const nestingLine = nestingContainer?.querySelector(
".nesting-sticky-line"
);
const sourceLine = nestingLine?.querySelector(".source-line");
const bestPretty = this._findBestPrettySymbolInSourceLineElem(sourceLine);
this.selectionTitle = bestPretty.short;
this.selectedSymbol = bestPretty.long;
}
This doesn't work for function definition with single line because the nesting container is not created for single line definition, because the block is closed in the same line.
In the same way, this doesn't work for the forward declaration also because the nesting container is not created, because forward declaration doesn't have a block.
Possible option is the following:
- given a set of line numbers, find the deepest nesting container
- given the set of line numbers, find the corresponding source lines
- find a first symbol in the source lines inside the deepest nesting container
- if there is such symbol, then
- return the symbol
- otherwise,
- in the nesting container, find the corresponding source line
- return a symbol in the line
This way, the single-line function definition and forward declaration also get reflected to the selected symbol,
and also a container is used when the selected lines don't contain any symbol.
| Assignee | ||
Comment 2•1 year ago
|
||
| Assignee | ||
Updated•1 year ago
|
Description
•