final Object input = getTreeViewer().getInput();
if (!(input instanceof ISourceElement)) {
return null;
}
final ISourceFile sourceFile = ((ISourceElement) input).getSourceFile();
final ISourceElement element = SourceElementUtil.getSourceElement(sourceFile,
selection.getOffset());
if (element == null) {
return null;
}
return new StructuredSelection(element);