Search in sources :

Example 1 with JavaElementImageDescriptor

use of org.eclipse.jdt.ui.JavaElementImageDescriptor in project che by eclipse.

the class ParameterGuesser method evaluateVisibleMatches.

private List<Variable> evaluateVisibleMatches(String expectedType, IJavaElement[] suggestions) throws JavaModelException {
    IType currentType = null;
    if (fEnclosingElement != null) {
        currentType = (IType) fEnclosingElement.getAncestor(IJavaElement.TYPE);
    }
    ArrayList<Variable> res = new ArrayList<Variable>();
    for (int i = 0; i < suggestions.length; i++) {
        Variable variable = createVariable(suggestions[i], currentType, expectedType, i);
        if (variable != null) {
            if (fAlreadyMatchedNames.contains(variable.name)) {
                variable.alreadyMatched = true;
            }
            res.add(variable);
        }
    }
    // add 'this'
    if (currentType != null && !(fEnclosingElement instanceof IMethod && Flags.isStatic(((IMethod) fEnclosingElement).getFlags()))) {
        String fullyQualifiedName = currentType.getFullyQualifiedName('.');
        if (fullyQualifiedName.equals(expectedType)) {
            ImageDescriptor desc = new JavaElementImageDescriptor(JavaPluginImages.DESC_FIELD_PUBLIC, JavaElementImageDescriptor.FINAL | JavaElementImageDescriptor.STATIC);
            res.add(new Variable(fullyQualifiedName, "this", Variable.LITERALS, false, res.size(), new char[] { '.' }, //$NON-NLS-1$
            desc));
        }
    }
    Code primitiveTypeCode = getPrimitiveTypeCode(expectedType);
    if (primitiveTypeCode == null) {
        // add 'null'
        //$NON-NLS-1$
        res.add(new Variable(expectedType, "null", Variable.LITERALS, false, res.size(), NO_TRIGGERS, null));
    } else {
        String typeName = primitiveTypeCode.toString();
        boolean isAutoboxing = !typeName.equals(expectedType);
        if (primitiveTypeCode == PrimitiveType.BOOLEAN) {
            // add 'true', 'false'
            //$NON-NLS-1$
            res.add(new Variable(typeName, "true", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null));
            //$NON-NLS-1$
            res.add(new Variable(typeName, "false", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null));
        } else {
            // add 0
            //$NON-NLS-1$
            res.add(new Variable(typeName, "0", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null));
        }
    }
    return res;
}
Also used : ILocalVariable(org.eclipse.jdt.core.ILocalVariable) ArrayList(java.util.ArrayList) JavaElementImageDescriptor(org.eclipse.jdt.ui.JavaElementImageDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IMethod(org.eclipse.jdt.core.IMethod) Code(org.eclipse.jdt.core.dom.PrimitiveType.Code) JavaElementImageDescriptor(org.eclipse.jdt.ui.JavaElementImageDescriptor) IType(org.eclipse.jdt.core.IType)

Example 2 with JavaElementImageDescriptor

use of org.eclipse.jdt.ui.JavaElementImageDescriptor in project che by eclipse.

the class JavaElementImageProvider method getJavaImageDescriptor.

//	/**
//	 * Returns an image descriptor for a compilation unit not on the class path.
//	 * The descriptor includes overlays, if specified.
//	 * @param file the cu resource file
//	 * @param flags the image flags
//	 * @return returns the image descriptor
//	 */
//	public ImageDescriptor getCUResourceImageDescriptor(IFile file, int flags) {
//		Point size = useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
//		return new JavaElementImageDescriptor(JavaPluginImages.DESC_OBJS_CUNIT_RESOURCE, 0, size);
//	}
/**
	 * 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);
    }
    return new JavaElementImageDescriptor(JavaPluginImages.DESC_OBJS_GHOST, 0);
}
Also used : JavaElementImageDescriptor(org.eclipse.jdt.ui.JavaElementImageDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) JavaElementImageDescriptor(org.eclipse.jdt.ui.JavaElementImageDescriptor)

Example 3 with JavaElementImageDescriptor

use of org.eclipse.jdt.ui.JavaElementImageDescriptor in project che by eclipse.

the class CompletionProposalLabelProvider method decorateImageDescriptor.

/**
	 * 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);
}
Also used : CompletionProposal(org.eclipse.jdt.core.CompletionProposal) JavaElementImageDescriptor(org.eclipse.jdt.ui.JavaElementImageDescriptor)

Example 4 with JavaElementImageDescriptor

use of org.eclipse.jdt.ui.JavaElementImageDescriptor in project che by eclipse.

the class BindingLabelProvider method getBindingImageDescriptor.

/**
	 * 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);
    }
    return null;
}
Also used : JavaElementImageDescriptor(org.eclipse.jdt.ui.JavaElementImageDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) JavaElementImageDescriptor(org.eclipse.jdt.ui.JavaElementImageDescriptor)

Aggregations

JavaElementImageDescriptor (org.eclipse.jdt.ui.JavaElementImageDescriptor)4 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 Point (org.eclipse.swt.graphics.Point)2 ArrayList (java.util.ArrayList)1 CompletionProposal (org.eclipse.jdt.core.CompletionProposal)1 ILocalVariable (org.eclipse.jdt.core.ILocalVariable)1 IMethod (org.eclipse.jdt.core.IMethod)1 IType (org.eclipse.jdt.core.IType)1 Code (org.eclipse.jdt.core.dom.PrimitiveType.Code)1