Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
entrySrc.statements.forEach(s => {
if (
s.kind === NodeKind.CLASSDECLARATION &&
s.decorators &&
s.decorators.length &&
s.decorators.some(d => d.name.text === "deserializable")
) {
const name = s.name.text
const marshalCode = buildMarshal(name, deserializableClasses[name])
console.log(marshalCode)
const marshalStmt = parseStatements(entrySrc, marshalCode)[0]
const method = Node.createMethodDeclaration(
marshalStmt.name,
null,
marshalStmt.signature,
marshalStmt.body,
null,
CommonFlags.STATIC,
entrySrc.range // TODO
entrySrc.statements.forEach(s => {
if (
s.kind === NodeKind.CLASSDECLARATION &&
s.decorators &&
s.decorators.length &&
s.decorators.some(d => d.name.text === "deserializable")
) {
if (s.isGeneric) {
throw Error("Generic classes are not currently @deserializable")
}
const fields = []
s.members.forEach(m => {
if (m.kind === NodeKind.FIELDDECLARATION) {
const name = m.name.text
const type = m.type.name.text
const typeArgs = m.type.typeArguments.map(t => t.name.text)
fields.push([m.name.text, type, ...typeArgs])
}