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

Side by Side Diff: dart/site/try/src/editor.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 | « no previous file | dart/site/try/src/interaction_manager.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.editor; 5 library trydart.editor;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 8
9 import 'package:compiler/implementation/scanner/scannerlib.dart' 9 import 'package:compiler/implementation/scanner/scannerlib.dart' show
10 show
11 EOF_TOKEN, 10 EOF_TOKEN,
11 ErrorToken,
12 StringScanner, 12 StringScanner,
13 Token; 13 Token;
14 14
15 import 'ui.dart' show 15 import 'ui.dart' show
16 currentTheme, 16 currentTheme,
17 hackDiv, 17 hackDiv,
18 mainEditorPane, 18 mainEditorPane,
19 observer, 19 observer,
20 outputDiv; 20 outputDiv;
21 21
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 var parent = element.parentNode; 193 var parent = element.parentNode;
194 if (parent == null) return; 194 if (parent == null) return;
195 for (Node child in new List.from(element.nodes)) { 195 for (Node child in new List.from(element.nodes)) {
196 child.remove(); 196 child.remove();
197 parent.insertBefore(child, element); 197 parent.insertBefore(child, element);
198 } 198 }
199 element.remove(); 199 element.remove();
200 } 200 }
201 201
202 Decoration getDecoration(Token token) { 202 Decoration getDecoration(Token token) {
203 if (token is ErrorToken) {
204 isMalformedInput = true;
205 return new DiagnosticDecoration('error', token.assertionMessage);
206 }
203 String tokenValue = token.value; 207 String tokenValue = token.value;
204 String tokenInfo = token.info.value; 208 String tokenInfo = token.info.value;
205 if (tokenInfo == 'string') return currentTheme.string; 209 if (tokenInfo == 'string') return currentTheme.string;
206 if (tokenInfo == 'identifier') { 210 if (tokenInfo == 'identifier') {
207 seenIdentifiers.add(tokenValue); 211 seenIdentifiers.add(tokenValue);
208 return CodeCompletionDecoration.from(currentTheme.foreground); 212 return CodeCompletionDecoration.from(currentTheme.foreground);
209 } 213 }
210 if (tokenInfo == 'keyword') return currentTheme.keyword; 214 if (tokenInfo == 'keyword') return currentTheme.keyword;
211 if (tokenInfo == 'comment') return currentTheme.singleLineComment; 215 if (tokenInfo == 'comment') return currentTheme.singleLineComment;
212 if (tokenInfo == 'malformed input') { 216 if (tokenInfo == 'malformed input') {
213 isMalformedInput = true; 217 isMalformedInput = true;
214 return new DiagnosticDecoration('error', tokenValue); 218 return new DiagnosticDecoration('error', tokenValue);
215 } 219 }
216 return currentTheme.foreground; 220 return currentTheme.foreground;
217 } 221 }
218 222
219 diagnostic(text, tip) { 223 diagnostic(text, tip) {
220 if (text is String) { 224 if (text is String) {
221 text = new Text(text); 225 text = new Text(text);
222 } 226 }
223 return new AnchorElement() 227 return new AnchorElement()
224 ..classes.add('diagnostic') 228 ..classes.add('diagnostic')
225 ..append(text) 229 ..append(text)
226 ..append(tip); 230 ..append(tip);
227 } 231 }
OLDNEW
« no previous file with comments | « no previous file | dart/site/try/src/interaction_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698