use of org.eclipse.jface.text.BadPositionCategoryException in project erlide_eclipse by erlang.
the class ErlangBracketInserter method left.
/*
* @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.
* jface.text.link.LinkedModeModel, int)
*/
@Override
@SuppressWarnings("synthetic-access")
public void left(final LinkedModeModel environment, final int flags) {
final BracketLevel level = fBracketLevelStack.pop();
if (flags != ILinkedModeListener.EXTERNAL_MODIFICATION) {
return;
}
// remove brackets
final IDocument document = sourceViewer.getDocument();
if (document instanceof IDocumentExtension) {
final IDocumentExtension extension = (IDocumentExtension) document;
extension.registerPostNotificationReplace(null, (d, owner) -> {
if ((level.fFirstPosition.isDeleted || level.fFirstPosition.length == 0) && !level.fSecondPosition.isDeleted && level.fSecondPosition.offset == level.fFirstPosition.offset) {
try {
document.replace(level.fSecondPosition.offset, level.fSecondPosition.length, // $NON-NLS-1$
"");
} catch (final BadLocationException e1) {
ErlLogger.error(e1);
}
}
if (fBracketLevelStack.isEmpty()) {
document.removePositionUpdater(fUpdater);
try {
document.removePositionCategory(CATEGORY);
} catch (final BadPositionCategoryException e2) {
ErlLogger.error(e2);
}
}
});
}
}
Aggregations