本文整理汇总了Java中org.eclipse.jdt.core.Flags.isSynchronized方法的典型用法代码示例。如果您正苦于以下问题:Java Flags.isSynchronized方法的具体用法?Java Flags.isSynchronized怎么用?Java Flags.isSynchronized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.Flags
的用法示例。
在下文中一共展示了Flags.isSynchronized方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSetterStub
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
* Create a stub for a getter of the given field using getter/setter
* templates. The resulting code has to be formatted and indented.
*
* @param field
* The field to create a getter for
* @param setterName
* The chosen name for the setter
* @param addComments
* If <code>true</code>, comments will be added.
* @param flags
* The flags signaling visibility, if static, synchronized or
* final
* @return Returns the generated stub.
* @throws CoreException
* when stub creation failed
*/
public static String getSetterStub(IField field, String setterName, boolean addComments, int flags) throws CoreException {
String fieldName = field.getElementName();
IType parentType = field.getDeclaringType();
String returnSig = field.getTypeSignature();
String typeName = Signature.toString(returnSig);
IJavaProject project = field.getJavaProject();
String accessorName = StubUtility.getBaseName(field);
String argname = StubUtility.suggestArgumentName(project, accessorName, EMPTY);
boolean isStatic = Flags.isStatic(flags);
boolean isSync = Flags.isSynchronized(flags);
boolean isFinal = Flags.isFinal(flags);
String lineDelim = "\n"; // Use default line delimiter, as generated stub has to be formatted anyway //$NON-NLS-1$
StringBuffer buf = new StringBuffer();
if (addComments) {
String comment = CodeGeneration.getSetterComment(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), setterName, field.getElementName(), typeName, argname, accessorName, lineDelim);
if (comment != null) {
buf.append(comment);
}
}
buf.append(JdtFlags.getVisibilityString(flags));
buf.append(' ');
if (isStatic) {
buf.append("static "); //$NON-NLS-1$
}
if (isSync) {
buf.append("synchronized "); //$NON-NLS-1$
}
if (isFinal) {
buf.append("final "); //$NON-NLS-1$
}
buf.append("void "); //$NON-NLS-1$
buf.append(setterName);
buf.append('(');
buf.append(typeName);
buf.append(' ');
buf.append(argname);
buf.append(") {"); //$NON-NLS-1$
buf.append(lineDelim);
if (argname.equals(fieldName) || !isStatic) {
if (isStatic) {
fieldName = parentType.getElementName() + '.' + fieldName;
} else {
fieldName = "this." + fieldName; //$NON-NLS-1$
}
}
String body = CodeGeneration.getSetterMethodBodyContent(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), setterName, fieldName, argname, lineDelim);
if (body != null) {
buf.append(body);
}
buf.append("}"); //$NON-NLS-1$
return buf.toString();
}
示例2: getGetterStub
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
* Create a stub for a getter of the given field using getter/setter
* templates. The resulting code has to be formatted and indented.
*
* @param field
* The field to create a getter for
* @param getterName
* The chosen name for the getter
* @param addComments
* If <code>true</code>, comments will be added.
* @param flags
* The flags signaling visibility, if static, synchronized or
* final
* @return Returns the generated stub.
* @throws CoreException
* when stub creation failed
*/
public static String getGetterStub(IField field, String getterName, boolean addComments, int flags) throws CoreException {
String fieldName = field.getElementName();
IType parentType = field.getDeclaringType();
boolean isStatic = Flags.isStatic(flags);
boolean isSync = Flags.isSynchronized(flags);
boolean isFinal = Flags.isFinal(flags);
String typeName = Signature.toString(field.getTypeSignature());
String accessorName = StubUtility.getBaseName(field);
String lineDelim = "\n"; // Use default line delimiter, as generated stub has to be formatted anyway //$NON-NLS-1$
StringBuffer buf = new StringBuffer();
if (addComments) {
String comment = CodeGeneration.getGetterComment(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), getterName, field.getElementName(), typeName, accessorName, lineDelim);
if (comment != null) {
buf.append(comment);
}
}
buf.append(JdtFlags.getVisibilityString(flags));
buf.append(' ');
if (isStatic) {
buf.append("static "); //$NON-NLS-1$
}
if (isSync) {
buf.append("synchronized "); //$NON-NLS-1$
}
if (isFinal) {
buf.append("final "); //$NON-NLS-1$
}
buf.append(typeName);
buf.append(' ');
buf.append(getterName);
buf.append("() {"); //$NON-NLS-1$
buf.append(lineDelim);
String body = CodeGeneration.getGetterMethodBodyContent(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), getterName, fieldName, lineDelim);
if (body != null) {
buf.append(body);
}
buf.append("}"); //$NON-NLS-1$
return buf.toString();
}
示例3: getModifiers
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private String getModifiers(int flags, int typeFlags) {
StringBuilder modifiers = new StringBuilder();
// package private modifier has no string representation
if (Flags.isPublic(flags)) {
modifiers.append("public ");
}
if (Flags.isProtected(flags)) {
modifiers.append("protected ");
}
if (Flags.isPrivate(flags)) {
modifiers.append("private ");
}
if (Flags.isStatic(flags)) {
modifiers.append("static ");
}
if (Flags.isAbstract(flags) && !Flags.isInterface(typeFlags)) {
modifiers.append("abstract ");
}
if (Flags.isFinal(flags)) {
modifiers.append("final ");
}
if (Flags.isNative(flags)) {
modifiers.append("native ");
}
if (Flags.isSynchronized(flags)) {
modifiers.append("synchronized ");
}
if (Flags.isVolatile(flags)) {
modifiers.append("volatile ");
}
int len = modifiers.length();
if (len == 0) return "";
modifiers.setLength(len - 1);
return modifiers.toString();
}
示例4: 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*/);
}
示例5: isSynchronized
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public static boolean isSynchronized(IMember member) throws JavaModelException {
return Flags.isSynchronized(member.getFlags());
}
示例6: getGetterStub
import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
* Create a stub for a getter of the given field using getter/setter templates. The resulting code
* has to be formatted and indented.
*
* @param field The field to create a getter for
* @param getterName The chosen name for the getter
* @param addComments If <code>true</code>, comments will be added.
* @param flags The flags signaling visibility, if static, synchronized or final
* @return Returns the generated stub.
* @throws CoreException when stub creation failed
*/
public static String getGetterStub(
IField field, String getterName, boolean addComments, int flags) throws CoreException {
String fieldName = field.getElementName();
IType parentType = field.getDeclaringType();
boolean isStatic = Flags.isStatic(flags);
boolean isSync = Flags.isSynchronized(flags);
boolean isFinal = Flags.isFinal(flags);
String typeName = Signature.toString(field.getTypeSignature());
String accessorName = StubUtility.getBaseName(field);
String lineDelim =
"\n"; // Use default line delimiter, as generated stub has to be formatted anyway
// //$NON-NLS-1$
StringBuffer buf = new StringBuffer();
if (addComments) {
String comment =
CodeGeneration.getGetterComment(
field.getCompilationUnit(),
parentType.getTypeQualifiedName('.'),
getterName,
field.getElementName(),
typeName,
accessorName,
lineDelim);
if (comment != null) {
buf.append(comment);
buf.append(lineDelim);
}
}
buf.append(JdtFlags.getVisibilityString(flags));
buf.append(' ');
if (isStatic) buf.append("static "); // $NON-NLS-1$
if (isSync) buf.append("synchronized "); // $NON-NLS-1$
if (isFinal) buf.append("final "); // $NON-NLS-1$
buf.append(typeName);
buf.append(' ');
buf.append(getterName);
buf.append("() {"); // $NON-NLS-1$
buf.append(lineDelim);
boolean useThis = StubUtility.useThisForFieldAccess(field.getJavaProject());
if (useThis && !isStatic) {
fieldName = "this." + fieldName; // $NON-NLS-1$
}
String body =
CodeGeneration.getGetterMethodBodyContent(
field.getCompilationUnit(),
parentType.getTypeQualifiedName('.'),
getterName,
fieldName,
lineDelim);
if (body != null) {
buf.append(body);
}
buf.append("}"); // $NON-NLS-1$
buf.append(lineDelim);
return buf.toString();
}
示例7: 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;
}