Title: [206015] trunk/Source/WebInspectorUI
Revision
206015
Author
joep...@webkit.org
Date
2016-09-16 01:47:08 -0700 (Fri, 16 Sep 2016)

Log Message

Web Inspector: Include _javascript_ completion for ES6 keywords and global variables
https://bugs.webkit.org/show_bug.cgi?id=162027

Reviewed by Brian Burg.

* UserInterface/Controllers/CodeMirrorCompletionController.js:
(WebInspector.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions):
Include ES6 keywords and provide them when they may be available.

* UserInterface/Views/ConsolePrompt.js:
(WebInspector.ConsolePrompt):
* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor.prototype.set mimeType):
For editors that might want to provide completion for global variables
use the mode with options way of setting the mode for CodeMirror. The
only mode that cares about "globalVars" are the _javascript_ variants.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (206014 => 206015)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-09-16 08:24:18 UTC (rev 206014)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-09-16 08:47:08 UTC (rev 206015)
@@ -1,3 +1,22 @@
+2016-09-16  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Include _javascript_ completion for ES6 keywords and global variables
+        https://bugs.webkit.org/show_bug.cgi?id=162027
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Controllers/CodeMirrorCompletionController.js:
+        (WebInspector.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions):
+        Include ES6 keywords and provide them when they may be available.
+
+        * UserInterface/Views/ConsolePrompt.js:
+        (WebInspector.ConsolePrompt):
+        * UserInterface/Views/TextEditor.js:
+        (WebInspector.TextEditor.prototype.set mimeType):
+        For editors that might want to provide completion for global variables
+        use the mode with options way of setting the mode for CodeMirror. The
+        only mode that cares about "globalVars" are the _javascript_ variants.
+
 2016-09-15  Devin Rousso  <dcrousso+web...@gmail.com>
 
         Web Inspector: support drag and drop of CSS classes and ids onto DOM nodes

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (206014 => 206015)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2016-09-16 08:24:18 UTC (rev 206014)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2016-09-16 08:47:08 UTC (rev 206015)
@@ -597,13 +597,21 @@
         var insideParenthesis = localState.lexical.type === ")";
         var insideBrackets = localState.lexical.type === "]";
 
-        var allKeywords = ["break", "case", "catch", "const", "continue", "debugger", "default", "delete", "do", "else", "false", "finally", "for", "function", "if", "in",
-            "Infinity", "instanceof", "NaN", "new", "null", "return", "switch", "this", "throw", "true", "try", "typeof", "undefined", "var", "void", "while", "with"];
+        // FIXME: Include module keywords if we know this is a module environment.
+        // var moduleKeywords = ["default", "export", "import"];
+
+        var allKeywords = [
+            "break", "case", "catch", "class", "const", "continue", "debugger", "default",
+            "delete", "do", "else", "extends", "false", "finally", "for", "function",
+            "if", "in", "Infinity", "instanceof", "let", "NaN", "new", "null", "of",
+            "return", "static", "super", "switch", "this", "throw", "true", "try",
+            "typeof", "undefined", "var", "void", "while", "with", "yield"
+        ];
         var valueKeywords = ["false", "Infinity", "NaN", "null", "this", "true", "undefined"];
 
         var allowedKeywordsInsideBlocks = allKeywords.keySet();
         var allowedKeywordsWhenDeclaringVariable = valueKeywords.keySet();
-        var allowedKeywordsInsideParenthesis = valueKeywords.concat(["function"]).keySet();
+        var allowedKeywordsInsideParenthesis = valueKeywords.concat(["class", "function"]).keySet();
         var allowedKeywordsInsideBrackets = allowedKeywordsInsideParenthesis;
         var allowedKeywordsOnlyInsideSwitch = ["case", "default"].keySet();
 
@@ -667,11 +675,11 @@
 
         case "(":
             matchVariables();
-            matchKeywords(["catch", "else", "for", "function", "if", "return", "switch", "throw", "while", "with"]);
+            matchKeywords(["catch", "else", "for", "function", "if", "return", "switch", "throw", "while", "with", "yield"]);
             break;
 
         case "{":
-            matchKeywords(["do", "else", "finally", "return", "try"]);
+            matchKeywords(["do", "else", "finally", "return", "try", "yield"]);
             break;
 
         case ":":

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js (206014 => 206015)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js	2016-09-16 08:24:18 UTC (rev 206014)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js	2016-09-16 08:47:08 UTC (rev 206015)
@@ -37,7 +37,7 @@
 
         this._codeMirror = WebInspector.CodeMirrorEditor.create(this.element, {
             lineWrapping: true,
-            mode: mimeType,
+            mode: {name: mimeType, globalVars: true},
             indentWithTabs: true,
             indentUnit: 4,
             matchBrackets: true

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (206014 => 206015)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2016-09-16 08:24:18 UTC (rev 206014)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2016-09-16 08:47:08 UTC (rev 206015)
@@ -198,7 +198,7 @@
         newMIMEType = parseMIMEType(newMIMEType).type;
 
         this._mimeType = newMIMEType;
-        this._codeMirror.setOption("mode", newMIMEType);
+        this._codeMirror.setOption("mode", {name: newMIMEType, globalVars: true});
     }
 
     get executionLineNumber()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to