Java源码示例:org.eclipse.jdt.ui.JavaElementImageDescriptor
示例1
@Override
public Object image(IEObjectDescription element) {
EClass eClass = element.getEClass();
int adornments = (descriptionFlags.isStatic(element)) ? JavaElementImageDescriptor.STATIC : 0;
if (eClass == XTEND_FILE)
return images.forFile();
else if (eClass == XIMPORT_DECLARATION)
return images.forImport();
else if (eClass == XTEND_CLASS || eClass == TypesPackage.Literals.JVM_GENERIC_TYPE)
return images.forClass(JvmVisibility.PUBLIC, adornments);
else if (eClass == XTEND_FUNCTION)
return images.forOperation(JvmVisibility.PUBLIC, adornments);
else if (eClass == XTEND_FIELD)
return images.forField(JvmVisibility.PUBLIC, adornments);
else if (eClass == TypesPackage.Literals.JVM_OPERATION)
return (descriptionFlags.isDispatcherOperation(element))
? images.forDispatcherFunction(JvmVisibility.PUBLIC, adornments)
: images.forOperation(JvmVisibility.PUBLIC, adornments);
else
return super.image(element);
}
示例2
@Override
protected int computeAdornmentFlags(Object obj) {
if (!(obj instanceof IWorkingSet))
return super.computeAdornmentFlags(obj);
IWorkingSet workingSet= (IWorkingSet)obj;
IAdaptable[] elements= workingSet.getElements();
int result= 0;
for (int i= 0; i < elements.length; i++) {
IAdaptable element= elements[i];
int flags= super.computeAdornmentFlags(element);
if ((flags & JavaElementImageDescriptor.BUILDPATH_ERROR) != 0)
return JavaElementImageDescriptor.BUILDPATH_ERROR;
result|= flags;
}
if ((result & JavaElementImageDescriptor.ERROR) != 0)
return JavaElementImageDescriptor.ERROR;
else if ((result & JavaElementImageDescriptor.WARNING) != 0)
return JavaElementImageDescriptor.WARNING;
return 0;
}
示例3
@Override
public Image getImage(Object element) {
if (element instanceof JavadocLinkRef) {
JavadocLinkRef ref= (JavadocLinkRef) element;
ImageDescriptor desc;
if (ref.isProjectRef()) {
desc= PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
} else {
desc= JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_JAR);
}
if (ref.getURL() == null) {
return JavaPlugin.getImageDescriptorRegistry().get(new JavaElementImageDescriptor(desc, JavaElementImageDescriptor.WARNING, JavaElementImageProvider.SMALL_SIZE));
}
return JavaPlugin.getImageDescriptorRegistry().get(desc);
}
return null;
}
示例4
public MethodDeclarationCompletionProposal(IType type, String methodName, String returnTypeSig, int start, int length, int relevance) {
super("", type.getCompilationUnit(), start, length, null, getDisplayName(methodName, returnTypeSig), relevance); //$NON-NLS-1$
Assert.isNotNull(type);
Assert.isNotNull(methodName);
fType= type;
fMethodName= methodName;
fReturnTypeSig= returnTypeSig;
if (returnTypeSig == null) {
setProposalInfo(new ProposalInfo(type));
ImageDescriptor desc= new JavaElementImageDescriptor(JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE);
setImage(JavaPlugin.getImageDescriptorRegistry().get(desc));
} else {
setImage(JavaPluginImages.get(JavaPluginImages.IMG_MISC_PRIVATE));
}
}
示例5
@Override
public Image getImage() {
IStatus status= getFixStatus();
if (status != null && !status.isOK()) {
ImageImageDescriptor image= new ImageImageDescriptor(super.getImage());
int flag= JavaElementImageDescriptor.WARNING;
if (status.getSeverity() == IStatus.ERROR) {
flag= JavaElementImageDescriptor.ERROR;
}
ImageDescriptor composite= new JavaElementImageDescriptor(image, flag, new Point(image.getImageData().width, image.getImageData().height));
return composite.createImage();
} else {
return super.getImage();
}
}
示例6
@Override
protected int computeAdornmentFlags(Object element) {
if (element instanceof IPackageFragment) {
return computePackageAdornmentFlags((IPackageFragment) element);
} else if (element instanceof LogicalPackage) {
IPackageFragment[] fragments= ((LogicalPackage) element).getFragments();
int res= 0;
for (int i= 0; i < fragments.length; i++) {
int flags= computePackageAdornmentFlags(fragments[i]);
if (flags == JavaElementImageDescriptor.ERROR) {
return flags;
} else if (flags != 0) {
res= flags;
}
}
return res;
}
return super.computeAdornmentFlags(element);
}
示例7
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex != 0) {
return null;
}
NameConventionEntry entry= (NameConventionEntry) element;
ImageDescriptorRegistry registry= JavaPlugin.getImageDescriptorRegistry();
switch (entry.kind) {
case FIELD:
return registry.get(JavaPluginImages.DESC_FIELD_PUBLIC);
case STATIC:
return registry.get(new JavaElementImageDescriptor(JavaPluginImages.DESC_FIELD_PUBLIC, JavaElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE));
case STATIC_FINAL:
return registry.get(new JavaElementImageDescriptor(JavaPluginImages.DESC_FIELD_PUBLIC, JavaElementImageDescriptor.STATIC | JavaElementImageDescriptor.FINAL, JavaElementImageProvider.SMALL_SIZE));
case ARGUMENT:
return registry.get(JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE);
default:
return registry.get(JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE);
}
}
示例8
public Image forOperation(JvmVisibility visibility, boolean isAbstract, boolean isStatic, boolean isFinal) {
ImageDescriptor descriptor = JavaElementImageProvider.getMethodImageDescriptor(false,
toFlags(visibility, isAbstract, isStatic, isFinal));
int adornment = 0;
if(isStatic)
adornment |= JavaElementImageDescriptor.STATIC;
if(isFinal)
adornment |= JavaElementImageDescriptor.FINAL;
if(isAbstract)
adornment |= JavaElementImageDescriptor.ABSTRACT;
if (adornment != 0)
return getDecoratedJdtImage(descriptor, adornment);
else
return getJdtImage(descriptor);
}
示例9
public Image forField(JvmVisibility visibility, boolean isStatic, boolean isFinal, boolean isExtension) {
ImageDescriptor descriptor = JavaElementImageProvider.getFieldImageDescriptor(false,
toFlags(visibility, false, isStatic, isFinal));
int adornment = 0;
if(isStatic)
adornment |= JavaElementImageDescriptor.STATIC;
if(isFinal)
adornment |= JavaElementImageDescriptor.FINAL;
if (adornment != 0)
return getDecoratedJdtImage(descriptor, adornment);
else
return getJdtImage(descriptor);
}
示例10
@Override
protected Function<IEObjectDescription, ICompletionProposal> getWrappedFactory(EObject model, EReference reference,
final Function<IEObjectDescription, ICompletionProposal> proposalFactory) {
if (!TypesPackage.Literals.JVM_TYPE.isSuperTypeOf(getEReferenceType(model, reference))) {
return new Function<IEObjectDescription, ICompletionProposal>() {
@Override
public ICompletionProposal apply(IEObjectDescription from) {
ICompletionProposal result = proposalFactory.apply(from);
if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_FEATURE, from.getEClass())) {
if (result instanceof ConfigurableCompletionProposal) {
EObject eObjectOrProxy = from.getEObjectOrProxy();
if (eObjectOrProxy.eIsProxy()) {
Image img = null;
if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_CONSTRUCTOR, from.getEClass())) {
img = computeConstructorImage(false, false, Flags.AccPublic, JavaElementImageDescriptor.CONSTRUCTOR);
} else if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_OPERATION, from.getEClass())) {
img = computeMethodImage(false, Flags.AccPublic, 0);
} else if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_FIELD, from.getEClass())) {
img = computeFieldImage(false, Flags.AccPublic, 0);
}
if (img != null) {
((ConfigurableCompletionProposal) result).setImage(img);
}
} else {
((ConfigurableCompletionProposal) result).setImage(computeImage((JvmFeature)eObjectOrProxy));
}
}
}
else if (from instanceof SimpleIdentifiableElementDescription && isLocalVarOrFormalParameter(from)){
if (result instanceof ConfigurableCompletionProposal) {
((ConfigurableCompletionProposal) result).setImage(JavaPlugin.getImageDescriptorRegistry().get(JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE));
}
}
return result;
}
};
}
return super.getWrappedFactory(model, reference, proposalFactory);
}
示例11
@Override
public IXtendOutlineContext buildDispatcherNode(JvmDeclaredType baseType, JvmFeature dispatcher,
List<JvmOperation> dispatchCases, IXtendOutlineContext context) {
EclipseXtendOutlineContext eclipseXtendOutlineContext = (EclipseXtendOutlineContext) context;
IOutlineNode parentNode = eclipseXtendOutlineContext.getParentNode();
int inheritanceDepth = eclipseXtendOutlineContext.getInheritanceDepth();
XtendFeatureNode dispatcherNode = createNodeForFeature(parentNode, baseType, dispatcher, inheritanceDepth);
dispatcherNode.setDispatch(true);
if (isInheritsDispatchCases(baseType, dispatchCases)) {
dispatcherNode.setImageDescriptor(images.forDispatcherFunction(dispatcher.getVisibility(),
adornments.get(dispatcher) | JavaElementImageDescriptor.OVERRIDES));
}
return eclipseXtendOutlineContext.withParentNode(dispatcherNode);
}
示例12
private static int getAdornmentFlags(IBinding binding) {
int adornments= 0;
final int modifiers= binding.getModifiers();
if (Modifier.isAbstract(modifiers))
adornments|= JavaElementImageDescriptor.ABSTRACT;
if (Modifier.isFinal(modifiers))
adornments|= JavaElementImageDescriptor.FINAL;
if (Modifier.isStatic(modifiers))
adornments|= JavaElementImageDescriptor.STATIC;
if (binding.isDeprecated())
adornments|= JavaElementImageDescriptor.DEPRECATED;
if (binding instanceof IMethodBinding) {
if (((IMethodBinding) binding).isConstructor())
adornments|= JavaElementImageDescriptor.CONSTRUCTOR;
if (Modifier.isSynchronized(modifiers))
adornments|= JavaElementImageDescriptor.SYNCHRONIZED;
if (Modifier.isNative(modifiers))
adornments|= JavaElementImageDescriptor.NATIVE;
ITypeBinding type= ((IMethodBinding) binding).getDeclaringClass();
if (type.isInterface() && !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers))
adornments|= JavaElementImageDescriptor.DEFAULT_METHOD;
if (((IMethodBinding) binding).getDefaultValue() != null)
adornments|= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
}
if (binding instanceof IVariableBinding && ((IVariableBinding) binding).isField()) {
if (Modifier.isTransient(modifiers))
adornments|= JavaElementImageDescriptor.TRANSIENT;
if (Modifier.isVolatile(modifiers))
adornments|= JavaElementImageDescriptor.VOLATILE;
}
return adornments;
}
示例13
/**
* Returns the image descriptor for a binding with the flags as defined by {@link JavaElementImageProvider}.
* @param binding The binding to get the image for.
* @param imageFlags The image flags as defined in {@link JavaElementImageProvider}.
* @return the image of the binding or null if there is no image
*/
public static ImageDescriptor getBindingImageDescriptor(IBinding binding, int imageFlags) {
ImageDescriptor baseImage= getBaseImageDescriptor(binding, imageFlags);
if (baseImage != null) {
int adornmentFlags= getAdornmentFlags(binding);
Point size= ((imageFlags & JavaElementImageProvider.SMALL_ICONS) != 0) ? JavaElementImageProvider.SMALL_SIZE : JavaElementImageProvider.BIG_SIZE;
return new JavaElementImageDescriptor(baseImage, adornmentFlags, size);
}
return null;
}
示例14
/**
* Returns an image descriptor for a java element. The descriptor includes overlays, if specified.
* @param element the Java element
* @param flags the image flags
* @return returns the image descriptor
*/
public ImageDescriptor getJavaImageDescriptor(IJavaElement element, int flags) {
Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
ImageDescriptor baseDesc= getBaseImageDescriptor(element, flags);
if (baseDesc != null) {
int adornmentFlags= computeJavaAdornmentFlags(element, flags);
return new JavaElementImageDescriptor(baseDesc, adornmentFlags, size);
}
return new JavaElementImageDescriptor(JavaPluginImages.DESC_OBJS_GHOST, 0, size);
}
示例15
/**
* Returns an image descriptor for a IAdaptable. The descriptor includes overlays, if specified (only error ticks apply).
* Returns <code>null</code> if no image could be found.
* @param adaptable the adaptable
* @param flags the image flags
* @return returns the image descriptor
*/
public ImageDescriptor getWorkbenchImageDescriptor(IAdaptable adaptable, int flags) {
IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
if (wbAdapter == null) {
return null;
}
ImageDescriptor descriptor= wbAdapter.getImageDescriptor(adaptable);
if (descriptor == null) {
return null;
}
Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
return new JavaElementImageDescriptor(descriptor, 0, size);
}
示例16
public static ImageDescriptor getImageDescriptor(TypeNameMatch typeRef, int flags) {
if (isSet(SHOW_TYPE_CONTAINER_ONLY, flags)) {
if (typeRef.getPackageName().equals(typeRef.getTypeContainerName()))
return JavaPluginImages.DESC_OBJS_PACKAGE;
// XXX cannot check outer type for interface efficiently (5887)
return JavaPluginImages.DESC_OBJS_CLASS;
} else if (isSet(SHOW_PACKAGE_ONLY, flags)) {
return JavaPluginImages.DESC_OBJS_PACKAGE;
} else {
boolean isInner= typeRef.getTypeContainerName().indexOf('.') != -1;
int modifiers= typeRef.getModifiers();
ImageDescriptor desc= JavaElementImageProvider.getTypeImageDescriptor(isInner, false, modifiers, false);
int adornmentFlags= 0;
if (Flags.isFinal(modifiers)) {
adornmentFlags |= JavaElementImageDescriptor.FINAL;
}
if (Flags.isAbstract(modifiers) && !Flags.isInterface(modifiers)) {
adornmentFlags |= JavaElementImageDescriptor.ABSTRACT;
}
if (Flags.isStatic(modifiers)) {
adornmentFlags |= JavaElementImageDescriptor.STATIC;
}
if (Flags.isDeprecated(modifiers)) {
adornmentFlags |= JavaElementImageDescriptor.DEPRECATED;
}
return new JavaElementImageDescriptor(desc, adornmentFlags, JavaElementImageProvider.BIG_SIZE);
}
}
示例17
/** Replies the diagnotic adornment for the given element.
*
* @param element the model element.
* @return the adornment.
*/
@SuppressWarnings("static-method")
protected int getIssueAdornment(XtendMember element) {
final ICompositeNode node = NodeModelUtils.getNode(element);
if (node == null) {
return 0;
}
// Error markers are more important than warning markers.
// Order of checks:
// - parser error (from the resource) or semantic error (from Diagnostician)
// - parser warning or semantic warning
final Resource resource = element.eResource();
if (!resource.getURI().isArchive()) {
if (hasParserIssue(node, resource.getErrors())) {
return JavaElementImageDescriptor.ERROR;
}
final Diagnostic diagnostic = Diagnostician.INSTANCE.validate(element);
switch (diagnostic.getSeverity()) {
case Diagnostic.ERROR:
return JavaElementImageDescriptor.ERROR;
case Diagnostic.WARNING:
return JavaElementImageDescriptor.WARNING;
default:
}
if (hasParserIssue(node, resource.getWarnings())) {
return JavaElementImageDescriptor.WARNING;
}
}
return 0;
}
示例18
@Override
public Image decorateImage(Image image, Object element) {
if (element instanceof XtendMember) {
final int adornment = getIssueAdornment((XtendMember) element);
if (adornment != 0) {
final ImageDescriptor descriptor = this.imageDescriptorHelper.getImageDescriptor(image);
final ImageDescriptor newDescriptor = new JavaElementImageDescriptor(descriptor, adornment, imagesSize());
return convertToImage(newDescriptor);
}
}
return image;
}
示例19
/** Assert the given image descriptor is for an image in a bundle.
*
* @param filename the name of the image file.
* @param desc the image descriptor to test.
*/
protected static void assertBundleImage(String filename, ImageDescriptor desc) {
assertNotNull(desc);
String s = desc.toString();
String regex = Pattern.quote("URLImageDescriptor(bundleentry://") //$NON-NLS-1$
+ "[^/]+" //$NON-NLS-1$
+ Pattern.quote("/icons/") //$NON-NLS-1$
+ "([^/]+[/])*" //$NON-NLS-1$
+ Pattern.quote(filename + ")"); //$NON-NLS-1$
if (!Pattern.matches(regex, s)) {
if (desc instanceof JavaElementImageDescriptor) {
JavaElementImageDescriptor jeid = (JavaElementImageDescriptor) desc;
try {
Field field = JavaElementImageDescriptor.class.getDeclaredField("fBaseImage");
boolean isAcc = field.isAccessible();
field.setAccessible(true);
try {
ImageDescriptor id = (ImageDescriptor) field.get(jeid);
s = id.toString();
assertTrue("Invalid image: " + filename //$NON-NLS-1$
+ ". Actual: " + s, Pattern.matches(regex, s)); //$NON-NLS-1$
} finally {
field.setAccessible(isAcc);
}
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
fail("Invalid background image descriptor: " + jeid.getClass().getName());
}
}
}
}
示例20
/** Assert the given image descriptor is for an image given by JDT.
*
* @param expected the expected base image descriptor.
* @param expectedFlags the additional expected flags.
* @param actual the image descriptor to test.
* @throws Exception if the test cannot be done.
*/
protected static void assertJdtImage(ImageDescriptor expected, int expectedFlags, ImageDescriptor actual) throws Exception {
assertNotNull(actual);
assertTrue(actual instanceof JavaElementImageDescriptor);
assertImageDescriptors(expected, actual);
assertEquals("Not the same flags", expectedFlags,
((JavaElementImageDescriptor) actual).getAdronments());
assertEquals("Not the same size.", JavaElementImageProvider.BIG_SIZE,
((JavaElementImageDescriptor) actual).getImageSize());
}
示例21
/**
* @throws Exception
*/
@Test
public void imageConstructor() throws Exception {
assertJdtImage(
JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR,
this.provider.image(mockMember(SarlConstructor.class, JvmVisibility.PUBLIC)));
}
示例22
/**
* @throws Exception
*/
@Test
public void imageActionSignature() throws Exception {
SarlAction action = mockMember(SarlAction.class, JvmVisibility.PUBLIC, mockJvmOperation("fct", true)); //$NON-NLS-1$
when(action.getName()).thenReturn("fct"); //$NON-NLS-1$
when(action.getExpression()).thenReturn(null);
//
assertJdtImage(
JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.ABSTRACT,
this.provider.image(action));
}
示例23
/**
* @throws Exception
*/
@Test
public void getImageDescriptorConstructor() throws Exception {
assertJdtImage(
JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR,
this.provider.getImageDescriptor(mockMember(SarlConstructor.class, JvmVisibility.PUBLIC)));
}
示例24
/**
* @throws Exception
*/
@Test
public void getImageDescriptorActionSignature() throws Exception {
SarlAction action = mockMember(SarlAction.class, JvmVisibility.PUBLIC, mockJvmOperation("fct", true)); //$NON-NLS-1$
when(action.getName()).thenReturn("fct"); //$NON-NLS-1$
when(action.getExpression()).thenReturn(null);
//
assertJdtImage(
JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.ABSTRACT,
this.provider.getImageDescriptor(action));
}
示例25
/**
* @throws Exception
*/
@Test
public void forActionSignature() throws Exception {
assertJdtImage(
JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.ABSTRACT,
this.images.forOperation(JvmVisibility.PUBLIC, JavaElementImageDescriptor.ABSTRACT));
}
示例26
/**
* @throws Exception
*/
@Test
public void forField_notWritable() throws Exception {
assertJdtImage(
JavaPluginImages.DESC_FIELD_PROTECTED, JavaElementImageDescriptor.FINAL,
this.images.forField(JvmVisibility.PROTECTED, JavaElementImageDescriptor.FINAL));
}
示例27
public Image forConstructor(JvmVisibility visibility) {
return getDecoratedJdtImage(JavaElementImageProvider.getMethodImageDescriptor(false, toFlags(visibility)),
JavaElementImageDescriptor.CONSTRUCTOR);
}
示例28
protected ImageDescriptor getDecorated(ImageDescriptor baseImage, int adornments) {
return new JavaElementImageDescriptor(baseImage, adornments, imagesSize());
}
示例29
protected Image computeImage(JvmFeature feature) {
int flags = 0;
int decorator = 0;
switch(feature.getVisibility()) {
case PUBLIC: flags = Flags.AccPublic; break;
case PROTECTED: flags = Flags.AccProtected; break;
case PRIVATE: flags = Flags.AccPrivate; break;
case DEFAULT: flags = Flags.AccDefault; break;
}
JvmDeclaredType declaringType = feature.getDeclaringType();
boolean interfaceOrAnnotation = false;
if (declaringType instanceof JvmGenericType) {
interfaceOrAnnotation = ((JvmGenericType) declaringType).isInterface();
} else if (declaringType instanceof JvmAnnotationType) {
interfaceOrAnnotation = true;
}
if (feature instanceof JvmConstructor) {
decorator = JavaElementImageDescriptor.CONSTRUCTOR;
if (declaringType.isAbstract()) {
flags |= Flags.AccAbstract;
decorator |= JavaElementImageDescriptor.ABSTRACT;
}
return computeConstructorImage(declaringType.getDeclaringType() != null, interfaceOrAnnotation, flags, decorator);
} else if (feature instanceof JvmOperation) {
JvmOperation operation = (JvmOperation) feature;
if (operation.isStatic()) {
flags |= Flags.AccStatic;
decorator |= JavaElementImageDescriptor.STATIC;
}
if (operation.isAbstract()) {
flags |= Flags.AccAbstract;
decorator |= JavaElementImageDescriptor.ABSTRACT;
}
if (operation.isFinal()) {
flags |= Flags.AccFinal;
decorator |= JavaElementImageDescriptor.FINAL;
}
return computeMethodImage(interfaceOrAnnotation, flags, decorator);
} else if (feature instanceof JvmField) {
JvmField field = (JvmField) feature;
if (field.isStatic()) {
flags |= Flags.AccStatic;
decorator |= JavaElementImageDescriptor.STATIC;
}
if (field.isFinal()) {
flags |= Flags.AccFinal;
decorator |= JavaElementImageDescriptor.FINAL;
}
if (declaringType instanceof JvmEnumerationType)
flags |= Flags.AccEnum;
return computeFieldImage(interfaceOrAnnotation, flags, decorator);
}
return null;
}
示例30
/**
* 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 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);
}