*/
protected IJavaElement getElement(
IJavaProject javaProject, String filename, int offset, int length)
throws Exception
{
ICodeAssist code = null;
try{
code = JavaUtils.getCompilationUnit(javaProject, filename);
}catch(IllegalArgumentException iae){
// source not found, try location the class file.
code = JavaUtils.findClassFile(javaProject, filename);
}
if (code != null){
IJavaElement[] elements = code.codeSelect(offset, length);
if(elements != null && elements.length > 0){
return elements[0];
}
}
return null;