forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyntacticCleaner.ts
More file actions
30 lines (25 loc) · 961 Bytes
/
Copy pathsyntacticCleaner.ts
File metadata and controls
30 lines (25 loc) · 961 Bytes
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
// Use this to get emitter-agnostic baselines
class SyntacticCleaner {
static clean(sourceFileContents: string) {
return sourceFileContents;
}
}
/* TODO: Re-implement or maybe delete
class SyntacticCleaner extends TypeScript.SyntaxWalker {
private emit: string[] = [];
public visitToken(token: TypeScript.ISyntaxToken): void {
this.emit.push(token.text());
if (token.kind() === TypeScript.SyntaxKind.SemicolonToken) {
this.emit.push('\r\n');
} else {
this.emit.push(' ');
}
}
static clean(sourceFileContents: string): string {
var parsed = TypeScript.Parser.parse('_emitted.ts', TypeScript.SimpleText.fromString(sourceFileContents), TypeScript.LanguageVersion.EcmaScript5, false);
var cleaner = new SyntacticCleaner();
cleaner.visitSourceUnit(parsed.sourceUnit());
return cleaner.emit.join('');
}
}
*/