本文整理汇总了Java中org.eclipse.jdt.core.Flags.isDefaultMethod方法的典型用法代码示例。如果您正苦于以下问题:Java Flags.isDefaultMethod方法的具体用法?Java Flags.isDefaultMethod怎么用?Java Flags.isDefaultMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.Flags
的用法示例。
在下文中一共展示了Flags.isDefaultMethod方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkDestinationInterfaceTargetMethods
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private RefactoringStatus checkDestinationInterfaceTargetMethods(IMethod sourceMethod) throws JavaModelException {
RefactoringStatus status = new RefactoringStatus();
logInfo("Checking destination interface target methods...");
// Ensure that target methods are not already default methods.
// For each method to move, add a warning if the associated target
// method is already default.
IMethod targetMethod = getTargetMethod(sourceMethod, Optional.empty());
if (targetMethod != null) {
int targetMethodFlags = targetMethod.getFlags();
if (Flags.isDefaultMethod(targetMethodFlags)) {
RefactoringStatusEntry entry = addError(status, sourceMethod,
PreconditionFailure.TargetMethodIsAlreadyDefault, targetMethod);
addUnmigratableMethod(sourceMethod, entry);
}
}
return status;
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:22,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java
示例2: getOldMethodSignature
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public String getOldMethodSignature() throws JavaModelException {
StringBuffer buff = new StringBuffer();
int flags = getMethod().getFlags();
buff.append(getVisibilityString(flags));
if (Flags.isStatic(flags)) {
buff.append("static "); // $NON-NLS-1$
} else if (Flags.isDefaultMethod(flags)) {
buff.append("default "); // $NON-NLS-1$
}
if (!getMethod().isConstructor()) buff.append(fReturnTypeInfo.getOldTypeName()).append(' ');
buff.append(
JavaElementLabels.getElementLabel(
fMethod.getParent(), JavaElementLabels.ALL_FULLY_QUALIFIED));
buff.append('.');
buff.append(fMethod.getElementName())
.append(Signature.C_PARAM_START)
.append(getOldMethodParameters())
.append(Signature.C_PARAM_END);
buff.append(getOldMethodThrows());
return BasicElementLabels.getJavaCodeString(buff.toString());
}
示例3: getNewMethodSignature
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public String getNewMethodSignature() throws JavaModelException {
StringBuffer buff = new StringBuffer();
buff.append(getVisibilityString(fVisibility));
int flags = getMethod().getFlags();
if (Flags.isStatic(flags)) {
buff.append("static "); // $NON-NLS-1$
} else if (Flags.isDefaultMethod(flags)) {
buff.append("default "); // $NON-NLS-1$
}
if (!getMethod().isConstructor()) buff.append(getReturnTypeString()).append(' ');
buff.append(getMethodName())
.append(Signature.C_PARAM_START)
.append(getMethodParameters())
.append(Signature.C_PARAM_END);
buff.append(getMethodThrows());
return BasicElementLabels.getJavaCodeString(buff.toString());
}
示例4: isAbstract
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public static boolean isAbstract(IMember member) throws JavaModelException {
int flags = member.getFlags();
if (!member.isBinary() && isInterfaceOrAnnotationMethod(member)) {
return !Flags.isStatic(flags) && !Flags.isDefaultMethod(flags);
}
return Flags.isAbstract(flags);
}
示例5: appendMethodDeclaration
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private int appendMethodDeclaration(StringBuffer cuString, String[] types, int parameterCount)
throws JavaModelException {
int flags = fMethod.getFlags();
if (Flags.isStatic(flags)) {
cuString.append("static "); // $NON-NLS-1$
} else if (Flags.isDefaultMethod(flags)) {
cuString.append("default "); // $NON-NLS-1$
}
ITypeParameter[] methodTypeParameters = fMethod.getTypeParameters();
if (methodTypeParameters.length != 0) {
cuString.append('<');
for (int i = 0; i < methodTypeParameters.length; i++) {
ITypeParameter typeParameter = methodTypeParameters[i];
if (i > 0) cuString.append(',');
cuString.append(typeParameter.getElementName());
}
cuString.append("> "); // $NON-NLS-1$
}
cuString.append(types[parameterCount]).append(' ');
int offsetBeforeMethodName = cuString.length();
cuString.append(METHOD_NAME).append('(');
for (int i = 0; i < parameterCount; i++) {
if (i > 0) cuString.append(',');
cuString.append(types[i]).append(" p").append(i); // $NON-NLS-1$
}
cuString.append(");"); // $NON-NLS-1$
return offsetBeforeMethodName;
}
示例6: decorateImageDescriptor
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
* Returns a version of <code>descriptor</code> decorated according to the passed <code>modifier
* </code> flags.
*
* @param descriptor the image descriptor to decorate
* @param proposal the proposal
* @return an image descriptor for a method proposal
* @see org.eclipse.jdt.core.Flags
*/
private ImageDescriptor decorateImageDescriptor(
ImageDescriptor descriptor, CompletionProposal proposal) {
int adornments = 0;
int flags = proposal.getFlags();
int kind = proposal.getKind();
boolean deprecated = Flags.isDeprecated(flags);
if (!deprecated) {
CompletionProposal[] requiredProposals = proposal.getRequiredProposals();
if (requiredProposals != null) {
for (int i = 0; i < requiredProposals.length; i++) {
CompletionProposal requiredProposal = requiredProposals[i];
if (requiredProposal.getKind() == CompletionProposal.TYPE_REF) {
deprecated |= Flags.isDeprecated(requiredProposal.getFlags());
}
}
}
}
if (deprecated) adornments |= JavaElementImageDescriptor.DEPRECATED;
if (kind == CompletionProposal.FIELD_REF
|| kind == CompletionProposal.METHOD_DECLARATION
|| kind == CompletionProposal.METHOD_NAME_REFERENCE
|| kind == CompletionProposal.METHOD_REF
|| kind == CompletionProposal.CONSTRUCTOR_INVOCATION)
if (Flags.isStatic(flags)) adornments |= JavaElementImageDescriptor.STATIC;
if (kind == CompletionProposal.METHOD_DECLARATION
|| kind == CompletionProposal.METHOD_NAME_REFERENCE
|| kind == CompletionProposal.METHOD_REF
|| kind == CompletionProposal.CONSTRUCTOR_INVOCATION)
if (Flags.isSynchronized(flags)) adornments |= JavaElementImageDescriptor.SYNCHRONIZED;
if (kind == CompletionProposal.METHOD_DECLARATION
|| kind == CompletionProposal.METHOD_NAME_REFERENCE
|| kind == CompletionProposal.METHOD_REF)
if (Flags.isDefaultMethod(flags)) adornments |= JavaElementImageDescriptor.DEFAULT_METHOD;
if (kind == CompletionProposal.ANNOTATION_ATTRIBUTE_REF)
if (Flags.isAnnnotationDefault(flags))
adornments |= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
if (kind == CompletionProposal.TYPE_REF && Flags.isAbstract(flags) && !Flags.isInterface(flags))
adornments |= JavaElementImageDescriptor.ABSTRACT;
if (kind == CompletionProposal.FIELD_REF) {
if (Flags.isFinal(flags)) adornments |= JavaElementImageDescriptor.FINAL;
if (Flags.isTransient(flags)) adornments |= JavaElementImageDescriptor.TRANSIENT;
if (Flags.isVolatile(flags)) adornments |= JavaElementImageDescriptor.VOLATILE;
}
return new JavaElementImageDescriptor(
descriptor, adornments /*, JavaElementImageProvider.SMALL_SIZE*/);
}
示例7: isDefaultMethod
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public static boolean isDefaultMethod(IMethod method) throws JavaModelException {
return Flags.isDefaultMethod(method.getFlags());
}
示例8: computeJavaAdornmentFlags
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private int computeJavaAdornmentFlags(IJavaElement element, int renderFlags) {
int flags = 0;
if (showOverlayIcons(renderFlags)) {
try {
if (element instanceof IMember) {
IMember member = (IMember) element;
int modifiers = member.getFlags();
if (confirmAbstract(member) && JdtFlags.isAbstract(member))
flags |= JavaElementImageDescriptor.ABSTRACT;
if (Flags.isFinal(modifiers)
|| isInterfaceOrAnnotationField(member)
|| isEnumConstant(member, modifiers)) flags |= JavaElementImageDescriptor.FINAL;
if (Flags.isStatic(modifiers)
|| isInterfaceOrAnnotationFieldOrType(member)
|| isEnumConstant(member, modifiers)) flags |= JavaElementImageDescriptor.STATIC;
if (Flags.isDeprecated(modifiers)) flags |= JavaElementImageDescriptor.DEPRECATED;
int elementType = element.getElementType();
if (elementType == IJavaElement.METHOD) {
if (((IMethod) element).isConstructor())
flags |= JavaElementImageDescriptor.CONSTRUCTOR;
if (Flags.isSynchronized(modifiers)) // collides with 'super' flag
flags |= JavaElementImageDescriptor.SYNCHRONIZED;
if (Flags.isNative(modifiers)) flags |= JavaElementImageDescriptor.NATIVE;
if (Flags.isDefaultMethod(modifiers))
flags |= JavaElementImageDescriptor.DEFAULT_METHOD;
if (Flags.isAnnnotationDefault(modifiers))
flags |= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
}
if (member.getElementType() == IJavaElement.TYPE) {
if (JavaModelUtil.hasMainMethod((IType) member)) {
flags |= JavaElementImageDescriptor.RUNNABLE;
}
}
if (member.getElementType() == IJavaElement.FIELD) {
if (Flags.isVolatile(modifiers)) flags |= JavaElementImageDescriptor.VOLATILE;
if (Flags.isTransient(modifiers)) flags |= JavaElementImageDescriptor.TRANSIENT;
}
} else if (element instanceof ILocalVariable
&& Flags.isFinal(((ILocalVariable) element).getFlags())) {
flags |= JavaElementImageDescriptor.FINAL;
}
} catch (JavaModelException e) {
// do nothing. Can't compute runnable adornment or get flags
}
}
return flags;
}