| 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 11 matching lines...) Expand all Loading... |
| 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @unrestricted | 30 * @unrestricted |
| 31 */ | 31 */ |
| 32 WebInspector.UISourceCodeFrame = class extends WebInspector.SourceFrame { | 32 Sources.UISourceCodeFrame = class extends SourceFrame.SourceFrame { |
| 33 /** | 33 /** |
| 34 * @param {!WebInspector.UISourceCode} uiSourceCode | 34 * @param {!Workspace.UISourceCode} uiSourceCode |
| 35 */ | 35 */ |
| 36 constructor(uiSourceCode) { | 36 constructor(uiSourceCode) { |
| 37 super(uiSourceCode.contentURL(), workingCopy); | 37 super(uiSourceCode.contentURL(), workingCopy); |
| 38 this._uiSourceCode = uiSourceCode; | 38 this._uiSourceCode = uiSourceCode; |
| 39 this.setEditable(this._canEditSource()); | 39 this.setEditable(this._canEditSource()); |
| 40 | 40 |
| 41 if (Runtime.experiments.isEnabled('sourceDiff')) | 41 if (Runtime.experiments.isEnabled('sourceDiff')) |
| 42 this._diff = new WebInspector.SourceCodeDiff(uiSourceCode.requestOriginalC
ontent(), this.textEditor); | 42 this._diff = new Sources.SourceCodeDiff(uiSourceCode.requestOriginalConten
t(), this.textEditor); |
| 43 | 43 |
| 44 /** @type {?WebInspector.AutocompleteConfig} */ | 44 /** @type {?UI.AutocompleteConfig} */ |
| 45 this._autocompleteConfig = {isWordChar: WebInspector.TextUtils.isWordChar}; | 45 this._autocompleteConfig = {isWordChar: Common.TextUtils.isWordChar}; |
| 46 WebInspector.moduleSetting('textEditorAutocompletion').addChangeListener(thi
s._updateAutocomplete, this); | 46 Common.moduleSetting('textEditorAutocompletion').addChangeListener(this._upd
ateAutocomplete, this); |
| 47 this._updateAutocomplete(); | 47 this._updateAutocomplete(); |
| 48 | 48 |
| 49 this._rowMessageBuckets = {}; | 49 this._rowMessageBuckets = {}; |
| 50 /** @type {!Set<string>} */ | 50 /** @type {!Set<string>} */ |
| 51 this._typeDecorationsPending = new Set(); | 51 this._typeDecorationsPending = new Set(); |
| 52 this._uiSourceCode.addEventListener( | 52 this._uiSourceCode.addEventListener( |
| 53 WebInspector.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopy
Changed, this); | 53 Workspace.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyCha
nged, this); |
| 54 this._uiSourceCode.addEventListener( | 54 this._uiSourceCode.addEventListener( |
| 55 WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCo
pyCommitted, this); | 55 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyC
ommitted, this); |
| 56 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message
Added, this._onMessageAdded, this); | 56 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.MessageAdd
ed, this._onMessageAdded, this); |
| 57 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message
Removed, this._onMessageRemoved, this); | 57 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.MessageRem
oved, this._onMessageRemoved, this); |
| 58 this._uiSourceCode.addEventListener( | 58 this._uiSourceCode.addEventListener( |
| 59 WebInspector.UISourceCode.Events.LineDecorationAdded, this._onLineDecora
tionAdded, this); | 59 Workspace.UISourceCode.Events.LineDecorationAdded, this._onLineDecoratio
nAdded, this); |
| 60 this._uiSourceCode.addEventListener( | 60 this._uiSourceCode.addEventListener( |
| 61 WebInspector.UISourceCode.Events.LineDecorationRemoved, this._onLineDeco
rationRemoved, this); | 61 Workspace.UISourceCode.Events.LineDecorationRemoved, this._onLineDecorat
ionRemoved, this); |
| 62 WebInspector.persistence.addEventListener( | 62 Persistence.persistence.addEventListener( |
| 63 WebInspector.Persistence.Events.BindingCreated, this._onBindingChanged,
this); | 63 Persistence.Persistence.Events.BindingCreated, this._onBindingChanged, t
his); |
| 64 WebInspector.persistence.addEventListener( | 64 Persistence.persistence.addEventListener( |
| 65 WebInspector.Persistence.Events.BindingRemoved, this._onBindingChanged,
this); | 65 Persistence.Persistence.Events.BindingRemoved, this._onBindingChanged, t
his); |
| 66 | 66 |
| 67 this.textEditor.addEventListener( | 67 this.textEditor.addEventListener( |
| 68 WebInspector.SourcesTextEditor.Events.EditorBlurred, | 68 SourceFrame.SourcesTextEditor.Events.EditorBlurred, |
| 69 () => WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, nul
l)); | 69 () => UI.context.setFlavor(Sources.UISourceCodeFrame, null)); |
| 70 this.textEditor.addEventListener( | 70 this.textEditor.addEventListener( |
| 71 WebInspector.SourcesTextEditor.Events.EditorFocused, | 71 SourceFrame.SourcesTextEditor.Events.EditorFocused, |
| 72 () => WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, thi
s)); | 72 () => UI.context.setFlavor(Sources.UISourceCodeFrame, this)); |
| 73 | 73 |
| 74 this._updateStyle(); | 74 this._updateStyle(); |
| 75 | 75 |
| 76 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element); | 76 this._errorPopoverHelper = new UI.PopoverHelper(this.element); |
| 77 this._errorPopoverHelper.initializeCallbacks(this._getErrorAnchor.bind(this)
, this._showErrorPopover.bind(this)); | 77 this._errorPopoverHelper.initializeCallbacks(this._getErrorAnchor.bind(this)
, this._showErrorPopover.bind(this)); |
| 78 | 78 |
| 79 this._errorPopoverHelper.setTimeout(100, 100); | 79 this._errorPopoverHelper.setTimeout(100, 100); |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * @return {!Promise<?string>} | 82 * @return {!Promise<?string>} |
| 83 */ | 83 */ |
| 84 function workingCopy() { | 84 function workingCopy() { |
| 85 if (uiSourceCode.isDirty()) | 85 if (uiSourceCode.isDirty()) |
| 86 return /** @type {!Promise<?string>} */ (Promise.resolve(uiSourceCode.wo
rkingCopy())); | 86 return /** @type {!Promise<?string>} */ (Promise.resolve(uiSourceCode.wo
rkingCopy())); |
| 87 return uiSourceCode.requestContent(); | 87 return uiSourceCode.requestContent(); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * @return {!WebInspector.UISourceCode} | 92 * @return {!Workspace.UISourceCode} |
| 93 */ | 93 */ |
| 94 uiSourceCode() { | 94 uiSourceCode() { |
| 95 return this._uiSourceCode; | 95 return this._uiSourceCode; |
| 96 } | 96 } |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @override | 99 * @override |
| 100 */ | 100 */ |
| 101 wasShown() { | 101 wasShown() { |
| 102 super.wasShown(); | 102 super.wasShown(); |
| 103 this._boundWindowFocused = this._windowFocused.bind(this); | 103 this._boundWindowFocused = this._windowFocused.bind(this); |
| 104 this.element.ownerDocument.defaultView.addEventListener('focus', this._bound
WindowFocused, false); | 104 this.element.ownerDocument.defaultView.addEventListener('focus', this._bound
WindowFocused, false); |
| 105 this._checkContentUpdated(); | 105 this._checkContentUpdated(); |
| 106 // We need CodeMirrorTextEditor to be initialized prior to this call as it c
alls |cursorPositionToCoordinates| internally. @see crbug.com/506566 | 106 // We need CodeMirrorTextEditor to be initialized prior to this call as it c
alls |cursorPositionToCoordinates| internally. @see crbug.com/506566 |
| 107 setImmediate(this._updateBucketDecorations.bind(this)); | 107 setImmediate(this._updateBucketDecorations.bind(this)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * @override | 111 * @override |
| 112 */ | 112 */ |
| 113 willHide() { | 113 willHide() { |
| 114 super.willHide(); | 114 super.willHide(); |
| 115 WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, null); | 115 UI.context.setFlavor(Sources.UISourceCodeFrame, null); |
| 116 this.element.ownerDocument.defaultView.removeEventListener('focus', this._bo
undWindowFocused, false); | 116 this.element.ownerDocument.defaultView.removeEventListener('focus', this._bo
undWindowFocused, false); |
| 117 delete this._boundWindowFocused; | 117 delete this._boundWindowFocused; |
| 118 this._uiSourceCode.removeWorkingCopyGetter(); | 118 this._uiSourceCode.removeWorkingCopyGetter(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * @return {boolean} | 122 * @return {boolean} |
| 123 */ | 123 */ |
| 124 _canEditSource() { | 124 _canEditSource() { |
| 125 if (WebInspector.persistence.binding(this._uiSourceCode)) | 125 if (Persistence.persistence.binding(this._uiSourceCode)) |
| 126 return true; | 126 return true; |
| 127 var projectType = this._uiSourceCode.project().type(); | 127 var projectType = this._uiSourceCode.project().type(); |
| 128 if (projectType === WebInspector.projectTypes.Service || projectType === Web
Inspector.projectTypes.Debugger || | 128 if (projectType === Workspace.projectTypes.Service || projectType === Worksp
ace.projectTypes.Debugger || |
| 129 projectType === WebInspector.projectTypes.Formatter) | 129 projectType === Workspace.projectTypes.Formatter) |
| 130 return false; | 130 return false; |
| 131 if (projectType === WebInspector.projectTypes.Network && | 131 if (projectType === Workspace.projectTypes.Network && |
| 132 this._uiSourceCode.contentType() === WebInspector.resourceTypes.Document
) | 132 this._uiSourceCode.contentType() === Common.resourceTypes.Document) |
| 133 return false; | 133 return false; |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 | 136 |
| 137 _windowFocused(event) { | 137 _windowFocused(event) { |
| 138 this._checkContentUpdated(); | 138 this._checkContentUpdated(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 _checkContentUpdated() { | 141 _checkContentUpdated() { |
| 142 if (!this.loaded || !this.isShowing()) | 142 if (!this.loaded || !this.isShowing()) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 160 if (this._diff) | 160 if (this._diff) |
| 161 this._diff.updateDiffMarkersImmediately(); | 161 this._diff.updateDiffMarkersImmediately(); |
| 162 super.onTextEditorContentSet(); | 162 super.onTextEditorContentSet(); |
| 163 for (var message of this._uiSourceCode.messages()) | 163 for (var message of this._uiSourceCode.messages()) |
| 164 this._addMessageToSource(message); | 164 this._addMessageToSource(message); |
| 165 this._decorateAllTypes(); | 165 this._decorateAllTypes(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * @override | 169 * @override |
| 170 * @param {!WebInspector.TextRange} oldRange | 170 * @param {!Common.TextRange} oldRange |
| 171 * @param {!WebInspector.TextRange} newRange | 171 * @param {!Common.TextRange} newRange |
| 172 */ | 172 */ |
| 173 onTextChanged(oldRange, newRange) { | 173 onTextChanged(oldRange, newRange) { |
| 174 if (this._diff) | 174 if (this._diff) |
| 175 this._diff.updateDiffMarkersWhenPossible(); | 175 this._diff.updateDiffMarkersWhenPossible(); |
| 176 super.onTextChanged(oldRange, newRange); | 176 super.onTextChanged(oldRange, newRange); |
| 177 this._clearMessages(); | 177 this._clearMessages(); |
| 178 if (this._isSettingContent) | 178 if (this._isSettingContent) |
| 179 return; | 179 return; |
| 180 this._muteSourceCodeEvents = true; | 180 this._muteSourceCodeEvents = true; |
| 181 if (this._textEditor.isClean()) | 181 if (this._textEditor.isClean()) |
| 182 this._uiSourceCode.resetWorkingCopy(); | 182 this._uiSourceCode.resetWorkingCopy(); |
| 183 else | 183 else |
| 184 this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(this._t
extEditor)); | 184 this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(this._t
extEditor)); |
| 185 delete this._muteSourceCodeEvents; | 185 delete this._muteSourceCodeEvents; |
| 186 } | 186 } |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * @param {!WebInspector.Event} event | 189 * @param {!Common.Event} event |
| 190 */ | 190 */ |
| 191 _onWorkingCopyChanged(event) { | 191 _onWorkingCopyChanged(event) { |
| 192 if (this._muteSourceCodeEvents) | 192 if (this._muteSourceCodeEvents) |
| 193 return; | 193 return; |
| 194 this._innerSetContent(this._uiSourceCode.workingCopy()); | 194 this._innerSetContent(this._uiSourceCode.workingCopy()); |
| 195 this.onUISourceCodeContentChanged(); | 195 this.onUISourceCodeContentChanged(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 /** | 198 /** |
| 199 * @param {!WebInspector.Event} event | 199 * @param {!Common.Event} event |
| 200 */ | 200 */ |
| 201 _onWorkingCopyCommitted(event) { | 201 _onWorkingCopyCommitted(event) { |
| 202 if (!this._muteSourceCodeEvents) { | 202 if (!this._muteSourceCodeEvents) { |
| 203 this._innerSetContent(this._uiSourceCode.workingCopy()); | 203 this._innerSetContent(this._uiSourceCode.workingCopy()); |
| 204 this.onUISourceCodeContentChanged(); | 204 this.onUISourceCodeContentChanged(); |
| 205 } | 205 } |
| 206 this._textEditor.markClean(); | 206 this._textEditor.markClean(); |
| 207 this._updateStyle(); | 207 this._updateStyle(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 /** | 210 /** |
| 211 * @param {!WebInspector.Event} event | 211 * @param {!Common.Event} event |
| 212 */ | 212 */ |
| 213 _onBindingChanged(event) { | 213 _onBindingChanged(event) { |
| 214 var binding = /** @type {!WebInspector.PersistenceBinding} */ (event.data); | 214 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); |
| 215 if (binding.network === this._uiSourceCode || binding.fileSystem === this._u
iSourceCode) | 215 if (binding.network === this._uiSourceCode || binding.fileSystem === this._u
iSourceCode) |
| 216 this._updateStyle(); | 216 this._updateStyle(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 _updateStyle() { | 219 _updateStyle() { |
| 220 this.element.classList.toggle( | 220 this.element.classList.toggle( |
| 221 'source-frame-unsaved-committed-changes', | 221 'source-frame-unsaved-committed-changes', |
| 222 WebInspector.persistence.hasUnsavedCommittedChanges(this._uiSourceCode))
; | 222 Persistence.persistence.hasUnsavedCommittedChanges(this._uiSourceCode)); |
| 223 this.setEditable(!this._canEditSource()); | 223 this.setEditable(!this._canEditSource()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 onUISourceCodeContentChanged() { | 226 onUISourceCodeContentChanged() { |
| 227 } | 227 } |
| 228 | 228 |
| 229 _updateAutocomplete() { | 229 _updateAutocomplete() { |
| 230 this._textEditor.configureAutocomplete( | 230 this._textEditor.configureAutocomplete( |
| 231 WebInspector.moduleSetting('textEditorAutocompletion').get() ? this._aut
ocompleteConfig : null); | 231 Common.moduleSetting('textEditorAutocompletion').get() ? this._autocompl
eteConfig : null); |
| 232 } | 232 } |
| 233 | 233 |
| 234 /** | 234 /** |
| 235 * @param {?WebInspector.AutocompleteConfig} config | 235 * @param {?UI.AutocompleteConfig} config |
| 236 */ | 236 */ |
| 237 configureAutocomplete(config) { | 237 configureAutocomplete(config) { |
| 238 this._autocompleteConfig = config; | 238 this._autocompleteConfig = config; |
| 239 this._updateAutocomplete(); | 239 this._updateAutocomplete(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 /** | 242 /** |
| 243 * @param {string} content | 243 * @param {string} content |
| 244 */ | 244 */ |
| 245 _innerSetContent(content) { | 245 _innerSetContent(content) { |
| 246 this._isSettingContent = true; | 246 this._isSettingContent = true; |
| 247 if (this._diff) { | 247 if (this._diff) { |
| 248 var oldContent = this._textEditor.text(); | 248 var oldContent = this._textEditor.text(); |
| 249 this.setContent(content); | 249 this.setContent(content); |
| 250 this._diff.highlightModifiedLines(oldContent, content); | 250 this._diff.highlightModifiedLines(oldContent, content); |
| 251 } else { | 251 } else { |
| 252 this.setContent(content); | 252 this.setContent(content); |
| 253 } | 253 } |
| 254 delete this._isSettingContent; | 254 delete this._isSettingContent; |
| 255 } | 255 } |
| 256 | 256 |
| 257 /** | 257 /** |
| 258 * @override | 258 * @override |
| 259 * @return {!Promise} | 259 * @return {!Promise} |
| 260 */ | 260 */ |
| 261 populateTextAreaContextMenu(contextMenu, lineNumber, columnNumber) { | 261 populateTextAreaContextMenu(contextMenu, lineNumber, columnNumber) { |
| 262 /** | 262 /** |
| 263 * @this {WebInspector.UISourceCodeFrame} | 263 * @this {Sources.UISourceCodeFrame} |
| 264 */ | 264 */ |
| 265 function appendItems() { | 265 function appendItems() { |
| 266 contextMenu.appendApplicableItems(this._uiSourceCode); | 266 contextMenu.appendApplicableItems(this._uiSourceCode); |
| 267 contextMenu.appendApplicableItems(new WebInspector.UILocation(this._uiSour
ceCode, lineNumber, columnNumber)); | 267 contextMenu.appendApplicableItems(new Workspace.UILocation(this._uiSourceC
ode, lineNumber, columnNumber)); |
| 268 contextMenu.appendApplicableItems(this); | 268 contextMenu.appendApplicableItems(this); |
| 269 } | 269 } |
| 270 | 270 |
| 271 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb
er).then(appendItems.bind(this)); | 271 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb
er).then(appendItems.bind(this)); |
| 272 } | 272 } |
| 273 | 273 |
| 274 /** | 274 /** |
| 275 * @param {!Array.<!WebInspector.Infobar|undefined>} infobars | 275 * @param {!Array.<!UI.Infobar|undefined>} infobars |
| 276 */ | 276 */ |
| 277 attachInfobars(infobars) { | 277 attachInfobars(infobars) { |
| 278 for (var i = infobars.length - 1; i >= 0; --i) { | 278 for (var i = infobars.length - 1; i >= 0; --i) { |
| 279 var infobar = infobars[i]; | 279 var infobar = infobars[i]; |
| 280 if (!infobar) | 280 if (!infobar) |
| 281 continue; | 281 continue; |
| 282 this.element.insertBefore(infobar.element, this.element.children[0]); | 282 this.element.insertBefore(infobar.element, this.element.children[0]); |
| 283 infobar.setParentView(this); | 283 infobar.setParentView(this); |
| 284 } | 284 } |
| 285 this.doResize(); | 285 this.doResize(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 dispose() { | 288 dispose() { |
| 289 this._textEditor.dispose(); | 289 this._textEditor.dispose(); |
| 290 WebInspector.moduleSetting('textEditorAutocompletion').removeChangeListener(
this._updateAutocomplete, this); | 290 Common.moduleSetting('textEditorAutocompletion').removeChangeListener(this._
updateAutocomplete, this); |
| 291 this.detach(); | 291 this.detach(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 /** | 294 /** |
| 295 * @param {!WebInspector.Event} event | 295 * @param {!Common.Event} event |
| 296 */ | 296 */ |
| 297 _onMessageAdded(event) { | 297 _onMessageAdded(event) { |
| 298 if (!this.loaded) | 298 if (!this.loaded) |
| 299 return; | 299 return; |
| 300 var message = /** @type {!WebInspector.UISourceCode.Message} */ (event.data)
; | 300 var message = /** @type {!Workspace.UISourceCode.Message} */ (event.data); |
| 301 this._addMessageToSource(message); | 301 this._addMessageToSource(message); |
| 302 } | 302 } |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * @param {!WebInspector.UISourceCode.Message} message | 305 * @param {!Workspace.UISourceCode.Message} message |
| 306 */ | 306 */ |
| 307 _addMessageToSource(message) { | 307 _addMessageToSource(message) { |
| 308 var lineNumber = message.lineNumber(); | 308 var lineNumber = message.lineNumber(); |
| 309 if (lineNumber >= this._textEditor.linesCount) | 309 if (lineNumber >= this._textEditor.linesCount) |
| 310 lineNumber = this._textEditor.linesCount - 1; | 310 lineNumber = this._textEditor.linesCount - 1; |
| 311 if (lineNumber < 0) | 311 if (lineNumber < 0) |
| 312 lineNumber = 0; | 312 lineNumber = 0; |
| 313 | 313 |
| 314 if (!this._rowMessageBuckets[lineNumber]) | 314 if (!this._rowMessageBuckets[lineNumber]) |
| 315 this._rowMessageBuckets[lineNumber] = | 315 this._rowMessageBuckets[lineNumber] = |
| 316 new WebInspector.UISourceCodeFrame.RowMessageBucket(this, this._textEd
itor, lineNumber); | 316 new Sources.UISourceCodeFrame.RowMessageBucket(this, this._textEditor,
lineNumber); |
| 317 var messageBucket = this._rowMessageBuckets[lineNumber]; | 317 var messageBucket = this._rowMessageBuckets[lineNumber]; |
| 318 messageBucket.addMessage(message); | 318 messageBucket.addMessage(message); |
| 319 } | 319 } |
| 320 | 320 |
| 321 /** | 321 /** |
| 322 * @param {!WebInspector.Event} event | 322 * @param {!Common.Event} event |
| 323 */ | 323 */ |
| 324 _onMessageRemoved(event) { | 324 _onMessageRemoved(event) { |
| 325 if (!this.loaded) | 325 if (!this.loaded) |
| 326 return; | 326 return; |
| 327 var message = /** @type {!WebInspector.UISourceCode.Message} */ (event.data)
; | 327 var message = /** @type {!Workspace.UISourceCode.Message} */ (event.data); |
| 328 this._removeMessageFromSource(message); | 328 this._removeMessageFromSource(message); |
| 329 } | 329 } |
| 330 | 330 |
| 331 /** | 331 /** |
| 332 * @param {!WebInspector.UISourceCode.Message} message | 332 * @param {!Workspace.UISourceCode.Message} message |
| 333 */ | 333 */ |
| 334 _removeMessageFromSource(message) { | 334 _removeMessageFromSource(message) { |
| 335 var lineNumber = message.lineNumber(); | 335 var lineNumber = message.lineNumber(); |
| 336 if (lineNumber >= this._textEditor.linesCount) | 336 if (lineNumber >= this._textEditor.linesCount) |
| 337 lineNumber = this._textEditor.linesCount - 1; | 337 lineNumber = this._textEditor.linesCount - 1; |
| 338 if (lineNumber < 0) | 338 if (lineNumber < 0) |
| 339 lineNumber = 0; | 339 lineNumber = 0; |
| 340 | 340 |
| 341 var messageBucket = this._rowMessageBuckets[lineNumber]; | 341 var messageBucket = this._rowMessageBuckets[lineNumber]; |
| 342 if (!messageBucket) | 342 if (!messageBucket) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 368 var element = target.enclosingNodeOrSelfWithClass('text-editor-line-decorati
on-icon') || | 368 var element = target.enclosingNodeOrSelfWithClass('text-editor-line-decorati
on-icon') || |
| 369 target.enclosingNodeOrSelfWithClass('text-editor-line-decoration-wave'); | 369 target.enclosingNodeOrSelfWithClass('text-editor-line-decoration-wave'); |
| 370 if (!element) | 370 if (!element) |
| 371 return; | 371 return; |
| 372 this._errorWavePopoverAnchor = new AnchorBox(event.clientX, event.clientY, 1
, 1); | 372 this._errorWavePopoverAnchor = new AnchorBox(event.clientX, event.clientY, 1
, 1); |
| 373 return element; | 373 return element; |
| 374 } | 374 } |
| 375 | 375 |
| 376 /** | 376 /** |
| 377 * @param {!Element} anchor | 377 * @param {!Element} anchor |
| 378 * @param {!WebInspector.Popover} popover | 378 * @param {!UI.Popover} popover |
| 379 */ | 379 */ |
| 380 _showErrorPopover(anchor, popover) { | 380 _showErrorPopover(anchor, popover) { |
| 381 var messageBucket = anchor.enclosingNodeOrSelfWithClass('text-editor-line-de
coration')._messageBucket; | 381 var messageBucket = anchor.enclosingNodeOrSelfWithClass('text-editor-line-de
coration')._messageBucket; |
| 382 var messagesOutline = messageBucket.messagesDescription(); | 382 var messagesOutline = messageBucket.messagesDescription(); |
| 383 var popoverAnchor = | 383 var popoverAnchor = |
| 384 anchor.enclosingNodeOrSelfWithClass('text-editor-line-decoration-icon')
? anchor : this._errorWavePopoverAnchor; | 384 anchor.enclosingNodeOrSelfWithClass('text-editor-line-decoration-icon')
? anchor : this._errorWavePopoverAnchor; |
| 385 popover.showForAnchor(messagesOutline, popoverAnchor); | 385 popover.showForAnchor(messagesOutline, popoverAnchor); |
| 386 } | 386 } |
| 387 | 387 |
| 388 _updateBucketDecorations() { | 388 _updateBucketDecorations() { |
| 389 for (var line in this._rowMessageBuckets) { | 389 for (var line in this._rowMessageBuckets) { |
| 390 var bucket = this._rowMessageBuckets[line]; | 390 var bucket = this._rowMessageBuckets[line]; |
| 391 bucket._updateDecoration(); | 391 bucket._updateDecoration(); |
| 392 } | 392 } |
| 393 } | 393 } |
| 394 | 394 |
| 395 /** | 395 /** |
| 396 * @param {!WebInspector.Event} event | 396 * @param {!Common.Event} event |
| 397 */ | 397 */ |
| 398 _onLineDecorationAdded(event) { | 398 _onLineDecorationAdded(event) { |
| 399 var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event.dat
a); | 399 var marker = /** @type {!Workspace.UISourceCode.LineMarker} */ (event.data); |
| 400 this._decorateTypeThrottled(marker.type()); | 400 this._decorateTypeThrottled(marker.type()); |
| 401 } | 401 } |
| 402 | 402 |
| 403 /** | 403 /** |
| 404 * @param {!WebInspector.Event} event | 404 * @param {!Common.Event} event |
| 405 */ | 405 */ |
| 406 _onLineDecorationRemoved(event) { | 406 _onLineDecorationRemoved(event) { |
| 407 var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event.dat
a); | 407 var marker = /** @type {!Workspace.UISourceCode.LineMarker} */ (event.data); |
| 408 this._decorateTypeThrottled(marker.type()); | 408 this._decorateTypeThrottled(marker.type()); |
| 409 } | 409 } |
| 410 | 410 |
| 411 /** | 411 /** |
| 412 * @param {string} type | 412 * @param {string} type |
| 413 */ | 413 */ |
| 414 _decorateTypeThrottled(type) { | 414 _decorateTypeThrottled(type) { |
| 415 if (this._typeDecorationsPending.has(type)) | 415 if (this._typeDecorationsPending.has(type)) |
| 416 return; | 416 return; |
| 417 this._typeDecorationsPending.add(type); | 417 this._typeDecorationsPending.add(type); |
| 418 self.runtime.extensions(WebInspector.UISourceCodeFrame.LineDecorator) | 418 self.runtime.extensions(Sources.UISourceCodeFrame.LineDecorator) |
| 419 .find(extension => extension.descriptor()['decoratorType'] === type) | 419 .find(extension => extension.descriptor()['decoratorType'] === type) |
| 420 .instance() | 420 .instance() |
| 421 .then(decorator => { | 421 .then(decorator => { |
| 422 this._typeDecorationsPending.delete(type); | 422 this._typeDecorationsPending.delete(type); |
| 423 decorator.decorate(this.uiSourceCode(), this._textEditor); | 423 decorator.decorate(this.uiSourceCode(), this._textEditor); |
| 424 }); | 424 }); |
| 425 } | 425 } |
| 426 | 426 |
| 427 _decorateAllTypes() { | 427 _decorateAllTypes() { |
| 428 var extensions = self.runtime.extensions(WebInspector.UISourceCodeFrame.Line
Decorator); | 428 var extensions = self.runtime.extensions(Sources.UISourceCodeFrame.LineDecor
ator); |
| 429 extensions.forEach(extension => this._decorateTypeThrottled(extension.descri
ptor()['decoratorType'])); | 429 extensions.forEach(extension => this._decorateTypeThrottled(extension.descri
ptor()['decoratorType'])); |
| 430 } | 430 } |
| 431 }; | 431 }; |
| 432 | 432 |
| 433 WebInspector.UISourceCodeFrame._iconClassPerLevel = {}; | 433 Sources.UISourceCodeFrame._iconClassPerLevel = {}; |
| 434 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess
age.Level.Error] = 'smallicon-error'; | 434 Sources.UISourceCodeFrame._iconClassPerLevel[Workspace.UISourceCode.Message.Leve
l.Error] = 'smallicon-error'; |
| 435 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess
age.Level.Warning] = 'smallicon-warning'; | 435 Sources.UISourceCodeFrame._iconClassPerLevel[Workspace.UISourceCode.Message.Leve
l.Warning] = 'smallicon-warning'; |
| 436 | 436 |
| 437 WebInspector.UISourceCodeFrame._bubbleTypePerLevel = {}; | 437 Sources.UISourceCodeFrame._bubbleTypePerLevel = {}; |
| 438 WebInspector.UISourceCodeFrame._bubbleTypePerLevel[WebInspector.UISourceCode.Mes
sage.Level.Error] = 'error'; | 438 Sources.UISourceCodeFrame._bubbleTypePerLevel[Workspace.UISourceCode.Message.Lev
el.Error] = 'error'; |
| 439 WebInspector.UISourceCodeFrame._bubbleTypePerLevel[WebInspector.UISourceCode.Mes
sage.Level.Warning] = 'warning'; | 439 Sources.UISourceCodeFrame._bubbleTypePerLevel[Workspace.UISourceCode.Message.Lev
el.Warning] = 'warning'; |
| 440 | 440 |
| 441 WebInspector.UISourceCodeFrame._lineClassPerLevel = {}; | 441 Sources.UISourceCodeFrame._lineClassPerLevel = {}; |
| 442 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess
age.Level.Error] = | 442 Sources.UISourceCodeFrame._lineClassPerLevel[Workspace.UISourceCode.Message.Leve
l.Error] = |
| 443 'text-editor-line-with-error'; | 443 'text-editor-line-with-error'; |
| 444 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess
age.Level.Warning] = | 444 Sources.UISourceCodeFrame._lineClassPerLevel[Workspace.UISourceCode.Message.Leve
l.Warning] = |
| 445 'text-editor-line-with-warning'; | 445 'text-editor-line-with-warning'; |
| 446 | 446 |
| 447 /** | 447 /** |
| 448 * @interface | 448 * @interface |
| 449 */ | 449 */ |
| 450 WebInspector.UISourceCodeFrame.LineDecorator = function() {}; | 450 Sources.UISourceCodeFrame.LineDecorator = function() {}; |
| 451 | 451 |
| 452 WebInspector.UISourceCodeFrame.LineDecorator.prototype = { | 452 Sources.UISourceCodeFrame.LineDecorator.prototype = { |
| 453 /** | 453 /** |
| 454 * @param {!WebInspector.UISourceCode} uiSourceCode | 454 * @param {!Workspace.UISourceCode} uiSourceCode |
| 455 * @param {!WebInspector.CodeMirrorTextEditor} textEditor | 455 * @param {!TextEditor.CodeMirrorTextEditor} textEditor |
| 456 */ | 456 */ |
| 457 decorate: function(uiSourceCode, textEditor) {} | 457 decorate: function(uiSourceCode, textEditor) {} |
| 458 }; | 458 }; |
| 459 | 459 |
| 460 /** | 460 /** |
| 461 * @unrestricted | 461 * @unrestricted |
| 462 */ | 462 */ |
| 463 WebInspector.UISourceCodeFrame.RowMessage = class { | 463 Sources.UISourceCodeFrame.RowMessage = class { |
| 464 /** | 464 /** |
| 465 * @param {!WebInspector.UISourceCode.Message} message | 465 * @param {!Workspace.UISourceCode.Message} message |
| 466 */ | 466 */ |
| 467 constructor(message) { | 467 constructor(message) { |
| 468 this._message = message; | 468 this._message = message; |
| 469 this._repeatCount = 1; | 469 this._repeatCount = 1; |
| 470 this.element = createElementWithClass('div', 'text-editor-row-message'); | 470 this.element = createElementWithClass('div', 'text-editor-row-message'); |
| 471 this._icon = this.element.createChild('label', '', 'dt-icon-label'); | 471 this._icon = this.element.createChild('label', '', 'dt-icon-label'); |
| 472 this._icon.type = WebInspector.UISourceCodeFrame._iconClassPerLevel[message.
level()]; | 472 this._icon.type = Sources.UISourceCodeFrame._iconClassPerLevel[message.level
()]; |
| 473 this._repeatCountElement = this.element.createChild('label', 'message-repeat
-count hidden', 'dt-small-bubble'); | 473 this._repeatCountElement = this.element.createChild('label', 'message-repeat
-count hidden', 'dt-small-bubble'); |
| 474 this._repeatCountElement.type = WebInspector.UISourceCodeFrame._bubbleTypePe
rLevel[message.level()]; | 474 this._repeatCountElement.type = Sources.UISourceCodeFrame._bubbleTypePerLeve
l[message.level()]; |
| 475 var linesContainer = this.element.createChild('div', 'text-editor-row-messag
e-lines'); | 475 var linesContainer = this.element.createChild('div', 'text-editor-row-messag
e-lines'); |
| 476 var lines = this._message.text().split('\n'); | 476 var lines = this._message.text().split('\n'); |
| 477 for (var i = 0; i < lines.length; ++i) { | 477 for (var i = 0; i < lines.length; ++i) { |
| 478 var messageLine = linesContainer.createChild('div'); | 478 var messageLine = linesContainer.createChild('div'); |
| 479 messageLine.textContent = lines[i]; | 479 messageLine.textContent = lines[i]; |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 /** | 483 /** |
| 484 * @return {!WebInspector.UISourceCode.Message} | 484 * @return {!Workspace.UISourceCode.Message} |
| 485 */ | 485 */ |
| 486 message() { | 486 message() { |
| 487 return this._message; | 487 return this._message; |
| 488 } | 488 } |
| 489 | 489 |
| 490 /** | 490 /** |
| 491 * @return {number} | 491 * @return {number} |
| 492 */ | 492 */ |
| 493 repeatCount() { | 493 repeatCount() { |
| 494 return this._repeatCount; | 494 return this._repeatCount; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 505 this._repeatCountElement.textContent = this._repeatCount; | 505 this._repeatCountElement.textContent = this._repeatCount; |
| 506 var showRepeatCount = this._repeatCount > 1; | 506 var showRepeatCount = this._repeatCount > 1; |
| 507 this._repeatCountElement.classList.toggle('hidden', !showRepeatCount); | 507 this._repeatCountElement.classList.toggle('hidden', !showRepeatCount); |
| 508 this._icon.classList.toggle('hidden', showRepeatCount); | 508 this._icon.classList.toggle('hidden', showRepeatCount); |
| 509 } | 509 } |
| 510 }; | 510 }; |
| 511 | 511 |
| 512 /** | 512 /** |
| 513 * @unrestricted | 513 * @unrestricted |
| 514 */ | 514 */ |
| 515 WebInspector.UISourceCodeFrame.RowMessageBucket = class { | 515 Sources.UISourceCodeFrame.RowMessageBucket = class { |
| 516 /** | 516 /** |
| 517 * @param {!WebInspector.UISourceCodeFrame} sourceFrame | 517 * @param {!Sources.UISourceCodeFrame} sourceFrame |
| 518 * @param {!WebInspector.CodeMirrorTextEditor} textEditor | 518 * @param {!TextEditor.CodeMirrorTextEditor} textEditor |
| 519 * @param {number} lineNumber | 519 * @param {number} lineNumber |
| 520 */ | 520 */ |
| 521 constructor(sourceFrame, textEditor, lineNumber) { | 521 constructor(sourceFrame, textEditor, lineNumber) { |
| 522 this._sourceFrame = sourceFrame; | 522 this._sourceFrame = sourceFrame; |
| 523 this._textEditor = textEditor; | 523 this._textEditor = textEditor; |
| 524 this._lineHandle = textEditor.textEditorPositionHandle(lineNumber, 0); | 524 this._lineHandle = textEditor.textEditorPositionHandle(lineNumber, 0); |
| 525 this._decoration = createElementWithClass('div', 'text-editor-line-decoratio
n'); | 525 this._decoration = createElementWithClass('div', 'text-editor-line-decoratio
n'); |
| 526 this._decoration._messageBucket = this; | 526 this._decoration._messageBucket = this; |
| 527 this._wave = this._decoration.createChild('div', 'text-editor-line-decoratio
n-wave'); | 527 this._wave = this._decoration.createChild('div', 'text-editor-line-decoratio
n-wave'); |
| 528 this._icon = this._wave.createChild('label', 'text-editor-line-decoration-ic
on', 'dt-icon-label'); | 528 this._icon = this._wave.createChild('label', 'text-editor-line-decoration-ic
on', 'dt-icon-label'); |
| 529 this._hasDecoration = false; | 529 this._hasDecoration = false; |
| 530 | 530 |
| 531 this._messagesDescriptionElement = createElementWithClass('div', 'text-edito
r-messages-description-container'); | 531 this._messagesDescriptionElement = createElementWithClass('div', 'text-edito
r-messages-description-container'); |
| 532 /** @type {!Array.<!WebInspector.UISourceCodeFrame.RowMessage>} */ | 532 /** @type {!Array.<!Sources.UISourceCodeFrame.RowMessage>} */ |
| 533 this._messages = []; | 533 this._messages = []; |
| 534 | 534 |
| 535 this._level = null; | 535 this._level = null; |
| 536 } | 536 } |
| 537 | 537 |
| 538 /** | 538 /** |
| 539 * @param {number} lineNumber | 539 * @param {number} lineNumber |
| 540 * @param {number} columnNumber | 540 * @param {number} columnNumber |
| 541 */ | 541 */ |
| 542 _updateWavePosition(lineNumber, columnNumber) { | 542 _updateWavePosition(lineNumber, columnNumber) { |
| 543 lineNumber = Math.min(lineNumber, this._textEditor.linesCount - 1); | 543 lineNumber = Math.min(lineNumber, this._textEditor.linesCount - 1); |
| 544 var lineText = this._textEditor.line(lineNumber); | 544 var lineText = this._textEditor.line(lineNumber); |
| 545 columnNumber = Math.min(columnNumber, lineText.length); | 545 columnNumber = Math.min(columnNumber, lineText.length); |
| 546 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length; | 546 var lineIndent = Common.TextUtils.lineIndent(lineText).length; |
| 547 if (this._hasDecoration) | 547 if (this._hasDecoration) |
| 548 this._textEditor.removeDecoration(this._decoration, lineNumber); | 548 this._textEditor.removeDecoration(this._decoration, lineNumber); |
| 549 this._hasDecoration = true; | 549 this._hasDecoration = true; |
| 550 this._textEditor.addDecoration(this._decoration, lineNumber, Math.max(column
Number - 1, lineIndent)); | 550 this._textEditor.addDecoration(this._decoration, lineNumber, Math.max(column
Number - 1, lineIndent)); |
| 551 } | 551 } |
| 552 | 552 |
| 553 /** | 553 /** |
| 554 * @return {!Element} | 554 * @return {!Element} |
| 555 */ | 555 */ |
| 556 messagesDescription() { | 556 messagesDescription() { |
| 557 this._messagesDescriptionElement.removeChildren(); | 557 this._messagesDescriptionElement.removeChildren(); |
| 558 for (var i = 0; i < this._messages.length; ++i) { | 558 for (var i = 0; i < this._messages.length; ++i) { |
| 559 this._messagesDescriptionElement.appendChild(this._messages[i].element); | 559 this._messagesDescriptionElement.appendChild(this._messages[i].element); |
| 560 } | 560 } |
| 561 return this._messagesDescriptionElement; | 561 return this._messagesDescriptionElement; |
| 562 } | 562 } |
| 563 | 563 |
| 564 detachFromEditor() { | 564 detachFromEditor() { |
| 565 var position = this._lineHandle.resolve(); | 565 var position = this._lineHandle.resolve(); |
| 566 if (!position) | 566 if (!position) |
| 567 return; | 567 return; |
| 568 var lineNumber = position.lineNumber; | 568 var lineNumber = position.lineNumber; |
| 569 if (this._level) | 569 if (this._level) |
| 570 this._textEditor.toggleLineClass( | 570 this._textEditor.toggleLineClass( |
| 571 lineNumber, WebInspector.UISourceCodeFrame._lineClassPerLevel[this._le
vel], false); | 571 lineNumber, Sources.UISourceCodeFrame._lineClassPerLevel[this._level],
false); |
| 572 if (this._hasDecoration) | 572 if (this._hasDecoration) |
| 573 this._textEditor.removeDecoration(this._decoration, lineNumber); | 573 this._textEditor.removeDecoration(this._decoration, lineNumber); |
| 574 this._hasDecoration = false; | 574 this._hasDecoration = false; |
| 575 } | 575 } |
| 576 | 576 |
| 577 /** | 577 /** |
| 578 * @return {number} | 578 * @return {number} |
| 579 */ | 579 */ |
| 580 uniqueMessagesCount() { | 580 uniqueMessagesCount() { |
| 581 return this._messages.length; | 581 return this._messages.length; |
| 582 } | 582 } |
| 583 | 583 |
| 584 /** | 584 /** |
| 585 * @param {!WebInspector.UISourceCode.Message} message | 585 * @param {!Workspace.UISourceCode.Message} message |
| 586 */ | 586 */ |
| 587 addMessage(message) { | 587 addMessage(message) { |
| 588 for (var i = 0; i < this._messages.length; ++i) { | 588 for (var i = 0; i < this._messages.length; ++i) { |
| 589 var rowMessage = this._messages[i]; | 589 var rowMessage = this._messages[i]; |
| 590 if (rowMessage.message().isEqual(message)) { | 590 if (rowMessage.message().isEqual(message)) { |
| 591 rowMessage.setRepeatCount(rowMessage.repeatCount() + 1); | 591 rowMessage.setRepeatCount(rowMessage.repeatCount() + 1); |
| 592 return; | 592 return; |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 | 595 |
| 596 var rowMessage = new WebInspector.UISourceCodeFrame.RowMessage(message); | 596 var rowMessage = new Sources.UISourceCodeFrame.RowMessage(message); |
| 597 this._messages.push(rowMessage); | 597 this._messages.push(rowMessage); |
| 598 this._updateDecoration(); | 598 this._updateDecoration(); |
| 599 } | 599 } |
| 600 | 600 |
| 601 /** | 601 /** |
| 602 * @param {!WebInspector.UISourceCode.Message} message | 602 * @param {!Workspace.UISourceCode.Message} message |
| 603 */ | 603 */ |
| 604 removeMessage(message) { | 604 removeMessage(message) { |
| 605 for (var i = 0; i < this._messages.length; ++i) { | 605 for (var i = 0; i < this._messages.length; ++i) { |
| 606 var rowMessage = this._messages[i]; | 606 var rowMessage = this._messages[i]; |
| 607 if (!rowMessage.message().isEqual(message)) | 607 if (!rowMessage.message().isEqual(message)) |
| 608 continue; | 608 continue; |
| 609 rowMessage.setRepeatCount(rowMessage.repeatCount() - 1); | 609 rowMessage.setRepeatCount(rowMessage.repeatCount() - 1); |
| 610 if (!rowMessage.repeatCount()) | 610 if (!rowMessage.repeatCount()) |
| 611 this._messages.splice(i, 1); | 611 this._messages.splice(i, 1); |
| 612 this._updateDecoration(); | 612 this._updateDecoration(); |
| 613 return; | 613 return; |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 _updateDecoration() { | 617 _updateDecoration() { |
| 618 if (!this._sourceFrame.isEditorShowing()) | 618 if (!this._sourceFrame.isEditorShowing()) |
| 619 return; | 619 return; |
| 620 if (!this._messages.length) | 620 if (!this._messages.length) |
| 621 return; | 621 return; |
| 622 var position = this._lineHandle.resolve(); | 622 var position = this._lineHandle.resolve(); |
| 623 if (!position) | 623 if (!position) |
| 624 return; | 624 return; |
| 625 | 625 |
| 626 var lineNumber = position.lineNumber; | 626 var lineNumber = position.lineNumber; |
| 627 var columnNumber = Number.MAX_VALUE; | 627 var columnNumber = Number.MAX_VALUE; |
| 628 var maxMessage = null; | 628 var maxMessage = null; |
| 629 for (var i = 0; i < this._messages.length; ++i) { | 629 for (var i = 0; i < this._messages.length; ++i) { |
| 630 var message = this._messages[i].message(); | 630 var message = this._messages[i].message(); |
| 631 columnNumber = Math.min(columnNumber, message.columnNumber()); | 631 columnNumber = Math.min(columnNumber, message.columnNumber()); |
| 632 if (!maxMessage || WebInspector.UISourceCode.Message.messageLevelComparato
r(maxMessage, message) < 0) | 632 if (!maxMessage || Workspace.UISourceCode.Message.messageLevelComparator(m
axMessage, message) < 0) |
| 633 maxMessage = message; | 633 maxMessage = message; |
| 634 } | 634 } |
| 635 this._updateWavePosition(lineNumber, columnNumber); | 635 this._updateWavePosition(lineNumber, columnNumber); |
| 636 | 636 |
| 637 if (this._level) { | 637 if (this._level) { |
| 638 this._textEditor.toggleLineClass( | 638 this._textEditor.toggleLineClass( |
| 639 lineNumber, WebInspector.UISourceCodeFrame._lineClassPerLevel[this._le
vel], false); | 639 lineNumber, Sources.UISourceCodeFrame._lineClassPerLevel[this._level],
false); |
| 640 this._icon.type = ''; | 640 this._icon.type = ''; |
| 641 } | 641 } |
| 642 this._level = maxMessage.level(); | 642 this._level = maxMessage.level(); |
| 643 if (!this._level) | 643 if (!this._level) |
| 644 return; | 644 return; |
| 645 this._textEditor.toggleLineClass(lineNumber, WebInspector.UISourceCodeFrame.
_lineClassPerLevel[this._level], true); | 645 this._textEditor.toggleLineClass(lineNumber, Sources.UISourceCodeFrame._line
ClassPerLevel[this._level], true); |
| 646 this._icon.type = WebInspector.UISourceCodeFrame._iconClassPerLevel[this._le
vel]; | 646 this._icon.type = Sources.UISourceCodeFrame._iconClassPerLevel[this._level]; |
| 647 } | 647 } |
| 648 }; | 648 }; |
| 649 | 649 |
| 650 WebInspector.UISourceCode.Message._messageLevelPriority = { | 650 Workspace.UISourceCode.Message._messageLevelPriority = { |
| 651 'Warning': 3, | 651 'Warning': 3, |
| 652 'Error': 4 | 652 'Error': 4 |
| 653 }; | 653 }; |
| 654 | 654 |
| 655 /** | 655 /** |
| 656 * @param {!WebInspector.UISourceCode.Message} a | 656 * @param {!Workspace.UISourceCode.Message} a |
| 657 * @param {!WebInspector.UISourceCode.Message} b | 657 * @param {!Workspace.UISourceCode.Message} b |
| 658 * @return {number} | 658 * @return {number} |
| 659 */ | 659 */ |
| 660 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b) { | 660 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) { |
| 661 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - | 661 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] - |
| 662 WebInspector.UISourceCode.Message._messageLevelPriority[b.level()]; | 662 Workspace.UISourceCode.Message._messageLevelPriority[b.level()]; |
| 663 }; | 663 }; |
| OLD | NEW |