/** * Returns the partition for the given offset in the given document. * * @param document the document * @param offset the offset * @return the partition * @throws BadLocationException if offset is invalid in the given document * @since 3.0 */ private ITypedRegion getPartition(IDocument document, int offset) throws BadLocationException { return TextUtilities.getPartition(document, getDocumentPartitioning(), offset, false); } }
/** * Returns the partition for the given offset in the given document. * * @param document the document * @param offset the offset * @return the partition * @throws BadLocationException if offset is invalid in the given document * @since 3.0 */ private ITypedRegion getPartition(IDocument document, int offset) throws BadLocationException { return TextUtilities.getPartition(document, getDocumentPartitioning(), offset, false); } }
/** * Returns the partition for the given offset in the given document. * * @param document the document * @param offset the offset * @return the partition * @throws BadLocationException if offset is invalid in the given document * @since 3.0 */ private ITypedRegion getPartition(IDocument document, int offset) throws BadLocationException { return TextUtilities.getPartition(document, getDocumentPartitioning(), offset, false); } }
/** * Get partition type covering offset * * @param d * @param offset * @return * @throws BadLocationException */ private String getRegionType(IDocument d, int offset) throws BadLocationException { int p = ((offset == d.getLength()) ? offset - 1 : offset); ITypedRegion region = TextUtilities.getPartition(d, fPartitioning, p, true); return region.getType(); }
/** * Returns partition information about the region containing the * specified position. * * @param pos a position within this document. * @return positioning information about the region containing the * position */ private ITypedRegion getPartition(int pos) { if (fCachedPartition == null || !contains(fCachedPartition, pos)) { Assert.isTrue(pos >= 0 && pos <= fLength); try { fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, pos, false); } catch (BadLocationException e) { fCachedPartition= null; } } return fCachedPartition; }
/** * Returns partition information about the region containing the * specified position. * * @param pos a position within this document. * @return positioning information about the region containing the * position */ private ITypedRegion getPartition(int pos) { if (fCachedPartition == null || !contains(fCachedPartition, pos)) { Assert.isTrue(pos >= 0 && pos <= fLength); try { fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, pos, false); } catch (BadLocationException e) { fCachedPartition= null; } } return fCachedPartition; }
/** * Checks whether <code>position</code> resides in a default (Java) partition of <code>document</code>. * * @param document the document being modified * @param position the position to be checked * @param partitioning the document partitioning * @return <code>true</code> if <code>position</code> is in the default partition of <code>document</code>, <code>false</code> otherwise */ private static boolean isDefaultPartition(IDocument document, int position, String partitioning) { Assert.isTrue(position >= 0); Assert.isTrue(position <= document.getLength()); try { ITypedRegion region= TextUtilities.getPartition(document, partitioning, position, false); return region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE); } catch (BadLocationException e) { } return false; }
/** * Checks whether <code>position</code> resides in a default (Java) partition of <code>document</code>. * * @param document the document being modified * @param position the position to be checked * @param partitioning the document partitioning * @return <code>true</code> if <code>position</code> is in the default partition of <code>document</code>, <code>false</code> otherwise */ private static boolean isDefaultPartition(IDocument document, int position, String partitioning) { Assert.isTrue(position >= 0); Assert.isTrue(position <= document.getLength()); try { // don't use getPartition2 since we're interested in the scanned character's partition ITypedRegion region= TextUtilities.getPartition(document, partitioning, position, false); return region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE); } catch (BadLocationException e) { } return false; }
/** * Checks whether <code>position</code> resides in a default (Java) partition of <code>document</code>. * * @param document the document being modified * @param position the position to be checked * @param partitioning the document partitioning * @return <code>true</code> if <code>position</code> is in the default partition of <code>document</code>, <code>false</code> otherwise */ private static boolean isDefaultPartition(IDocument document, int position, String partitioning) { Assert.isTrue(position >= 0); Assert.isTrue(position <= document.getLength()); try { ITypedRegion region= TextUtilities.getPartition(document, partitioning, position, false); return region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE); } catch (BadLocationException e) { } return false; }
/** * Returns the partition type of the document displayed in <code>viewer</code> at <code>startLine</code>. * @param viewer the viewer * @param startLine the line in the viewer * @return the partition type at the start of <code>startLine</code>, or <code>IDocument.DEFAULT_CONTENT_TYPE</code> if none can be detected */ private String getPartition(ISourceViewer viewer, int startLine) { if (viewer == null) return null; IDocument doc= viewer.getDocument(); if (doc == null) return null; if (startLine <= 0) return IDocument.DEFAULT_CONTENT_TYPE; try { ITypedRegion region= TextUtilities.getPartition(doc, fPartitioning, doc.getLineOffset(startLine) - 1, true); return region.getType(); } catch (BadLocationException e) { } return IDocument.DEFAULT_CONTENT_TYPE; }
/** * Checks whether <code>position</code> resides in a default (Java) partition of <code>document</code>. * * @param document the document being modified * @param position the position to be checked * @param partitioning the document partitioning * @return <code>true</code> if <code>position</code> is in the default partition of <code>document</code>, <code>false</code> otherwise */ private static boolean isDefaultPartition(IDocument document, int position, String partitioning) { Assert.isTrue(position >= 0); Assert.isTrue(position <= document.getLength()); try { // don't use getPartition2 since we're interested in the scanned character's partition ITypedRegion region= TextUtilities.getPartition(document, partitioning, position, false); return region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE); } catch (BadLocationException e) { } return false; }
/** * Checks whether <code>position</code> resides in a default (Java) partition of <code>document</code>. * * @param document the document being modified * @param position the position to be checked * @param partitioning the document partitioning * @return <code>true</code> if <code>position</code> is in the default partition of <code>document</code>, <code>false</code> otherwise */ private static boolean isDefaultPartition(IDocument document, int position, String partitioning) { Assert.isTrue(position >= 0); Assert.isTrue(position <= document.getLength()); try { ITypedRegion region= TextUtilities.getPartition(document, partitioning, position, false); return region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE); } catch (BadLocationException e) { } return false; }
/** * Returns the partition type of the document displayed in <code>viewer</code> at <code>startLine</code>. * @param viewer the viewer * @param startLine the line in the viewer * @return the partition type at the start of <code>startLine</code>, or <code>IDocument.DEFAULT_CONTENT_TYPE</code> if none can be detected */ private String getPartition(ISourceViewer viewer, int startLine) { if (viewer == null) return null; IDocument doc= viewer.getDocument(); if (doc == null) return null; if (startLine <= 0) return IDocument.DEFAULT_CONTENT_TYPE; try { ITypedRegion region= TextUtilities.getPartition(doc, fPartitioning, doc.getLineOffset(startLine) - 1, true); return region.getType(); } catch (BadLocationException e) { } return IDocument.DEFAULT_CONTENT_TYPE; }
/** * Checks whether <code>position</code> resides in a default (Java) partition of <code>document</code>. * * @param document the document being modified * @param position the position to be checked * @param partitioning the document partitioning * @return <code>true</code> if <code>position</code> is in the default partition of <code>document</code>, <code>false</code> otherwise */ private static boolean isDefaultPartition(IDocument document, int position, String partitioning) { Assert.isTrue(position >= 0); Assert.isTrue(position <= document.getLength()); try { // don't use getPartition2 since we're interested in the scanned character's partition ITypedRegion region= TextUtilities.getPartition(document, partitioning, position, false); return region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE); } catch (BadLocationException e) { } return false; }
private IRegion match(IDocument document, int offset) { try { if ((document.getChar(offset) == '"') || (document.getChar(offset) == '\'') || (document.getChar(offset - 1) == '"') || (document.getChar(offset - 1) == '\'')) { return TextUtilities.getPartition(document, fPartitioning, offset, true); } } catch (BadLocationException e) { } return null; } }
private String createMethodTags(IDocument document, DocumentCommand command, String indentation, String lineDelimiter, IMethod method) throws CoreException, BadLocationException { IRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset, false); IMethod inheritedMethod= getInheritedMethod(method); String comment= CodeGeneration.getMethodComment(method, inheritedMethod, lineDelimiter); if (comment != null) { comment= comment.trim(); boolean javadocComment= comment.startsWith("/**"); //$NON-NLS-1$ if (!isFirstComment(document, command, method, javadocComment)) return null; boolean isJavaDoc= partition.getLength() >= 3 && document.get(partition.getOffset(), 3).equals("/**"); //$NON-NLS-1$ if (javadocComment == isJavaDoc) { return prepareTemplateComment(comment, indentation, method.getJavaProject(), lineDelimiter); } } return null; }
@Override protected IRegion findExtendedDoubleClickSelection(IDocument document, int offset) { IRegion match= super.findExtendedDoubleClickSelection(document, offset); if (match != null) return match; try { ITypedRegion region= TextUtilities.getPartition(document, fPartitioning, offset, true); if (offset == region.getOffset() + 1 || offset == region.getOffset() + region.getLength() - 1) { return getSelectedRegion(document, region); } } catch (BadLocationException e) { return null; } return null; }
/** * Returns the partition at <code>position</code>. * * @param position the position to get the partition for * @return the partition at <code>position</code> or a dummy zero-length * partition if accessing the document fails */ private ITypedRegion getPartition(int position) { if (!contains(fCachedPartition, position)) { Assert.isTrue(position >= 0); Assert.isTrue(position <= fDocument.getLength()); try { fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, position, false); } catch (BadLocationException e) { fCachedPartition= new TypedRegion(position, 0, "__no_partition_at_all"); //$NON-NLS-1$ } } return fCachedPartition; }
/** * Returns the partition at <code>position</code>. * * @param position the position to get the partition for * @return the partition at <code>position</code> or a dummy zero-length * partition if accessing the document fails */ private ITypedRegion getPartition(int position) { if (!contains(fCachedPartition, position)) { Assert.isTrue(position >= 0); Assert.isTrue(position <= fDocument.getLength()); try { fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, position, false); } catch (BadLocationException e) { fCachedPartition= new TypedRegion(position, 0, "__no_partition_at_all"); //$NON-NLS-1$ } } return fCachedPartition; }
/** * Returns the partition at <code>position</code>. * * @param position the position to get the partition for * @return the partition at <code>position</code> or a dummy zero-length * partition if accessing the document fails */ private ITypedRegion getPartition(int position) { if (!contains(fCachedPartition, position)) { Assert.isTrue(position >= 0); Assert.isTrue(position <= fDocument.getLength()); try { fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, position, false); } catch (BadLocationException e) { fCachedPartition= new TypedRegion(position, 0, "__no_partition_at_all"); //$NON-NLS-1$ } } return fCachedPartition; }