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

Unified Diff: dart/site/try/src/editor.dart

Issue 345143002: Handle incremental diagnostics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/site/try/src/decoration.dart ('k') | dart/site/try/src/interaction_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/src/editor.dart
diff --git a/dart/site/try/src/editor.dart b/dart/site/try/src/editor.dart
index 880ff3c4202e66ad267793a1784e58cadfa9ac85..615a8539aec63a83cf4fbb88e6228b433286dce3 100644
--- a/dart/site/try/src/editor.dart
+++ b/dart/site/try/src/editor.dart
@@ -15,6 +15,7 @@ import 'package:compiler/implementation/scanner/scannerlib.dart' show
import 'ui.dart' show
currentTheme,
hackDiv,
+ interaction,
mainEditorPane,
observer,
outputDiv;
@@ -152,20 +153,54 @@ addDiagnostic(String kind, String message, int begin, int end) {
if (offset <= begin && begin < newOffset) {
hasSelection = node == anchorNode;
anchorOffset = selection.anchorOffset;
- Node marker = new Text("");
- node.replaceWith(marker);
- // TODO(ahe): Don't highlight everything in the node. Find the
- // relevant token (works for now as we create a node for each token,
- // which is probably not great for performance).
+ var alert;
if (kind == 'error') {
- marker.replaceWith(diagnostic(node, error(message)));
+ alert = error(message);
} else if (kind == 'warning') {
- marker.replaceWith(diagnostic(node, warning(message)));
+ alert = warning(message);
} else {
- marker.replaceWith(diagnostic(node, info(message)));
+ alert = info(message);
}
- if (hasSelection) {
- selection.collapse(node, anchorOffset);
+ Element parent = node.parent;
+ if (parent.classes.contains("diagnostic") &&
kasperl 2014/06/23 06:44:34 Consider factoring this code out in a method of it
ahe 2014/06/23 12:41:39 Yes. I hope to clean up this code when I fix the T
+ !interaction.oldDiagnostics.contains(parent)) {
+ Element other = parent.lastChild;
+ other.remove();
+ SpanElement wrapper = new SpanElement();
+ wrapper.style
+ ..fontWeight = 'normal';
+ var root = getShadowRoot(wrapper);
+ if (root is ShadowRoot) {
+ // When https://code.google.com/p/chromium/issues/detail?id=313458
+ // is fixed:
+ // var link = new LinkElement()
+ // ..rel = "stylesheet"
+ // ..type = "text/css"
+ // ..href = "dartlang-style.css";
+ // root.append(link);
+ root.append(
+ new StyleElement()..text = '@import url(dartlang-style.css)');
+ }
+ root
+ ..append(other)
+ ..append(alert);
+ other.style.display = 'block';
+ alert.style.display = 'block';
+ parent.append(wrapper);
+ } else {
+ if (interaction.oldDiagnostics.contains(parent)) {
+ node.remove();
+ parent.replaceWith(node);
+ }
+ Node marker = new Text("");
+ node.replaceWith(marker);
+ // TODO(ahe): Don't highlight everything in the node. Find the
+ // relevant token (works for now as we create a node for each token,
+ // which is probably not great for performance).
+ marker.replaceWith(diagnostic(node, alert));
+ if (hasSelection) {
+ selection.collapse(node, anchorOffset);
+ }
}
foundNode = true;
return;
« no previous file with comments | « dart/site/try/src/decoration.dart ('k') | dart/site/try/src/interaction_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698