Skip to content

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

Closed
wants to merge 9 commits into from
Closed

Conversation

ghost
Copy link

@ghost ghost commented May 17, 2016

Fixes #5258
Should wait for #8622.

@msftclas
Copy link

Hi @Andy-MS, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Andy Hanson). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@ghost ghost force-pushed the navigation_bar_class_expression branch from e39352b to 2a67c6e Compare May 17, 2016 17:46

default:
const childrens: Node[] = [];
forEachChild(node, child => { childrens.push(child) });
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Author

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).

Copy link
Contributor

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?

@ghost ghost force-pushed the navigation_bar_class_expression branch 2 times, most recently from e8c1e94 to 61f8e99 Compare May 17, 2016 19:39
function addTopLevelNodes(nodes: Node[], higherLevel: Node[]): void {
const thisLevel: Node[] = [];
for (let node of nodes)
addTopLevelNode(node, thisLevel);
Copy link
Member

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #8662

@ghost ghost force-pushed the navigation_bar_class_expression branch 2 times, most recently from 76d341b to ecfac58 Compare May 18, 2016 17:19
@mhegazy
Copy link
Contributor

mhegazy commented May 18, 2016

👍

@ghost ghost force-pushed the navigation_bar_class_expression branch 3 times, most recently from 5a0de9b to 42d15d1 Compare May 20, 2016 21:07
@ghost ghost force-pushed the navigation_bar_class_expression branch from 42d15d1 to f8acf11 Compare May 23, 2016 13:12
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.
@ghost ghost force-pushed the navigation_bar_class_expression branch from f8acf11 to c9ec628 Compare May 23, 2016 13:12
@ghost ghost assigned mhegazy May 24, 2016
@ghost
Copy link
Author

ghost commented May 25, 2016

This should wait on #8811 so we can add SyntaxKind.ClassExpression to the case there.

@ghost
Copy link
Author

ghost commented May 26, 2016

This should probably also wait on #8812.

}
}

function isAnonFn(item: NavigationBarItem): boolean {
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdoc comments

@ghost ghost mentioned this pull request May 27, 2016
@ghost
Copy link
Author

ghost commented Jun 3, 2016

Closed in favor of #8958

@ghost ghost closed this Jun 3, 2016
@ghost ghost mentioned this pull request Jun 13, 2016
@mhegazy mhegazy deleted the navigation_bar_class_expression branch November 2, 2017 21:02
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants