List of usage examples for org.eclipse.jdt.core IMethod getPrimaryElement
IJavaElement getPrimaryElement();
From source file:org.eclipse.jst.j2ee.internal.common.operations.JavaModelUtil.java
License:Open Source License
private static IMethod toOriginalMethod(IMethod method) { ICompilationUnit cu = method.getCompilationUnit(); if (cu == null || isPrimary(cu)) { return method; }//from w w w . ja v a 2 s .c o m try { //use the workaround only if needed if (!method.getElementName().equals(method.getDeclaringType().getElementName())) return (IMethod) method.getPrimaryElement(); IType originalType = (IType) toOriginal(method.getDeclaringType()); IMethod[] methods = originalType.findMethods(method); boolean isConstructor = method.isConstructor(); for (int i = 0; i < methods.length; i++) { if (methods[i].isConstructor() == isConstructor) return methods[i]; } return null; } catch (JavaModelException e) { return null; } }
From source file:org.eclipse.jst.jsf.common.ui.internal.utils.JavaModelUtil.java
License:Open Source License
private static IMethod toOriginalMethod(IMethod method) { ICompilationUnit cu = method.getCompilationUnit(); if (cu == null || isPrimary(cu)) { return method; }//from w w w .j a v a 2s. c om try { // use the workaround only if needed if (!method.getElementName().equals(method.getDeclaringType().getElementName())) return (IMethod) method.getPrimaryElement(); IType originalType = (IType) toOriginal(method.getDeclaringType()); IMethod[] methods = originalType.findMethods(method); boolean isConstructor = method.isConstructor(); for (int i = 0; i < methods.length; i++) { if (methods[i].isConstructor() == isConstructor) return methods[i]; } return null; } catch (JavaModelException e) { return null; } }