Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createFillNodeFromMixinStructuresFunctions(opts: Options) {
const {classVMs, fillOnlyFunctionVMs, overloadStructureVMs} = opts;
classVMs.forEach(c => removeNotAllowedMixins(c));
const writer = new CodeBlockWriter();
const mixinsOfMixins = getMixinsOfMixins(classVMs);
writer.writeLine("/* tslint:disable */");
writer.writeLine("// DO NOT MANUALLY EDIT!! File generated via: npm run code-generate").newLine();
writer.writeLine(`import * as compiler from "./../compiler";`);
writer.writeLine(`import * as structures from "./../structures";`);
writer.writeLine(`import * as fillFuncs from "./fillMixinFunctions";`);
writer.writeLine(`import * as fillOnlyFuncs from "./fillOnlyFunctions";`);
for (const vm of [...classVMs.filter(c => isAllowedClass(c) && c.mixins.length > 0), ...mixinsOfMixins.filter(m => m.mixins.length > 0)]) {
writer.newLine();
write(writer, vm, fillOnlyFunctionVMs);
}
for (const vm of overloadStructureVMs) {
writer.newLine();
private generateMainJsFile (): CodeBlockWriter {
const writer = new CodeBlockWriter(this.writerOptions)
writer
.writeLine(`import app from './bootstrap'`)
.writeLine(`app.__wane__init()`)
return writer
}
it(`prints an empty string for {{ greeting }} and {{ someone }} because it is already initialized when dom is created`, () => {
const wr = new CodeBlockWriter()
greeting.printInit(wr, greeting.getResponsibleFactory())
expect(wr.toString()).toBe(``)
const wr2 = new CodeBlockWriter()
someone.printInit(wr, greeting.getResponsibleFactory())
expect(wr2.toString()).toBe(``)
})
})
it(`prints assembling logic`, () => {
const string = stripIndent`
util.__wane__appendChildren(this.__wane__root, [
util.__wane__appendChildren(this.__wane__domNodes[0], [
])
util.__wane__appendChildren(this.__wane__domNodes[1], [
])
util.__wane__appendChildren(this.__wane__domNodes[2], [
])
util.__wane__appendChildren(this.__wane__domNodes[3], [
])
util.__wane__appendChildren(this.__wane__domNodes[4], [
])
])
`
const wr = new CodeBlockWriter({ indentNumberOfSpaces: 2 })
app.printAssemblingDomNodes(wr)
expect((stripIndent as any)(wr.toString())).toEqual(string)
})
})
static createWriter(writeOptions: WriteOptions | undefined) {
return new CodeBlockWriter(writeOptions);
}
function expectWriter (spy: (wr: CodeBlockWriter) => void, expectation: string): void {
const wr = new CodeBlockWriter({ indentNumberOfSpaces: 2 })
spy(wr)
expect(wr.toString().trim()).toBe(expectation.trim())
}
export function getCodeBlockWriter(manipulationSettings: ManipulationSettingsContainer) {
const indentationText = manipulationSettings.getIndentationText();
return new CodeBlockWriter({
newLine: manipulationSettings.getNewLineKindAsString(),
indentNumberOfSpaces: indentationText === IndentationText.Tab ? undefined : indentationText.length,
useTabs: indentationText === IndentationText.Tab,
useSingleQuote: manipulationSettings.getQuoteType() === QuoteType.Single
});
}
export function getCodeFromClasses(options: Options) {
const importWriter = new CodeBlockWriter();
const writer = new CodeBlockWriter();
const types = new TypesDictionary();
const {libraryName, classes, importMapping} = options;
classes.forEach((c, classIndex) => {
if (classIndex > 0) {
writer.newLine();
}
const classWriter = new ClassWriter(c, types, options.classMapping[c.name] || c.name);
classWriter.writeToWriter(writer);
});
importWriter.writeLine(`import {${CLIENT_BASE_NAME}} from "${libraryName}";`);
Object.keys(types.getTypes()).forEach(typeName => {
function getCodeFromClasses(options) {
var importWriter = new code_block_writer_1.default();
var writer = new code_block_writer_1.default();
var types = new types_dictionary_1.TypesDictionary();
var libraryName = options.libraryName, classes = options.classes, importMapping = options.importMapping;
classes.forEach(function (c, classIndex) {
if (classIndex > 0) {
writer.newLine();
}
var classWriter = new class_writer_1.ClassWriter(c, types, options.classMapping[c.name] || c.name);
classWriter.writeToWriter(writer);
});
importWriter.writeLine("import {" + CLIENT_BASE_NAME + "} from \"" + libraryName + "\";");
Object.keys(types.getTypes()).forEach(function (typeName) {
if (typeName === CLIENT_BASE_NAME) {
throw new Error("Having a type with the name ClientBase is currently not supported. Please use a different type name.");
}
else if (importMapping[typeName] == null) {
function getCodeFromClasses(options) {
var importWriter = new code_block_writer_1.default();
var writer = new code_block_writer_1.default();
var types = new types_dictionary_1.TypesDictionary();
var libraryName = options.libraryName, classes = options.classes, importMapping = options.importMapping;
classes.forEach(function (c, classIndex) {
if (classIndex > 0) {
writer.newLine();
}
var classWriter = new class_writer_1.ClassWriter(c, types, options.classMapping[c.name] || c.name);
classWriter.writeToWriter(writer);
});
importWriter.writeLine("import {" + CLIENT_BASE_NAME + "} from \"" + libraryName + "\";");
Object.keys(types.getTypes()).forEach(function (typeName) {
if (typeName === CLIENT_BASE_NAME) {
throw new Error("Having a type with the name ClientBase is currently not supported. Please use a different type name.");
}
else if (importMapping[typeName] == null) {
throw new Error("An import mapping needs to be specified on the options parameter for '" + typeName + "' when calling getGeneratedCode()");