Skip to content
Snippets Groups Projects
Commit 394d7e5d authored by René Schöne's avatar René Schöne
Browse files

One step forward (build still fails)

parent b64ab782
No related branches found
No related tags found
No related merge requests found
Showing
with 434 additions and 0 deletions
import {TypeRef} from '../type-ref';
import {AstComponent} from './ast-component';
export class AstDecl {
name: string;
extends?: TypeRef;
components?: AstComponent[];
static fromJson(json: any): AstDecl {
if (!json) {
return undefined;
}
var ext: TypeRef = undefined
if (json.e) {
ext = TypeRef.fromJson(json.e)
}
var components: AstComponent[] = undefined;
if (json.c) {
components = (json.c as any[]).map(c => AstComponent.fromJson(c));
}
return {
name: json.n as string,
extends: ext,
components: components,
};
}
}
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DeclaredAtComponent } from './declared-at.component';
describe('DeclaredAtComponent', () => {
let component: DeclaredAtComponent;
let fixture: ComponentFixture<DeclaredAtComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DeclaredAtComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DeclaredAtComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Input } from '@angular/core';
import {Doc} from '../doc';
@Component({
selector: 'declared-at',
template: `
Declared at <a [routerLink]="['/source', filename, line]">{{filepath}}:{{line}}.</a>
`,
})
export class DeclaredAtComponent {
private _doc: Doc;
filename: string;
filepath: string;
line: string;
constructor() { }
@Input()
set doc(doc: Doc) {
this._doc = doc;
this.filepath = doc.ragFile;
this.filename = this.filepath.replace(/\/|\\|\./g, '_');
this.line = String(doc.line);
}
}
import {AstDecl} from './ast-decl/ast-decl';
export class Doc {
ast: string;
astdecl: AstDecl;
ragFile: string;
line: number;
description: string;
apilevel: string;
params: string[]
static fromJson(json: any): Doc {
var astdecl: AstDecl = undefined;
if (json.astdecl) {
astdecl = AstDecl.fromJson(json.astdecl);
}
return {
ast: json.ast,
astdecl: astdecl,
ragFile: json.ragFile,
line: json.line,
description: json.description,
apilevel: json.apilevel,
params: json.params,
};
}
}
import { EditorDirective } from './editor.directive';
describe('EditorDirective', () => {
it('should create an instance', () => {
const directive = new EditorDirective();
expect(directive).toBeTruthy();
});
});
import { Directive, ElementRef, Input, OnChanges } from '@angular/core';
import * as CodeMirror from 'codemirror';
import 'codemirror/mode/clike/clike';
import 'codemirror/addon/selection/active-line';
@Directive({
selector: '[appEditor]'
})
export class EditorDirective implements OnChanges {
editor: any;
@Input() sourceText: string;
@Input() sourceLine: number;
constructor(public element: ElementRef) {
this.editor = new CodeMirror.fromTextArea(element.nativeElement, {
mode: 'text/x-java',
theme: 'mbo',
lineNumbers: true,
styleActiveLine: true,
lineWrapping: false,
});
this.editor.setSize('100%', '100%');
}
ngOnChanges() {
this.editor.setValue(this.sourceText || 'loading...');
if (this.sourceLine) {
var line = this.sourceLine - 1;
this.editor.scrollIntoView({line: line + 30, ch: 0});
this.editor.setCursor({line: line, ch: 0});
}
}
}
import {TypeRef} from './type-ref';
export class InheritedMembers {
superclass: TypeRef;
members: string[];
static fromJson(json: any): InheritedMembers {
return {
superclass: TypeRef.fromJson(json.superclass),
members: json.members as string[],
};
}
}
import { TestBed, inject } from '@angular/core/testing';
import { MemberFilterService } from './member-filter.service';
describe('MemberFilterService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [MemberFilterService]
});
});
it('should ...', inject([MemberFilterService], (service: MemberFilterService) => {
expect(service).toBeTruthy();
}));
});
import { Injectable } from '@angular/core';
import {Subject} from 'rxjs/Subject';
@Injectable()
export class MemberFilterService {
private filter = new Subject<string>();
filter$ = this.filter.asObservable();
constructor() { }
setFilter(filter: string) {
this.filter.next(filter);
}
}
import {Parameter} from './parameter';
import {Doc} from './doc';
import {TypeRef} from './type-ref';
export class Member {
name: string;
type?: TypeRef;
doc: Doc;
parameters: Parameter[];
throws: TypeRef[];
constructor(name: string, type: TypeRef, doc: Doc, parameters: Parameter[],
throws: TypeRef[]) {
this.name = name;
this.type = type;
this.doc = doc;
this.parameters = parameters;
this.throws = throws;
}
get isVoid(): boolean {
return this.type.isVoid;
}
static fromJson(json: any): Member {
var params: Parameter[] = [];
var doc: Doc = undefined;
var name: string = json.name as string;
if (json.doc) {
doc = Doc.fromJson(json.doc);
}
if (json.params) {
params = json.params.map(param => Parameter.fromJson(param));
}
var throws: TypeRef[] = undefined;
if (json.throws) {
throws = (json.throws as TypeRef[]).map(TypeRef.fromJson);
}
if (json.type) {
return new Member(name,
TypeRef.fromJson(json.type),
doc,
params,
throws);
} else {
return new Member(name,
undefined,
doc,
params,
throws);
}
}
}
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'nameFilter'
})
export class NameFilterPipe implements PipeTransform {
transform(items: any[], filter: string): any {
if (!items || !filter) {
return items;
}
return items.filter(item => item.name.toLowerCase().indexOf(filter.toLowerCase()) >= 0);
}
}
import {TypeRef} from './type-ref';
export class PackageEntry {
kind: string;
name: string;
id: string;
static fromJson(json: any): PackageEntry {
return json as PackageEntry;
}
}
import { Injectable } from '@angular/core';
import { Headers, Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import { Package } from './package';
@Injectable()
export class PackageService {
private packageUrl = 'data/packages.json';
constructor(private http: Http) { }
getPackages(): Promise<Package[]> {
return this.http.get(this.packageUrl)
.toPromise()
.then(response => (response.json().data as Package[]).map(pkg => Package.fromJson(pkg)))
.catch(res => Promise.reject(`Failed to load packages: ${res}`));
}
}
import { PackageEntry } from './package-entry';
export class Package {
name: string;
groups: any[];
static fromJson(json: any): Package {
return json as Package;
}
}
import {TypeRef} from './type-ref';
export class Parameter {
type: TypeRef;
name: string;
static fromJson(json: any): Parameter {
return {
type: TypeRef.fromJson(json.t),
name: json.n,
};
}
}
import { Component, Input, ComponentFactoryResolver } from '@angular/core';
import {Parameter} from './parameter';
@Component({
selector: 'parameters',
styles: [`
.parameters {
display: inline;
height: 1.2em;
overflow: hidden;
text-overflow: ellipsis;
}
.parameter {
display: inline;
}
.sep {
display: inline;
margin-right: .3em;
}
`],
template: `
<div class="parameters">
<div *ngFor="let param of params; let isLast=last" class="parameter">
<type-ref [type]="param.type"></type-ref><div *ngIf="!isLast" class="sep">,</div>
</div>
</div>
`
})
export class ParametersComponent {
@Input() params : Parameter[];
constructor(private _componentFactoryResolver: ComponentFactoryResolver) { }
}
import {Injectable} from '@angular/core';
import {Subject} from 'rxjs/Subject';
@Injectable()
export class SelectionService {
private selection = new Subject<string>();
selection$ = this.selection.asObservable();
select(id: string) {
this.selection.next(id);
}
}
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SourceViewComponent } from './source-view.component';
describe('SourceViewComponent', () => {
let component: SourceViewComponent;
let fixture: ComponentFixture<SourceViewComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SourceViewComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SourceViewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import 'rxjs/add/operator/switchMap';
import {SourceService} from '../source.service';
@Component({
selector: 'app-source-viewer',
providers: [ SourceService ],
template: `<textarea appEditor [sourceText]="source" [sourceLine]="line">{{source}}</textarea>`,
})
export class SourceViewComponent implements OnInit {
source: string;
line: number;
constructor(private sourceService: SourceService,
private route: ActivatedRoute) { }
ngOnInit() {
this.route.params.switchMap((params: Params) => {
this.line = +params['line'];
return this.sourceService.getSource(params['filename']);
})
.subscribe(source => {
this.source = source;
});
}
}
import { TestBed, inject } from '@angular/core/testing';
import { SourceService } from './source.service';
describe('SourceService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [SourceService]
});
});
it('should ...', inject([SourceService], (service: SourceService) => {
expect(service).toBeTruthy();
}));
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment