Skip to content

Commit

Permalink
Cleanup/fix handling of unnamed structure items
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrey-easyesi committed Feb 23, 2018
1 parent 78427a9 commit 8e66c57
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" : (<any>node.name).text;
if (! name) { // anonymous function
return;
}
var res: any = {
name: name,
name: node.name && (<any>node.name).text || "<unnamed>",
kind: kind,
kindModifiers: ts.getNodeModifiers(node),
start: ts.skipTrivia(sourceFile.text, node.pos),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -517,7 +514,8 @@ class Program {
add(<ts.MethodSignature>node, SEK.memberFunctionElement, node.symbol);
break;
case SK.Constructor:
addFunc(<ts.ConstructorDeclaration>node, SEK.constructorImplementationElement);
var res = addFunc(<ts.ConstructorDeclaration>node, SEK.constructorImplementationElement);
res.name = "constructor";
(<ts.ConstructorDeclaration>node).parameters.forEach(function(p) {
if (ts.hasModifier(p, ts.ModifierFlags.ParameterPropertyModifier))
add(p, SEK.memberVariableElement, p.symbol);
Expand Down

0 comments on commit 8e66c57

Please sign in to comment.