Skip to content
Snippets Groups Projects
Select Git revision
  • d67f23a8b29f6af299e1f4f2778cc495257a2179
  • main default
  • kinetic protected
  • hydro
  • indigo
  • obsolete/master
  • 0.3.3
  • 0.3.2
  • 0.3.1
  • 0.3.0
  • 0.1.24
  • 0.1.23
  • 0.2.1
  • 0.1.22
  • 0.1.21
  • 0.1.20
  • 0.1.19
  • 0.1.18
  • 0.1.17
  • 0.1.16
  • 0.1.15
  • 0.1.14
  • 0.1.13
  • 0.1.12
  • 0.1.11
  • 0.1.10
26 results

gradle.properties

Blame
  • type-ref.ts 1.21 KiB
    export class TypeRef {
      name: string;
      id?: string;
      args: TypeRef[];
    
      constructor(name: string, id: string, args: TypeRef[]) {
        this.name = name;
        this.id = id;
        this.args = args;
      }
    
      static fromJson(json: any): TypeRef {
        var args: TypeRef[] = undefined;
        if (json.a) {
          args = (json.a as TypeRef[]).map(TypeRef.fromJson);
        }
        if (json.u) {
          // User type.
          if (json.i) {
            return new TypeRef(json.u, TypeRef.typeId(json.u, json.i), args);
          } else {
            return new TypeRef(json.u, TypeRef.simpleName(json.u), args);
          }
        } else {
          // Library or built-in type.
          return new TypeRef(json.n, undefined, args);
        }
      }
    
      // Remove array and type args.
      static simpleName(name: string): string {
        return TypeRef.strip('<', TypeRef.strip('[', name));
      }
    
      static strip(tok: string, name: string): string {
        const index = name.indexOf(tok);
        if (index < 0) {
          return name;
        } else {
          var simple = name.substring(0, index);
          return simple;
        }
      }
    
      get isVoid(): boolean {
        return this.name == 'void';
      }
    
      static typeId(name: string, idPattern: string): string {
        return idPattern.replace('%', TypeRef.simpleName(name));
      }
    }