Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) =>
{
phpParser.parser.locations = true;
phpParser.parser.docBlocks = true;
var ast = phpParser.parseCode(text);
this.BuildObjectTree(ast, filePath).then((tree) =>
{
// TODO -- Convert this to promise
var symbolCache = this.BuildSymbolCache(tree, filePath);
var returnObj = {
tree: tree,
symbolCache: symbolCache
};
// DEBUG
console.log("Built tree for file: " + filePath);
resolve(returnObj);
});
fs.readFile(filename, function(err, data) {
if (!err) {
counter ++;
try {
var ast = parser.parseCode(data.toString(), {
parser: {
extractDoc: true,
debug: isDebug
},
ast: {
withPositions: true
}
});
var code = unparse(ast);
if (isDebug) console.log(code);
if (counter === total) {
console.log('Finished to test ' + total + ' file(s)');
process.exit(0);
}
if (counter % 500 === 0) {
console.log(counter + ' of ' + total + ' - ' + Math.round(counter / total * 100) + '%');
var Writer = function(buffer, options = {}) {
this.options = Object.assign({}, defaultOptions, options);
this.ast = parser.parseCode(buffer, this.options);
};
editor(Writer, 1);
function refreshOutput() {
try {
var ast = parser.parseCode(
editor.getValue(), {
ast: {
withPositions: true
},
parser: {
extractDoc: true
}
}, 'browser input'
);
var code = transpiler.generate(ast, {}, 'browser input');
$('#error-msg').hide();
$('#output').show();
output.setValue(code);
output.setReadOnly(true);
} catch(e) {
$('#error-msg').show();