Skip to content

Navigation bar class expression - #8648

Closed
Deleted user (ghost) wants to merge 9 commits into
masterfrom
navigation_bar_class_expression
Closed

Navigation bar class expression#8648
Deleted user (ghost) wants to merge 9 commits into
masterfrom
navigation_bar_class_expression

Conversation

@ghost

Copy link
Copy Markdown

Fixes#5258
Should wait for #8622.

@msftclas

Hi Andy (Andrewkraft) (@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;

Comment threadsrc/services/navigationBar.ts Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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:

functionaddTopLevelNodes(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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 61f8e99CompareMay 17, 2016 19:39
Comment threadsrc/services/navigationBar.ts Outdated
function addTopLevelNodes(nodes: Node[], higherLevel: Node[]): void {
const thisLevel: Node[] = [];
for (let node of nodes)
addTopLevelNode(node, thisLevel);

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
Copy Markdown
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 ecfac58CompareMay 18, 2016 17:19
@mhegazy

Copy link
Copy Markdown
Contributor

👍

@ghost
ghost force-pushed the navigation_bar_class_expression branch 3 times, most recently from 5a0de9b to 42d15d1CompareMay 20, 2016 21:07
@ghost
ghost force-pushed the navigation_bar_class_expression branch from 42d15d1 to f8acf11CompareMay 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 c9ec628CompareMay 23, 2016 13:12
@ghost

Copy link
Copy Markdown
Author

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

@ghost

Copy link
Copy Markdown
Author

This should probably also wait on #8812.

Comment threadsrc/services/navigationBar.ts Outdated
}
}

function isAnonFn(item: NavigationBarItem): boolean {

Copy link
Copy Markdown
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

Comment threadsrc/services/navigationBar.ts Outdated
const anonFnText = "<function>";
const anonClassText = "<class>";

// Get the name for a (possibly anonymous) class/function expression.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

jsdoc comments

@ghostghost mentioned this pull request May 27, 2016
@ghost

Copy link
Copy Markdown
Author

Closed in favor of #8958

@ghostghost closed this Jun 3, 2016
@ghostghost mentioned this pull request Jun 13, 2016
@mhegazy
Mohamed Hegazy (mhegazy) deleted the navigation_bar_class_expression branch November 2, 2017 21:02
@microsoftMicrosoft (microsoft) locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
Sign up for freeto 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

@msftclas@mhegazy@DanielRosenwasser