-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1238 from IgniteUI/bpenkov/typescript-ast-transfo…
…rmer Implement an AST transformer
- Loading branch information
Showing
10 changed files
with
2,082 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface KeyValuePair<T> { | ||
[key: string]: T; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import * as ts from 'typescript'; | ||
import { Expression, FormatCodeSettings } from 'typescript'; | ||
|
||
export interface FormattingService { | ||
path: string; | ||
/** Applies formatting to the file after reading it form the `fs`. */ | ||
applyFormatting(sourceFile: ts.SourceFile): string; | ||
} | ||
|
||
export interface FormatSettings extends FormatCodeSettings { | ||
singleQuotes?: boolean; | ||
} | ||
|
||
export interface Identifier { | ||
name: string; | ||
alias?: string; | ||
} | ||
|
||
export interface ImportDeclarationMeta { | ||
identifiers: Identifier | Identifier[]; | ||
moduleName: string; | ||
} | ||
|
||
export interface PropertyAssignment { | ||
name: string; | ||
value: Expression; | ||
} | ||
|
||
/** | ||
* The type of change to apply to the source file. | ||
*/ | ||
export enum ChangeType { | ||
NewNode = 'new-node', | ||
NodeUpdate = 'node-update', | ||
} | ||
|
||
/** | ||
* The kind of syntax node to transform in the source file. | ||
*/ | ||
export enum SyntaxKind { | ||
PropertyAssignment = 'property-assignment', | ||
ObjectLiteralExpression = 'object-literal-expression', | ||
ArrayLiteralExpression = 'array-literal-expression', | ||
ImportDeclaration = 'import-declaration', | ||
Primitive = 'primitive', | ||
Expression = 'expression', | ||
} | ||
|
||
/** | ||
* A request to change the source file. | ||
*/ | ||
export interface ChangeRequest<T extends ts.Node> { | ||
/** | ||
* A unique identifier for the change request. It can represent the accumulated values of a node's text or properties. | ||
*/ | ||
id: string; | ||
/** | ||
* The type of change to apply to the source file. | ||
*/ | ||
type: ChangeType; | ||
/** | ||
* The transformer factory to apply to the source file. | ||
*/ | ||
transformerFactory: ts.TransformerFactory<ts.SourceFile>; | ||
/** | ||
* The kind of syntax node to transform in the source file. | ||
*/ | ||
syntaxKind: SyntaxKind; | ||
/** | ||
* The affected node in the source file. | ||
*/ | ||
node: T | ts.NodeArray<T>; | ||
} |
Oops, something went wrong.