Hide the navigation nodes for unmodified nodes in diff (#9015)
This commit is contained in:
Родитель
34d0ef64aa
Коммит
d99e90ceca
|
@ -186,6 +186,9 @@ namespace ApiView
|
||||||
List<ReviewToken> currentLineTokens = new List<ReviewToken>();
|
List<ReviewToken> currentLineTokens = new List<ReviewToken>();
|
||||||
foreach(var oldToken in Tokens)
|
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;
|
ReviewToken token = null;
|
||||||
switch(oldToken.Kind)
|
switch(oldToken.Kind)
|
||||||
{
|
{
|
||||||
|
@ -270,6 +273,13 @@ namespace ApiView
|
||||||
reviewLine.parentLine = parent;
|
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)
|
if (currentLineTokens.Count == 0)
|
||||||
{
|
{
|
||||||
//Empty line. So just add previous line as related line
|
//Empty line. So just add previous line as related line
|
||||||
|
|
|
@ -9,4 +9,5 @@ export class NavigationTreeNode {
|
||||||
data: NavigationTreeNodeData = new NavigationTreeNodeData();
|
data: NavigationTreeNodeData = new NavigationTreeNodeData();
|
||||||
expanded: boolean = false;
|
expanded: boolean = false;
|
||||||
children: NavigationTreeNode[] = [];
|
children: NavigationTreeNode[] = [];
|
||||||
|
visible: boolean = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,18 +27,22 @@ addEventListener('message', ({ data }) => {
|
||||||
if (!codePanelData?.hasDiff) {
|
if (!codePanelData?.hasDiff) {
|
||||||
apiTreeBuilderData!.diffStyle = FULL_DIFF_STYLE; // If there is no diff nodes and tree diff will not work
|
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);
|
buildCodePanelRows("root", navigationTree);
|
||||||
const codePanelRowDataMessage : InsertCodePanelRowDataMessage = {
|
const codePanelRowDataMessage : InsertCodePanelRowDataMessage = {
|
||||||
directive: ReviewPageWorkerMessageDirective.UpdateCodePanelRowData,
|
directive: ReviewPageWorkerMessageDirective.UpdateCodePanelRowData,
|
||||||
payload: codePanelRowData
|
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);
|
postMessage(codePanelRowDataMessage);
|
||||||
|
|
||||||
const navigationTreeMessage : InsertCodePanelRowDataMessage = {
|
const navigationTreeMessage : InsertCodePanelRowDataMessage = {
|
||||||
|
@ -259,4 +263,18 @@ function shouldAppendIfRowIsHiddenAPI(row: CodePanelRowData) {
|
||||||
} else {
|
} else {
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
Загрузка…
Ссылка в новой задаче