List of usage examples for org.eclipse.jdt.internal.core NamedMember getDeclaringType
@Override
public IType getDeclaringType()
From source file:org.eclipse.wst.xml.search.editor.util.JdtUtils.java
License:Open Source License
public static boolean isImplementsClass(final IJavaElement javaElement, final String className) throws JavaModelException { Assert.isNotNull(javaElement);/* ww w.j av a 2s . co m*/ if (javaElement != null && javaElement instanceof NamedMember) { final NamedMember method = (NamedMember) javaElement; final IType type = method.getDeclaringType(); if (type != null) { if (type.getFullyQualifiedName().equals(className)) { return true; } return hierarchyContainsComponent(type, className); } } return false; }
From source file:qwickie.util.DocumentHelper.java
License:Apache License
/** Finds the IRegion where a wicket Component (one that extends Component) is found */ public static IRegion getRegionOfWicketComponent(final IDocument document, final int offset, final IJavaElement javaElement) throws JavaModelException { if (javaElement != null && javaElement instanceof NamedMember) { final NamedMember method = (NamedMember) javaElement; final IType type = method.getDeclaringType(); if (type != null) { final ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null); if (hierarchy != null) { final IType[] supertypes = hierarchy.getAllSupertypes(type); for (final IType iType : supertypes) { if (iType.getFullyQualifiedName().equals(TypeHelper.COMPONENT)) { try { final IRegion lineInfo = document.getLineInformationOfOffset(offset); final String line = document.get(lineInfo.getOffset(), lineInfo.getLength()); final int lineRelativeOffset = offset - lineInfo.getOffset(); final int index = line.indexOf(javaElement.getElementName()); return new Region(offset - lineRelativeOffset + index, javaElement.getElementName().length()); } catch (final Exception ex) { return null; }/* w ww. j a v a 2 s . c o m*/ } } } } } return null; }