Commit 572a17e2 authored by joepeck@webkit.org's avatar joepeck@webkit.org

Web Inspector: Breakpoint Actions

https://bugs.webkit.org/show_bug.cgi?id=120576

Reviewed by Timothy Hatcher.

Give the CodeMirror editor for JavaScript Breakpoint Actions JS Runtime
completions (like window, document, etc.).

The logic was inside of JavaScriptLogViewController but was already
entirely independent. Factor it out into its own class and plug it into
CodeMirrorCompletionController as a "CompletionsProvider".

Because the class hooks into a global event to reset some state, make
it a singleton, so new instances are not leaked.

* UserInterface/Main.html:
* UserInterface/Main.js:
(WebInspector.loaded):
* UserInterface/RuntimeManager.js: Added.
(WebInspector.RuntimeManager):
(WebInspector.RuntimeManager.prototype.evalCallback):
(WebInspector.RuntimeManager.prototype.evaluateInInspectedWindow):
Move eval in window to new RuntimeManager. A slightly cleaner place to this
since it is used both by the console and JS completions provider.

* UserInterface/CodeMirrorCompletionController.js:
(WebInspector.CodeMirrorCompletionController):
(WebInspector.CodeMirrorCompletionController.prototype.setExtendedCompletionProvider):
(WebInspector.CodeMirrorCompletionController.prototype._completeAtCurrentPosition):
Allow a completions provider plugin to completions controller. If one
is available, this supercedes the delegate extend completions path.

* UserInterface/BreakpointActionView.js:
* UserInterface/ConsolePrompt.js:
(WebInspector.ConsolePrompt):
Use the new JS completions provider to get runtime JS completions.
NOTE: ConsolePrompt still needs the delegate path for SQL completions.

* UserInterface/JavaScriptLogViewController.js:
(WebInspector.JavaScriptLogViewController):
(WebInspector.JavaScriptLogViewController.prototype.consolePromptTextCommitted):
* UserInterface/JavaScriptRuntimeCompletionProvider.js: Added.
(WebInspector.JavaScriptRuntimeCompletionProvider):
(get WebInspector.JavaScriptRuntimeCompletionProvider.prototype.):
(get WebInspector.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded):
Move the JS completions code to a new class. No changes needed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155134 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8dbc7b8e
2013-09-05 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: Breakpoint Actions
https://bugs.webkit.org/show_bug.cgi?id=120576
Reviewed by Timothy Hatcher.
Give the CodeMirror editor for JavaScript Breakpoint Actions JS Runtime
completions (like window, document, etc.).
The logic was inside of JavaScriptLogViewController but was already
entirely independent. Factor it out into its own class and plug it into
CodeMirrorCompletionController as a "CompletionsProvider".
Because the class hooks into a global event to reset some state, make
it a singleton, so new instances are not leaked.
* UserInterface/Main.html:
* UserInterface/Main.js:
(WebInspector.loaded):
* UserInterface/RuntimeManager.js: Added.
(WebInspector.RuntimeManager):
(WebInspector.RuntimeManager.prototype.evalCallback):
(WebInspector.RuntimeManager.prototype.evaluateInInspectedWindow):
Move eval in window to new RuntimeManager. A slightly cleaner place to this
since it is used both by the console and JS completions provider.
* UserInterface/CodeMirrorCompletionController.js:
(WebInspector.CodeMirrorCompletionController):
(WebInspector.CodeMirrorCompletionController.prototype.setExtendedCompletionProvider):
(WebInspector.CodeMirrorCompletionController.prototype._completeAtCurrentPosition):
Allow a completions provider plugin to completions controller. If one
is available, this supercedes the delegate extend completions path.
* UserInterface/BreakpointActionView.js:
* UserInterface/ConsolePrompt.js:
(WebInspector.ConsolePrompt):
Use the new JS completions provider to get runtime JS completions.
NOTE: ConsolePrompt still needs the delegate path for SQL completions.
* UserInterface/JavaScriptLogViewController.js:
(WebInspector.JavaScriptLogViewController):
(WebInspector.JavaScriptLogViewController.prototype.consolePromptTextCommitted):
* UserInterface/JavaScriptRuntimeCompletionProvider.js: Added.
(WebInspector.JavaScriptRuntimeCompletionProvider):
(get WebInspector.JavaScriptRuntimeCompletionProvider.prototype.):
(get WebInspector.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded):
Move the JS completions code to a new class. No changes needed.
2013-09-05 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: Breakpoint Actions
......
......@@ -157,6 +157,7 @@ WebInspector.BreakpointActionView.prototype = {
this._codeMirror.on("blur", this._codeMirrorBlurred.bind(this));
var completionController = new WebInspector.CodeMirrorCompletionController(this._codeMirror);
completionController.addExtendedCompletionProvider("javascript", WebInspector.javaScriptRuntimeCompletionProvider);
// CodeMirror needs a refresh after the popover displays, to layout, otherwise it doesn't appear.
setTimeout(function() {
......
......@@ -38,6 +38,7 @@ WebInspector.CodeMirrorCompletionController = function(codeMirror, delegate, sto
this._lineNumber = NaN;
this._prefix = "";
this._completions = [];
this._extendedCompletionProviders = {};
this._suggestionsView = new WebInspector.CompletionSuggestionsView(this);
......@@ -88,6 +89,11 @@ WebInspector.CodeMirrorCompletionController.prototype = {
return this._delegate;
},
addExtendedCompletionProvider: function(modeName, provider)
{
this._extendedCompletionProviders[modeName] = provider;
},
updateCompletions: function(completions, implicitSuffix)
{
if (isNaN(this._startOffset) || isNaN(this._endOffset) || isNaN(this._lineNumber))
......@@ -498,6 +504,12 @@ WebInspector.CodeMirrorCompletionController.prototype = {
break;
}
var extendedCompletionsProvider = this._extendedCompletionProviders[modeName];
if (extendedCompletionsProvider) {
extendedCompletionsProvider.completionControllerCompletionsNeeded(this, defaultCompletions, baseScanResult ? baseScanResult.string : null, this._prefix, suffix, force);
return;
}
if (this._delegate && typeof this._delegate.completionControllerCompletionsNeeded === "function")
this._delegate.completionControllerCompletionsNeeded(this, this._prefix, defaultCompletions, baseScanResult ? baseScanResult.string : null, suffix, force);
else
......
......@@ -53,6 +53,7 @@ WebInspector.ConsolePrompt = function(delegate, mimeType, element)
this._codeMirror.addKeyMap(keyMap);
this._completionController = new WebInspector.CodeMirrorCompletionController(this._codeMirror, this);
this._completionController.addExtendedCompletionProvider("javascript", WebInspector.javaScriptRuntimeCompletionProvider);
this._history = [{}];
this._historyIndex = 0;
......
......@@ -185,6 +185,7 @@
<script src="ResourceTimelineRecord.js"></script>
<script src="FrameResourceManager.js"></script>
<script src="IssueManager.js"></script>
<script src="RuntimeManager.js"></script>
<script src="Frame.js"></script>
<script src="SourceCode.js"></script>
<script src="Resource.js"></script>
......@@ -384,6 +385,7 @@
<script src="FormatterSourceMap.js"></script>
<script src="CodeMirrorCompletionController.js"></script>
<script src="CodeMirrorTokenTrackingController.js"></script>
<script src="JavaScriptRuntimeCompletionProvider.js"></script>
<script src="CompletionSuggestionsView.js"></script>
<script src="ExecutionContext.js"></script>
<script src="ExecutionContextList.js"></script>
......
......@@ -73,6 +73,7 @@ WebInspector.loaded = function()
this.cssStyleManager = new WebInspector.CSSStyleManager;
this.logManager = new WebInspector.LogManager;
this.issueManager = new WebInspector.IssueManager;
this.runtimeManager = new WebInspector.RuntimeManager;
this.applicationCacheManager = new WebInspector.ApplicationCacheManager;
this.timelineManager = new WebInspector.TimelineManager;
this.profileManager = new WebInspector.ProfileManager;
......@@ -84,10 +85,6 @@ WebInspector.loaded = function()
// Enable the Console Agent after creating the singleton managers.
ConsoleAgent.enable();
// Enable the RuntimeAgent to receive notification of execution contexts.
if (RuntimeAgent.enable)
RuntimeAgent.enable();
// Register for events.
this.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Paused, this._debuggerDidPause, this);
this.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.InspectModeStateChanged, this._inspectModeStateChanged, this);
......
/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
WebInspector.RuntimeManager = function()
{
WebInspector.Object.call(this);
// Enable the RuntimeAgent to receive notification of execution contexts.
if (RuntimeAgent.enable)
RuntimeAgent.enable();
};
WebInspector.RuntimeManager.prototype = {
constructor: WebInspector.RuntimeManager,
// Public
evaluateInInspectedWindow: function(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback)
{
if (!expression) {
// There is no expression, so the completion should happen against global properties.
expression = "this";
}
function evalCallback(error, result, wasThrown)
{
if (error) {
console.error(error);
callback(null, false);
return;
}
if (returnByValue)
callback(null, wasThrown, wasThrown ? null : result);
else
callback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
}
if (WebInspector.debuggerManager.activeCallFrame) {
DebuggerAgent.evaluateOnCallFrame(WebInspector.debuggerManager.activeCallFrame.id, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, evalCallback);
return;
}
// COMPATIBILITY (iOS 6): Execution context identifiers (contextId) did not exist
// in iOS 6. Fallback to including the frame identifier (frameId).
var contextId = WebInspector.quickConsole.executionContextIdentifier;
RuntimeAgent.evaluate.invoke({expression: expression, objectGroup: objectGroup, includeCommandLineAPI: includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole: doNotPauseOnExceptionsAndMuteConsole, contextId: contextId, frameId: contextId, returnByValue: returnByValue}, evalCallback);
}
};
WebInspector.RuntimeManager.prototype.__proto__ = WebInspector.Object.prototype;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment