-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Navigation bar class expression #8648
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
Conversation
Hi @Andy-MS, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
e39352b
to
2a67c6e
Compare
|
||
default: | ||
const childrens: Node[] = []; | ||
forEachChild(node, child => { childrens.push(child) }); |
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.
We should change this function to take a node instead of a list. the allocations here are not really needed. we put nodes in a new array just to call the function, then throw them away.
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.
It does sort the nodes first. Although it looks like it would be equivalent to add nodes in arbitrary order and sort topLevelNodes
at the end.
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.
i woudl split this into two functions, addTopLevelNodes:
function addTopLevelNodes(nodes: Node[], topLevelNodes: Node[]): void {
forEach(nodes, addTopLevelNode);
}
Now the next issue is to figure out what to do with the sorting. i believe we can sort the output instead.
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.
Although it looks like it would be equivalent to add nodes in arbitrary order and sort topLevelNodes at the end.
I think they are the same.
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.
Currently it sorts within a single level, so e.g. methods of a class will be sorted just among each other. For levels of expressions we probably don't want that (foo(foo(class Y {}, class X {}), foo(class B {}, class A{}))
should show as A B X Y
).
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.
we can do a deep sort on the result once at the end, would that work?
e8c1e94
to
61f8e99
Compare
function addTopLevelNodes(nodes: Node[], higherLevel: Node[]): void { | ||
const thisLevel: Node[] = []; | ||
for (let node of nodes) | ||
addTopLevelNode(node, thisLevel); |
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.
We always use curlies in these constructs. Could you add this file to the lint sources in Jakefile.js
?
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.
See #8662
76d341b
to
ecfac58
Compare
👍 |
5a0de9b
to
42d15d1
Compare
42d15d1
to
f8acf11
Compare
Previous algorithm would sort *after* adding to top-level nodes. This was broken because top-level nodes were simply all in a flat array, so this would cause sorting among unrelated elements. Now we collect all the nodes in a single logical level and sort them before adding them to topLevelNodes.
f8acf11
to
c9ec628
Compare
This should wait on #8811 so we can add |
This should probably also wait on #8812. |
} | ||
} | ||
|
||
function isAnonFn(item: NavigationBarItem): boolean { |
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.
Please spell names out, so anonymousFunctionText
, isAnonymousFunction
, and anonymousClassText
const anonFnText = "<function>"; | ||
const anonClassText = "<class>"; | ||
|
||
// Get the name for a (possibly anonymous) class/function expression. |
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.
jsdoc comments
Closed in favor of #8958 |
Fixes #5258
Should wait for #8622.