diff --git a/src/dotnet/APIView/APIView/Model/CodeFile.cs b/src/dotnet/APIView/APIView/Model/CodeFile.cs index 3a9414544..28248572c 100644 --- a/src/dotnet/APIView/APIView/Model/CodeFile.cs +++ b/src/dotnet/APIView/APIView/Model/CodeFile.cs @@ -186,6 +186,9 @@ namespace ApiView List currentLineTokens = new List(); 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 diff --git a/src/dotnet/APIView/ClientSPA/src/app/_models/navigationTreeModels.ts b/src/dotnet/APIView/ClientSPA/src/app/_models/navigationTreeModels.ts index 3bd2acfae..d10ee121e 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_models/navigationTreeModels.ts +++ b/src/dotnet/APIView/ClientSPA/src/app/_models/navigationTreeModels.ts @@ -9,4 +9,5 @@ export class NavigationTreeNode { data: NavigationTreeNodeData = new NavigationTreeNodeData(); expanded: boolean = false; children: NavigationTreeNode[] = []; + visible: boolean = true; } diff --git a/src/dotnet/APIView/ClientSPA/src/app/_workers/apitree-builder.worker.ts b/src/dotnet/APIView/ClientSPA/src/app/_workers/apitree-builder.worker.ts index a0719becd..f48bf99b7 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_workers/apitree-builder.worker.ts +++ b/src/dotnet/APIView/ClientSPA/src/app/_workers/apitree-builder.worker.ts @@ -27,18 +27,22 @@ addEventListener('message', ({ data }) => { if (!codePanelData?.hasDiff) { 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 = { @@ -259,4 +263,18 @@ function shouldAppendIfRowIsHiddenAPI(row: CodePanelRowData) { } else { 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; + } } \ No newline at end of file