/** * Gets the partitions of the given document as an array of * <code>ITypedRegion</code> objects. There is a distinct non-overlapping partition * for each comment line, string literal, delimited identifier, and "everything else" * (that is, SQL code other than a string literal or delimited identifier). * * @param doc the document to parse into partitions * @return an array containing the document partion regions */ public static ITypedRegion[] getDocumentRegions( IDocument doc ) { ITypedRegion[] regions = null; try { regions = TextUtilities.computePartitioning( doc, SQLPartitionScanner.SQL_PARTITIONING, 0, doc.getLength(), false ); } catch ( BadLocationException e ) { // ignore } return regions; }
/** * Computes and returns the partitioning for the given region of the input document * of the reconciler's connected text viewer. * * @param offset the region offset * @param length the region length * @return the computed partitioning * @since 3.0 */ private ITypedRegion[] computePartitioning(int offset, int length) { ITypedRegion[] regions= null; try { regions= TextUtilities.computePartitioning(getDocument(), getDocumentPartitioning(), offset, length, false); } catch (BadLocationException x) { regions= new TypedRegion[0]; } return regions; } }
/** * Computes and returns the partitioning for the given region of the input document * of the reconciler's connected text viewer. * * @param offset the region offset * @param length the region length * @return the computed partitioning * @since 3.0 */ private ITypedRegion[] computePartitioning(int offset, int length) { ITypedRegion[] regions= null; try { regions= TextUtilities.computePartitioning(getDocument(), getDocumentPartitioning(), offset, length, false); } catch (BadLocationException x) { regions= new TypedRegion[0]; } return regions; } }
protected ITypedRegion[] computePartitioning(int offset, int length, String partitionType) { ITypedRegion[] result = new ITypedRegion[0]; ITypedRegion[] allRegions = new ITypedRegion[0]; try { allRegions = TextUtilities.computePartitioning(getDocument(), partitionType, offset, length, false); } catch (BadLocationException x) { } for (int i = 0; i < allRegions.length; i++) { if (shouldProcess(allRegions[i])) { result = concat(result, allRegions[i]); } } return result; }
for (int i= 0; i < regions.length; i++) { IRegion region= regions[i]; ITypedRegion[] partitions= TextUtilities.computePartitioning(document, IJavaPartitions.JAVA_PARTITIONING, region.getOffset(), region.getLength(), false); for (int index= 0; index < partitions.length; index++) { if (monitor != null && monitor.isCanceled())
/** * Returns the partitioning of the given region of the document to be formatted. * As one partition after the other will be formatted and formatting will * probably change the length of the formatted partition, it must be kept * track of the modifications in order to submit the correct partition to all * formatting strategies. For this, all partitions are remembered as positions * in a dedicated position category. (As formatting strategies might rely on each * other, calling them in reversed order is not an option.) * * @param region the region for which the partitioning must be determined * @return the partitioning of the specified region * @exception BadLocationException of region is invalid in the document * @since 3.0 */ private TypedPosition[] getPartitioning(IRegion region) throws BadLocationException { ITypedRegion[] regions= TextUtilities.computePartitioning(fDocument, fPartitioning, region.getOffset(), region.getLength(), false); TypedPosition[] positions= new TypedPosition[regions.length]; for (int i= 0; i < regions.length; i++) { positions[i]= new TypedPosition(regions[i]); try { fDocument.addPosition(PARTITIONING, positions[i]); } catch (BadPositionCategoryException x) { // should not happen } } return positions; }
/** * Returns the partitioning of the given region of the document to be formatted. * As one partition after the other will be formatted and formatting will * probably change the length of the formatted partition, it must be kept * track of the modifications in order to submit the correct partition to all * formatting strategies. For this, all partitions are remembered as positions * in a dedicated position category. (As formatting strategies might rely on each * other, calling them in reversed order is not an option.) * * @param region the region for which the partitioning must be determined * @return the partitioning of the specified region * @exception BadLocationException of region is invalid in the document * @since 3.0 */ private TypedPosition[] getPartitioning(IRegion region) throws BadLocationException { ITypedRegion[] regions= TextUtilities.computePartitioning(fDocument, fPartitioning, region.getOffset(), region.getLength(), false); TypedPosition[] positions= new TypedPosition[regions.length]; for (int i= 0; i < regions.length; i++) { positions[i]= new TypedPosition(regions[i]); try { fDocument.addPosition(PARTITIONING, positions[i]); } catch (BadPositionCategoryException x) { // should not happen } } return positions; }
for (int i= 0; i < regions.length; i++) { IRegion region= regions[i]; ITypedRegion[] partitions= TextUtilities.computePartitioning(document, IJavaPartitions.JAVA_PARTITIONING, region.getOffset(), region.getLength(), false); for (int index= 0; index < partitions.length; index++) { if (monitor != null && monitor.isCanceled())
for (int i= 0; i < regions.length; i++) { IRegion region= regions[i]; ITypedRegion[] partitions= TextUtilities.computePartitioning(document, IJavaPartitions.JAVA_PARTITIONING, region.getOffset(), region.getLength(), false); for (int index= 0; index < partitions.length; index++) { if (monitor != null && monitor.isCanceled())
ITypedRegion[] regions= TextUtilities.computePartitioning(document, IJavaPartitions.JAVA_PARTITIONING, 0, document.getLength(), false); for (int i= 0; i < regions.length; i++) { ITypedRegion region= regions[i];
try { final ITypedRegion[] partitions= TextUtilities.computePartitioning(document, fPartitioning, offset, length, false);
try { final ITypedRegion[] partitions= TextUtilities.computePartitioning(document, fPartitioning, offset, length, false);
List<ITypedRegion> partitionList= new ArrayList<>(); for (int i= 0; i < regions.length; i++) partitionList.addAll(Arrays.asList(TextUtilities.computePartitioning(document, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, regions[i].getOffset(), regions[i].getLength(), false))); ITypedRegion[] partitions= partitionList.toArray(new ITypedRegion[partitionList.size()]);
List<ITypedRegion> partitionList= new ArrayList<>(); for (int i= 0; i < regions.length; i++) partitionList.addAll(Arrays.asList(TextUtilities.computePartitioning(document, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, regions[i].getOffset(), regions[i].getLength(), false))); ITypedRegion[] partitions= partitionList.toArray(new ITypedRegion[partitionList.size()]);
ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength(), false); for (int i= 0; i < partitioning.length; i++) { ITypedRegion r= partitioning[i];
ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength(), false); for (int i= 0; i < partitioning.length; i++) { ITypedRegion r= partitioning[i];
/** * Constructs a "repair description" for the given damage and returns this * description as a text presentation. For this, it queries the partitioning * of the damage region and asks the appropriate presentation repairer for * each partition to construct the "repair description" for this partition. * * @param damage the damage to be repaired * @param document the document whose presentation must be repaired * @return the presentation repair description as text presentation or * <code>null</code> if the partitioning could not be computed */ protected TextPresentation createPresentation(IRegion damage, IDocument document) { try { if (fRepairers == null || fRepairers.isEmpty()) { TextPresentation presentation= new TextPresentation(damage, 100); presentation.setDefaultStyleRange(new StyleRange(damage.getOffset(), damage.getLength(), null, null)); return presentation; } TextPresentation presentation= new TextPresentation(damage, 1000); ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength(), false); for (ITypedRegion r : partitioning) { IPresentationRepairer repairer= getRepairer(r.getType()); if (repairer != null) repairer.createPresentation(presentation, r); } return presentation; } catch (BadLocationException x) { return null; } }
ITypedRegion[] regions= TextUtilities.computePartitioning(document, fDocumentPartitioning, block.getOffset(), block.getLength(), false);
ITypedRegion[] regions= TextUtilities.computePartitioning(document, fDocumentPartitioning, block.getOffset(), block.getLength(), false);
ITypedRegion[] regions= TextUtilities.computePartitioning(document, fDocumentPartitioning, block.getOffset(), block.getLength(), false);