本文整理汇总了Java中org.eclipse.jdt.core.IMember.getElementType方法的典型用法代码示例。如果您正苦于以下问题:Java IMember.getElementType方法的具体用法?Java IMember.getElementType怎么用?Java IMember.getElementType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IMember
的用法示例。
在下文中一共展示了IMember.getElementType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHTMLContentReader
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
/**
* Gets a reader for an IMember's Javadoc comment content from the source attachment. and renders
* the tags in HTML. 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 org.eclipse.jdt.core.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;
}
示例2: isExtractSupertypeAvailable
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isExtractSupertypeAvailable(IMember member) throws JavaModelException {
if (!member.exists()) return false;
final int type = member.getElementType();
if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
return false;
if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE) return false;
if (!Checks.isAvailable(member)) return false;
if (member instanceof IMethod) {
final IMethod method = (IMethod) member;
if (method.isConstructor()) return false;
if (JdtFlags.isNative(method)) return false;
member = method.getDeclaringType();
} else if (member instanceof IField) {
member = member.getDeclaringType();
}
if (member instanceof IType) {
if (JdtFlags.isEnum(member) || JdtFlags.isAnnotation(member)) return false;
if (member.getDeclaringType() != null && !JdtFlags.isStatic(member)) return false;
if (((IType) member).isAnonymous())
return false; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=253727
if (((IType) member).isLambda()) return false;
}
return true;
}
示例3: isMoveStaticAvailable
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isMoveStaticAvailable(final IMember member) throws JavaModelException {
if (!member.exists()) return false;
final int type = member.getElementType();
if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
return false;
if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE) return false;
final IType declaring = member.getDeclaringType();
if (declaring == null) return false;
if (!Checks.isAvailable(member)) return false;
if (type == IJavaElement.METHOD && declaring.isInterface()) {
boolean is18OrHigher = JavaModelUtil.is18OrHigher(member.getJavaProject());
if (!is18OrHigher || !Flags.isStatic(member.getFlags())) return false;
}
if (type == IJavaElement.METHOD && !JdtFlags.isStatic(member)) return false;
if (type == IJavaElement.METHOD && ((IMethod) member).isConstructor()) return false;
if (type == IJavaElement.TYPE && !JdtFlags.isStatic(member)) return false;
if (!declaring.isInterface() && !JdtFlags.isStatic(member)) return false;
return true;
}
示例4: isPullUpAvailable
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isPullUpAvailable(IMember member) throws JavaModelException {
if (!member.exists()) return false;
final int type = member.getElementType();
if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
return false;
if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE) return false;
if (!Checks.isAvailable(member)) return false;
if (member instanceof IType) {
if (!JdtFlags.isStatic(member) && !JdtFlags.isEnum(member) && !JdtFlags.isAnnotation(member))
return false;
}
if (member instanceof IMethod) {
final IMethod method = (IMethod) member;
if (method.isConstructor()) return false;
if (JdtFlags.isNative(method)) return false;
final IType declaring = method.getDeclaringType();
if (declaring != null && declaring.isAnnotation()) return false;
}
return true;
}
示例5: isPushDownAvailable
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isPushDownAvailable(final IMember member) throws JavaModelException {
if (!member.exists()) return false;
final int type = member.getElementType();
if (type != IJavaElement.METHOD && type != IJavaElement.FIELD) return false;
if (JdtFlags.isEnum(member)) return false;
if (!Checks.isAvailable(member)) return false;
if (JdtFlags.isStatic(member)) return false;
if (type == IJavaElement.METHOD) {
final IMethod method = (IMethod) member;
if (method.isConstructor()) return false;
if (JdtFlags.isNative(method)) return false;
final IType declaring = method.getDeclaringType();
if (declaring != null && declaring.isAnnotation()) return false;
}
return true;
}
示例6: isVisible
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
/**
* Evaluates if a member (possible from another package) is visible from elements in a package.
*
* @param member The member to test the visibility for
* @param pack The package in 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 isVisible(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)
|| (declaringType != null && isInterfaceOrAnnotation(declaringType))) {
return true;
} else if (Flags.isPrivate(otherflags)) {
return false;
}
IPackageFragment otherpack =
(IPackageFragment) member.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
return (pack != null && otherpack != null && isSamePackage(pack, otherpack));
}
示例7: getIMethodFromMethodWrapper
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
private static IMethod getIMethodFromMethodWrapper(MethodWrapper m) {
try {
IMember im = m.getMember();
if (im.getElementType() == IJavaElement.METHOD) {
return (IMethod) m.getMember();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例8: getKind
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
private String getKind(IMember member) {
switch (member.getElementType()) {
case IJavaElement.METHOD:
return KIND_METHOD;
case IJavaElement.INITIALIZER:
return KIND_INITIALIZER;
case IJavaElement.FIELD:
return KIND_FIELD;
case IJavaElement.TYPE:
IType type = (IType) member;
try {
if (type.isAnnotation()) {
return KIND_ANNOTATION;
}
if (type.isInterface()) {
return KIND_INTERFACE;
}
if (type.isEnum()) {
return KIND_ENUM;
}
if (type.isClass()) {
return KIND_CLASS;
}
} catch (JavaModelException e) {
return KIND_TYPE;
}
return KIND_TYPE;
default:
return null;
}
}
示例9: isStatic
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
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());
}
示例10: acceptSearchMatch
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
if (match.getAccuracy() == SearchMatch.A_ACCURATE && !match.isInsideDocComment()) {
Object element = match.getElement();
if (element instanceof IType || element instanceof IMethod) {
IMember member = (IMember) element;
IType type =
member.getElementType() == IJavaElement.TYPE
? (IType) member
: member.getDeclaringType();
addTypeAndSubtypes(type);
}
}
}
示例11: createSignature
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static String createSignature(IMember member) {
switch (member.getElementType()) {
case IJavaElement.FIELD:
return createFieldSignature((IField) member);
case IJavaElement.TYPE:
return BasicElementLabels.getJavaElementName(((IType) member).getFullyQualifiedName('.'));
case IJavaElement.INITIALIZER:
return RefactoringCoreMessages.JavaElementUtil_initializer;
case IJavaElement.METHOD:
return createMethodSignature((IMethod) member);
default:
Assert.isTrue(false);
return null;
}
}
示例12: isInterfaceOrAnnotationField
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
private static boolean isInterfaceOrAnnotationField(IMember element) throws JavaModelException {
// always show the final symbol on interface fields
if (element.getElementType() == IJavaElement.FIELD) {
return JavaModelUtil.isInterfaceOrAnnotation(element.getDeclaringType());
}
return false;
}
示例13: isInterfaceOrAnnotationFieldOrType
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
private static boolean isInterfaceOrAnnotationFieldOrType(IMember element)
throws JavaModelException {
// always show the static symbol on interface fields and types
if (element.getElementType() == IJavaElement.FIELD) {
return JavaModelUtil.isInterfaceOrAnnotation(element.getDeclaringType());
} else if (element.getElementType() == IJavaElement.TYPE
&& element.getDeclaringType() != null) {
return JavaModelUtil.isInterfaceOrAnnotation(element.getDeclaringType());
}
return false;
}
示例14: getHTMLContentReader
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
/**
* Gets a reader for an IMember's Javadoc comment content from the source
* attachment. and renders the tags in HTML. 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
*/
static Reader getHTMLContentReader(IMember member, boolean allowInherited, boolean useAttachedJavadoc)
throws JavaModelException {
Reader contentReader= internalGetContentReader(member);
if (contentReader != null) {
return 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, useAttachedJavadoc);
}
return null;
}
示例15: isInterfaceOrAnnotationMethod
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
private static boolean isInterfaceOrAnnotationMethod(IMember member) throws JavaModelException {
return member.getElementType() == IJavaElement.METHOD && isInterfaceOrAnnotationMember(member);
}