-
-
Notifications
You must be signed in to change notification settings - Fork 201
Expand file tree
/
Copy pathcode-entity.ts
More file actions
58 lines (46 loc) · 1.27 KB
/
code-entity.ts
File metadata and controls
58 lines (46 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import * as _ from "lodash";
import { injector } from "../yok";
import { CodeGeneration } from "./code-generation";
export enum CodeEntityType {
Line,
Block,
}
export class Line implements CodeGeneration.ILine {
public content: string;
constructor(content: string) {
this.content = content;
}
public get codeEntityType() {
return CodeEntityType.Line;
}
public static create(content: string): CodeGeneration.ILine {
return new Line(content);
}
}
injector.register("swaggerLine", Line);
export class Block implements CodeGeneration.IBlock {
public opener: string;
public codeEntities: CodeGeneration.ICodeEntity[];
public endingCharacter: string;
constructor(opener?: string) {
this.opener = opener;
this.codeEntities = [];
}
public get codeEntityType() {
return CodeEntityType.Block;
}
public addBlock(block: CodeGeneration.IBlock): void {
this.codeEntities.push(block);
}
public addLine(line: CodeGeneration.ILine): void {
this.codeEntities.push(line);
}
public addBlocks(blocks: CodeGeneration.IBlock[]): void {
_.each(blocks, (block: CodeGeneration.IBlock) => this.addBlock(block));
}
public writeLine(content: string): void {
const line = Line.create(content);
this.codeEntities.push(line);
}
}
injector.register("swaggerBlock", Block);