Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exit (astPath) {
if (hasComponentDidShow && !hasComponentDidMount) {
astPath.pushContainer('body', t.classMethod(
'method', t.identifier('componentDidMount'), [],
t.blockStatement([]), false, false))
}
if (hasComponentDidHide && !hasComponentWillUnmount) {
astPath.pushContainer('body', t.classMethod(
'method', t.identifier('componentWillUnmount'), [],
t.blockStatement([]), false, false))
}
//@fix
// if (!hasConstructor) {
// astPath.pushContainer('body', t.classMethod(
// 'method', t.identifier('constructor'), [t.identifier('props'), t.identifier('context')],
// t.blockStatement([toAst('super(props, context)'), additionalConstructorNode]), false, false))
// }
if (tabBar) {
if (!hasComponentWillMount) {
astPath.pushContainer('body', t.classMethod(
'method', t.identifier('componentWillMount'), [],
enter: function (path: NodePath>): void {
// Set line mapping
if(path.node.lineMapping) {
lineMapping = path.node.lineMapping
} else {
// NOTE(rachit): This can't actually happen
throw new Error('No line mapping found')
}
// Wrap program into a function.
const prog = path.node.body;
const func = t.functionDeclaration(
t.identifier('$runProg'), [], t.blockStatement(prog))
path.node.body = [func]
},
exit: function (path: NodePath): void {
function functionFromExamples(sources, options) {
const body = flatten(sources.map(s => parseJs(s).program.body));
const { _code, _map, ast } = babel.transformFromAst(t.program(body), null, options);
return new Raw(t.functionExpression(
null,
[],
t.blockStatement(ast.program.body)
));
}
t.objectExpression(
propertyDefinitions
)
]
);
statements.push(t.expressionStatement(
t.assignmentExpression(
'=',
t.memberExpression(
t.identifier('module'),
t.identifier('exports')
),
t.functionExpression(
null,
[t.identifier('prototype')],
t.blockStatement([t.expressionStatement(definePropertiesCall)])
)
)
));
out_file.write(generate(t.program(statements)).code + '\n')
out_file.end(function (err) {
if (err) {
throw err;
}
});
function buildConstructor() {
const ctor = t.classMethod('constructor', t.identifier('constructor'), [t.identifier('props')], t.blockStatement([
t.expressionStatement(t.callExpression(t.identifier('super'), [
t.identifier('props')
]))
]));
return ctor;
}
function processThisPropsFnMemberProperties(member, path, args, binded) {
exportBody() {
return t.blockStatement([
this.modelDefinition(),
this.associate(),
this.datFileGetter(),
t.returnStatement(t.identifier('model')),
]);
}
t.memberExpression(
t.identifier(this.templateVariableName),
t.identifier('displayName')
),
t.stringLiteral(fileName)
)
),
])
)
);
this.program.body.push(
t.exportDefaultDeclaration(
t.functionDeclaration(
t.identifier(fileName),
[t.identifier('props')],
t.blockStatement([
t.returnStatement(
t.callExpression(
t.memberExpression(
t.identifier(this.templateVariableName),
t.identifier('render')
),
[t.identifier('props')]
)
),
])
)
//t.identifier(this.templateVariableName),
)
);
path.replaceWithJS(this.program);
},
function getValidatorResult (identifier, cache) {
const result = t.identifier(`${identifier}Result`);
return [
createConst(result, cache),
t.ifStatement(
callExpression(
'shouldReturnResult',
result
),
t.blockStatement([
t.returnStatement(result),
])
),
];
}
function generator(node) {
var body = [];
var container = t.functionExpression(null, [], t.blockStatement(body), true);
container.shadow = true;
body.push(buildComprehension(node, function () {
return t.expressionStatement(t.yieldExpression(node.body));
}));
return t.callExpression(container, []);
}