@Override public ITypedRegion[] computePartitioning(int offset, int length) { return computePartitioning(offset, length, false); }
@Override public void connect(IDocument document) { connect(document, false); }
@Override public boolean documentChanged(DocumentEvent e) { if (fIsInitialized) { IRegion region= documentChanged2(e); return (region != null); } return false; }
Position p= category[i]; if (p.isDeleted) { rememberDeletedOffset(e.getOffset()); break; contentType= getTokenContentType(token); if (!isSupportedContentType(contentType)) { token= fScanner.nextToken(); continue; rememberRegion(p.offset, p.length); d.removePosition(fPositionCategory, p); ++ first; return createRegion(); ++ first; } else { rememberRegion(start, length); } catch (BadPositionCategoryException x) { } catch (BadLocationException x) { p= (TypedPosition) category[first++]; d.removePosition(fPositionCategory, p); rememberRegion(p.offset, p.length); return createRegion();
@Override public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) { checkInitialization(); List<TypedRegion> list= new ArrayList<>(); Position gap= new Position(0); int startIndex= getFirstIndexEndingAfterOffset(category, offset); int endIndex= getFirstIndexStartingAfterOffset(category, endOffset); for (int i= startIndex; i < endIndex; i++) { gap.setOffset(gapOffset); gap.setLength(current.getOffset() - gapOffset); if ((includeZeroLengthPartitions && overlapsOrTouches(gap, offset, length)) || (gap.getLength() > 0 && gap.overlapsWith(offset, length))) { start= Math.max(offset, gapOffset); gap.setOffset(gapOffset); gap.setLength(fDocument.getLength() - gapOffset); if ((includeZeroLengthPartitions && overlapsOrTouches(gap, offset, length)) || (gap.getLength() > 0 && gap.overlapsWith(offset, length))) { start= Math.max(offset, gapOffset);
@Override public String getContentType(int offset) { checkInitialization(); TypedPosition p= findClosestPosition(offset); if (p != null && p.includes(offset)) return p.getType(); return IDocument.DEFAULT_CONTENT_TYPE; }
@Override public void connect(IDocument document, boolean delayInitialization) { Assert.isNotNull(document); Assert.isTrue(!document.containsPositionCategory(fPositionCategory)); fDocument= document; fDocument.addPositionCategory(fPositionCategory); fIsInitialized= false; if (!delayInitialization) checkInitialization(); }
/** * Sets up the document to be ready for use by a text file buffer. * * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument) */ public void setup( IDocument document ) { if (document instanceof IDocumentExtension3) { IDocumentExtension3 extension3 = (IDocumentExtension3) document; IDocumentPartitioner partitioner = new DefaultPartitioner( SQLEditorPlugin.getDefault().getSQLPartitionScanner(), SQLPartitionScanner.SQL_PARTITION_TYPES ); partitioner.connect( document ); extension3.setDocumentPartitioner( SQLPartitionScanner.SQL_PARTITIONING, partitioner ); } } }
@Override public void stopRewriteSession(DocumentRewriteSession session) { if (fActiveRewriteSession == session) flushRewriteSession(); }
Position p= category[i]; if (p.isDeleted) { rememberDeletedOffset(e.getOffset()); break; contentType= getTokenContentType(token); if (!isSupportedContentType(contentType)) { token= fScanner.nextToken(); continue; rememberRegion(p.offset, p.length); d.removePosition(fPositionCategory, p); ++ first; return createRegion(); ++ first; } else { rememberRegion(start, length); } catch (BadPositionCategoryException x) { } catch (BadLocationException x) { p= (TypedPosition) category[first++]; d.removePosition(fPositionCategory, p); rememberRegion(p.offset, p.length); return createRegion();
@Override public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) { checkInitialization(); List<TypedRegion> list= new ArrayList<>(); Position gap= new Position(0); int startIndex= getFirstIndexEndingAfterOffset(category, offset); int endIndex= getFirstIndexStartingAfterOffset(category, endOffset); for (int i= startIndex; i < endIndex; i++) { gap.setOffset(gapOffset); gap.setLength(current.getOffset() - gapOffset); if ((includeZeroLengthPartitions && overlapsOrTouches(gap, offset, length)) || (gap.getLength() > 0 && gap.overlapsWith(offset, length))) { start= Math.max(offset, gapOffset); gap.setOffset(gapOffset); gap.setLength(fDocument.getLength() - gapOffset); if ((includeZeroLengthPartitions && overlapsOrTouches(gap, offset, length)) || (gap.getLength() > 0 && gap.overlapsWith(offset, length))) { start= Math.max(offset, gapOffset);
@Override public String getContentType(int offset) { checkInitialization(); TypedPosition p= findClosestPosition(offset); if (p != null && p.includes(offset)) return p.getType(); return IDocument.DEFAULT_CONTENT_TYPE; }
@Override public void connect(IDocument document, boolean delayInitialization) { Assert.isNotNull(document); Assert.isTrue(!document.containsPositionCategory(fPositionCategory)); fDocument= document; fDocument.addPositionCategory(fPositionCategory); fIsInitialized= false; if (!delayInitialization) checkInitialization(); }
@Override protected IDocument createDocument(Object element) throws CoreException { IDocument document = super.createDocument(element); if (document != null) { IDocumentPartitioner partitioner = new DefaultPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT }); partitioner.connect(document); document.setDocumentPartitioner(partitioner); } return document; } }
@Override public void stopRewriteSession(DocumentRewriteSession session) { if (fActiveRewriteSession == session) flushRewriteSession(); }
@Override public ITypedRegion getPartition(int offset) { checkInitialization(); try { Position[] category = fDocument.getPositions(fPositionCategory); if (category == null || category.length == 0) return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE); int index= fDocument.computeIndexInCategory(fPositionCategory, offset); if (index < category.length) { TypedPosition next= (TypedPosition) category[index]; if (offset == next.offset) return new TypedRegion(next.getOffset(), next.getLength(), next.getType()); if (index == 0) return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE); TypedPosition previous= (TypedPosition) category[index - 1]; if (previous.includes(offset)) return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); int endOffset= previous.getOffset() + previous.getLength(); return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); } TypedPosition previous= (TypedPosition) category[category.length - 1]; if (previous.includes(offset)) return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); int endOffset= previous.getOffset() + previous.getLength(); return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); } catch (BadPositionCategoryException x) { } catch (BadLocationException x) { } return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE); }
@Override public boolean documentChanged(DocumentEvent e) { if (fIsInitialized) { IRegion region= documentChanged2(e); return (region != null); } return false; }
@Override public ITypedRegion[] computePartitioning(int offset, int length) { return computePartitioning(offset, length, false); }
@Override public void connect(IDocument document) { connect(document, false); }
@Override public ITypedRegion getPartition(int offset) { checkInitialization(); try { Position[] category = fDocument.getPositions(fPositionCategory); if (category == null || category.length == 0) return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE); int index= fDocument.computeIndexInCategory(fPositionCategory, offset); if (index < category.length) { TypedPosition next= (TypedPosition) category[index]; if (offset == next.offset) return new TypedRegion(next.getOffset(), next.getLength(), next.getType()); if (index == 0) return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE); TypedPosition previous= (TypedPosition) category[index - 1]; if (previous.includes(offset)) return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); int endOffset= previous.getOffset() + previous.getLength(); return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); } TypedPosition previous= (TypedPosition) category[category.length - 1]; if (previous.includes(offset)) return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType()); int endOffset= previous.getOffset() + previous.getLength(); return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE); } catch (BadPositionCategoryException x) { } catch (BadLocationException x) { } return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE); }