Search in sources :

Example 1 with DocumentRewriteSessionEvent

use of org.eclipse.jface.text.DocumentRewriteSessionEvent in project webtools.sourceediting by eclipse.

the class BasicStructuredDocument method internalStartRewriteSession.

/**
 * NOT-API. Final protected so clients may call this method if needed, but
 * cannot override.
 *
 * @param sessionType
 * @return
 * @throws IllegalStateException
 */
protected final DocumentRewriteSession internalStartRewriteSession(DocumentRewriteSessionType sessionType) throws IllegalStateException {
    if (getActiveRewriteSession() != null)
        throw new IllegalStateException("already in a rewrite session");
    DocumentRewriteSession session = new StructuredDocumentRewriteSession(sessionType);
    DocumentRewriteSessionEvent event = new DocumentRewriteSessionEvent(this, session, DocumentRewriteSessionEvent.SESSION_START);
    fireDocumentRewriteSessionEvent(event);
    ILineTracker tracker = getTracker();
    if (tracker instanceof ILineTrackerExtension) {
        ILineTrackerExtension extension = (ILineTrackerExtension) tracker;
        extension.startRewriteSession(session);
    }
    startRewriteSessionOnPartitioners(session);
    if (DocumentRewriteSessionType.SEQUENTIAL == sessionType)
        startSequentialRewrite(false);
    else if (DocumentRewriteSessionType.STRICTLY_SEQUENTIAL == sessionType)
        startSequentialRewrite(true);
    fActiveRewriteSession = session;
    return session;
}
Also used : ILineTrackerExtension(org.eclipse.jface.text.ILineTrackerExtension) DocumentRewriteSession(org.eclipse.jface.text.DocumentRewriteSession) DocumentRewriteSessionEvent(org.eclipse.jface.text.DocumentRewriteSessionEvent) ILineTracker(org.eclipse.jface.text.ILineTracker)

Example 2 with DocumentRewriteSessionEvent

use of org.eclipse.jface.text.DocumentRewriteSessionEvent in project webtools.sourceediting by eclipse.

the class BasicStructuredDocument method internalStopRewriteSession.

/**
 * NOT-API. Final protected so clients may call this method if needed, but
 * cannot override.
 *
 * @param session
 */
protected final void internalStopRewriteSession(DocumentRewriteSession session) {
    if (fActiveRewriteSession == session) {
        DocumentRewriteSessionType sessionType = session.getSessionType();
        if (DocumentRewriteSessionType.SEQUENTIAL == sessionType || DocumentRewriteSessionType.STRICTLY_SEQUENTIAL == sessionType)
            stopSequentialRewrite();
        stopRewriteSessionOnPartitioners(session);
        ILineTracker tracker = getTracker();
        if (tracker instanceof ILineTrackerExtension) {
            ILineTrackerExtension extension = (ILineTrackerExtension) tracker;
            extension.stopRewriteSession(session, get());
        }
        fActiveRewriteSession = null;
        DocumentRewriteSessionEvent event = new DocumentRewriteSessionEvent(this, session, DocumentRewriteSessionEvent.SESSION_STOP);
        fireDocumentRewriteSessionEvent(event);
    }
}
Also used : ILineTrackerExtension(org.eclipse.jface.text.ILineTrackerExtension) DocumentRewriteSessionType(org.eclipse.jface.text.DocumentRewriteSessionType) DocumentRewriteSessionEvent(org.eclipse.jface.text.DocumentRewriteSessionEvent) ILineTracker(org.eclipse.jface.text.ILineTracker)

Aggregations

DocumentRewriteSessionEvent (org.eclipse.jface.text.DocumentRewriteSessionEvent)2 ILineTracker (org.eclipse.jface.text.ILineTracker)2 ILineTrackerExtension (org.eclipse.jface.text.ILineTrackerExtension)2 DocumentRewriteSession (org.eclipse.jface.text.DocumentRewriteSession)1 DocumentRewriteSessionType (org.eclipse.jface.text.DocumentRewriteSessionType)1