}
}
private IModelElement getEnclosingMethod(IModelElement input,
ITextSelection selection) {
IModelElement enclosingElement = null;
try {
switch (input.getElementType()) {
// case IModelElement.CLASS_FILE :
// IClassFile classFile= (IClassFile)
// input.getAncestor(IModelElement.CLASS_FILE);
// if (classFile != null) {
// enclosingElement= classFile.getElementAt(selection.getOffset());
// }
// break;
case IModelElement.SOURCE_MODULE:
ISourceModule cu = (ISourceModule) input
.getAncestor(IModelElement.SOURCE_MODULE);
if (cu != null) {
enclosingElement = cu.getElementAt(selection.getOffset());
}
break;
}
if (enclosingElement != null
&& enclosingElement.getElementType() == IModelElement.METHOD) {
return enclosingElement;
}
} catch (ModelException e) {
DLTKUIPlugin.log(e);
}