/** * Factory method for creating a Java-specific document partitioner * using this object's partitions scanner. This method is a * convenience method. * * @return a newly created Java document partitioner */ public IDocumentPartitioner createDocumentPartitioner() { return new FastPartitioner(getPartitionScanner(), LEGAL_CONTENT_TYPES); }
@Override public final void connect(IDocument document) { connect(document, false); }
/** * {@inheritDoc} * <p> * May be extended by subclasses. * </p> */ public void stopRewriteSession(DocumentRewriteSession session) { if (fActiveRewriteSession == session) flushRewriteSession(); }
/** * {@inheritDoc} * <p> * May be replaced or extended by subclasses. * </p> */ public String getContentType(int offset) { checkInitialization(); TypedPosition p= findClosestPosition(offset); if (p != null && p.includes(offset)) return p.getType(); return IDocument.DEFAULT_CONTENT_TYPE; }
/** * Installs a partitioner with <code>document</code>. * * @param document * the document */ private static void installStuff(Document document) { String[] types = new String[] { RutaPartitions.RUTA_STRING, RutaPartitions.RUTA_COMMENT, IDocument.DEFAULT_CONTENT_TYPE }; FastPartitioner partitioner = new FastPartitioner(new RutaPartitionScanner(), types); partitioner.connect(document); document.setDocumentPartitioner(RutaPartitions.RUTA_PARTITIONING, partitioner); }
Position[] category= getPositions(); IRegion line= fDocument.getLineInformationOfOffset(e.getOffset()); int reparseStart= line.getOffset(); Position p= category[i]; if (p.isDeleted) { rememberDeletedOffset(e.getOffset()); break; clearPositionCache(); category= getPositions(); contentType= getTokenContentType(token); if (!isSupportedContentType(contentType)) { token= fScanner.nextToken(); continue; rememberRegion(p.offset, p.length); fDocument.removePosition(fPositionCategory, p); ++ first; return createRegion(); ++ first; } else { rememberRegion(start, length); } catch (BadPositionCategoryException x) { } catch (BadLocationException x) {
checkInitialization(); List<TypedRegion> list= new ArrayList<>(); Position[] category= getPositions(); 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); clearPositionCache(); } catch (RuntimeException ex) { clearPositionCache(); throw ex;
/** * Performs the initial partitioning of the partitioner's document. * <p> * May be extended by subclasses. * </p> */ protected void initialize() { fIsInitialized= true; clearPositionCache(); fScanner.setRange(fDocument, 0, fDocument.getLength()); try { IToken token= fScanner.nextToken(); while (!token.isEOF()) { String contentType= getTokenContentType(token); if (isSupportedContentType(contentType)) { TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType); fDocument.addPosition(fPositionCategory, p); } token= fScanner.nextToken(); } } catch (BadLocationException x) { // cannot happen as offsets come from scanner } catch (BadPositionCategoryException x) { // cannot happen if document has been connected before } }
checkInitialization(); Position[] category = getPositions();
public final boolean documentChanged(DocumentEvent e) { if (fIsInitialized) { IRegion region= documentChanged2(e); return (region != null); } return false; }
@Override public final ITypedRegion[] computePartitioning(int offset, int length) { return computePartitioning(offset, length, false); }
/** * {@inheritDoc} * <p> * May be extended by subclasses. * </p> */ 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) { JsonScanner scanner = new JsonScanner(new ColorManager(), store); Set<String> tokens = YAMLToken.VALID_TOKENS.keySet(); FastPartitioner partitioner = new FastPartitioner(scanner, tokens.toArray(new String[tokens.size()])); document.setDocumentPartitioner(partitioner); partitioner.connect(document); } return document; }
Position[] category= getPositions(); IRegion line= fDocument.getLineInformationOfOffset(e.getOffset()); int reparseStart= line.getOffset(); Position p= category[i]; if (p.isDeleted) { rememberDeletedOffset(e.getOffset()); break; clearPositionCache(); category= getPositions(); contentType= getTokenContentType(token); if (!isSupportedContentType(contentType)) { token= fScanner.nextToken(); continue; rememberRegion(p.offset, p.length); fDocument.removePosition(fPositionCategory, p); ++ first; return createRegion(); ++ first; } else { rememberRegion(start, length); } catch (BadPositionCategoryException x) { } catch (BadLocationException x) {
checkInitialization(); List list= new ArrayList(); Position[] category= getPositions(); 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); clearPositionCache(); } catch (RuntimeException ex) { clearPositionCache(); throw ex;
/** * Performs the initial partitioning of the partitioner's document. * <p> * May be extended by subclasses. * </p> */ protected void initialize() { fIsInitialized= true; clearPositionCache(); fScanner.setRange(fDocument, 0, fDocument.getLength()); try { IToken token= fScanner.nextToken(); while (!token.isEOF()) { String contentType= getTokenContentType(token); if (isSupportedContentType(contentType)) { TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType); fDocument.addPosition(fPositionCategory, p); } token= fScanner.nextToken(); } } catch (BadLocationException x) { // cannot happen as offsets come from scanner } catch (BadPositionCategoryException x) { // cannot happen if document has been connected before } }
/** * {@inheritDoc} * <p> * May be replaced or extended by subclasses. * </p> */ public String getContentType(int offset) { checkInitialization(); TypedPosition p= findClosestPosition(offset); if (p != null && p.includes(offset)) return p.getType(); return IDocument.DEFAULT_CONTENT_TYPE; }
checkInitialization(); Position[] category = getPositions();
public final boolean documentChanged(DocumentEvent e) { if (fIsInitialized) { IRegion region= documentChanged2(e); return (region != null); } return false; }
@Override public final ITypedRegion[] computePartitioning(int offset, int length) { return computePartitioning(offset, length, false); }