/** * Sets the tag position if one is associated with the NLS element. * * @param start the start offset * @param length the length */ public void setTagPosition(int start, int length) { fTagPosition= new Region(start, length); }
public NLSElement(String value, int start, int length, int index, boolean isEclipseNLS) { fValue= value; fIndex= index; Assert.isNotNull(fValue); fPosition= new Region(start, length); fIsEclipseNLS= isEclipseNLS; }
/** * Sets the specified range as changed region for the given partitioning. * * @param partitioning the partitioning * @param offset the region offset * @param length the region length */ public void setPartitionChange(String partitioning, int offset, int length) { Assert.isNotNull(partitioning); fMap.put(partitioning, new Region(offset, length)); }
/** * @see org.eclipse.jdt.core.formatter.CodeFormatter#format(int, java.lang.String, int, int, int, java.lang.String) */ @Override public TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator) { return format(kind, source, new IRegion[] { new Region(offset, length) }, indentationLevel, lineSeparator); }
/** * @see org.eclipse.jdt.core.formatter.CodeFormatter#format(int, java.lang.String, int, int, int, java.lang.String) */ public TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator) { return format(kind, source, new IRegion[] { new Region(offset, length) }, indentationLevel, lineSeparator); }
@Override public IRegion getCoverage() { Position[] fragments= getFragments(); if (fragments != null && fragments.length > 0) { Position first=fragments[0]; Position last= fragments[fragments.length -1]; return new Region(first.offset, exclusiveEnd(last) - first.offset); } return new Region(0, 0); }
@Override public void documentPartitioningChanged(IDocument document) { if (!fDocumentChanging && fCachedRedrawState) processDamage(new Region(0, document.getLength()), document); else fDocumentPartitioningChanged= true; }
public static IRegion getNameRegion(IDOMAttr attr) { int regOffset = attr.getNameRegionStartOffset(); int regLength = attr.getNameRegionText().length(); return new Region(regOffset, regLength); }
/** * Finds hyperlinks at the current offset. * * @return the hyperlinks or <code>null</code> if none. */ protected IHyperlink[] findHyperlinks() { int offset= getCurrentTextOffset(); if (offset == -1) return null; IRegion region= new Region(offset, 0); return findHyperlinks(region); }
private /*static*/ final boolean isVisible(ITextViewer viewer, int offset, int length) { if (viewer instanceof ITextViewerExtension5) { ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; IRegion overlap= extension.modelRange2WidgetRange(new Region(offset, length)); return overlap != null; } return viewer.overlapsWithVisibleRegion(offset, length); }
private List<Location> findImplementations(IType type, int offset, IProgressMonitor monitor) throws CoreException { //java.lang.Object is a special case. We need to minimize heavy cost of I/O, // by avoiding opening all files from the Object hierarchy boolean useDefaultLocation = "java.lang.Object".equals(type.getFullyQualifiedName()); ImplementationToLocationMapper mapper = new ImplementationToLocationMapper(preferenceManager.isClientSupportsClassFileContent(), useDefaultLocation); ImplementationCollector<Location> searcher = new ImplementationCollector<>(new Region(offset, 0), type, mapper); return searcher.findImplementations(monitor); }
private IRegion getRegion(IDocument document, ILineRange lineRange) throws BadLocationException { final int startLine= lineRange.getStartLine(); int offset= document.getLineOffset(startLine); final int numberOfLines= lineRange.getNumberOfLines(); if (numberOfLines < 1) return new Region(offset, 0); int endLine= startLine + numberOfLines - 1; int endOffset= document.getLineOffset(endLine) + document.getLineLength(endLine); return new Region(offset, endOffset - offset); }
@Override public IRegion getVisibleRegion() { IDocument document= getVisibleDocument(); if (document instanceof ChildDocument) { Position p= ((ChildDocument) document).getParentDocumentRange(); return new Region(p.getOffset(), p.getLength()); } return new Region(0, document == null ? 0 : document.getLength()); }
@Override public IRegion getRangeIndication() { if (fRangeIndicator != null && fVisualAnnotationModel != null) { Position position= fVisualAnnotationModel.getPosition(fRangeIndicator); if (position != null) return new Region(position.getOffset(), position.getLength()); } return null; }
@Override public IRegion getRangeIndication() { if (fRangeIndicator != null && fVisualAnnotationModel != null) { Position position= fVisualAnnotationModel.getPosition(fRangeIndicator); if (position != null) return new Region(position.getOffset(), position.getLength()); } return null; }
/** * Same as {@link #modelRange2WidgetRange(IRegion)} just for a {@link org.eclipse.jface.text.Position}. * * @param modelPosition the position describing a range in the viewer's document * @return a region describing a range in the viewer's widget * @since 2.1 */ protected IRegion modelRange2WidgetRange(Position modelPosition) { return modelRange2WidgetRange(new Region(modelPosition.getOffset(), modelPosition.getLength())); }
@Override protected void process(DirtyRegion dirtyRegion) { if(dirtyRegion != null) fStrategy.reconcile(dirtyRegion, dirtyRegion); else { IDocument document= getDocument(); if (document != null) fStrategy.reconcile(new Region(0, document.getLength())); } }
private IRegion findPrefixRange(IDocument document, IRegion line) throws BadLocationException { int lineOffset = line.getOffset(); int lineEnd = lineOffset + line.getLength(); int indentEnd = findEndOfWhiteSpace(document, lineOffset, lineEnd); if (indentEnd < lineEnd && document.getChar(indentEnd) == '*') { indentEnd++; while (indentEnd < lineEnd && document.getChar(indentEnd) == ' ') { indentEnd++; } } return new Region(lineOffset, indentEnd - lineOffset); }
@Override protected IRegion findExtendedDoubleClickSelection(IDocument document, int offset) { IRegion match= fPairMatcher.match(document, offset); if (match != null && match.getLength() >= 2) return new Region(match.getOffset() + 1, match.getLength() - 2); return findWord(document, offset); }
private void select() { ITextViewer viewer= fCurrentTarget.getViewer(); if (viewer instanceof ITextViewerExtension5) { ITextViewerExtension5 extension5= (ITextViewerExtension5) viewer; extension5.exposeModelRange(new Region(fFramePosition.offset, fFramePosition.length)); } else if (!viewer.overlapsWithVisibleRegion(fFramePosition.offset, fFramePosition.length)) { viewer.resetVisibleRegion(); } viewer.revealRange(fFramePosition.offset, fFramePosition.length); viewer.setSelectedRange(fFramePosition.offset, fFramePosition.length); }