List of usage examples for org.eclipse.jdt.internal.core SourceType getMethods
@Override public IMethod[] getMethods() throws JavaModelException
From source file:costabs.utils.SourceUtils.java
License:Open Source License
public static IMethod[] getMethodsFromJavaFile(IJavaElement element) throws Exception { try {//from ww w . j a v a 2s . c o m ICompilationUnit unit = (ICompilationUnit) element; IJavaElement elements[] = unit.getChildren(); for (int i = 0; i < elements.length; i++) { //LogUtils.debug(elements[i].getClass()); if (elements[i] instanceof org.eclipse.jdt.internal.core.SourceType) { SourceType source = (SourceType) elements[i]; return source.getMethods(); } } throw new Exception("No methods found in file "); } catch (Exception e) { throw new Exception("Cannot find the methods from Java file"); } }