This commit is contained in:
syuilo 2017-02-09 22:09:44 +09:00
parent e7cd3d3707
commit 351f306cd9
1 changed files with 10 additions and 6 deletions

View File

@ -173,11 +173,13 @@ const elements = [
const match = varDef.filter(v => code.substr(0, v.length + 1) == v + ' ')[0]; const match = varDef.filter(v => code.substr(0, v.length + 1) == v + ' ')[0];
if (match) { if (match) {
const bar = code.substr(match.length + 1).match(/^[a-zA-Z0-9_-]+/); const bars = code.substr(match.length + 1).match(/^[a-zA-Z0-9_\-,\s]+/);
if (bar) { if (bars) {
bars[0].replace(/,/g, ' ').split(' ').filter(x => x != '').forEach(bar => {
if (!keywords.some(k => k == bar)) { if (!keywords.some(k => k == bar)) {
vars.push(bar[0]); vars.push(bar);
} }
});
} }
} }
@ -187,7 +189,9 @@ const elements = [
// vars // vars
(code, i, source, vars) => { (code, i, source, vars) => {
const prev = source[i - 1]; const prev = source[i - 1];
if (prev && /[a-zA-Z]/.test(prev)) return null; // プロパティは変数と認識させないために、
// 前に . や > (PHPなどではプロパティに -> でアクセスするため) が無いかチェック
if (prev && /[a-zA-Z\.>]/.test(prev)) return null;
const match = vars.sort((a, b) => b.length - a.length) const match = vars.sort((a, b) => b.length - a.length)
.filter(v => code.substr(0, v.length) == v)[0]; .filter(v => code.substr(0, v.length) == v)[0];