summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorJayaprakash Arthanareeswaran2012-02-02 05:33:41 (EST)
committer Mark Macdonald2012-02-13 10:36:56 (EST)
commit4795ea3bd2b9403ca171e35458350dc79fe6c61b (patch)
treea67eb7ea15d5fc2b5fceab77b786101c8e8293b2
parent724a1b4cb9a3e31b8cf8e9fcc82a0c18d8ddaa1a (diff)
downloadorg.eclipse.orion.client-4795ea3bd2b9403ca171e35458350dc79fe6c61b.zip
org.eclipse.orion.client-4795ea3bd2b9403ca171e35458350dc79fe6c61b.tar.gz
org.eclipse.orion.client-4795ea3bd2b9403ca171e35458350dc79fe6c61b.tar.bz2
Fix for bug 369289: Hook up CodeMirror error styles to annotation model in CodeMirrorStyler
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/mirror.js46
1 files changed, 44 insertions, 2 deletions
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/mirror.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/mirror.js
index cef9dda..b1f8dff 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/mirror.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/mirror.js
@@ -733,6 +733,10 @@ define("orion/editor/mirror", ["orion/textview/eventTarget"], function(mEventTar
modeApplier.highlight(lineIndex, Math.min(lineIndex + LINESTYLE_OVERSHOOT, lineCount - 1), true /*don't dispatch*/);
style = modeApplier.getLineStyle(lineIndex);
}
+
+ var min = Number.MAX_VALUE, max = -1;
+ var model = this.textView.getModel();
+
if (style) {
// Now we have a style for the line. It may not be correct in the case where lineIndex is at the end of a large
// buffer. But in that case, the highlight job kicked off by ModelChanged will eventually reach it and fix it up.
@@ -740,8 +744,46 @@ define("orion/editor/mirror", ["orion/textview/eventTarget"], function(mEventTar
if (rangesAndErrors) {
e.ranges = rangesAndErrors[0];
- // TODO: deal with error annotations in rangesAndErrors[1]
- // We should use code from aSyncStyler here
+ for (var i=0; i < e.ranges.length; i++) {
+ min = Math.min(min, model.getLineAtOffset(e.ranges[i].start));
+ max = Math.max(max, model.getLineAtOffset(e.ranges[i].end));
+ }
+
+ //console.debug("Got style for lines " + (min+1) + " to " + (max+1));
+ var annotationModel = this.annotationModel;
+ if (annotationModel) {
+ var toRemove = [];
+ var toAdd = [];
+
+ if (rangesAndErrors[1]) {
+ for (var i=0; i < rangesAndErrors[1].length; i++) {
+ var error = rangesAndErrors[1][i];
+ if (error.style.styleClass === "cm-error") {
+ toAdd.push({
+ start: error.start,
+ end: error.end,
+ type: "orion.annotation.highlightError",
+ title: "Syntax error.",
+ html: "<div class='annotationHTML error'></div>",
+ rangeStyle: {styleClass: "annotationRange error"}
+ });
+ }
+ }
+
+ }
+ min = Math.max(min, 0);
+ max = Math.min(max, model.getLineCount() -1);
+ var annos = annotationModel.getAnnotations(model.getLineStart(min), model.getLineEnd(max));
+ while (annos.hasNext()) {
+ var anno = annos.next();
+ if (anno.type === "orion.annotation.highlightError") {
+ toRemove.push(anno);
+ }
+ }
+ annotationModel.replaceAnnotations(toRemove, toAdd);
+ //console.debug("Redrawing lines " + (min+1) + " to " + (max+1));
+ this.textView.redrawLines(min, max+1);
+ }
}
}
},