Skip to content
Snippets Groups Projects
Select Git revision
  • a860b0c0635500e628f91d26082a5df477f454e7
  • master default protected
  • ci
  • relations
4 results

type.ts

Blame
  • user avatar
    Jesper Öqvist authored and Jesper Öqvist committed
    This is an Angular 4.0 application for viewing JastAdd documentation.
    
    CodeMirror is used to display JastAdd source code.
    a860b0c0
    History
    type.ts 2.23 KiB
    import {Doc} from './doc';
    import {Member} from './member';
    import {TypeRef} from './type-ref';
    import {InheritedMembers} from './inherited-members';
    
    export class Type {
      kind: string;
      name: string;
      pkg: string;
      mods: string[];
      id: string;
      doc: Doc;
      groups: { [id: string] : Member[]; };
      args: TypeRef[]; // Type arguments.
      superclass: TypeRef;
      superinterfaces: TypeRef[];
      inherited_methods: InheritedMembers[];
      inherited_attributes: InheritedMembers[];
      inherited_fields: InheritedMembers[];
    
      static fromJson(json: any): Type {
        var groups = {};
        if (json.groups) {
          for (var i = 0; i < json.groups.length; i++) {
            var group = json.groups[i];
            if (group.members) {
              groups[group.kind] = (group.members as Member[]).map(member => Member.fromJson(member));
            }
          }
        }
        var superclass: TypeRef = undefined;
        if (json.superclass) {
          superclass = TypeRef.fromJson(json.superclass);
        }
        var superinterfaces: TypeRef[] = undefined;
        if (json.superinterfaces) {
          superinterfaces = (json.superinterfaces as TypeRef[]).map(TypeRef.fromJson);
        }
        var inherited_methods: InheritedMembers[] = undefined;
        if (json.inherited_methods) {
          inherited_methods = (json.inherited_methods as any[]).map(inherited =>
              InheritedMembers.fromJson(inherited));
        }
        var inherited_attributes: InheritedMembers[] = undefined;
        if (json.inherited_attributes) {
          inherited_attributes = (json.inherited_attributes as any[]).map(inherited =>
              InheritedMembers.fromJson(inherited));
        }
        var inherited_fields: InheritedMembers[] = undefined;
        if (json.inherited_fields) {
          inherited_fields = (json.inherited_fields as any[]).map(inherited =>
              InheritedMembers.fromJson(inherited));
        }
        var args: TypeRef[] = undefined;
        if (json.args) {
          args = (json.args as any[]).map(arg => TypeRef.fromJson(arg));
        }
        return Object.assign({}, json, {
          groups: groups,
          id: TypeRef.typeId(json.name, json.id),
          superclass: superclass,
          superinterfaces: superinterfaces,
          inherited_methods: inherited_methods,
          inherited_attributes: inherited_attributes,
          inherited_fields: inherited_fields,
        });
      }
    }