fix : showing up where . should sometimes in functions

This commit is contained in:
Jill 2021-12-16 02:31:00 +03:00
parent 6e52d74003
commit 1ce244db94
1 changed files with 3 additions and 3 deletions

View File

@ -62,7 +62,7 @@ function transpileType(type) {
return type;
}
function transpile(parsed, indent, prefix) {
function transpile(parsed, indent, prefix, gl) {
let global = false;
indent = indent || 0;
const type = parsed[0];
@ -86,10 +86,10 @@ function transpile(parsed, indent, prefix) {
}
classes[d.name] = contents;
return `${comments}---@class ${d.name}${d.extends ? ' : ' + d.extends : ''}${n}${contents.filter(e => e[0] === 'const').map(c => `---@field public ${c[1].name} ${transpileType(c[1].type)}${n}`).join('')}${global ? '' : '__class_'}${d.name} = {}${n}${contents.filter(e => e[0] !== 'const').map(c => transpile(c, indent, `${global ? '' : '__class_'}${d.name}`)).join(n)}\n`;
return `${comments}---@class ${d.name}${d.extends ? ' : ' + d.extends : ''}${n}${contents.filter(e => e[0] === 'const').map(c => `---@field public ${c[1].name} ${transpileType(c[1].type)}${n}`).join('')}${global ? '' : '__class_'}${d.name} = {}${n}${contents.filter(e => e[0] !== 'const').map(c => transpile(c, indent, `${global ? '' : '__class_'}${d.name}`, global)).join(n)}\n`;
case 'function':
if (d.arguments[0] && d.arguments[0].type === 'void') d.arguments = d.arguments.slice(1);
return `${comments}${d.arguments.map(p => `---@param ${p.name.replace('?', '')} ${transpileType(p.type)}${n}`).join('')}---@return ${transpileType(d.returns)}${n}function ${prefix ? prefix + ':' : ''}${d.name}(${d.arguments.map(a => a.name.replace('?', '')).join(', ')}) end`;
return `${comments}${d.arguments.map(p => `---@param ${p.name.replace('?', '')} ${transpileType(p.type)}${n}`).join('')}---@return ${transpileType(d.returns)}${n}function ${prefix ? prefix + (gl ? '.' : ':') : ''}${d.name}(${d.arguments.map(a => a.name.replace('?', '')).join(', ')}) end`;
case 'const':
return `${comments}---@type ${transpileType(d.type)}${n}${prefix ? prefix + '.' : ''}${d.name} = nil`;
case 'enum':