Skip to content
Browse files

Remove dead code visualization/annotations when the live evaluator is…

… off.
  • Loading branch information...
1 parent 5b09f5b commit 4609d0d4611e4b12c2cadc797188ecfa48f3aa01 @neonux committed Apr 2, 2012
Showing with 16 additions and 0 deletions.
  1. +8 −0 content/LiveEvaluator.jsm
  2. +8 −0 content/LiveEvaluatorUI.jsm
View
8 content/LiveEvaluator.jsm
@@ -115,12 +115,14 @@ LiveEvaluator.prototype = {
if (this._editor) {
this._editor.removeEventListener(this._editor.EVENTS.TEXT_CHANGED,
this._onTextChangeBinding);
+ this._triggerObservers("EditorDetach");
}
this._editor = aEditor;
if (this._editor) {
this._window = this._editor.editorElement.ownerDocument.defaultView;
+ this._triggerObservers("EditorAttach");
this._editor.addEventListener(this._editor.EVENTS.TEXT_CHANGED,
this._onTextChangeBinding);
}
@@ -294,6 +296,12 @@ LiveEvaluator.prototype = {
* Add an observer for LiveEvaluator events.
*
* The observer implements ILiveEvaluatorObserver := {
+ * onEditorAttach Called when an editor has been attached.
+ * Arguments: (LiveEvaluator aEvaluator)
+ *
+ * onEditorDetach Called when an editor has been detached.
+ * Arguments: (LiveEvaluator aEvaluator)
+ *
* onStartEvaluation: Called when an evaluation starts.
* Arguments: (LiveEvaluator aEvaluator)
*
View
8 content/LiveEvaluatorUI.jsm
@@ -362,6 +362,14 @@ LiveEvaluatorUI.prototype =
/* ILiveEvaluatorObserver implementation */
/* @see LiveEvaluator.addObserver */
+ onEditorDetach: function LEO_onEditorDetach(aEvaluator)
+ {
+ if (this._annotationAdded) {
+ let annotationModel = aEvaluator.editor._annotationModel;
+ annotationModel.removeAnnotations(DEADCODE_ANNOTATION);
+ }
+ },
+
onStartEvaluation: function LEO_onStartEvaluation(aEvaluator, aNode)
{
delete this._root.dataset.abortReason;

0 comments on commit 4609d0d

Please sign in to comment.
Something went wrong with that request. Please try again.