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

Side by Side Diff: dart/site/try/src/interaction_manager.dart

Issue 257613003: Update Try Dart to new scanner behavior. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « dart/site/try/src/editor.dart ('k') | dart/tests/try/paste_content_rewriting_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library trydart.interaction_manager; 5 library trydart.interaction_manager;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 8
9 import 'dart:convert' show 9 import 'dart:convert' show
10 JSON; 10 JSON;
11 11
12 import 'dart:math' show 12 import 'dart:math' show
13 max, 13 max,
14 min; 14 min;
15 15
16 import 'dart:async' show 16 import 'dart:async' show
17 Future; 17 Future;
18 18
19 import 'package:compiler/implementation/scanner/scannerlib.dart' 19 import 'package:compiler/implementation/scanner/scannerlib.dart' show
20 show 20 BeginGroupToken,
21 EOF_TOKEN, 21 EOF_TOKEN,
22 ErrorToken,
22 StringScanner, 23 StringScanner,
23 Token; 24 Token;
24 25
25 import 'package:compiler/implementation/source_file.dart' show 26 import 'package:compiler/implementation/source_file.dart' show
26 StringSourceFile; 27 StringSourceFile;
27 28
28 import 'compilation.dart' show 29 import 'compilation.dart' show
29 currentSource, 30 currentSource,
30 scheduleCompilation; 31 scheduleCompilation;
31 32
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 // do identifier_abcdefghijklmnopqrst 679 // do identifier_abcdefghijklmnopqrst
679 for (Token token = tokenize(currentText); 680 for (Token token = tokenize(currentText);
680 token.kind != EOF_TOKEN; 681 token.kind != EOF_TOKEN;
681 token = token.next) { 682 token = token.next) {
682 int charOffset = token.charOffset; 683 int charOffset = token.charOffset;
683 int charCount = token.charCount; 684 int charCount = token.charCount;
684 685
685 if (charOffset < offset) continue; // Happens for scanner errors. 686 if (charOffset < offset) continue; // Happens for scanner errors.
686 687
687 Decoration decoration = editor.getDecoration(token); 688 Decoration decoration = editor.getDecoration(token);
689
690 Token follow = token.next;
691 if (token is BeginGroupToken) {
692 follow = token.endGroup.next;
693 }
694 if (follow is ErrorToken) {
695 decoration = editor.getDecoration(follow);
696 }
697
688 if (decoration == null) continue; 698 if (decoration == null) continue;
689 699
690 // Add a node for text before current token. 700 // Add a node for text before current token.
691 trySelection.addNodeFromSubstring(offset, charOffset, nodes); 701 trySelection.addNodeFromSubstring(offset, charOffset, nodes);
692 702
693 // Add a node for current token. 703 // Add a node for current token.
694 trySelection.addNodeFromSubstring( 704 trySelection.addNodeFromSubstring(
695 charOffset, charOffset + charCount, nodes, decoration); 705 charOffset, charOffset + charCount, nodes, decoration);
696 706
697 offset = charOffset + charCount; 707 offset = charOffset + charCount;
(...skipping 15 matching lines...) Expand all
713 StringBuffer buffer = new StringBuffer(); 723 StringBuffer buffer = new StringBuffer();
714 int selectionOffset = htmlToText(node, buffer, selection); 724 int selectionOffset = htmlToText(node, buffer, selection);
715 Text newNode = new Text('$buffer'); 725 Text newNode = new Text('$buffer');
716 node.replaceWith(newNode); 726 node.replaceWith(newNode);
717 if (selectionOffset != -1) { 727 if (selectionOffset != -1) {
718 selection.anchorNode = newNode; 728 selection.anchorNode = newNode;
719 selection.anchorOffset = selectionOffset; 729 selection.anchorOffset = selectionOffset;
720 } 730 }
721 } 731 }
722 } 732 }
OLDNEW
« no previous file with comments | « dart/site/try/src/editor.dart ('k') | dart/tests/try/paste_content_rewriting_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698