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

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

Issue 373563002: Handle multiline interpolated strings in line-based scanner. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: getDecoration has side effects Created 6 years, 5 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' show 9 import 'package:compiler/implementation/scanner/scannerlib.dart' show
10 EOF_TOKEN, 10 EOF_TOKEN,
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 outputDiv.appendText('$message\n'); 227 outputDiv.appendText('$message\n');
228 } 228 }
229 229
230 observer.takeRecords(); 230 observer.takeRecords();
231 observer.observe( 231 observer.observe(
232 mainEditorPane, childList: true, characterData: true, subtree: true); 232 mainEditorPane, childList: true, characterData: true, subtree: true);
233 } 233 }
234 234
235 Decoration getDecoration(Token token) { 235 Decoration getDecoration(Token token) {
236 if (token is ErrorToken) { 236 if (token is ErrorToken) {
237 // TODO(ahe): Remove side effects from this method. It only leads to
238 // confusion.
237 isMalformedInput = true; 239 isMalformedInput = true;
238 return new DiagnosticDecoration('error', token.assertionMessage); 240 return new DiagnosticDecoration('error', token.assertionMessage);
239 } 241 }
240 String tokenValue = token.value; 242 String tokenValue = token.value;
241 String tokenInfo = token.info.value; 243 String tokenInfo = token.info.value;
242 if (tokenInfo == 'string') return currentTheme.string; 244 if (tokenInfo == 'string') return currentTheme.string;
243 if (tokenInfo == 'identifier') { 245 if (tokenInfo == 'identifier') {
244 seenIdentifiers.add(tokenValue); 246 seenIdentifiers.add(tokenValue);
245 Decoration decoration = currentTheme.foreground; 247 Decoration decoration = currentTheme.foreground;
246 if (settings.enableCodeCompletion.value) { 248 if (settings.enableCodeCompletion.value) {
247 decoration = CodeCompletionDecoration.from(decoration); 249 decoration = CodeCompletionDecoration.from(decoration);
248 } 250 }
249 return decoration; 251 return decoration;
250 } 252 }
251 if (tokenInfo == 'keyword') return currentTheme.keyword; 253 if (tokenInfo == 'keyword') return currentTheme.keyword;
252 if (tokenInfo == 'comment') return currentTheme.singleLineComment; 254 if (tokenInfo == 'comment') return currentTheme.singleLineComment;
253 if (tokenInfo == 'malformed input') { 255 if (tokenInfo == 'malformed input') {
256 // TODO(ahe): Remove side effects from this method. It only leads to
257 // confusion.
254 isMalformedInput = true; 258 isMalformedInput = true;
255 return new DiagnosticDecoration('error', tokenValue); 259 return new DiagnosticDecoration('error', tokenValue);
256 } 260 }
257 return currentTheme.foreground; 261 return currentTheme.foreground;
258 } 262 }
259 263
260 diagnostic(content, tip) { 264 diagnostic(content, tip) {
261 if (content is String) { 265 if (content is String) {
262 content = new Text(content); 266 content = new Text(content);
263 } 267 }
264 if (content is! List) { 268 if (content is! List) {
265 content = [content]; 269 content = [content];
266 } 270 }
267 return new AnchorElement() 271 return new AnchorElement()
268 ..classes.add('diagnostic') 272 ..classes.add('diagnostic')
269 ..append(tip) // Should be first for better Firefox editing. 273 ..append(tip) // Should be first for better Firefox editing.
270 ..nodes.addAll(content); 274 ..nodes.addAll(content);
271 } 275 }
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