Merge pull request #13401 from Microsoft/navbar_exported_functions
Include "export" modifier on function assigned to an export (`export const x = () => 0;`).
This commit is contained in:
commit
d86d850211
3 changed files with 87 additions and 6 deletions
|
@ -514,7 +514,7 @@ namespace ts.NavigationBar {
|
|||
return {
|
||||
text: getItemName(n.node),
|
||||
kind: getNodeKind(n.node),
|
||||
kindModifiers: getNodeModifiers(n.node),
|
||||
kindModifiers: getModifiers(n.node),
|
||||
spans: getSpans(n),
|
||||
childItems: map(n.children, convertToTree)
|
||||
};
|
||||
|
@ -524,7 +524,7 @@ namespace ts.NavigationBar {
|
|||
return {
|
||||
text: getItemName(n.node),
|
||||
kind: getNodeKind(n.node),
|
||||
kindModifiers: getNodeModifiers(n.node),
|
||||
kindModifiers: getModifiers(n.node),
|
||||
spans: getSpans(n),
|
||||
childItems: map(n.children, convertToChildItem) || emptyChildItemArray,
|
||||
indent: n.indent,
|
||||
|
@ -594,6 +594,13 @@ namespace ts.NavigationBar {
|
|||
: createTextSpanFromNode(node, curSourceFile);
|
||||
}
|
||||
|
||||
function getModifiers(node: ts.Node): string {
|
||||
if (node.parent && node.parent.kind === SyntaxKind.VariableDeclaration) {
|
||||
node = node.parent;
|
||||
}
|
||||
return getNodeModifiers(node);
|
||||
}
|
||||
|
||||
function getFunctionOrClassName(node: FunctionExpression | FunctionDeclaration | ArrowFunction | ClassLikeDeclaration): string {
|
||||
if (node.name && getFullWidth(node.name) > 0) {
|
||||
return declarationNameToString(node.name);
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
//// .a = function() { };
|
||||
//// })();
|
||||
|
||||
function navExact(name: string, kind: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
verify.navigationTree(
|
||||
{
|
||||
"text": "<global>",
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////export const value = 2;
|
||||
////export const func = () => 2;
|
||||
////export const func2 = function() { };
|
||||
////export function exportedFunction() { }
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "\"navigationBarItemsNamedArrowFunctions\"",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "exportedFunction",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export"
|
||||
},
|
||||
{
|
||||
"text": "func",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "func2",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "value",
|
||||
"kind": "const",
|
||||
"kindModifiers": "export"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "exportedFunction",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "func",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "func2",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
|
||||
verify.navigationTree({
|
||||
"text": "\"navigationBarItemsNamedArrowFunctions\"",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "exportedFunction",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export"
|
||||
},
|
||||
{
|
||||
"text": "func",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export"
|
||||
},
|
||||
{
|
||||
"text": "func2",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export"
|
||||
},
|
||||
{
|
||||
"text": "value",
|
||||
"kind": "const",
|
||||
"kindModifiers": "export"
|
||||
}
|
||||
]
|
||||
});
|
Loading…
Reference in a new issue