List of usage examples for org.eclipse.jdt.core IMember getElementType
int getElementType();
From source file:at.bestsolution.fxide.jdt.corext.util.JavaModelUtil.java
License:Open Source License
/** * Evaluates if a member in the focus' element hierarchy is visible from * elements in a package.//ww w . j a va 2 s . c o m * @param member The member to test the visibility for * @param pack The package of the focus element focus * @return returns <code>true</code> if the member is visible from the package * @throws JavaModelException thrown when the member can not be accessed */ public static boolean isVisibleInHierarchy(IMember member, IPackageFragment pack) throws JavaModelException { int type = member.getElementType(); if (type == IJavaElement.INITIALIZER || (type == IJavaElement.METHOD && member.getElementName().startsWith("<"))) { //$NON-NLS-1$ return false; } int otherflags = member.getFlags(); IType declaringType = member.getDeclaringType(); if (Flags.isPublic(otherflags) || Flags.isProtected(otherflags) || (declaringType != null && isInterfaceOrAnnotation(declaringType))) { return true; } else if (Flags.isPrivate(otherflags)) { return false; } IPackageFragment otherpack = (IPackageFragment) member.getAncestor(IJavaElement.PACKAGE_FRAGMENT); return (pack != null && pack.equals(otherpack)); }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
public static boolean isStatic(IMember member) throws JavaModelException { if (isNestedInterfaceOrAnnotation(member)) return true; if (member.getElementType() != IJavaElement.METHOD && isInterfaceOrAnnotationMember(member)) return true; if (isEnum(member) && (member.getElementType() == IJavaElement.FIELD || member.getDeclaringType() != null)) return true; return Flags.isStatic(member.getFlags()); }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
private static boolean isEnumTypeFinal(IMember member) throws JavaModelException { if (!(isEnum(member) && member.getElementType() == IJavaElement.TYPE)) return false; // An enum type is implicitly final unless it contains at least one enum constant that has a class body. IJavaElement[] children = member.getChildren(); for (IJavaElement child : children) { if (isEnumConstant((IMember) child) && ((IField) child).getChildren().length != 0) { return false; }//from w w w . j a v a 2 s. c om } return true; }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
private static boolean isInterfaceOrAnnotationMethod(IMember member) throws JavaModelException { return member.getElementType() == IJavaElement.METHOD && isInterfaceOrAnnotationMember(member); }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
private static boolean isInterfaceOrAnnotationField(IMember member) throws JavaModelException { return member.getElementType() == IJavaElement.FIELD && isInterfaceOrAnnotationMember(member); }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
private static boolean isNestedInterfaceOrAnnotation(IMember member) throws JavaModelException { return member.getElementType() == IJavaElement.TYPE && member.getDeclaringType() != null && JavaModelUtil.isInterfaceOrAnnotation((IType) member); }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
private static boolean isEnumConstant(IMember member) throws JavaModelException { return member.getElementType() == IJavaElement.FIELD && isEnum(member); }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
private static boolean isAnonymousType(IMember member) throws JavaModelException { return member.getElementType() == IJavaElement.TYPE && ((IType) member).isAnonymous(); }
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess.java
License:Open Source License
/** * Gets a reader for an IMember's Javadoc comment content from the source attachment. * The content does contain only the text from the comment without the Javadoc leading star characters. * Returns <code>null</code> if the member does not contain a Javadoc comment or if no source is available. * @param member The member to get the Javadoc of. * @param allowInherited For methods with no (Javadoc) comment, the comment of the overridden class * is returned if <code>allowInherited</code> is <code>true</code>. * @return Returns a reader for the Javadoc comment content or <code>null</code> if the member * does not contain a Javadoc comment or if no source is available * @throws JavaModelException is thrown when the elements javadoc can not be accessed *//*from w ww . j ava 2s . c om*/ public static Reader getContentReader(IMember member, boolean allowInherited) throws JavaModelException { Reader contentReader = internalGetContentReader(member); if (contentReader != null || !(allowInherited && (member.getElementType() == IJavaElement.METHOD))) return contentReader; return findDocInHierarchy((IMethod) member, false, false); }
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess.java
License:Open Source License
/** * Gets a reader for an IMember's Javadoc comment content from the source attachment. * and renders the tags in HTML./*from w w w . j ava 2 s .com*/ * Returns <code>null</code> if the member does not contain a Javadoc comment or if no source is available. * * @param member the member to get the Javadoc of. * @param allowInherited for methods with no (Javadoc) comment, the comment of the overridden * class is returned if <code>allowInherited</code> is <code>true</code> * @param useAttachedJavadoc if <code>true</code> Javadoc will be extracted from attached Javadoc * if there's no source * @return a reader for the Javadoc comment content in HTML or <code>null</code> if the member * does not contain a Javadoc comment or if no source is available * @throws JavaModelException is thrown when the elements Javadoc can not be accessed * @since 3.2 */ public static Reader getHTMLContentReader(IMember member, boolean allowInherited, boolean useAttachedJavadoc) throws JavaModelException { Reader contentReader = internalGetContentReader(member); if (contentReader != null) return new JavaDoc2HTMLTextReader(contentReader); if (useAttachedJavadoc && member.getOpenable().getBuffer() == null) { // only if no source available String s = member.getAttachedJavadoc(null); if (s != null) return new StringReader(s); } if (allowInherited && (member.getElementType() == IJavaElement.METHOD)) return findDocInHierarchy((IMethod) member, true, useAttachedJavadoc); return null; }