Java Code Examples for org.eclipse.jdt.internal.corext.util.JavaModelUtil#isInterfaceOrAnnotation()

The following examples show how to use org.eclipse.jdt.internal.corext.util.JavaModelUtil#isInterfaceOrAnnotation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaElementUtil.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static IMethod[] getAllConstructors(IType type) throws JavaModelException {
	if (JavaModelUtil.isInterfaceOrAnnotation(type)) {
		return new IMethod[0];
	}
	List<IMethod> result= new ArrayList<>();
	IMethod[] methods= type.getMethods();
	for (int i= 0; i < methods.length; i++) {
		IMethod iMethod= methods[i];
		if (iMethod.isConstructor()) {
			result.add(iMethod);
		}
	}
	return result.toArray(new IMethod[result.size()]);
}
 
Example 2
Source File: RenameFieldProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static boolean isInstanceField(IField field) throws CoreException{
	if (JavaModelUtil.isInterfaceOrAnnotation(field.getDeclaringType())) {
		return false;
	} else {
		return ! JdtFlags.isStatic(field);
	}
}
 
Example 3
Source File: MemberVisibilityAdjustor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adjusts the visibility of the referenced body declaration.
 *
 * @param member the member where to adjust the visibility
 * @param threshold the visibility keyword representing the required visibility, or <code>null</code> for default visibility
 * @param template the message template to use
 * @throws JavaModelException if an error occurs
 */
private void adjustOutgoingVisibility(final IMember member, final ModifierKeyword threshold, final String template) throws JavaModelException {
	Assert.isTrue(!member.isBinary() && !member.isReadOnly());
	boolean adjust= true;
	final IType declaring= member.getDeclaringType();
	if (declaring != null && (JavaModelUtil.isInterfaceOrAnnotation(declaring)
			|| (member instanceof IField) && Flags.isEnum(member.getFlags()) 
			|| declaring.equals(fReferenced)))
		adjust= false;
	if (adjust && hasLowerVisibility(member.getFlags(), keywordToVisibility(threshold)) && needsVisibilityAdjustment(member, threshold))
		fAdjustments.put(member, new OutgoingMemberVisibilityAdjustment(member, threshold, RefactoringStatus.createStatus(fVisibilitySeverity, Messages.format(template, new String[] { JavaElementLabels.getTextLabel(member, JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.ALL_FULLY_QUALIFIED), getLabel(threshold)}), JavaStatusContext.create(member), null, RefactoringStatusEntry.NO_CODE, null)));
}
 
Example 4
Source File: JavaElementUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static IMethod[] getAllConstructors(IType type) throws JavaModelException {
	if (JavaModelUtil.isInterfaceOrAnnotation(type))
		return new IMethod[0];
	List<IMethod> result= new ArrayList<IMethod>();
	IMethod[] methods= type.getMethods();
	for (int i= 0; i < methods.length; i++) {
		IMethod iMethod= methods[i];
		if (iMethod.isConstructor())
			result.add(iMethod);
	}
	return result.toArray(new IMethod[result.size()]);
}
 
Example 5
Source File: JavaElementImageProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean confirmAbstract(IMember element) throws JavaModelException {
	// never show the abstract symbol on interfaces
	if (element.getElementType() == IJavaElement.TYPE) {
		return ! JavaModelUtil.isInterfaceOrAnnotation((IType) element);
	}
	return true;
}
 
Example 6
Source File: JavaElementImageProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: JavaElementImageProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 8
Source File: RenameFieldProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static boolean isInstanceField(IField field) throws CoreException{
	if (JavaModelUtil.isInterfaceOrAnnotation(field.getDeclaringType()))
		return false;
	else
		return ! JdtFlags.isStatic(field);
}
 
Example 9
Source File: MemberFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean isMemberInInterfaceOrAnnotation(IMember member) throws JavaModelException {
	IType parent= member.getDeclaringType();
	return parent != null && JavaModelUtil.isInterfaceOrAnnotation(parent);
}
 
Example 10
Source File: MemberFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean isFieldInInterfaceOrAnnotation(IMember member) throws JavaModelException {
	return (member.getElementType() == IJavaElement.FIELD) && JavaModelUtil.isInterfaceOrAnnotation(member.getDeclaringType());
}