Title: [176324] trunk/Source/WebInspectorUI
Revision
176324
Author
[email protected]
Date
2014-11-19 10:32:30 -0800 (Wed, 19 Nov 2014)

Log Message

Web Inspector: Improve basic _javascript_ completion in inline <script>s
https://bugs.webkit.org/show_bug.cgi?id=138845

Patch by Joseph Pecoraro <[email protected]> on 2014-11-19
Reviewed by Timothy Hatcher.

* UserInterface/Controllers/CodeMirrorCompletionController.js:
(WebInspector.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions):
Fix up CodeMirror mode handling for _javascript_ completion when inside of mixed mode
input (html). Also add completion for CodeMirror's localVars list.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (176323 => 176324)


--- trunk/Source/WebInspectorUI/ChangeLog	2014-11-19 18:27:33 UTC (rev 176323)
+++ trunk/Source/WebInspectorUI/ChangeLog	2014-11-19 18:32:30 UTC (rev 176324)
@@ -1 +1,13 @@
+2014-11-19  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Improve basic _javascript_ completion in inline <script>s
+        https://bugs.webkit.org/show_bug.cgi?id=138845
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Controllers/CodeMirrorCompletionController.js:
+        (WebInspector.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions):
+        Fix up CodeMirror mode handling for _javascript_ completion when inside of mixed mode
+        input (html). Also add completion for CodeMirror's localVars list.
+
 == Rolled over to ChangeLog-2014-11-19 ==

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (176323 => 176324)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2014-11-19 18:27:33 UTC (rev 176323)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js	2014-11-19 18:32:30 UTC (rev 176324)
@@ -574,12 +574,14 @@
 
         const prefix = this._prefix;
 
-        const declaringVariable = mainToken.state.lexical.type === "vardef";
-        const insideSwitch = mainToken.state.lexical.prev ? mainToken.state.lexical.prev.info === "switch" : false;
-        const insideBlock = mainToken.state.lexical.prev ? mainToken.state.lexical.prev.type === "}" : false;
-        const insideParenthesis = mainToken.state.lexical.type === ")";
-        const insideBrackets = mainToken.state.lexical.type === "]";
+        var localState = mainToken.state.localState ? mainToken.state.localState : mainToken.state;
 
+        const declaringVariable = localState.lexical.type === "vardef";
+        const insideSwitch = localState.lexical.prev ? localState.lexical.prev.info === "switch" : false;
+        const insideBlock = localState.lexical.prev ? localState.lexical.prev.type === "}" : false;
+        const insideParenthesis = localState.lexical.type === ")";
+        const insideBrackets = localState.lexical.type === "]";
+
         const 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"];
         const valueKeywords = ["false", "Infinity", "NaN", "null", "this", "true", "undefined"];
@@ -622,13 +624,17 @@
                 }
             }
 
-            var context = mainToken.state.context;
+            var context = localState.context;
             while (context) {
-                filterVariables(context.vars);
+                if (context.vars)
+                    filterVariables(context.vars);
                 context = context.prev;
             }
 
-            filterVariables(mainToken.state.globalVars);
+            if (localState.localVars)
+                filterVariables(localState.localVars);
+            if (localState.globalVars)
+                filterVariables(localState.globalVars);
         }
 
         switch (suffix.substring(0, 1)) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to