Skip to content

Commit

Permalink
Fixed more issues
Browse files Browse the repository at this point in the history
  • Loading branch information
remojansen committed Mar 28, 2018
1 parent 4091451 commit 34467b2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsuml",
"version": "0.0.1-alpha.6",
"version": "0.0.1-alpha.7",
"description": "UML diagrams for TypeScript",
"main": "dist/lib/index.js",
"bin": {
Expand Down
57 changes: 40 additions & 17 deletions src/core/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function getAst(tsConfigPath: string, sourceFilesPaths?: string[]) {

export function parseClasses(classDeclaration: SimpleAST.ClassDeclaration) {

const className = classDeclaration.getName();
const className = classDeclaration.getSymbol()!.getName();
const propertyDeclarations = classDeclaration.getProperties();
const methodDeclarations = classDeclaration.getMethods();

Expand All @@ -43,7 +43,7 @@ export function parseClasses(classDeclaration: SimpleAST.ClassDeclaration) {

export function parseInterfaces(interfaceDeclaration: SimpleAST.InterfaceDeclaration) {

const interfaceName = interfaceDeclaration.getName();
const interfaceName = interfaceDeclaration.getSymbol()!.getName();
const propertyDeclarations = interfaceDeclaration.getProperties();
const methodDeclarations = interfaceDeclaration.getMethods();

Expand All @@ -70,20 +70,43 @@ export function parseInterfaces(interfaceDeclaration: SimpleAST.InterfaceDeclara

export function parseHeritageClauses(classDeclaration: SimpleAST.ClassDeclaration) {

const className = classDeclaration.getName();
const heritageClauses = classDeclaration.getHeritageClauses();

const implementsClauses = heritageClauses.map(heritageClause => {
return flatten(
heritageClause
.getChildren()
.map(ff => ff.getChildren().map(c => c.getText()))
);
});

const result = flatten(implementsClauses).map(
clause => ({ clause, className }) as HeritageClause
);
const className = classDeclaration.getSymbol()!.getName();
const extended = classDeclaration.getExtends();
const implemented = classDeclaration.getImplements();
let heritageClauses: HeritageClause[] = [];

return result;
if (extended) {
const identifier = extended.getChildrenOfKind(ts.SyntaxKind.Identifier)[0];
if (identifier) {
const sym = identifier.getSymbol();
if (sym) {
heritageClauses.push(
{
clause: sym.getName(),
className
}
);
}
}
}

if (implemented) {
implemented.forEach(i => {
const identifier = i.getChildrenOfKind(ts.SyntaxKind.Identifier)[0];
if (identifier) {
const sym = identifier.getSymbol();
if (sym) {
heritageClauses.push(
{
clause: sym.getName(),
className
}
);
}
}
});
}

return heritageClauses;
}

0 comments on commit 34467b2

Please sign in to comment.