Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1774)

Unified Diff: Source/devtools/front_end/script_formatter_worker/JavaScriptFormatter.js

Issue 479033002: DevTools: improve javascript formatter to support "return" properties. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address @vsevik comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/inspector/sources/debugger/script-formatter-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/script_formatter_worker/JavaScriptFormatter.js
diff --git a/Source/devtools/front_end/script_formatter_worker/JavaScriptFormatter.js b/Source/devtools/front_end/script_formatter_worker/JavaScriptFormatter.js
index bcc75accee1097790c026e99a1d9359afced37ea..935efa643c6ea60d6b36691c7946c307a95a6f7d 100644
--- a/Source/devtools/front_end/script_formatter_worker/JavaScriptFormatter.js
+++ b/Source/devtools/front_end/script_formatter_worker/JavaScriptFormatter.js
@@ -41,6 +41,8 @@ FormatterWorker.JavaScriptFormatter = function(tokenizer, builder)
this._nextToken = this._tokenizer.next();
}
+FormatterWorker.JavaScriptFormatter._identifierRegex = /^[$A-Z_][0-9A-Z_$]*$/i;
+
FormatterWorker.JavaScriptFormatter.prototype = {
format: function()
{
@@ -91,6 +93,13 @@ FormatterWorker.JavaScriptFormatter.prototype = {
throw "Unexpected token: expected " + token + ", actual " + next;
},
+ _expectGeneralIdentifier: function()
+ {
+ var next = this._next();
+ if (next !== FormatterWorker.JavaScriptTokens.IDENTIFIER && !FormatterWorker.JavaScriptFormatter._identifierRegex.test(this._token.value))
+ throw "Unexpected token: expected javascript identifier, actual " + this._token.value;
+ },
+
_expectSemicolon: function()
{
if (this._peek() === FormatterWorker.JavaScriptTokens.SEMICOLON)
@@ -522,7 +531,7 @@ FormatterWorker.JavaScriptFormatter.prototype = {
case FormatterWorker.JavaScriptTokens.PERIOD:
this._consume(FormatterWorker.JavaScriptTokens.PERIOD);
- this._expect(FormatterWorker.JavaScriptTokens.IDENTIFIER);
+ this._expectGeneralIdentifier();
break;
default:
@@ -563,7 +572,7 @@ FormatterWorker.JavaScriptFormatter.prototype = {
case FormatterWorker.JavaScriptTokens.PERIOD:
this._consume(FormatterWorker.JavaScriptTokens.PERIOD);
- this._expect(FormatterWorker.JavaScriptTokens.IDENTIFIER);
+ this._expectGeneralIdentifier();
break;
case FormatterWorker.JavaScriptTokens.LPAREN:
« no previous file with comments | « LayoutTests/inspector/sources/debugger/script-formatter-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698