* added some more tests * changed 3rd party licenses respectively fortune cookie message = Your present plans are going to succeed.
28 lines
895 B
Java
28 lines
895 B
Java
package com.sourcetrail;
|
|
|
|
import org.eclipse.jdt.core.dom.ASTNode;
|
|
import org.eclipse.jdt.core.dom.BodyDeclaration;
|
|
import org.eclipse.jdt.core.dom.CompilationUnit;
|
|
import org.eclipse.jdt.core.dom.Javadoc;
|
|
|
|
public class Utility
|
|
{
|
|
public static Range getRange(ASTNode node, CompilationUnit compilationUnit)
|
|
{
|
|
int startPosition = node.getStartPosition() + 1;
|
|
int endPosition = node.getStartPosition() + node.getLength() - 1;
|
|
|
|
if (node instanceof BodyDeclaration && ((BodyDeclaration) node).getJavadoc() != null)
|
|
{
|
|
Javadoc javadoc = ((BodyDeclaration) node).getJavadoc();
|
|
startPosition = javadoc.getStartPosition() + javadoc.getLength() + 2;
|
|
}
|
|
|
|
return new Range(
|
|
compilationUnit.getLineNumber(startPosition),
|
|
compilationUnit.getColumnNumber(startPosition),
|
|
compilationUnit.getLineNumber(endPosition),
|
|
compilationUnit.getColumnNumber(endPosition) + 1);
|
|
}
|
|
}
|