org.eclipse.wst.jsdt.core.ISourceRange Java Examples

The following examples show how to use org.eclipse.wst.jsdt.core.ISourceRange. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSDocAutoIndentStrategy.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * Returns <code>true</code> if the comment being inserted at
 * <code>command.offset</code> is the first comment (the first javadoc
 * comment if <code>ignoreJavadoc</code> is <code>true</code>) of the given
 * member.
 * <p>
 * see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=55325 (don't add
 * parameters if the member already has a comment)
 * </p>
 */
private boolean isFirstComment(IDocument document, DocumentCommand command, IMember member,
		boolean ignoreNonJavadoc) throws BadLocationException, JavaScriptModelException {
	IRegion partition = TextUtilities.getPartition(document, fPartitioning, command.offset, false);
	ISourceRange sourceRange = member.getSourceRange();
	if (sourceRange == null || sourceRange.getOffset() != partition.getOffset())
		return false;
	int srcOffset = sourceRange.getOffset();
	int srcLength = sourceRange.getLength();
	int nameRelativeOffset = member.getNameRange().getOffset() - srcOffset;
	int partitionRelativeOffset = partition.getOffset() - srcOffset;
	String token = ignoreNonJavadoc ? "/**" : "/*"; //$NON-NLS-1$ //$NON-NLS-2$
	return document.get(srcOffset, srcLength).lastIndexOf(token, nameRelativeOffset) == partitionRelativeOffset;
}
 
Example #2
Source File: NodeFinder.java    From api-mining with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Maps a selection to a given ASTNode, where the selection is defined using
 * a source range. It calls
 * <code>perform(root, range.getOffset(), range.getLength())</code>.
 * 
 * @return the result node
 * @see #perform(ASTNode, int, int)
 */
public static ASTNode perform(final ASTNode root, final ISourceRange range) {
	return perform(root, range.getOffset(), range.getLength());
}
 
Example #3
Source File: NodeFinder.java    From tassal with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Maps a selection to a given ASTNode, where the selection is defined using
 * a source range. It calls
 * <code>perform(root, range.getOffset(), range.getLength())</code>.
 * 
 * @return the result node
 * @see #perform(ASTNode, int, int)
 */
public static ASTNode perform(final ASTNode root, final ISourceRange range) {
	return perform(root, range.getOffset(), range.getLength());
}
 
Example #4
Source File: NodeFinder.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Maps a selection to a given ASTNode, where the selection is defined using
 * a source range. It calls
 * <code>perform(root, range.getOffset(), range.getLength())</code>.
 * 
 * @return the result node
 * @see #perform(ASTNode, int, int)
 */
public static ASTNode perform(final ASTNode root, final ISourceRange range) {
	return perform(root, range.getOffset(), range.getLength());
}