Hide the navigation nodes for unmodified nodes in diff (#9015)

This commit is contained in:
Praven Kuttappan 2024-10-11 12:12:30 -04:00 коммит произвёл GitHub
Родитель 34d0ef64aa
Коммит d99e90ceca
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 35 добавлений и 6 удалений

Просмотреть файл

@ -186,6 +186,9 @@ namespace ApiView
List<ReviewToken> currentLineTokens = new List<ReviewToken>();
foreach(var oldToken in Tokens)
{
//Don't include documentation in converted code file due to incorrect documentation formatting used in previous model.
if (isDocumentation && oldToken.Kind != CodeFileTokenKind.DocumentRangeEnd)
continue;
ReviewToken token = null;
switch(oldToken.Kind)
{
@ -270,6 +273,13 @@ namespace ApiView
reviewLine.parentLine = parent;
}
//Handle specific cases for C++ line with 'public:' and '{' to mark related line
if ((currentLineTokens.Count == 1 && currentLineTokens.First().Value == "{") ||
(currentLineTokens.Count == 2 && currentLineTokens.Any(t => t.Kind == TokenKind.Keyword && t.Value == "public")))
{
reviewLine.RelatedToLine = previousLine?.LineId;
}
if (currentLineTokens.Count == 0)
{
//Empty line. So just add previous line as related line

Просмотреть файл

@ -9,4 +9,5 @@ export class NavigationTreeNode {
data: NavigationTreeNodeData = new NavigationTreeNodeData();
expanded: boolean = false;
children: NavigationTreeNode[] = [];
visible: boolean = true;
}

Просмотреть файл

@ -28,17 +28,21 @@ addEventListener('message', ({ data }) => {
apiTreeBuilderData!.diffStyle = FULL_DIFF_STYLE; // If there is no diff nodes and tree diff will not work
}
if (codePanelData?.navigationTreeNodes && codePanelData?.navigationTreeNodes.length > 0)
{
isNavigationTreeCreated = true;
navigationTree = codePanelData?.navigationTreeNodes;
}
buildCodePanelRows("root", navigationTree);
const codePanelRowDataMessage : InsertCodePanelRowDataMessage = {
directive: ReviewPageWorkerMessageDirective.UpdateCodePanelRowData,
payload: codePanelRowData
};
if (codePanelData?.navigationTreeNodes && codePanelData?.navigationTreeNodes.length > 0)
{
isNavigationTreeCreated = true;
navigationTree = codePanelData?.navigationTreeNodes;
//Remove navigation nodes for nodes that are not visible in diff style view
navigationTree.forEach(node => FilterVisibleNavigationNodes(node));
navigationTree = navigationTree.filter(n => n.visible);
}
postMessage(codePanelRowDataMessage);
const navigationTreeMessage : InsertCodePanelRowDataMessage = {
@ -260,3 +264,17 @@ function shouldAppendIfRowIsHiddenAPI(row: CodePanelRowData) {
return true;
}
}
function FilterVisibleNavigationNodes(node: NavigationTreeNode) {
// Recursively perform a bottom up traversal and trim down any invisible nodes
if (node.children) {
for (let child of node.children) {
FilterVisibleNavigationNodes(child);
}
node.children = node.children.filter(c => c.visible);
}
if (visibleNodes.has(node.data.nodeIdHashed) || (node.children && node.children.some(c => c.visible))) {
node.visible = true;
}
}