Fix the incorrect detection of arrow when it would be function call

Fixes #403
This commit is contained in:
Sheetal Nandi 2017-01-10 11:32:05 -08:00
Родитель 9b0d80d1b8
Коммит 8011e8756d
5 изменённых файлов: 455 добавлений и 3 удалений

Просмотреть файл

@ -1595,7 +1595,7 @@ repository:
(?:
(?<!\.|\$)(\basync)(?=\s*[<(])
) |
((?<!\])\s*
((?<![})\]])\s*
(?=
# sure shot arrow functions even if => is on new line
(

Просмотреть файл

@ -4401,7 +4401,7 @@
<key>begin</key>
<string>(?x) (?:
(?&lt;!\.|\$)(\basync)(?=\s*[&lt;(])
) | ((?&lt;!\])\s*
) | ((?&lt;![})\]])\s*
(?=
# sure shot arrow functions even if =&gt; is on new line
(

Просмотреть файл

@ -4383,7 +4383,7 @@
<key>begin</key>
<string>(?x) (?:
(?&lt;!\.|\$)(\basync)(?=\s*[&lt;(])
) | ((?&lt;!\])\s*
) | ((?&lt;![})\]])\s*
(?=
# sure shot arrow functions even if =&gt; is on new line
(

Просмотреть файл

@ -0,0 +1,444 @@
original file
-----------------------------------
p.parseJSON = function(t) {
if (e.JSON && e.JSON.parse) return e.JSON.parse(t + "");
var n, r = null,
i = p.trim(t + "");
return i && !p.trim(i.replace(Nn, function(e, t, i, s) {
return n && t && (r = 0), r === 0 ? e : (n = i || t, r += !s - !i, "")
})) ? Function("return " + i)() : p.error("Invalid JSON: " + t)
}
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>p.parseJSON = function(t) {
^
source.ts variable.other.object.ts
^
source.ts punctuation.accessor.ts
^^^^^^^^^
source.ts entity.name.function.ts
^
source.ts
^
source.ts keyword.operator.assignment.ts
^
source.ts
^^^^^^^^
source.ts meta.function.ts storage.type.function.ts
^
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.function.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.function.ts
^
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.function.ts meta.block.ts
> if (e.JSON && e.JSON.parse) return e.JSON.parse(t + "");
^^^^^^^^
source.ts meta.function.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts keyword.control.conditional.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts variable.other.object.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^
source.ts meta.function.ts meta.block.ts variable.other.constant.property.ts
^
source.ts meta.function.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts keyword.operator.logical.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts variable.other.object.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^
source.ts meta.function.ts meta.block.ts variable.other.constant.object.property.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^^
source.ts meta.function.ts meta.block.ts variable.other.property.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts
^^^^^^
source.ts meta.function.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts variable.other.object.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^
source.ts meta.function.ts meta.block.ts variable.other.constant.object.property.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^^
source.ts meta.function.ts meta.block.ts support.function.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.arithmetic.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts punctuation.terminator.statement.ts
^^
source.ts meta.function.ts meta.block.ts
> var n, r = null,
^^^^^^^^
source.ts meta.function.ts meta.block.ts
^^^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts punctuation.separator.comma.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts keyword.operator.assignment.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts
^^^^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts constant.language.null.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts punctuation.separator.comma.ts
^
source.ts meta.function.ts meta.block.ts meta.var.expr.ts
> i = p.trim(t + "");
^^^^^^^^^^^^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.assignment.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts variable.other.object.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^
source.ts meta.function.ts meta.block.ts entity.name.function.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.arithmetic.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts punctuation.terminator.statement.ts
^^
source.ts meta.function.ts meta.block.ts
> return i && !p.trim(i.replace(Nn, function(e, t, i, s) {
^^^^^^^^
source.ts meta.function.ts meta.block.ts
^^^^^^
source.ts meta.function.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts keyword.operator.logical.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.logical.ts
^
source.ts meta.function.ts meta.block.ts variable.other.object.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^
source.ts meta.function.ts meta.block.ts entity.name.function.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts variable.other.object.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^^^^
source.ts meta.function.ts meta.block.ts support.function.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^^
source.ts meta.function.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts punctuation.separator.comma.ts
^
source.ts meta.function.ts meta.block.ts
^^^^^^^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts storage.type.function.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts punctuation.separator.parameter.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
> return n && t && (r = 0), r === 0 ? e : (n = i || t, r += !s - !i, "")
^^^^^^^^^^^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^^^^^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.logical.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.logical.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.assignment.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts constant.numeric.decimal.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts punctuation.separator.comma.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.comparison.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts constant.numeric.decimal.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.ternary.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.ternary.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.assignment.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.logical.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts punctuation.separator.comma.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.assignment.compound.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.logical.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.arithmetic.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts keyword.operator.logical.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts punctuation.separator.comma.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts meta.brace.round.ts
^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
> })) ? Function("return " + i)() : p.error("Invalid JSON: " + t)
^^^^^^^^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.function.expression.ts meta.block.ts punctuation.definition.block.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.ternary.ts
^
source.ts meta.function.ts meta.block.ts
^^^^^^^^
source.ts meta.function.ts meta.block.ts support.class.builtin.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^^^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.arithmetic.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.ternary.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts variable.other.object.ts
^
source.ts meta.function.ts meta.block.ts punctuation.accessor.ts
^^^^^
source.ts meta.function.ts meta.block.ts entity.name.function.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^^^^^^^^^^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.arithmetic.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^^
source.ts meta.function.ts meta.block.ts
> }
^^^^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts

Просмотреть файл

@ -0,0 +1,8 @@
p.parseJSON = function(t) {
if (e.JSON && e.JSON.parse) return e.JSON.parse(t + "");
var n, r = null,
i = p.trim(t + "");
return i && !p.trim(i.replace(Nn, function(e, t, i, s) {
return n && t && (r = 0), r === 0 ? e : (n = i || t, r += !s - !i, "")
})) ? Function("return " + i)() : p.error("Invalid JSON: " + t)
}