public void recalculate() { myApplianceManager.reset(); myStorage.removeAll(); myDeferredFoldRegions.clear(); myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); myApplianceManager.recalculateIfNecessary(); }
/** * We know that there are problems with incremental soft wraps cache update at the moment. Hence, * we may implement full cache reconstruction when the problem is encountered in order to avoid * customer annoyance. * * <p>However, the problems still should be fixed, hence, we report them only if dedicated flag is * set. * * <p>Current method encapsulates the logic mentioned above. * * @param task command object that which execution may trigger incremental update of update soft * wraps cache */ @SuppressWarnings({"UseOfArchaicSystemPropertyAccessors"}) private void executeSafely(SoftWrapAwareTask task) { try { task.run(true); } catch (Throwable e) { if (Boolean.getBoolean(DEBUG_PROPERTY_NAME) || ApplicationManager.getApplication().isUnitTestMode()) { String info = myEditor.dumpState(); LOG.error( String.format("Unexpected exception occurred during performing '%s'", task), e, info); } myEditor.getFoldingModel().rebuild(); myDataMapper.release(); myApplianceManager.reset(); myStorage.removeAll(); myApplianceManager.recalculateIfNecessary(); try { task.run(true); } catch (Throwable e1) { String info = myEditor.dumpState(); LOG.error( String.format("Can't perform %s even with complete soft wraps cache re-parsing", task), e1, info); myEditor.getSettings().setUseSoftWraps(false); task.run(false); } } }
@Override public void release() { myDataMapper.release(); myApplianceManager.release(); myStorage.removeAll(); myDeferredFoldRegions.clear(); }
/** * Called on editor settings change. Current model is expected to drop all cached information * about the settings if any. */ public void reinitSettings() { boolean softWrapsUsedBefore = myUseSoftWraps; myUseSoftWraps = areSoftWrapsEnabledInEditor(); int tabWidthBefore = myTabWidth; myTabWidth = EditorUtil.getTabSize(myEditor); boolean fontsChanged = false; if (!myFontPreferences.equals(myEditor.getColorsScheme().getFontPreferences()) && myEditorTextRepresentationHelper instanceof DefaultEditorTextRepresentationHelper) { fontsChanged = true; myEditor.getColorsScheme().getFontPreferences().copyTo(myFontPreferences); ((DefaultEditorTextRepresentationHelper) myEditorTextRepresentationHelper) .clearSymbolWidthCache(); myPainter.reinit(); } if ((myUseSoftWraps ^ softWrapsUsedBefore) || (tabWidthBefore >= 0 && myTabWidth != tabWidthBefore) || fontsChanged) { myApplianceManager.reset(); myDeferredFoldRegions.clear(); myStorage.removeAll(); myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); } }
/** * We know that there are problems with incremental soft wraps cache update at the moment. Hence, * we may implement full cache reconstruction when the problem is encountered in order to avoid * customer annoyance. * * <p>However, the problems still should be fixed, hence, we report them only if dedicated flag is * set. * * <p>Current method encapsulates the logic mentioned above. * * @param task command object that which execution may trigger incremental update of update soft * wraps cache */ @SuppressWarnings({"UseOfArchaicSystemPropertyAccessors"}) private void executeSafely(SoftWrapAwareTask task) { try { task.run(true); } catch (Throwable e) { if (Boolean.getBoolean(DEBUG_PROPERTY_NAME)) { LOG.error( String.format( "Unexpected exception occurred during performing '%s'. Current soft wraps cache: %n" + "%s%nFold regions: %s", task, myDataMapper, Arrays.toString(myEditor.getFoldingModel().fetchTopLevel())), e); } myEditor.getFoldingModel().rebuild(); myDataMapper.release(); myApplianceManager.reset(); myStorage.removeAll(); try { task.run(true); } catch (Throwable e1) { LOG.error( String.format( "Can't perform %s even with complete soft wraps cache re-parsing. Current soft wraps cache: %n" + "%s. Document:%n%s%nFold regions: %s", task, myDataMapper, myEditor.getDocument().getText(), Arrays.toString(myEditor.getFoldingModel().fetchTopLevel())), e1); myEditor.getSettings().setUseSoftWraps(false); task.run(false); } } }
/** * Encapsulates preparations for performing document dimension mapping (e.g. visual to logical * position) and answers if soft wraps-aware processing should be used (e.g. there is no need to * consider soft wraps if user configured them not to be used). * * @return <code>true</code> if soft wraps-aware processing should be used; <code>false</code> * otherwise */ public boolean prepareToMapping() { if (myUpdateInProgress || myBulkUpdateInProgress || myActive > 0 || !isSoftWrappingEnabled() || myEditor.getDocument().getTextLength() <= 0) { return false; } if (myDirty) { myStorage.removeAll(); myApplianceManager.reset(); myDeferredFoldRegions.clear(); myDirty = false; } return myApplianceManager.recalculateIfNecessary(); }
public void recalculate() { myApplianceManager.reset(); myStorage.removeAll(); myDeferredFoldRegions.clear(); myApplianceManager.recalculateIfNecessary(); }