Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/source_frame/UISourceCodeFrame.js

Issue 2608043002: DevTools: extract modules (with extensions) (Closed)
Patch Set: refactor py Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 Sources.UISourceCodeFrame = class extends SourceFrame.SourceFrame { 32 SourceFrame.UISourceCodeFrame = class extends SourceFrame.SourceFrame {
33 /** 33 /**
34 * @param {!Workspace.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 Sources.SourceCodeDiff(uiSourceCode.requestOriginalConten t(), this.textEditor); 42 this._diff = new SourceFrame.SourceCodeDiff(uiSourceCode.requestOriginalCo ntent(), this.textEditor);
43 43
44 /** @type {?UI.AutocompleteConfig} */ 44 /** @type {?UI.AutocompleteConfig} */
45 this._autocompleteConfig = {isWordChar: Common.TextUtils.isWordChar}; 45 this._autocompleteConfig = {isWordChar: Common.TextUtils.isWordChar};
46 Common.moduleSetting('textEditorAutocompletion').addChangeListener(this._upd ateAutocomplete, this); 46 Common.moduleSetting('textEditorAutocompletion').addChangeListener(this._upd ateAutocomplete, this);
47 this._updateAutocomplete(); 47 this._updateAutocomplete();
48 48
49 /** @type {?Persistence.PersistenceBinding} */ 49 /** @type {?Persistence.PersistenceBinding} */
50 this._persistenceBinding = Persistence.persistence.binding(uiSourceCode); 50 this._persistenceBinding = Persistence.persistence.binding(uiSourceCode);
51 51
52 /** @type {!Map<number, !Sources.UISourceCodeFrame.RowMessageBucket>} */ 52 /** @type {!Map<number, !SourceFrame.UISourceCodeFrame.RowMessageBucket>} */
53 this._rowMessageBuckets = new Map(); 53 this._rowMessageBuckets = new Map();
54 /** @type {!Set<string>} */ 54 /** @type {!Set<string>} */
55 this._typeDecorationsPending = new Set(); 55 this._typeDecorationsPending = new Set();
56 this._uiSourceCode.addEventListener( 56 this._uiSourceCode.addEventListener(
57 Workspace.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyCha nged, this); 57 Workspace.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyCha nged, this);
58 this._uiSourceCode.addEventListener( 58 this._uiSourceCode.addEventListener(
59 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyC ommitted, this); 59 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyC ommitted, this);
60 60
61 this._messageAndDecorationListeners = []; 61 this._messageAndDecorationListeners = [];
62 this._installMessageAndDecorationListeners(); 62 this._installMessageAndDecorationListeners();
63 63
64 Persistence.persistence.subscribeForBindingEvent(this._uiSourceCode, this._o nBindingChanged.bind(this)); 64 Persistence.persistence.subscribeForBindingEvent(this._uiSourceCode, this._o nBindingChanged.bind(this));
65 65
66 this.textEditor.addEventListener( 66 this.textEditor.addEventListener(
67 SourceFrame.SourcesTextEditor.Events.EditorBlurred, 67 SourceFrame.SourcesTextEditor.Events.EditorBlurred,
68 () => UI.context.setFlavor(Sources.UISourceCodeFrame, null)); 68 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, null));
69 this.textEditor.addEventListener( 69 this.textEditor.addEventListener(
70 SourceFrame.SourcesTextEditor.Events.EditorFocused, 70 SourceFrame.SourcesTextEditor.Events.EditorFocused,
71 () => UI.context.setFlavor(Sources.UISourceCodeFrame, this)); 71 () => UI.context.setFlavor(SourceFrame.UISourceCodeFrame, this));
72 72
73 this._updateStyle(); 73 this._updateStyle();
74 74
75 this._errorPopoverHelper = new UI.PopoverHelper(this.element); 75 this._errorPopoverHelper = new UI.PopoverHelper(this.element);
76 this._errorPopoverHelper.initializeCallbacks(this._getErrorAnchor.bind(this) , this._showErrorPopover.bind(this)); 76 this._errorPopoverHelper.initializeCallbacks(this._getErrorAnchor.bind(this) , this._showErrorPopover.bind(this));
77 77
78 this._errorPopoverHelper.setTimeout(100, 100); 78 this._errorPopoverHelper.setTimeout(100, 100);
79 79
80 /** 80 /**
81 * @return {!Promise<?string>} 81 * @return {!Promise<?string>}
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 super.wasShown(); 129 super.wasShown();
130 // We need CodeMirrorTextEditor to be initialized prior to this call as it c alls |cursorPositionToCoordinates| internally. @see crbug.com/506566 130 // We need CodeMirrorTextEditor to be initialized prior to this call as it c alls |cursorPositionToCoordinates| internally. @see crbug.com/506566
131 setImmediate(this._updateBucketDecorations.bind(this)); 131 setImmediate(this._updateBucketDecorations.bind(this));
132 } 132 }
133 133
134 /** 134 /**
135 * @override 135 * @override
136 */ 136 */
137 willHide() { 137 willHide() {
138 super.willHide(); 138 super.willHide();
139 UI.context.setFlavor(Sources.UISourceCodeFrame, null); 139 UI.context.setFlavor(SourceFrame.UISourceCodeFrame, null);
140 this._uiSourceCode.removeWorkingCopyGetter(); 140 this._uiSourceCode.removeWorkingCopyGetter();
141 } 141 }
142 142
143 /** 143 /**
144 * @return {boolean} 144 * @return {boolean}
145 */ 145 */
146 _canEditSource() { 146 _canEditSource() {
147 if (Persistence.persistence.binding(this._uiSourceCode)) 147 if (Persistence.persistence.binding(this._uiSourceCode))
148 return true; 148 return true;
149 if (this._uiSourceCode.project().canSetFileContent()) 149 if (this._uiSourceCode.project().canSetFileContent())
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 287 }
288 delete this._isSettingContent; 288 delete this._isSettingContent;
289 } 289 }
290 290
291 /** 291 /**
292 * @override 292 * @override
293 * @return {!Promise} 293 * @return {!Promise}
294 */ 294 */
295 populateTextAreaContextMenu(contextMenu, lineNumber, columnNumber) { 295 populateTextAreaContextMenu(contextMenu, lineNumber, columnNumber) {
296 /** 296 /**
297 * @this {Sources.UISourceCodeFrame} 297 * @this {SourceFrame.UISourceCodeFrame}
298 */ 298 */
299 function appendItems() { 299 function appendItems() {
300 contextMenu.appendApplicableItems(this._uiSourceCode); 300 contextMenu.appendApplicableItems(this._uiSourceCode);
301 contextMenu.appendApplicableItems(new Workspace.UILocation(this._uiSourceC ode, lineNumber, columnNumber)); 301 contextMenu.appendApplicableItems(new Workspace.UILocation(this._uiSourceC ode, lineNumber, columnNumber));
302 contextMenu.appendApplicableItems(this); 302 contextMenu.appendApplicableItems(this);
303 } 303 }
304 304
305 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb er).then(appendItems.bind(this)); 305 return super.populateTextAreaContextMenu(contextMenu, lineNumber, columnNumb er).then(appendItems.bind(this));
306 } 306 }
307 307
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (!this.loaded) 340 if (!this.loaded)
341 return; 341 return;
342 var lineNumber = message.lineNumber(); 342 var lineNumber = message.lineNumber();
343 if (lineNumber >= this.textEditor.linesCount) 343 if (lineNumber >= this.textEditor.linesCount)
344 lineNumber = this.textEditor.linesCount - 1; 344 lineNumber = this.textEditor.linesCount - 1;
345 if (lineNumber < 0) 345 if (lineNumber < 0)
346 lineNumber = 0; 346 lineNumber = 0;
347 347
348 var messageBucket = this._rowMessageBuckets.get(lineNumber); 348 var messageBucket = this._rowMessageBuckets.get(lineNumber);
349 if (!messageBucket) { 349 if (!messageBucket) {
350 messageBucket = new Sources.UISourceCodeFrame.RowMessageBucket(this, this. textEditor, lineNumber); 350 messageBucket = new SourceFrame.UISourceCodeFrame.RowMessageBucket(this, t his.textEditor, lineNumber);
351 this._rowMessageBuckets.set(lineNumber, messageBucket); 351 this._rowMessageBuckets.set(lineNumber, messageBucket);
352 } 352 }
353 messageBucket.addMessage(message); 353 messageBucket.addMessage(message);
354 } 354 }
355 355
356 /** 356 /**
357 * @param {!Common.Event} event 357 * @param {!Common.Event} event
358 */ 358 */
359 _onMessageRemoved(event) { 359 _onMessageRemoved(event) {
360 var message = /** @type {!Workspace.UISourceCode.Message} */ (event.data); 360 var message = /** @type {!Workspace.UISourceCode.Message} */ (event.data);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 this._decorateTypeThrottled(marker.type()); 431 this._decorateTypeThrottled(marker.type());
432 } 432 }
433 433
434 /** 434 /**
435 * @param {string} type 435 * @param {string} type
436 */ 436 */
437 _decorateTypeThrottled(type) { 437 _decorateTypeThrottled(type) {
438 if (this._typeDecorationsPending.has(type)) 438 if (this._typeDecorationsPending.has(type))
439 return; 439 return;
440 this._typeDecorationsPending.add(type); 440 this._typeDecorationsPending.add(type);
441 self.runtime.extensions(Sources.UISourceCodeFrame.LineDecorator) 441 self.runtime.extensions(SourceFrame.UISourceCodeFrame.LineDecorator)
442 .find(extension => extension.descriptor()['decoratorType'] === type) 442 .find(extension => extension.descriptor()['decoratorType'] === type)
443 .instance() 443 .instance()
444 .then(decorator => { 444 .then(decorator => {
445 this._typeDecorationsPending.delete(type); 445 this._typeDecorationsPending.delete(type);
446 decorator.decorate( 446 decorator.decorate(
447 this._persistenceBinding ? this._persistenceBinding.network : this .uiSourceCode(), this.textEditor); 447 this._persistenceBinding ? this._persistenceBinding.network : this .uiSourceCode(), this.textEditor);
448 }); 448 });
449 } 449 }
450 450
451 _decorateAllTypes() { 451 _decorateAllTypes() {
452 var extensions = self.runtime.extensions(Sources.UISourceCodeFrame.LineDecor ator); 452 var extensions = self.runtime.extensions(SourceFrame.UISourceCodeFrame.LineD ecorator);
453 extensions.forEach(extension => this._decorateTypeThrottled(extension.descri ptor()['decoratorType'])); 453 extensions.forEach(extension => this._decorateTypeThrottled(extension.descri ptor()['decoratorType']));
454 } 454 }
455 }; 455 };
456 456
457 Sources.UISourceCodeFrame._iconClassPerLevel = {}; 457 SourceFrame.UISourceCodeFrame._iconClassPerLevel = {};
458 Sources.UISourceCodeFrame._iconClassPerLevel[Workspace.UISourceCode.Message.Leve l.Error] = 'smallicon-error'; 458 SourceFrame.UISourceCodeFrame._iconClassPerLevel[Workspace.UISourceCode.Message. Level.Error] = 'smallicon-error';
459 Sources.UISourceCodeFrame._iconClassPerLevel[Workspace.UISourceCode.Message.Leve l.Warning] = 'smallicon-warning'; 459 SourceFrame.UISourceCodeFrame._iconClassPerLevel[Workspace.UISourceCode.Message. Level.Warning] = 'smallicon-warning';
460 460
461 Sources.UISourceCodeFrame._bubbleTypePerLevel = {}; 461 SourceFrame.UISourceCodeFrame._bubbleTypePerLevel = {};
462 Sources.UISourceCodeFrame._bubbleTypePerLevel[Workspace.UISourceCode.Message.Lev el.Error] = 'error'; 462 SourceFrame.UISourceCodeFrame._bubbleTypePerLevel[Workspace.UISourceCode.Message .Level.Error] = 'error';
463 Sources.UISourceCodeFrame._bubbleTypePerLevel[Workspace.UISourceCode.Message.Lev el.Warning] = 'warning'; 463 SourceFrame.UISourceCodeFrame._bubbleTypePerLevel[Workspace.UISourceCode.Message .Level.Warning] = 'warning';
464 464
465 Sources.UISourceCodeFrame._lineClassPerLevel = {}; 465 SourceFrame.UISourceCodeFrame._lineClassPerLevel = {};
466 Sources.UISourceCodeFrame._lineClassPerLevel[Workspace.UISourceCode.Message.Leve l.Error] = 466 SourceFrame.UISourceCodeFrame._lineClassPerLevel[Workspace.UISourceCode.Message. Level.Error] =
467 'text-editor-line-with-error'; 467 'text-editor-line-with-error';
468 Sources.UISourceCodeFrame._lineClassPerLevel[Workspace.UISourceCode.Message.Leve l.Warning] = 468 SourceFrame.UISourceCodeFrame._lineClassPerLevel[Workspace.UISourceCode.Message. Level.Warning] =
469 'text-editor-line-with-warning'; 469 'text-editor-line-with-warning';
470 470
471 /** 471 /**
472 * @interface 472 * @interface
473 */ 473 */
474 Sources.UISourceCodeFrame.LineDecorator = function() {}; 474 SourceFrame.UISourceCodeFrame.LineDecorator = function() {};
475 475
476 Sources.UISourceCodeFrame.LineDecorator.prototype = { 476 SourceFrame.UISourceCodeFrame.LineDecorator.prototype = {
477 /** 477 /**
478 * @param {!Workspace.UISourceCode} uiSourceCode 478 * @param {!Workspace.UISourceCode} uiSourceCode
479 * @param {!TextEditor.CodeMirrorTextEditor} textEditor 479 * @param {!TextEditor.CodeMirrorTextEditor} textEditor
480 */ 480 */
481 decorate(uiSourceCode, textEditor) {} 481 decorate(uiSourceCode, textEditor) {}
482 }; 482 };
483 483
484 /** 484 /**
485 * @unrestricted 485 * @unrestricted
486 */ 486 */
487 Sources.UISourceCodeFrame.RowMessage = class { 487 SourceFrame.UISourceCodeFrame.RowMessage = class {
488 /** 488 /**
489 * @param {!Workspace.UISourceCode.Message} message 489 * @param {!Workspace.UISourceCode.Message} message
490 */ 490 */
491 constructor(message) { 491 constructor(message) {
492 this._message = message; 492 this._message = message;
493 this._repeatCount = 1; 493 this._repeatCount = 1;
494 this.element = createElementWithClass('div', 'text-editor-row-message'); 494 this.element = createElementWithClass('div', 'text-editor-row-message');
495 this._icon = this.element.createChild('label', '', 'dt-icon-label'); 495 this._icon = this.element.createChild('label', '', 'dt-icon-label');
496 this._icon.type = Sources.UISourceCodeFrame._iconClassPerLevel[message.level ()]; 496 this._icon.type = SourceFrame.UISourceCodeFrame._iconClassPerLevel[message.l evel()];
497 this._repeatCountElement = this.element.createChild('label', 'message-repeat -count hidden', 'dt-small-bubble'); 497 this._repeatCountElement = this.element.createChild('label', 'message-repeat -count hidden', 'dt-small-bubble');
498 this._repeatCountElement.type = Sources.UISourceCodeFrame._bubbleTypePerLeve l[message.level()]; 498 this._repeatCountElement.type = SourceFrame.UISourceCodeFrame._bubbleTypePer Level[message.level()];
499 var linesContainer = this.element.createChild('div', 'text-editor-row-messag e-lines'); 499 var linesContainer = this.element.createChild('div', 'text-editor-row-messag e-lines');
500 var lines = this._message.text().split('\n'); 500 var lines = this._message.text().split('\n');
501 for (var i = 0; i < lines.length; ++i) { 501 for (var i = 0; i < lines.length; ++i) {
502 var messageLine = linesContainer.createChild('div'); 502 var messageLine = linesContainer.createChild('div');
503 messageLine.textContent = lines[i]; 503 messageLine.textContent = lines[i];
504 } 504 }
505 } 505 }
506 506
507 /** 507 /**
508 * @return {!Workspace.UISourceCode.Message} 508 * @return {!Workspace.UISourceCode.Message}
(...skipping 20 matching lines...) Expand all
529 this._repeatCountElement.textContent = this._repeatCount; 529 this._repeatCountElement.textContent = this._repeatCount;
530 var showRepeatCount = this._repeatCount > 1; 530 var showRepeatCount = this._repeatCount > 1;
531 this._repeatCountElement.classList.toggle('hidden', !showRepeatCount); 531 this._repeatCountElement.classList.toggle('hidden', !showRepeatCount);
532 this._icon.classList.toggle('hidden', showRepeatCount); 532 this._icon.classList.toggle('hidden', showRepeatCount);
533 } 533 }
534 }; 534 };
535 535
536 /** 536 /**
537 * @unrestricted 537 * @unrestricted
538 */ 538 */
539 Sources.UISourceCodeFrame.RowMessageBucket = class { 539 SourceFrame.UISourceCodeFrame.RowMessageBucket = class {
540 /** 540 /**
541 * @param {!Sources.UISourceCodeFrame} sourceFrame 541 * @param {!SourceFrame.UISourceCodeFrame} sourceFrame
542 * @param {!TextEditor.CodeMirrorTextEditor} textEditor 542 * @param {!TextEditor.CodeMirrorTextEditor} textEditor
543 * @param {number} lineNumber 543 * @param {number} lineNumber
544 */ 544 */
545 constructor(sourceFrame, textEditor, lineNumber) { 545 constructor(sourceFrame, textEditor, lineNumber) {
546 this._sourceFrame = sourceFrame; 546 this._sourceFrame = sourceFrame;
547 this.textEditor = textEditor; 547 this.textEditor = textEditor;
548 this._lineHandle = textEditor.textEditorPositionHandle(lineNumber, 0); 548 this._lineHandle = textEditor.textEditorPositionHandle(lineNumber, 0);
549 this._decoration = createElementWithClass('div', 'text-editor-line-decoratio n'); 549 this._decoration = createElementWithClass('div', 'text-editor-line-decoratio n');
550 this._decoration._messageBucket = this; 550 this._decoration._messageBucket = this;
551 this._wave = this._decoration.createChild('div', 'text-editor-line-decoratio n-wave'); 551 this._wave = this._decoration.createChild('div', 'text-editor-line-decoratio n-wave');
552 this._icon = this._wave.createChild('label', 'text-editor-line-decoration-ic on', 'dt-icon-label'); 552 this._icon = this._wave.createChild('label', 'text-editor-line-decoration-ic on', 'dt-icon-label');
553 this._hasDecoration = false; 553 this._hasDecoration = false;
554 554
555 this._messagesDescriptionElement = createElementWithClass('div', 'text-edito r-messages-description-container'); 555 this._messagesDescriptionElement = createElementWithClass('div', 'text-edito r-messages-description-container');
556 /** @type {!Array.<!Sources.UISourceCodeFrame.RowMessage>} */ 556 /** @type {!Array.<!SourceFrame.UISourceCodeFrame.RowMessage>} */
557 this._messages = []; 557 this._messages = [];
558 558
559 this._level = null; 559 this._level = null;
560 } 560 }
561 561
562 /** 562 /**
563 * @param {number} lineNumber 563 * @param {number} lineNumber
564 * @param {number} columnNumber 564 * @param {number} columnNumber
565 */ 565 */
566 _updateWavePosition(lineNumber, columnNumber) { 566 _updateWavePosition(lineNumber, columnNumber) {
(...skipping 17 matching lines...) Expand all
584 584
585 return this._messagesDescriptionElement; 585 return this._messagesDescriptionElement;
586 } 586 }
587 587
588 detachFromEditor() { 588 detachFromEditor() {
589 var position = this._lineHandle.resolve(); 589 var position = this._lineHandle.resolve();
590 if (!position) 590 if (!position)
591 return; 591 return;
592 var lineNumber = position.lineNumber; 592 var lineNumber = position.lineNumber;
593 if (this._level) 593 if (this._level)
594 this.textEditor.toggleLineClass(lineNumber, Sources.UISourceCodeFrame._lin eClassPerLevel[this._level], false); 594 this.textEditor.toggleLineClass(lineNumber, SourceFrame.UISourceCodeFrame. _lineClassPerLevel[this._level], false);
595 if (this._hasDecoration) 595 if (this._hasDecoration)
596 this.textEditor.removeDecoration(this._decoration, lineNumber); 596 this.textEditor.removeDecoration(this._decoration, lineNumber);
597 this._hasDecoration = false; 597 this._hasDecoration = false;
598 } 598 }
599 599
600 /** 600 /**
601 * @return {number} 601 * @return {number}
602 */ 602 */
603 uniqueMessagesCount() { 603 uniqueMessagesCount() {
604 return this._messages.length; 604 return this._messages.length;
605 } 605 }
606 606
607 /** 607 /**
608 * @param {!Workspace.UISourceCode.Message} message 608 * @param {!Workspace.UISourceCode.Message} message
609 */ 609 */
610 addMessage(message) { 610 addMessage(message) {
611 for (var i = 0; i < this._messages.length; ++i) { 611 for (var i = 0; i < this._messages.length; ++i) {
612 var rowMessage = this._messages[i]; 612 var rowMessage = this._messages[i];
613 if (rowMessage.message().isEqual(message)) { 613 if (rowMessage.message().isEqual(message)) {
614 rowMessage.setRepeatCount(rowMessage.repeatCount() + 1); 614 rowMessage.setRepeatCount(rowMessage.repeatCount() + 1);
615 return; 615 return;
616 } 616 }
617 } 617 }
618 618
619 var rowMessage = new Sources.UISourceCodeFrame.RowMessage(message); 619 var rowMessage = new SourceFrame.UISourceCodeFrame.RowMessage(message);
620 this._messages.push(rowMessage); 620 this._messages.push(rowMessage);
621 this._updateDecoration(); 621 this._updateDecoration();
622 } 622 }
623 623
624 /** 624 /**
625 * @param {!Workspace.UISourceCode.Message} message 625 * @param {!Workspace.UISourceCode.Message} message
626 */ 626 */
627 removeMessage(message) { 627 removeMessage(message) {
628 for (var i = 0; i < this._messages.length; ++i) { 628 for (var i = 0; i < this._messages.length; ++i) {
629 var rowMessage = this._messages[i]; 629 var rowMessage = this._messages[i];
(...skipping 21 matching lines...) Expand all
651 var maxMessage = null; 651 var maxMessage = null;
652 for (var i = 0; i < this._messages.length; ++i) { 652 for (var i = 0; i < this._messages.length; ++i) {
653 var message = this._messages[i].message(); 653 var message = this._messages[i].message();
654 columnNumber = Math.min(columnNumber, message.columnNumber()); 654 columnNumber = Math.min(columnNumber, message.columnNumber());
655 if (!maxMessage || Workspace.UISourceCode.Message.messageLevelComparator(m axMessage, message) < 0) 655 if (!maxMessage || Workspace.UISourceCode.Message.messageLevelComparator(m axMessage, message) < 0)
656 maxMessage = message; 656 maxMessage = message;
657 } 657 }
658 this._updateWavePosition(lineNumber, columnNumber); 658 this._updateWavePosition(lineNumber, columnNumber);
659 659
660 if (this._level) { 660 if (this._level) {
661 this.textEditor.toggleLineClass(lineNumber, Sources.UISourceCodeFrame._lin eClassPerLevel[this._level], false); 661 this.textEditor.toggleLineClass(lineNumber, SourceFrame.UISourceCodeFrame. _lineClassPerLevel[this._level], false);
662 this._icon.type = ''; 662 this._icon.type = '';
663 } 663 }
664 this._level = maxMessage.level(); 664 this._level = maxMessage.level();
665 if (!this._level) 665 if (!this._level)
666 return; 666 return;
667 this.textEditor.toggleLineClass(lineNumber, Sources.UISourceCodeFrame._lineC lassPerLevel[this._level], true); 667 this.textEditor.toggleLineClass(lineNumber, SourceFrame.UISourceCodeFrame._l ineClassPerLevel[this._level], true);
668 this._icon.type = Sources.UISourceCodeFrame._iconClassPerLevel[this._level]; 668 this._icon.type = SourceFrame.UISourceCodeFrame._iconClassPerLevel[this._lev el];
669 } 669 }
670 }; 670 };
671 671
672 Workspace.UISourceCode.Message._messageLevelPriority = { 672 Workspace.UISourceCode.Message._messageLevelPriority = {
673 'Warning': 3, 673 'Warning': 3,
674 'Error': 4 674 'Error': 4
675 }; 675 };
676 676
677 /** 677 /**
678 * @param {!Workspace.UISourceCode.Message} a 678 * @param {!Workspace.UISourceCode.Message} a
679 * @param {!Workspace.UISourceCode.Message} b 679 * @param {!Workspace.UISourceCode.Message} b
680 * @return {number} 680 * @return {number}
681 */ 681 */
682 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) { 682 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) {
683 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] - 683 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] -
684 Workspace.UISourceCode.Message._messageLevelPriority[b.level()]; 684 Workspace.UISourceCode.Message._messageLevelPriority[b.level()];
685 }; 685 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698