-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide the navigation nodes for unmodified nodes in diff #9015
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,6 +186,9 @@ public void ConvertToTreeTokenModel() | |
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 @@ public void ConvertToTreeTokenModel() | |
reviewLine.parentLine = parent; | ||
} | ||
|
||
//Handle specific cases for C++ line with 'public:' and '{' to mark related line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there another way we can guarantee this is only for c++? my worry is that another parser might have something similar and we don't know about and they run this tool and get a behavior that is not accurate |
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should you make this private? |
||
// 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; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did you find out this discrepancy? are there any automated tests we can run to keep this tool up to date with the design (as it changes)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also couldn't you convert the old documentation to new. Seem like that would be a straightforward mapping? Would be weird to just exclude documentation.