From 4e8bb603ca5c3d64311a85cb4f0de05e0de1fe4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20=C3=96qvist?= <jesper.oqvist@cs.lth.se> Date: Wed, 24 Jan 2018 16:10:53 +0100 Subject: [PATCH] Add direct subtypes, improve declared-at updating --- src/app/declared-at/declared-at.component.ts | 17 +++++++++-------- src/app/type-details.component.html | 5 ++++- src/app/type.ts | 6 ++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/app/declared-at/declared-at.component.ts b/src/app/declared-at/declared-at.component.ts index 12d3c65..16ec099 100644 --- a/src/app/declared-at/declared-at.component.ts +++ b/src/app/declared-at/declared-at.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; import {Doc} from '../doc'; @@ -8,19 +8,20 @@ import {Doc} from '../doc'; Declared at <a [routerLink]="['/source', filename, line]">{{filepath}}:{{line}}.</a> `, }) -export class DeclaredAtComponent implements OnInit { +export class DeclaredAtComponent { - @Input() doc: Doc; + private _doc: Doc; filename: string; filepath: string; line: string; constructor() { } - ngOnInit() { - this.filepath = this.doc.ragFile; - this.filename = this.filepath.replace(/\/|\\/g, '_'); - this.line = String(this.doc.line); + @Input() + set doc(doc: Doc) { + this._doc = doc; + this.filepath = doc.ragFile; + this.filename = this.filepath.replace(/\/|\\|\./g, '_'); + this.line = String(doc.line); } - } diff --git a/src/app/type-details.component.html b/src/app/type-details.component.html index 93344b7..6a8b39e 100644 --- a/src/app/type-details.component.html +++ b/src/app/type-details.component.html @@ -3,10 +3,13 @@ <p *ngIf="type.superclass">extends <type-ref [type]="type.superclass"></type-ref> <ng-container *ngIf="type.superinterfaces">implements <ng-container *ngFor="let iface of type.superinterfaces; let isLast = last"><type-ref [type]="iface"></type-ref><div *ngIf="!isLast" class="sep">, </div></ng-container></ng-container> </p> + <p> + <ng-container *ngIf="type.subtypes">Direct subtypes: <ng-container *ngFor="let subtype of type.subtypes; let isLast = last"><type-ref [type]="subtype"></type-ref><div *ngIf="!isLast" class="sep">, </div></ng-container></ng-container> + </p> <div *ngIf="type.doc"> <p [innerHTML]="type.doc.description"> - <p *ngIf="type.doc.astdecl">JastAdd production: {{type.doc.astdecl}} + <p *ngIf="type.doc.astdecl">JastAdd production: <b>{{type.doc.astdecl}}</b> <p *ngIf="type.doc && type.doc.ragFile"><declared-at [doc]="type.doc"></declared-at> </div> diff --git a/src/app/type.ts b/src/app/type.ts index 6ad43f6..8b73139 100644 --- a/src/app/type.ts +++ b/src/app/type.ts @@ -17,6 +17,7 @@ export class Type { inherited_methods: InheritedMembers[]; inherited_attributes: InheritedMembers[]; inherited_fields: InheritedMembers[]; + subtypes: TypeRef[]; static fromJson(json: any): Type { var groups = {}; @@ -55,6 +56,10 @@ export class Type { if (json.args) { args = (json.args as any[]).map(arg => TypeRef.fromJson(arg)); } + var subtypes: TypeRef[] = undefined; + if (json.subtypes) { + subtypes = (json.subtypes as any[]).map(arg => TypeRef.fromJson(arg)); + } return Object.assign({}, json, { groups: groups, id: TypeRef.typeId(json.name, json.id), @@ -63,6 +68,7 @@ export class Type { inherited_methods: inherited_methods, inherited_attributes: inherited_attributes, inherited_fields: inherited_fields, + subtypes: subtypes, }); } } -- GitLab