Refine search
/** * Returns <code>true</code> if <code>region</code> contains <code>position</code>. * * @param region a region * @param position an offset * @return <code>true</code> if <code>region</code> contains <code>position</code> * @since 3.2 */ private boolean contains(IRegion region, int position) { int offset= region.getOffset(); return offset <= position && position < offset + region.getLength(); }
/** * Configures this document iterator with the document section to be visited. * * @param document the document to be iterated * @param iteratorRange the range in the document to be iterated */ public void setDocument(IDocument document, IRegion iteratorRange) { fDocument= document; fOffset= iteratorRange.getOffset(); fEndOffset= fOffset + iteratorRange.getLength(); }
/** * @param p * @param region * @return true if p overlaps with region, or if region is null */ private boolean intersectsRegion(Position p, IRegion region) { if (region==null) return true; if (p.offset > region.getOffset()+region.getLength()) return false; if (p.offset+p.length < region.getOffset()) return false; return true; }
/** * Advances this cursor to the next import in the original order. */ void advance() { IRegion declarationAndComments = this.currentOriginalImport.declarationAndComments; this.currentPosition = declarationAndComments.getOffset() + declarationAndComments.getLength(); this.currentOriginalImport = this.originalImportIterator.hasNext() ? this.originalImportIterator.next() : null; } }
@Override public void documentPartitioningChanged(IDocument document, IRegion changedRegion) { if (!fDocumentChanging && fCachedRedrawState) { processDamage(new Region(changedRegion.getOffset(), changedRegion.getLength()), document); } else { fDocumentPartitioningChanged= true; fChangedDocumentPartitions= changedRegion; } }
/** * Creates a folding position that remembers its member from an * {@link #alignRegion(IRegion, DefaultJavaFoldingStructureProvider.FoldingStructureComputationContext) aligned} * region. * * @param aligned an aligned region * @param member the member to remember * @return a folding position corresponding to <code>aligned</code> */ protected final Position createMemberPosition(IRegion aligned, IMember member) { return new JavaElementPosition(aligned.getOffset(), aligned.getLength(), member); }
private static ReplaceEdit[] splitIntersectLeft(ReplaceEdit edit, IRegion intersect) { ReplaceEdit[] result= new ReplaceEdit[2]; result[0]= new ReplaceEdit(intersect.getOffset(), intersect.getLength(), edit.getText()); result[1]= new ReplaceEdit( // this is the actual delete. We use replace to only deal with one type intersect.getOffset() + intersect.getLength(), edit.getLength() - intersect.getLength(), ""); //$NON-NLS-1$ return result; }
private static IRegion getAttributeRegion(IDocument document, String value, int offset) { try { FindReplaceDocumentAdapter findReplaceAdapter = new FindReplaceDocumentAdapter(document); IRegion nameRegion = findReplaceAdapter.find(offset, value, true, true, false, false); if (nameRegion != null) { if (document.get(nameRegion.getOffset() + nameRegion.getLength() - value.length(), value.length()).equals(value)) return new Region(nameRegion.getOffset() + nameRegion.getLength() - value.length(), value.length()); } } catch (BadLocationException e) { } return null; }
public String[] getArguments() { String prefix= ""; //$NON-NLS-1$ String postfix= ""; //$NON-NLS-1$ try { IRegion line= fDocument.getLineInformationOfOffset(fSourceStart); prefix= fDocument.get(line.getOffset(), fSourceStart - line.getOffset()); postfix= fDocument.get(fSourceEnd + 1, line.getOffset() + line.getLength() - fSourceEnd); } catch (BadLocationException exception) { // Do nothing } return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false), fMatch ? Boolean.toString(true) : Boolean.toString(false) }; }
protected FoldedPosition newFoldedPosition(IRegion region, ITextRegion significantRegion) { if (region == null) return null; if (significantRegion != null) return new DefaultFoldedPosition(region.getOffset(), region.getLength(), significantRegion.getOffset() - region.getOffset(), significantRegion.getLength()); return new DefaultFoldedPosition(region.getOffset(), region.getLength(), DefaultFoldedPosition.UNSET, DefaultFoldedPosition.UNSET); }
private static ASTNode getHoveredASTNode(ITypeRoot editorInputElement, IRegion hoverRegion) { if (editorInputElement == null) return null; CompilationUnit unit= SharedASTProviderCore.getAST(editorInputElement, SharedASTProviderCore.WAIT_ACTIVE_ONLY, null); if (unit == null) return null; return NodeFinder.perform(unit, hoverRegion.getOffset(), hoverRegion.getLength()); }
private void repairRepresentation() { if (fActiveRegion == null) return; int offset= fActiveRegion.getOffset(); int length= fActiveRegion.getLength(); fActiveRegion= null; // Invalidate ==> remove applied text presentation if (fTextViewer instanceof ITextViewerExtension2) ((ITextViewerExtension2) fTextViewer).invalidateTextPresentation(offset, length); else fTextViewer.invalidateTextPresentation(); }