From 8e66c578de7a252fbfc4fd13d9cc200a0660e09f Mon Sep 17 00:00:00 2001 From: Jeffrey Morlan Date: Thu, 22 Feb 2018 21:24:00 -0800 Subject: [PATCH] Cleanup/fix handling of unnamed structure items --- server/main.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/server/main.ts b/server/main.ts index d9661a0..06e76f0 100644 --- a/server/main.ts +++ b/server/main.ts @@ -448,12 +448,8 @@ class Program { function buildResults(topNode: ts.Node, inFunction: boolean, baseTypes?: [ts.Type, boolean][]) { var results: any[] = []; function add(node: ts.NamedDeclaration, kind: string, symbol?: ts.Symbol) { - var name = node.kind === SK.Constructor ? "constructor" : (node.name).text; - if (! name) { // anonymous function - return; - } var res: any = { - name: name, + name: node.name && (node.name).text || "", kind: kind, kindModifiers: ts.getNodeModifiers(node), start: ts.skipTrivia(sourceFile.text, node.pos), @@ -489,6 +485,7 @@ class Program { if (node.body) { res.children = buildResults(node.body, true); } + return res; } function addClass(node: ts.ClassDeclaration | ts.InterfaceDeclaration, kind: string) { var res = add(node, kind); @@ -517,7 +514,8 @@ class Program { add(node, SEK.memberFunctionElement, node.symbol); break; case SK.Constructor: - addFunc(node, SEK.constructorImplementationElement); + var res = addFunc(node, SEK.constructorImplementationElement); + res.name = "constructor"; (node).parameters.forEach(function(p) { if (ts.hasModifier(p, ts.ModifierFlags.ParameterPropertyModifier)) add(p, SEK.memberVariableElement, p.symbol);