Open alexr00 opened 5 years ago
Thanks for reporting, I will have a look.
I root caused the issue - variable pattern causes the problem, will try fixing it.
Seems to be caused by class
:
https://github.com/atom/language-java/blob/047fd33bd12f4926bc5dbc0c930cd9d5fa280602/grammars/java.cson#L279-L367
and record
:
https://github.com/atom/language-java/blob/047fd33bd12f4926bc5dbc0c930cd9d5fa280602/grammars/java.cson#L1286-L1348
Commenting both out reduces lag massively
the [\\w\\s]*
and \\b(?:class|(?<!@)interface|enum)\\s+
clashes quite badly causing catastrophic backtracking when no class/record is found on a standalone word
combine that with the begin
rule is a 0width lookahead with no outside anchoring points
not a good recipe for performance
changing (?=\\w?[\\w\\s-]*\\b(?:class|(?<!@)interface|enum)\\s+[\\w$]+)
to (?=(?>(?!\\b(?>class|(?<!@)interface|enum)\\s)\\w++|[\\w\\s-&&[^cei]]++)*+\\b(?>class|(?<!@)interface|enum)\\s+[\\w$])
helps out alot, but does not remove the lag entirely
and the same for record
: (?=\\w?[\\w\\s]*\\b(?:record)\\s+[\\w$]+)
=> (?=(?>(?!\\brecord\\s)\\w++|[\\w\\s&&[^r]]++)*+\\brecord\\s+[\\w$])
From @swbrenneis in https://github.com/microsoft/vscode/issues/79640
Paste the following into a java file:
The grammar will cause a freeze