private int rank(LinkedPosition o1) { int relativeRank = o1.getOffset() + o1.length - invocationOffset; if (relativeRank < 0) return Integer.MAX_VALUE + relativeRank; else return relativeRank; } };
public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException { return new ReplaceEdit(position.getOffset(), position.getLength(), fDisplayString); } }
/** * Returns the currently selected region or <code>null</code>. * * @return the currently selected region or <code>null</code> */ public IRegion getSelectedRegion() { if (fFramePosition != null) return new Region(fFramePosition.getOffset(), fFramePosition.getLength()); if (fExitPosition != null) return new Region(fExitPosition.getOffset(), fExitPosition.getLength()); return null; }
/** * Returns the currently selected region or <code>null</code>. * * @return the currently selected region or <code>null</code> */ public IRegion getSelectedRegion() { if (fFramePosition != null) return new Region(fFramePosition.getOffset(), fFramePosition.getLength()); if (fExitPosition != null) return new Region(fExitPosition.getOffset(), fExitPosition.getLength()); return null; }
@SuppressWarnings("unused") public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException { return new ReplaceEdit(position.getOffset(), position.getLength(), fDisplayString); } }
public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException { return new ReplaceEdit(position.getOffset(), position.getLength(), fDisplayString); } }
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) { if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) { LinkedPosition position= model.findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP)); if (position != null) { if (event.character == SWT.BS) { if (offset - 1 < position.getOffset()) { //skip backspace at beginning of linked position event.doit= false; } } else /* event.character == SWT.DEL */ { if (offset + 1 > position.getOffset() + position.getLength()) { //skip delete at end of linked position event.doit= false; } } } } return null; // don't change behavior } }
/** * Checks whether the given event touches the given position. To touch means * to overlap or come up to the borders of the position. * * @param position the position * @param event the event * @return <code>true</code> if <code>position</code> and * <code>event</code> are not absolutely disjoint * @since 3.1 */ private boolean overlapsOrTouches(LinkedPosition position, DocumentEvent event) { return position.getDocument().equals(event.getDocument()) && position.getOffset() <= event.getOffset() + event.getLength() && position.getOffset() + position.getLength() >= event.getOffset(); }
/** * Checks whether the given event touches the given position. To touch means * to overlap or come up to the borders of the position. * * @param position the position * @param event the event * @return <code>true</code> if <code>position</code> and * <code>event</code> are not absolutely disjoint * @since 3.1 */ private boolean overlapsOrTouches(LinkedPosition position, DocumentEvent event) { return position.getDocument().equals(event.getDocument()) && position.getOffset() <= event.getOffset() + event.getLength() && position.getOffset() + position.getLength() >= event.getOffset(); }
/** * Returns whether this position includes <code>position</code>. * * @param position the position to check. * @return <code>true</code> if this position includes * <code>position</code>,<code>false</code> otherwise */ public boolean includes(LinkedPosition position) { return includes(position.getDocument(), position.getOffset(), position.getLength()); }
/** * Returns whether this position overlaps with <code>position</code>. * * @param position the position to check. * @return <code>true</code> if this position overlaps with * <code>position</code>,<code>false</code> otherwise */ public boolean overlapsWith(LinkedPosition position) { return position.getDocument() == fDocument && overlapsWith(position.getOffset(), position.getLength()); }
/** * Returns whether this position includes <code>position</code>. * * @param position the position to check. * @return <code>true</code> if this position includes * <code>position</code>,<code>false</code> otherwise */ public boolean includes(LinkedPosition position) { return includes(position.getDocument(), position.getOffset(), position.getLength()); }
/** * Returns whether this position overlaps with <code>position</code>. * * @param position the position to check. * @return <code>true</code> if this position overlaps with * <code>position</code>,<code>false</code> otherwise */ public boolean overlapsWith(LinkedPosition position) { return position.getDocument() == fDocument && overlapsWith(position.getOffset(), position.getLength()); }
@Override public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException { ImportRewrite impRewrite= CodeStyleConfiguration.createImportRewrite(fCompilationUnit, true); String replaceString= impRewrite.addImport(fTypeProposal); MultiTextEdit composedEdit= new MultiTextEdit(); composedEdit.addChild(new ReplaceEdit(position.getOffset(), position.getLength(), replaceString)); composedEdit.addChild(impRewrite.rewriteImports(null)); return composedEdit; } }
public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException { ImportRewrite impRewrite= StubUtility.createImportRewrite(fCompilationUnit, true); String replaceString= impRewrite.addImport(fTypeProposal); MultiTextEdit composedEdit= new MultiTextEdit(); composedEdit.addChild(new ReplaceEdit(position.getOffset(), position.getLength(), replaceString)); composedEdit.addChild(impRewrite.rewriteImports(null)); return composedEdit; } }
@Override public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException { ImportRewrite impRewrite= CodeStyleConfiguration.createImportRewrite(fCompilationUnit, true); String replaceString= impRewrite.addImport(fTypeProposal); MultiTextEdit composedEdit= new MultiTextEdit(); composedEdit.addChild(new ReplaceEdit(position.getOffset(), position.getLength(), replaceString)); composedEdit.addChild(impRewrite.rewriteImports(null)); return composedEdit; } }
@Override public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException { ImportRewrite impRewrite= StubUtility.createImportRewrite(fCompilationUnit, true); String replaceString= impRewrite.addImport(fTypeProposal); MultiTextEdit composedEdit= new MultiTextEdit(); composedEdit.addChild(new ReplaceEdit(position.getOffset(), position.getLength(), replaceString)); composedEdit.addChild(impRewrite.rewriteImports(null)); return composedEdit; } }
@Override public void documentAboutToBeChanged(DocumentEvent event) { // default behavior: any document change outside a linked position // causes us to exit int end= event.getOffset() + event.getLength(); for (int offset= event.getOffset(); offset <= end; offset++) { if (!fModel.anyPositionContains(offset)) { ITextViewer viewer= fCurrentTarget.getViewer(); if (fFramePosition != null && viewer instanceof IEditingSupportRegistry) { IEditingSupport[] helpers= ((IEditingSupportRegistry) viewer).getRegisteredSupports(); for (int i= 0; i < helpers.length; i++) { if (helpers[i].isOriginator(null, new Region(fFramePosition.getOffset(), fFramePosition.getLength()))) return; } } leave(ILinkedModeListener.EXTERNAL_MODIFICATION); return; } } // Make sure that any document change is done inside a compound change beginCompoundChangeIfNeeded(); }