@Override public IRegion getSubject(ITextViewer textViewer, int offset) { if (textViewer != null) return JavaWordFinder.findWord(textViewer.getDocument(), offset); return null; }
public IRegion getSubject(ITextViewer textViewer, int offset) { if (textViewer != null) return JavaWordFinder.findWord(textViewer.getDocument(), offset); return null; }
@Override public IRegion getSubject(ITextViewer textViewer, int offset) { if (textViewer != null) return JavaWordFinder.findWord(textViewer.getDocument(), offset); return null; }
public IRegion getHoverRegion(ITextViewer textViewer, int offset) { if (textViewer != null) { return JavaWordFinder.findWord(textViewer.getDocument(), offset); } return null; }
@Override public int getLineOfLastMouseButtonActivity() { if (fLastMouseButtonActivityLine == -1) fLastMouseButtonActivityLine= toDocumentLineNumber(fLocation.y); else if (fTextViewer.getDocument() == null || fLastMouseButtonActivityLine >= fTextViewer.getDocument().getNumberOfLines()) fLastMouseButtonActivityLine= -1; return fLastMouseButtonActivityLine; }
@Override public void uninstall() { fViewer.removeTextInputListener(fInternalListener); // Ensure we uninstall all listeners fInternalListener.inputDocumentAboutToBeChanged(fViewer.getDocument(), null); }
public IContextInformation[] computeContextInformation(final ITextViewer viewer, final int offset) { if (contextInformationProvider == null) return null; IXtextDocument document = (IXtextDocument) viewer.getDocument(); return document.readOnly(createContextInformationComputer(viewer, offset)); }
@Override public void connect(ITextViewer textViewer) { if (fTextViewer == null && textViewer != null) { fTextViewer= textViewer; addListeners(); } IDocument doc= fTextViewer.getDocument(); connectDocumentUndoManager(doc); }
/** * @see IDataDisplay#clear() */ public void clear() { IDocument document= getTextViewer().getDocument(); if (document != null) { document.set(""); //$NON-NLS-1$ } }
public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) { if ((hoverRegion == null) || (viewer == null) || (viewer.getDocument() == null)) { return null; } String displayText = null; int documentOffset = hoverRegion.getOffset(); displayText = computeHoverHelp(viewer, documentOffset); return displayText; }
public IRegion getSubject(ITextViewer textViewer, int offset) { if (textViewer != null && fEditor != null) { IRegion region= JavaWordFinder.findWord(textViewer.getDocument(), offset); if (region != null) return region; else return new Region(offset, 0); } return null; }
private String getPrefix(ITextViewer viewer, int offset) throws BadLocationException { IDocument doc= viewer.getDocument(); if (doc == null || offset > doc.getLength()) return null; int length= 0; while (--offset >= 0 && Character.isJavaIdentifierPart(doc.getChar(offset))) length++; return doc.get(offset + 1, length); }
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { if (contentProposalProvider == null) return null; IXtextDocument document = (IXtextDocument) viewer.getDocument(); ICompletionProposal[] result = document.readOnly(createCompletionProposalComputer(viewer, offset)); Arrays.sort(result, completionProposalComparator); result = completionProposalPostProcessor.postProcess(result); return result; }
public String getHoverInfo(ITextViewer textViewer, IRegion region) { try { IDocument doc = textViewer.getDocument(); String text = doc.get(region.getOffset(), region.getLength()); return "<b>"+text+"</b>"; } catch (Exception e) { return null; } }
private void restorePosition() { if (fPosition != null && !fPosition.isDeleted() && fViewer.getDocument() != null) { fViewer.setSelectedRange(fPosition.offset, fPosition.length); fViewer.revealRange(fPosition.offset, fPosition.length); } fPosition= null; }
private boolean controlUndoBehavior(int offset, int length) { LinkedPosition position= fModel.findPosition(new LinkedPosition(fCurrentTarget.getViewer().getDocument(), offset, length, LinkedPositionGroup.NO_STOP)); if (position != null) { // if the last position is not the same and there is an open change: close it. if (!position.equals(fPreviousPosition)) endCompoundChangeIfNeeded(); beginCompoundChangeIfNeeded(); } fPreviousPosition= position; return fPreviousPosition != null; }
/** * Determines the current prefix that should be used for completion. */ private String getCurrentPrefix() { if (currentPrefix != null) { return currentPrefix; } ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection(); IDocument doc = viewer.getDocument(); return getPrefixFromDocument(doc.get(), selection.getOffset() + selection.getLength()).toLowerCase(); }
@Override public void doubleClicked(ITextViewer text) { int offset= text.getSelectedRange().x; if (offset < 0) return; final IDocument document= text.getDocument(); IRegion region= findExtendedDoubleClickSelection(document, offset); if (region == null) region= findWord(document, offset); if (region != null) text.setSelectedRange(region.getOffset(), region.getLength()); }
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) { this.setReplacementLength(offset - getReplacementOffset() + viewer.getSelectedRange().y); boolean replaceRight = (stateMask & SWT.CTRL) != 0; if (replaceRight) { setReplacementLength(getReplaceContextLength()); } apply(viewer.getDocument()); }
@Override public void doubleClicked(ITextViewer text) { int offset= text.getSelectedRange().x; if (offset < 0) return; final IDocument document= text.getDocument(); IRegion region= findExtendedDoubleClickSelection(document, offset); if (region == null) region= findWord(document, offset); if (region != null) text.setSelectedRange(region.getOffset(), region.getLength()); }