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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/html/XmlNode.java

Issue 11673007: Improve our html editor; add syntax highlighting for script tags; hyperlink detection and navigatio… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 12 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
Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/html/XmlNode.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/html/XmlNode.java (revision 16584)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/html/XmlNode.java (working copy)
@@ -78,8 +78,10 @@
public int getEndOffset() {
if (endToken != null) {
return endToken.getLocation() + endToken.getValue().length();
+ } else if (startToken != null) {
+ return startToken.getLocation() + startToken.getValue().length();
} else {
- return startToken.getLocation() + startToken.getValue().length();
+ return -1;
}
}
@@ -99,12 +101,28 @@
return label;
}
+ public XmlNode getNodeFor(int offset) {
+ if (getStartOffset() <= offset && offset <= getEndOffset()) {
+ return this;
+ }
+
+ for (int i = 0; i < children.size(); i++) {
+ XmlNode node = children.get(i).getNodeFor(offset);
+
+ if (node != null) {
+ return node;
+ }
+ }
+
+ return null;
+ }
+
public XmlNode getParent() {
return parent;
}
public int getStartOffset() {
- return startToken.getLocation();
+ return startToken == null ? -1 : startToken.getLocation();
}
public Token getStartToken() {

Powered by Google App Engine
This is Rietveld 408576698