/** * Creates an iterator, starting at offset <code>first</code>. * * @param document the document backing this iterator * @param first the first character to consider * @throws BadLocationException if the indices are out of bounds */ public DocumentCharacterIterator(IDocument document, int first) throws BadLocationException { this(document, first, document.getLength()); }
public void configureForwardReader(IDocument document, int offset, int length, boolean skipComments, boolean skipStrings) throws IOException { fDocument= document; fOffset= offset; fSkipComments= skipComments; fSkipStrings= skipStrings; fForward= true; fEnd= Math.min(fDocument.getLength(), fOffset + length); }
/** * Creates a JavaNode for a CU. It represents the root of a * JavaNode tree, so its parent is null. * @param document the document which contains the Java element */ public JavaNode(IDocument document) { super(CU, JavaCompareUtilities.buildID(CU, "root"), document, 0, document.getLength()); //$NON-NLS-1$ }
private static int getNextPosition(IDocument doc, int offset, char ch) { int i = 0; try { for (i = 0; i + offset < doc.getLength(); i++) { if (ch == doc.get(offset + i, 1).toCharArray()[0]) break; } } catch (BadLocationException e) { } return i; }
@Override public void documentPartitioningChanged(IDocument document) { if (!fDocumentChanging && fCachedRedrawState) processDamage(new Region(0, document.getLength()), document); else fDocumentPartitioningChanged= true; }
private void updateDocument(IDocument document, IStreamContentAccessor sa) throws InvocationTargetException { try { String text= Utilities.readString(sa); document.replace(0, document.getLength(), text); } catch (CoreException e) { throw new InvocationTargetException(e); } catch (BadLocationException e) { throw new InvocationTargetException(e); } }
@Override public void append(String text) { try { fDocument.replace(fDocument.getLength(), 0, text); } catch (BadLocationException e) { throw new IndexOutOfBoundsException(e.getMessage()); } }
@Override public void append(String text) { if (DEBUG_LINE_DELIMITERS) { validateLineDelimiters(text); } fReplaceCmd.replace(fDocument.getLength(), 0, text); }
public void append(String text) { if (DEBUG_LINE_DELIMITERS) { validateLineDelimiters(text); } fReplaceCmd.replace(fDocument.getLength(), 0, text); }
public static RefactoringStatus isValid(IDocument document, int length) { RefactoringStatus result= new RefactoringStatus(); if (length != document.getLength()) { result.addFatalError(RefactoringCoreMessages.TextChanges_error_document_content_changed); } return result; } }
public void initialReconcile() { if (document == null) { return; } reconcile(new Region(0, document.getLength())); }
public static RefactoringStatus isValid(IDocument document, int length) { RefactoringStatus result= new RefactoringStatus(); if (length != document.getLength()) { result.addFatalError(RefactoringCoreMessages.TextChanges_error_document_content_changed); } return result; } }
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); }
@Override public boolean overlapsWithVisibleRegion(int start, int length) { IDocument document= getVisibleDocument(); if (document instanceof ChildDocument) { ChildDocument cdoc= (ChildDocument) document; return cdoc.getParentDocumentRange().overlapsWith(start, length); } else if (document != null) { int size= document.getLength(); return (start >= 0 && length >= 0 && start + length <= size); } return false; }
@Override public void documentAboutToBeChanged(DocumentEvent e) { Assert.isTrue(e.getDocument() == fDocument); fPreviousDocumentLength= e.getDocument().getLength(); fStartOffset= -1; fEndOffset= -1; fDeleteOffset= -1; }
public ISelection getSelection() { if (fControl instanceof StyledText) { IDocument document= new Document(((StyledText)fControl).getSelectionText()); return new TextSelection(document, 0, document.getLength()); } else { // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022 return StructuredSelection.EMPTY; } }
private void collapseAll() { int offset= 0; IDocument doc= getDocument(); int length= doc == null ? 0 : doc.getLength(); if (isProjectionMode()) { fProjectionAnnotationModel.collapseAll(offset, length); } }
@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())); } }
/** * {@inheritDoc} */ public String getCurrentContent(IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) throws CoreException { Assert.isNotNull(region); Assert.isTrue(surroundingLines >= 0); IDocument document= getCurrentDocument(pm); Assert.isTrue(document.getLength() >= region.getOffset() + region.getLength()); return getContent(document, region, expandRegionToFullLine, surroundingLines); }
@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()); }