本文整理汇总了TypeScript中escodegen.generate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript generate函数的具体用法?TypeScript generate怎么用?TypeScript generate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
enter: function (n:any) {
if (matcher(n)) {
var classname = escodegen.generate(n.arguments[0]).replace(/AWS\.(\w+)\.prototype/, "$1")
var methodList = n.arguments[1].properties.map((x:any) => {
var context = {
classname: classname,
name: x.key.name,
commentStr: (x.leadingComments && x.leadingComments.map((x: any) => { return x.value }).join('\n')) || ""
} as ExtraClientMethod
context.commentStr = context.commentStr.replace(/\n\s+\*/g, "\n *");
var m = /@api\s+private/.exec(context.commentStr)
if (m) {
return null
}
if (0 == context.commentStr.length) {
context.commentStr = null;
}
return context
}).filter((x: ExtraClientMethod) => {
return null != x
})
console.log("Adding class: ", classname, " and methods: ", methodList)
methodsToAdd[classname] = methodList
}
}
开发者ID:AitorGuerrero,项目名称:aws-sdk-typescript,代码行数:33,代码来源:app.ts
示例2: function
enter: function(n: any) {
if (matcher(n)) {
var classname = escodegen.generate(n.arguments[0]).replace(/AWS\.(\w+)\.prototype/, "$1")
var methodList = n.arguments[1].properties.map(function(x: any) { return x.key.name })
console.log("Adding class: ", classname, " and methods: ", methodList)
methodsToAdd[classname] = methodList
}
}
开发者ID:Bnaya,项目名称:aws-sdk-typescript,代码行数:11,代码来源:app.ts
示例3: getLscAst
return qFs.read(inputLambdaScriptFile).then(function(lambdaScriptCode: string) {
const lscAst = getLscAst(lambdaScriptCode),
jsAst = astToJsAst(lscAst);
logger.debug({jsAst: jsAst}, 'Converted LambdaScript AST to JS AST');
const js = escodegen.generate(jsAst);
logger.debug({js: js}, 'Generated raw js');
const jsWithPrelude = withPrelude(js);
logger.debug({jsWithPrelude: jsWithPrelude}, 'Added prelude to raw js');
return qFs.write(outputJsFile, jsWithPrelude);
});
开发者ID:NickHeiner,项目名称:lambdascript,代码行数:13,代码来源:index.ts
示例4: bundle
export function bundle(options: IBundleOptions, host: IHost = new DefaultHost()): string {
const context: IPaeckchenContext = {
config: createConfig(options, host),
host
};
if (!context.config.input.entryPoint) {
throw new Error('Missing entry-point');
}
const detectedGlobals: IDetectedGlobals = {
global: false,
process: false,
buffer: false
};
const paeckchenAst = parse(paeckchenSource);
const modules = getModules(paeckchenAst).elements;
const absoluteEntryPath = join(host.cwd(), context.config.input.entryPoint);
// start bundling...
enqueueModule(getModulePath('.', absoluteEntryPath, context));
while (bundleNextModule(modules, context, detectedGlobals)) {
process.stderr.write('.');
}
// ... when ready inject globals...
injectGlobals(detectedGlobals, paeckchenAst, context);
// ... and bundle global dependencies
while (bundleNextModule(modules, context, detectedGlobals)) {
process.stderr.write('.');
}
process.stderr.write('\n');
const bundleResult = generate(paeckchenAst, {
comment: true
});
if (context.config.output.file) {
host.writeFile(
host.joinPath(context.config.output.folder, context.config.output.file),
bundleResult);
return undefined;
}
return bundleResult;
}
开发者ID:ZauberNerd,项目名称:paeckchen,代码行数:41,代码来源:bundle.ts
示例5: function
files.forEach((file: {src: string[]; dest: string}) => {
var jsFileContent = fs.readFileSync(file.src[0]).toString(),
ast = esprima.parse(jsFileContent, {loc: true, range: true});
// Ensure destination folder exists
if (!fs.existsSync(path.dirname(file.dest))) {
grunt.file.mkdir(path.dirname(file.dest));
}
var processedAst = estraverse.replace(ast, {
enter: function(node: any) {
if (node.type === 'ExpressionStatement' &&
node.expression.type === 'CallExpression' &&
remove.indexOf(node.expression.callee.name) > -1) {
return {type:'EmptyStatement'};
}
}
}), output = escodegen.generate(processedAst, {sourceMap: path.relative(path.dirname(file.dest), file.src[0]), sourceMapWithCode: true});
var mapDest = file.dest + '.map';
fs.writeFileSync(mapDest, output.map);
fs.writeFileSync(file.dest, `${output.code}\n//# sourceMappingURL=${path.basename(file.dest)}.map`);
});
开发者ID:Warlander,项目名称:doppio,代码行数:21,代码来源:ice-cream.ts
示例6: addShadowDomTests
async function addShadowDomTests(element: ElementRepo): Promise<void> {
const testDir = path.join(element.dir, 'test');
if (!existsSync(testDir) || !fs.statSync(testDir).isDirectory()) {
return; // nothing to do
}
const testIndexFile = path.join(testDir, 'index.html');
if (!existsSync(testIndexFile)) {
return; // nothing to do
}
const contents = fs.readFileSync(testIndexFile, 'utf8');
const domTree = dom5.parse(contents);
const scripts = dom5.queryAll(domTree, (n) => n.tagName === 'script');
let updateNeeded = false;
for (const script of scripts) {
const data = script.childNodes[0];
if (!data || data.nodeName !== '#text') {
continue;
}
const program = espree.parse(data.value, {attachComment: true});
estree_walker.walk(program, {
enter(n) {
if (!(n.type === 'CallExpression' &&
n.callee.type === 'MemberExpression')) {
return;
}
if (!(n.callee.object && n.callee.property)) {
return;
}
if (!(n.callee.object.name === 'WCT' &&
n.callee.property.name === 'loadSuites')) {
return;
}
if (!(n.arguments && n.arguments.length === 1 &&
n.arguments[0].type === 'ArrayExpression')) {
return;
}
const testFilenameExpressions = n.arguments[0];
const shadyFilenames = new Set<string>();
const shadowFilenames = new Set<string>();
for (const filenameExpression of testFilenameExpressions.elements) {
if (/dom=shadow/.test(filenameExpression.value)) {
shadowFilenames.add(filenameExpression.value);
} else {
shadyFilenames.add(filenameExpression.value);
}
}
for (const shadyFilename of shadyFilenames) {
if (!shadowFilenames.has(shadyFilename + '?dom=shadow')) {
updateNeeded = true;
}
}
testFilenameExpressions.elements = [];
for (const shadyFilename of shadyFilenames) {
testFilenameExpressions.elements.push(
{type: 'Literal', value: shadyFilename});
}
for (const shadyFilename of shadyFilenames) {
testFilenameExpressions.elements.push(
{type: 'Literal', value: shadyFilename + '?dom=shadow'});
}
}
});
// Try to infer indentation
let indentation = ' ';
const parent = script.parentNode;
const scriptIndex = parent.childNodes.indexOf(script);
if (scriptIndex >= 0 &&
parent.childNodes[scriptIndex - 1].nodeName === '#text') {
const textJustBefore = parent.childNodes[scriptIndex - 1].value;
indentation = textJustBefore.match(/( +)$/)[1];
}
data.value = '\n' + escodegen.generate(program, {
comment: true,
format: {
indent: {
style: ' ',
base: (indentation.length / 2) + 1,
adjustMultilineComment: true
}
}
}) + '\n' + indentation;
}
if (updateNeeded) {
fs.writeFileSync(testIndexFile, dom5.serialize(domTree) + '\n', 'utf8');
element.needsReview = true;
await makeCommit(
element, ['test/index.html'],
'Add shadow dom test configurations.');
}
}
开发者ID:BruceZu,项目名称:tedium,代码行数:92,代码来源:tests.ts
示例7:
safeConcatenation: true,
preserveBlankLines: true
};
let emptyMozillaOptions: escodegen.MozillaOptions = {};
let mozillaOptions: escodegen.MozillaOptions = {
starlessGenerator: true,
parenthesizedComprehensionBlock: true,
comprehensionExpressionStartsWithAssignment: true
}
let emptyGenerateOptions: escodegen.GenerateOptions = {};
let generateOptions: escodegen.GenerateOptions = {
format: formatOptions,
moz: mozillaOptions,
parse: () => {},
comment: true,
sourceMap: " ",
sourceMapWithCode: true,
sourceContent: " ",
sourceCode: " ",
sourceMapRoot: " ",
directive: true,
file: " ",
verbatim: " "
};
let precedence: escodegen.Precedence = escodegen.Precedence.Primary;
let myCode: string = escodegen.generate({}, generateOptions);
let ast: any = escodegen.attachComments({}, {}, {});
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:30,代码来源:escodegen-tests.ts
示例8: generate
export function generate(node: ESTree.Node): string {
return escodegen.generate(node);
};
开发者ID:devlucas,项目名称:stryker,代码行数:3,代码来源:parserUtils.ts
示例9: function
export default function (tree: ESTree.Program, options?: TransformOptions): string {
return escodegen.generate(transform(tree, options));
}
开发者ID:KallynGowdy,项目名称:RxUI-View,代码行数:3,代码来源:emit.ts
注:本文中的escodegen.generate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论