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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js

Issue 2880863002: [DevTools] Handle more cases for async step in markers (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/continue-to-location-markers-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 var decoration = this.textEditor.highlightRange(highlightRange, 'source- frame-continue-to-location'); 733 var decoration = this.textEditor.highlightRange(highlightRange, 'source- frame-continue-to-location');
734 this._continueToLocationDecorations.set(decoration, location.continueToL ocation.bind(location)); 734 this._continueToLocationDecorations.set(decoration, location.continueToL ocation.bind(location));
735 if (location.type === Protocol.Debugger.BreakLocationType.Call) 735 if (location.type === Protocol.Debugger.BreakLocationType.Call)
736 previousCallLine = lineNumber; 736 previousCallLine = lineNumber;
737 737
738 var isAsyncCall = (line[token.startColumn - 1] === '.' && tokenContent = == 'then') || 738 var isAsyncCall = (line[token.startColumn - 1] === '.' && tokenContent = == 'then') ||
739 tokenContent === 'setTimeout' || tokenContent === 'setInterval'; 739 tokenContent === 'setTimeout' || tokenContent === 'setInterval';
740 var isCurrentPosition = this._executionLocation && lineNumber === this._ executionLocation.lineNumber && 740 var isCurrentPosition = this._executionLocation && lineNumber === this._ executionLocation.lineNumber &&
741 location.columnNumber === this._executionLocation.columnNumber; 741 location.columnNumber === this._executionLocation.columnNumber;
742 if (location.type === Protocol.Debugger.BreakLocationType.Call && isAsyn cCall) { 742 if (location.type === Protocol.Debugger.BreakLocationType.Call && isAsyn cCall) {
743 var functionPosition = line.indexOf('(', token.endColumn); 743 var asyncStepInRange = this._findAsyncStepInRange(this.textEditor, lin eNumber, line, token.endColumn);
744 if (functionPosition !== -1) { 744 if (asyncStepInRange) {
745 functionPosition++; 745 highlightRange =
746 while (functionPosition < line.length && line[functionPosition] === ' ') 746 new TextUtils.TextRange(lineNumber, asyncStepInRange.from, lineN umber, asyncStepInRange.to - 1);
747 functionPosition++; 747 decoration = this.textEditor.highlightRange(highlightRange, 'source- frame-async-step-in');
748 var nextToken = this.textEditor.tokenAtTextPosition(lineNumber, func tionPosition); 748 this._continueToLocationDecorations.set(
749 if (nextToken) { 749 decoration, this._asyncStepIn.bind(this, location, isCurrentPosi tion));
750 if (line.substring(nextToken.startColumn, nextToken.endColumn) === '(') {
751 var closeParen = line.indexOf(')', nextToken.endColumn);
752 nextToken.endColumn = closeParen === -1 ? line.length : closePar en + 1;
753 }
754 highlightRange =
755 new TextUtils.TextRange(lineNumber, nextToken.startColumn, lin eNumber, nextToken.endColumn - 1);
756 decoration = this.textEditor.highlightRange(highlightRange, 'sourc e-frame-async-step-in');
757 this._continueToLocationDecorations.set(
758 decoration, this._asyncStepIn.bind(this, location, isCurrentPo sition));
759 }
760 } 750 }
761 } 751 }
762 } 752 }
753
754 this._continueToLocationRenderedForTest();
755 }
756 }
757
758 _continueToLocationRenderedForTest() {
759 }
760
761 /**
762 * @param {!SourceFrame.SourcesTextEditor} textEditor
763 * @param {number} lineNumber
764 * @param {string} line
765 * @param {number} column
766 * @return {?{from: number, to: number}}
767 */
768 _findAsyncStepInRange(textEditor, lineNumber, line, column) {
769 var token;
770 var tokenText;
771 var from = column;
772 var to = line.length;
773
774 var position = line.indexOf('(', column);
775 if (position === -1)
776 return null;
777 position++;
778
779 skipWhitespace();
780 if (position >= line.length)
781 return null;
782
783 nextToken();
784 if (!token)
785 return null;
786 from = token.startColumn;
787
788 if (token.type === 'js-keyword' && tokenText === 'async') {
789 skipWhitespace();
790 if (position >= line.length)
791 return {from: from, to: to};
792 nextToken();
793 if (!token)
794 return {from: from, to: to};
795 }
796
797 if (token.type === 'js-keyword' && tokenText === 'function')
798 return {from: from, to: to};
799
800 if (token.type && this._isIdentifier(token.type))
801 return {from: from, to: to};
802
803 if (tokenText !== '(')
804 return null;
805 var closeParen = line.indexOf(')', position);
806 if (closeParen === -1 || line.substring(position, closeParen).indexOf('(') ! == -1)
807 return {from: from, to: to};
808 return {from: from, to: closeParen + 1};
809
810 function nextToken() {
811 token = textEditor.tokenAtTextPosition(lineNumber, position);
812 if (token) {
813 position = token.endColumn;
814 to = token.endColumn;
815 tokenText = line.substring(token.startColumn, token.endColumn);
816 }
817 }
818
819 function skipWhitespace() {
820 while (position < line.length) {
821 if (line[position] === ' ') {
822 position++;
823 continue;
824 }
825 var token = textEditor.tokenAtTextPosition(lineNumber, position);
826 if (token.type === 'js-comment') {
827 position = token.endColumn;
828 continue;
829 }
830 break;
831 }
763 } 832 }
764 } 833 }
765 834
766 /** 835 /**
767 * @param {!SDK.DebuggerModel.BreakLocation} location 836 * @param {!SDK.DebuggerModel.BreakLocation} location
768 * @param {boolean} isCurrentPosition 837 * @param {boolean} isCurrentPosition
769 */ 838 */
770 _asyncStepIn(location, isCurrentPosition) { 839 _asyncStepIn(location, isCurrentPosition) {
771 if (!isCurrentPosition) 840 if (!isCurrentPosition)
772 location.continueToLocation(asyncStepIn); 841 location.continueToLocation(asyncStepIn);
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 return; 1675 return;
1607 this.bookmark.clear(); 1676 this.bookmark.clear();
1608 this.bookmark = null; 1677 this.bookmark = null;
1609 } 1678 }
1610 }; 1679 };
1611 1680
1612 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); 1681 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark');
1613 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); 1682 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element');
1614 1683
1615 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark'); 1684 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark');
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/continue-to-location-markers-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698