下面列出了org.eclipse.jface.text.IDocument#containsPositionCategory ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void partClosed(IWorkbenchPartReference partRef) {
if (partRef instanceof IEditorReference) {
IEditorPart epart = ((IEditorReference) partRef).getEditor(false);
ITextEditor editor = (location != null ? location.getEditor() : null);
if (editor == EmacsPlusUtils.getTextEditor(epart, false)) {
RegisterLocation loc = location;
// we're out of here
removeListener(this);
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
// remove position category, if still present
if (document.containsPositionCategory(MarkRing.MARK_CATEGORY)) {
try {
document.removePositionUpdater(MarkRing.updater);
document.removePositionCategory(MarkRing.MARK_CATEGORY);
} catch (BadPositionCategoryException e) {
}
}
// convert to path
loc.setPath(convertToPath(editor));
}
}
}
/**
* Positions created for template contexts have to be added to the document so they are updated when the document
* is modified.
*
* @since 2.8
*/
protected Position createPosition(ContentAssistContext context) {
Position position = new Position(context.getReplaceRegion().getOffset(), context.getReplaceRegion().getLength());
IDocument document = context.getDocument();
if (document.containsPositionCategory(XTEXT_TEMPLATE_POS_CATEGORY)) {
try {
document.addPosition(XTEXT_TEMPLATE_POS_CATEGORY, position);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
return position;
}
private void ensurePositionCategoryRemoved(IDocument document) {
if (document.containsPositionCategory(getCategory())) {
try {
document.removePositionCategory(getCategory());
} catch (BadPositionCategoryException e) {
// ignore
}
document.removePositionUpdater(fUpdater);
}
}
private void ensurePositionCategoryRemoved(IDocument document)
{
if (document.containsPositionCategory(getCategory()))
{
try
{
document.removePositionCategory(getCategory());
}
catch (BadPositionCategoryException e)
{
// ignore
}
document.removePositionUpdater(fUpdater);
}
}
private void ensurePositionCategoryRemoved(IDocument document) {
if (document.containsPositionCategory(getCategory())) {
try {
document.removePositionCategory(getCategory());
} catch (BadPositionCategoryException e) {
// ignore
}
document.removePositionUpdater(fUpdater);
}
}
private void ensurePositionCategoryRemoved(IDocument document) {
if (document.containsPositionCategory(getCategory())) {
try {
document.removePositionCategory(getCategory());
} catch (BadPositionCategoryException e) {
// ignore
}
document.removePositionUpdater(fUpdater);
}
}
/**
* Remove the document's mark buffer from the local Mark list
* Also, remove the position updating information from the document
*
* @param document
*/
static void removeMarks(IDocument document) {
MarkList local = localMarks.remove(document);
if (local != null || document.containsPositionCategory(MARK_CATEGORY)) {
document.removePositionUpdater(updater);
try {
// this also removes all the positions
document.removePositionCategory(MARK_CATEGORY);
} catch (BadPositionCategoryException e) {
}
}
}
public List<HighlightedPositionCore> reconciled(IDocument document, ASTNode ast, boolean forced, IProgressMonitor progressMonitor) throws BadPositionCategoryException {
// ensure at most one thread can be reconciling at any time
synchronized (fReconcileLock) {
if (fIsReconciling) {
return emptyList();
} else {
fIsReconciling= true;
}
}
fJobPresenter= fPresenter;
fJobSemanticHighlightings= fSemanticHighlightings;
fJobHighlightings= fHighlightings;
try {
if (ast == null) {
return emptyList();
}
ASTNode[] subtrees= getAffectedSubtrees(ast);
if (subtrees.length == 0) {
return emptyList();
}
startReconcilingPositions();
if (!fJobPresenter.isCanceled()) {
fJobDeprecatedMemberHighlighting= null;
for (int i= 0, n= fJobSemanticHighlightings.length; i < n; i++) {
SemanticHighlightingCore semanticHighlighting= fJobSemanticHighlightings[i];
if (semanticHighlighting instanceof DeprecatedMemberHighlighting) {
fJobDeprecatedMemberHighlighting = fJobHighlightings.get(i);
break;
}
}
reconcilePositions(subtrees);
}
// We need to manually install the position category
if (!document.containsPositionCategory(fPresenter.getPositionCategory())) {
document.addPositionCategory(fPresenter.getPositionCategory());
}
updatePresentation(document, fAddedPositions, fRemovedPositions);
stopReconcilingPositions();
Position[] positions = document.getPositions(fPresenter.getPositionCategory());
for (Position position : positions) {
Preconditions.checkState(position instanceof HighlightedPositionCore);
}
return FluentIterable.from(Arrays.asList(positions)).filter(HighlightedPositionCore.class).toList();
} finally {
fJobPresenter= null;
fJobSemanticHighlightings= null;
fJobHighlightings= null;
fJobDeprecatedMemberHighlighting= null;
synchronized (fReconcileLock) {
fIsReconciling= false;
}
}
}