Коммит
7018666b67
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -12,8 +12,8 @@
|
|||
"dependencies": {
|
||||
"@types/yargs": "^10.0.2",
|
||||
"change-case": "^3.0.2",
|
||||
"ts-simple-ast": "^9.5.0",
|
||||
"typescript": "^2.9.2",
|
||||
"ts-morph": "^1.2.0",
|
||||
"typescript": "^3.3.1",
|
||||
"yargs": "^11.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
import * as sast from "ts-simple-ast";
|
||||
import {ts, SyntaxKind, TypeGuards } from 'ts-simple-ast';
|
||||
import * as sast from "ts-morph";
|
||||
import {ts, SyntaxKind, TypeGuards } from 'ts-morph';
|
||||
import {ContextInterface} from "./Context";
|
||||
import * as cc from "change-case";
|
||||
import * as os from "os";
|
||||
|
@ -69,7 +69,7 @@ const ValueTypeTextMap = [
|
|||
return emitTypeQuery(node, context);
|
||||
case SyntaxKind.LastTypeNode:
|
||||
return emitLastTypeNodeAsType(node, context);
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.LiteralType:
|
||||
return emitTypeLiteral(node, context);
|
||||
default:
|
||||
throw new Error(`Unknown TypeNode kind ${SyntaxKind[node.getKind()]}`);
|
||||
|
@ -116,7 +116,7 @@ const ValueTypeTextMap = [
|
|||
|
||||
//endNode(node, context);
|
||||
//source.push("object");
|
||||
return _emitType("object", node, context);
|
||||
return _emitType("string", node, context);
|
||||
//return source.join('');
|
||||
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ export function emitComputedPropertyName(node: sast.ComputedPropertyName,
|
|||
return source.join('');
|
||||
}
|
||||
|
||||
export function emitClassName(node: sast.Identifier, context: ContextInterface, changeCase?: boolean): string {
|
||||
export function emitClassName(node: sast.BindingName, context: ContextInterface, changeCase?: boolean): string {
|
||||
|
||||
const source: string[] = [];
|
||||
addLeadingComment(source, node, context);
|
||||
|
@ -541,7 +541,7 @@ export function emitComputedPropertyName(node: sast.ComputedPropertyName,
|
|||
return false;
|
||||
}
|
||||
|
||||
// at this time UnionTypeNode is not wrapped by ts-simple-ast
|
||||
// at this time UnionTypeNode is not wrapped by ts-morph
|
||||
export function emitUnionType(node: sast.UnionTypeNode, context: ContextInterface): string {
|
||||
const source: string[] = [];
|
||||
|
||||
|
@ -635,16 +635,16 @@ export function emitComputedPropertyName(node: sast.ComputedPropertyName,
|
|||
if (typeof typeParameters !== 'undefined' && typeParameters.length > 0)
|
||||
{
|
||||
for (let i = 0, n = typeParameters.length; i < n; i++) {
|
||||
if (typeof typeParameters[i].getConstraintNode() !== 'undefined')
|
||||
if (typeof typeParameters[i].getConstraint() !== 'undefined')
|
||||
{
|
||||
source.push(' where ');
|
||||
source.push(emit(typeParameters[i], context));
|
||||
source.push(' : ');
|
||||
source.push(emitTypeNode(typeParameters[i].getConstraintNode(), context));
|
||||
source.push(emitTypeNode(typeParameters[i].getConstraint(), context));
|
||||
}
|
||||
if (typeof typeParameters[i].getDefaultNode() !== 'undefined')
|
||||
if (typeof typeParameters[i].getDefault() !== 'undefined')
|
||||
{
|
||||
context.diagnostics.pushWarningAtLoc("C# does not support default generic types", typeParameters[i].getDefaultNode() );
|
||||
context.diagnostics.pushWarningAtLoc("C# does not support default generic types", typeParameters[i].getDefault() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import {Node} from "ts-simple-ast";
|
||||
import {Node} from "ts-morph";
|
||||
|
||||
export class Stack<T> {
|
||||
_store: T[] = [];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import {Node} from "ts-simple-ast";
|
||||
import {Node} from "ts-morph";
|
||||
|
||||
export interface DiagnosticsInterface
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
import * as sast from "ts-simple-ast";
|
||||
import {ts, SyntaxKind, TypeGuards, Node} from "ts-simple-ast"
|
||||
import * as sast from "ts-morph";
|
||||
import {ts, SyntaxKind, TypeGuards, Node} from "ts-morph"
|
||||
import {ContextInterface} from "./Context";
|
||||
import {Stack} from "./DataStructures";
|
||||
import {emitPropertyName, emitMethodName, emitClassName} from "./CSharpEmitter";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import * as fs from "fs";
|
||||
import Ast, {ts, ScriptTarget, getCompilerOptionsFromTsConfig, ModuleResolutionKind, ModuleKind} from "ts-simple-ast";
|
||||
import Ast, {ts, ScriptTarget, getCompilerOptionsFromTsConfig, ModuleResolutionKind} from "ts-morph";
|
||||
import * as path from "path";
|
||||
import * as os from "os";
|
||||
|
||||
|
@ -19,7 +19,7 @@ function CreateAST(useVirtualFileSystem? : boolean) : Ast
|
|||
const ast = new Ast({
|
||||
compilerOptions: {
|
||||
target: ScriptTarget.ESNext,
|
||||
module: ModuleKind.CommonJS,
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
moduleResolution: ModuleResolutionKind.NodeJs,
|
||||
noLib: true
|
||||
},
|
||||
|
@ -43,7 +43,7 @@ class Startup {
|
|||
const ast = CreateAST();
|
||||
|
||||
console.log('Resolving File: ' + fileName + ' => ' + path.resolve(fileName));
|
||||
const sf = ast.addSourceFileIfExists(path.resolve(fileName));
|
||||
const sf = ast.addExistingSourceFileIfExists(path.resolve(fileName));
|
||||
const sfs = ast.getSourceFiles();
|
||||
const context = new Context(genOptions);
|
||||
|
||||
|
@ -95,7 +95,7 @@ class Startup {
|
|||
console.log('Combining files: ' + virtualFile);
|
||||
vfs.writeFileSync(virtualFile, virtualSource);
|
||||
|
||||
ast.addSourceFileIfExists(virtualFile);
|
||||
ast.addExistingSourceFileIfExists(virtualFile);
|
||||
|
||||
const sfs = ast.getSourceFiles();
|
||||
const context = new Context(genOptions);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import * as sast from "ts-simple-ast"
|
||||
import * as sast from "ts-morph"
|
||||
|
||||
import {SourceFile, SyntaxKind, TypeGuards, ts} from "ts-simple-ast";
|
||||
import {SourceFile, SyntaxKind, TypeGuards, ts} from "ts-morph";
|
||||
|
||||
import * as emitter from "./CSharpEmitter";
|
||||
import {ContextInterface} from "./Context";
|
||||
|
@ -158,7 +158,7 @@ function visitIndexSignature(node: sast.IndexSignatureDeclaration, context: Cont
|
|||
|
||||
source.push(visitTypeNode(node.getKeyTypeNode(), context));
|
||||
source.push(" ");
|
||||
source.push(emitter.emitParameterName(node.getKeyNameNode(), context));
|
||||
source.push(emitter.emitParameterName(node.getKeyNameNode() as sast.Identifier, context));
|
||||
|
||||
emitStatic(source, ']', node, context);
|
||||
|
||||
|
@ -513,13 +513,13 @@ function visitVariableStatement(node: sast.VariableStatement, context: ContextIn
|
|||
|
||||
function visitVariableDeclarationList(source: string[], node: sast.VariableDeclarationList, context: ContextInterface) : void {
|
||||
|
||||
switch(node.getDeclarationTypeKeyword().getKind())
|
||||
switch(node.getDeclarationKindKeyword().getKind())
|
||||
{
|
||||
case SyntaxKind.VarKeyword:
|
||||
visitVariableDeclarations(source, node, context);
|
||||
break;
|
||||
default:
|
||||
context.diagnostics.pushErrorAtLoc("Declaration type " + node.getDeclarationTypeKeyword().getKindName() + " is not yet supported", node);
|
||||
context.diagnostics.pushErrorAtLoc("Declaration type " + node.getDeclarationKindKeyword().getKindName() + " is not yet supported", node);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as path from "path";
|
||||
import {expect} from "chai";
|
||||
import * as fs from "fs";
|
||||
import Ast, {ts, ScriptTarget, ModuleResolutionKind, ModuleKind} from "ts-simple-ast";
|
||||
import Ast, {ts, ScriptTarget, ModuleResolutionKind} from "ts-morph";
|
||||
import {TsToCSharpGenerator} from "./TStoCSharpGenerator";
|
||||
import {GenOptions} from "./GenerateOptions";
|
||||
import {Context} from "./Context";
|
||||
|
@ -28,7 +28,7 @@ function CreateAST() : Ast
|
|||
const ast = new Ast({
|
||||
compilerOptions: {
|
||||
target: ScriptTarget.ESNext,
|
||||
module: ModuleKind.CommonJS,
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
moduleResolution: ModuleResolutionKind.NodeJs,
|
||||
noLib: true
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ describe("TsToCSharpGenerator", () => {
|
|||
const ast = CreateAST();
|
||||
|
||||
//console.log("Adding Source File: " + path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
ast.addSourceFileIfExists(path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
ast.addExistingSourceFileIfExists(path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
|
||||
const sourceFiles = ast.getSourceFiles();
|
||||
const context = new Context(new TestGenOptions());
|
||||
|
@ -222,7 +222,7 @@ describe("TsToCSharpGenerator", function () {
|
|||
const ast = CreateAST();
|
||||
|
||||
//console.log("Adding Source File: " + path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
ast.addSourceFileIfExists(path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
ast.addExistingSourceFileIfExists(path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
|
||||
const sourceFiles = ast.getSourceFiles();
|
||||
const context = new Context(genOptions);
|
||||
|
@ -254,7 +254,7 @@ describe("TsToCSharpGenerator", () => {
|
|||
|
||||
const ast = CreateAST();
|
||||
|
||||
ast.addSourceFileIfExists(path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
ast.addExistingSourceFileIfExists(path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
|
||||
const sourceFiles = ast.getSourceFiles();
|
||||
const context = new Context(new TestGenOptions());
|
||||
|
@ -269,7 +269,7 @@ describe("TsToCSharpGenerator", () => {
|
|||
|
||||
const ast = CreateAST();
|
||||
|
||||
ast.addSourceFileIfExists(path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
ast.addExistingSourceFileIfExists(path.resolve(path.join(definitionsPath,testPath,testFile + ".d.ts")));
|
||||
|
||||
const sourceFiles = ast.getSourceFiles();
|
||||
const context = new Context(new TestClassGenOptions());
|
||||
|
|
Загрузка…
Ссылка в новой задаче