OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * | 10 * |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 onTextChanged: function(oldRange, newRange) | 107 onTextChanged: function(oldRange, newRange) |
108 { | 108 { |
109 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne
wRange); | 109 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne
wRange); |
110 if (this._isSettingContent) | 110 if (this._isSettingContent) |
111 return; | 111 return; |
112 this._muteSourceCodeEvents = true; | 112 this._muteSourceCodeEvents = true; |
113 if (this._textEditor.isClean()) | 113 if (this._textEditor.isClean()) |
114 this._uiSourceCode.resetWorkingCopy(); | 114 this._uiSourceCode.resetWorkingCopy(); |
115 else | 115 else |
116 this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(t
his._textEditor)); | 116 this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(t
his._textEditor)); |
| 117 WebInspector.workspace.dispatchEventToListeners(WebInspector.Workspace.E
vents.UISourceCodeEdited, { |
| 118 range: oldRange, |
| 119 replacement: this._textEditor.copyRange(newRange), |
| 120 uiSourceCode: this._uiSourceCode |
| 121 }); |
117 delete this._muteSourceCodeEvents; | 122 delete this._muteSourceCodeEvents; |
118 }, | 123 }, |
119 | 124 |
120 /** | 125 /** |
121 * @param {!WebInspector.Event} event | 126 * @param {!WebInspector.Event} event |
122 */ | 127 */ |
123 _onWorkingCopyChanged: function(event) | 128 _onWorkingCopyChanged: function(event) |
124 { | 129 { |
125 if (this._muteSourceCodeEvents) | 130 if (this._muteSourceCodeEvents) |
126 return; | 131 return; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 /** | 166 /** |
162 * @param {string} content | 167 * @param {string} content |
163 */ | 168 */ |
164 _innerSetContent: function(content) | 169 _innerSetContent: function(content) |
165 { | 170 { |
166 this._isSettingContent = true; | 171 this._isSettingContent = true; |
167 this.setContent(content); | 172 this.setContent(content); |
168 delete this._isSettingContent; | 173 delete this._isSettingContent; |
169 }, | 174 }, |
170 | 175 |
| 176 /** |
| 177 * @override |
| 178 * @return {!Promise} |
| 179 */ |
171 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) | 180 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) |
172 { | 181 { |
173 WebInspector.SourceFrame.prototype.populateTextAreaContextMenu.call(this
, contextMenu, lineNumber, columnNumber); | 182 /** |
174 contextMenu.appendApplicableItems(this._uiSourceCode); | 183 * @this {WebInspector.UISourceCodeFrame} |
175 contextMenu.appendApplicableItems(new WebInspector.UILocation(this._uiSo
urceCode, lineNumber, columnNumber)); | 184 */ |
176 contextMenu.appendSeparator(); | 185 function appendItems() { |
| 186 contextMenu.appendApplicableItems(this._uiSourceCode); |
| 187 contextMenu.appendApplicableItems(new WebInspector.UILocation(this._
uiSourceCode, lineNumber, columnNumber)); |
| 188 contextMenu.appendSeparator(); |
| 189 } |
| 190 |
| 191 return WebInspector.SourceFrame.prototype.populateTextAreaContextMenu.ca
ll(this, contextMenu, lineNumber, columnNumber).then((function(){ |
| 192 var mimeType = WebInspector.ResourceType.mimeFromURL(this._uiSourceC
ode.uri()); |
| 193 if (!mimeType) { |
| 194 return; |
| 195 } |
| 196 if (!WebInspector.languageService.handles.populateContextMenu(mimeTy
pe)) { |
| 197 return; |
| 198 } |
| 199 return WebInspector.languageService.populateContextMenu(mimeType, { |
| 200 source: this._uiSourceCode.uri(), |
| 201 line: lineNumber, |
| 202 column: columnNumber |
| 203 }).then(function(items) { |
| 204 items.forEach(function(elem) { |
| 205 contextMenu.appendItem(elem.text, elem.callback); |
| 206 }); |
| 207 }); |
| 208 }).bind(this)).then(appendItems.bind(this), appendItems.bind(this)); //I
gnore failure in language service handler |
177 }, | 209 }, |
178 | 210 |
179 /** | 211 /** |
180 * @param {!Array.<!WebInspector.UISourceCodeFrame.Infobar|undefined>} infob
ars | 212 * @param {!Array.<!WebInspector.UISourceCodeFrame.Infobar|undefined>} infob
ars |
181 */ | 213 */ |
182 attachInfobars: function(infobars) | 214 attachInfobars: function(infobars) |
183 { | 215 { |
184 for (var i = infobars.length - 1; i >= 0; --i) { | 216 for (var i = infobars.length - 1; i >= 0; --i) { |
185 var infobar = infobars[i]; | 217 var infobar = infobars[i]; |
186 if (!infobar) | 218 if (!infobar) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 298 |
267 dispose: function() | 299 dispose: function() |
268 { | 300 { |
269 this.element.remove(); | 301 this.element.remove(); |
270 this._onResize(); | 302 this._onResize(); |
271 delete this._uiSourceCodeFrame; | 303 delete this._uiSourceCodeFrame; |
272 }, | 304 }, |
273 | 305 |
274 __proto__: WebInspector.Infobar.prototype | 306 __proto__: WebInspector.Infobar.prototype |
275 } | 307 } |
OLD | NEW |