当前位置: 首页>>代码示例>>Java>>正文


Java DocumentRewriteSessionType类代码示例

本文整理汇总了Java中org.eclipse.jface.text.DocumentRewriteSessionType的典型用法代码示例。如果您正苦于以下问题:Java DocumentRewriteSessionType类的具体用法?Java DocumentRewriteSessionType怎么用?Java DocumentRewriteSessionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DocumentRewriteSessionType类属于org.eclipse.jface.text包,在下文中一共展示了DocumentRewriteSessionType类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyAllInSameDocument

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
/**
 * Applies all given changes to the given document. This method assumes that 'changes' contains only changes
 * intended for the given document; the actual URI stored in the changes is ignored.
 */
public void applyAllInSameDocument(Collection<? extends IAtomicChange> changes, IDocument document)
		throws BadLocationException {
	DocumentRewriteSession rewriteSession = null;
	try {
		// prepare
		if (document instanceof IDocumentExtension4) {
			rewriteSession = ((IDocumentExtension4) document).startRewriteSession(
					DocumentRewriteSessionType.UNRESTRICTED);
		}
		// perform replacements
		for (IAtomicChange currRepl : changes) {
			currRepl.apply(document);
		}
	} finally {
		// cleanup
		if (rewriteSession != null)
			((IDocumentExtension4) document).stopRewriteSession(rewriteSession);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:ChangeManager.java

示例2: setDocumentText

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
/**
    * Sets text to a document
    * @param document
    * @param message
    * @param append
    * @throws BadLocationException
    * Has to be run from non-UI thread
    */
public static synchronized void setDocumentText(final Document document, final String message,
		final boolean append) {

	UIHelper.runUIAsync(new Runnable() {
		public void run() {
			try {
				DocumentRewriteSession rewriteSession;
				if (append && !isDefaultLabel(document)) {
					rewriteSession = document.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
					// append to existing document (0 length is valid and means message is going to be appended)
					document.replace(document.getLength(), 0, message + ((message.endsWith(CR)) ? EMPTY : CR));
				} else {
					rewriteSession = document.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
					// replace of complete document
					document.replace(0, document.getLength(), message + ((message.endsWith(CR)) ? EMPTY : CR));
				}
				document.stopRewriteSession(rewriteSession);
			} catch (BadLocationException ignored) {
			}
		}
	});
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:31,代码来源:TLCModelLaunchDataProvider.java

示例3: performEdits

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
/**
 * Executes the text edits on the given document. Subclasses that override this method should call
 * <code>super.performEdits(document)</code>.
 *
 * @param document the document
 * @return an object representing the undo of the executed edits
 * @exception MalformedTreeException is thrown if the edit tree isn't in a valid state. This
 *     exception is thrown before any edit is executed. So the document is still in its original
 *     state.
 * @exception BadLocationException is thrown if one of the edits in the tree can't be executed.
 *     The state of the document is undefined if this exception is thrown.
 * @since 3.5
 */
protected UndoEdit performEdits(IDocument document)
    throws BadLocationException, MalformedTreeException {
  DocumentRewriteSession session = null;
  try {
    if (document instanceof IDocumentExtension4) {
      session =
          ((IDocumentExtension4) document)
              .startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
    }

    LinkedModeModel.closeAllModels(document);
    TextEditProcessor processor = createTextEditProcessor(document, TextEdit.CREATE_UNDO, false);
    return processor.performEdits();

  } finally {
    if (session != null) {
      ((IDocumentExtension4) document).stopRewriteSession(session);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:TextChange.java

示例4: performEdits

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
protected UndoEdit performEdits(IDocument document) throws BadLocationException, MalformedTreeException {
	DocumentRewriteSession session= null;
	try {
		if (document instanceof IDocumentExtension4) {
			session= ((IDocumentExtension4)document).startRewriteSession(
				DocumentRewriteSessionType.UNRESTRICTED);
		}
		return undoEdit.apply(document);
	} finally {
		if (session != null) {
			((IDocumentExtension4)document).stopRewriteSession(session);
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:EditorDocumentUndoChange.java

示例5: startRewriteSession

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
public DocumentRewriteSession startRewriteSession(DocumentRewriteSessionType sessionType) {
  Object lockObject = getLockObject();
  if (lockObject == null) {
    return super.startRewriteSession(sessionType);
  }
  synchronized (lockObject) {
    return super.startRewriteSession(sessionType);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:SynchronizableDocument.java

示例6: performChangesInSynchronizationContext

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
private void performChangesInSynchronizationContext(
    final IDocument document, final LinkedList undoList, final boolean preview)
    throws BadLocationException {
  DocumentRewriteSession session = null;
  try {
    if (document instanceof IDocumentExtension4)
      session =
          ((IDocumentExtension4) document)
              .startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);

    for (final Iterator iterator = fChanges.iterator(); iterator.hasNext(); ) {
      final ComposableBufferChange change = (ComposableBufferChange) iterator.next();

      final UndoEdit edit =
          createTextEditProcessor(
                  change,
                  document,
                  undoList != null ? TextEdit.CREATE_UNDO : TextEdit.NONE,
                  preview)
              .performEdits();
      if (undoList != null) undoList.addFirst(edit);
    }

  } finally {
    if (session != null) ((IDocumentExtension4) document).stopRewriteSession(session);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:MultiStateTextFileChange.java

示例7: startWrite

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
/**
 * Starts a rewrite session (keep things in a single undo/redo)
 */
public static DocumentRewriteSession startWrite(IDocument doc) {
    if (doc instanceof IDocumentExtension4) {
        IDocumentExtension4 d = (IDocumentExtension4) doc;
        return d.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
    }
    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:11,代码来源:TextSelectionUtils.java

示例8: TagBasedTLCOutputIncrementalParser

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
public TagBasedTLCOutputIncrementalParser(Model model, int prio, boolean isTraceExplorer, Mode mode, final long size)
  {
// create the document
      document = new LargeTextStoreDocument(size);

      this.analyzer = new TagBasedTLCAnalyzer(document);
      this.source = new CachingTLCOutputSource(model, prio);

      // set up the partitioner
      FastPartitioner partitioner = new FastPartitioner(new TagBasedTLCOutputTokenScanner(),
              TagBasedTLCOutputTokenScanner.CONTENT_TYPES);
      partitioner.connect(document);
      document.setDocumentPartitioner(partitioner);
      

      // now register the listener, responsible for evaluating the partitioning information
      document.addDocumentPartitioningListener(new TLCOutputPartitionChangeListener(mode));

      /*
       *  Register the process source
       *  
       *  There are two different source registries, one for trace exploration
       *  and one for model checking. The source must be added to the
       *  appropriate registry.
       */
      if (isTraceExplorer)
      {
          TLCOutputSourceRegistry.getTraceExploreSourceRegistry().addTLCOutputSource(this.source);
      } else
      {
      	if (mode == Mode.BATCH) {
      		// TLC always appends to the document. Therefore, we can tell the
      		// document to use a more efficient rewrite mode which reduces the time
      		// taken to execute replace operations from minutes and hours to
      		// seconds.
		// Its down side is that the ResultPage is only updated when the
		// complete log file is fully parsed, whereas in incremental
		// mode, it (potentially) updates after each line.
      		document.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
      	}
      	
          TLCOutputSourceRegistry.getModelCheckSourceRegistry().addTLCOutputSource(this.source);
      }
  }
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:45,代码来源:TagBasedTLCOutputIncrementalParser.java

示例9: startRewriteSession

import org.eclipse.jface.text.DocumentRewriteSessionType; //导入依赖的package包/类
@Override
public DocumentRewriteSession startRewriteSession(DocumentRewriteSessionType sessionType)
        throws IllegalStateException {
    throw new RuntimeException("not implemented");
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:6,代码来源:DocCopy.java


注:本文中的org.eclipse.jface.text.DocumentRewriteSessionType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。