/** * Called when document changes. Marks the document dirty and schedules the parsing job. * * <p>When we return from here this.isDirty must remain true until new parseJob has finished. * * <p>If the previous parseJob is not cancelled immediately (parseJob.cancel() returns false) a * smarter way to calculate the next scheduling delay could be used. However we should not spend * much time in documentChanged() */ public void documentChanged(DocumentEvent event) { // set isDirty true and prevent possibly running parseJob from // changing it back to false // order of acquire, cancel and setDirty matters! try { lock.acquire(); parseJob.cancel(); this.setDirty(true); } finally { lock.release(); } // if parseJob was running, now it is either cancelled or it will // be before it tries setDirty(false) // inform outline that model is dirty TexOutlinePage outline = editor.getOutlinePage(); if (outline != null) { editor.getOutlinePage().modelGotDirty(); } TexOutlineTreeView fullOutline = editor.getFullOutline(); if (fullOutline != null) { fullOutline.modelGotDirty(); } // reschedule parsing with delay if (autoParseEnabled) { parseJob.schedule(parseDelay); } }
private void parse(boolean force) { if (!force) { if (_parseJob.isScheduled() || _parseJob.isRunning()) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Parse scheduled or active, skipping"); return; } } else { if (LOGGER.isDebugEnabled()) LOGGER.debug("Canceling.."); if (_compileJob != null) _compileJob.cancel(); if (_parseJob != null) _parseJob.cancel(); } if (LOGGER.isDebugEnabled()) LOGGER.debug("Scheduling parse"); _parseJob.schedule(200); }
/** * Cancels possibly running parseJob and schedules it to run again immediately. * * <p>Called when new outline is created, so it is quite likely that there is no parseJob running. * * <p>If parseJob were running we could maybe use isDirty to figure out if it would be smarter to * wait for the running parseJob. */ public void updateNow() { parseJob.cancel(); parseJob.schedule(); }