Java Code Examples for org.eclipse.jdt.core.IType#isLambda()

The following examples show how to use org.eclipse.jdt.core.IType#isLambda() . 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: RefactoringAvailabilityTester.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
public static boolean isRenameAvailable(final IType type) throws JavaModelException {
	if (type == null) {
		return false;
	}
	if (type.isAnonymous()) {
		return false;
	}
	if (type.isLambda()) {
		return false;
	}
	if (!Checks.isAvailable(type)) {
		return false;
	}
	if (isRenameProhibited(type)) {
		return false;
	}
	return true;
}
 
Example 2
Source File: AbstractHierarchyViewerSorter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public int category(Object element) {
	if (element instanceof IType) {
		IType type= (IType) element;
		try {
			if (type.isAnonymous() || type.isLambda()) {
				return ANONYM;
			}
		} catch (JavaModelException e1) {
			if (type.getElementName().length() == 0) {
				return ANONYM;
			}
		}
		try {
			int flags= getTypeFlags(type);
			if (Flags.isInterface(flags)) {
				return INTERFACE;
			} else {
				return CLASS;
			}
		} catch (JavaModelException e) {
			// ignore
		}
	}
	return OTHER;
}
 
Example 3
Source File: RefactoringAvailabilityTester.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static boolean isExtractClassAvailable(IType type) throws JavaModelException {
	if (type == null) {
		return false;
	}
	if (!type.exists()) {
		return false;
	}
	return ReorgUtils.isInsideCompilationUnit(type) && type.isClass() && !type.isAnonymous() && !type.isLambda();
}
 
Example 4
Source File: RefactoringAvailabilityTester.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean isRenameAvailable(final IType type) throws JavaModelException {
	if (type == null)
		return false;
	if (type.isAnonymous())
		return false;
	if (type.isLambda())
		return false;
	if (!Checks.isAvailable(type))
		return false;
	if (isRenameProhibited(type))
		return false;
	return true;
}
 
Example 5
Source File: RefactoringAvailabilityTester.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean isExtractClassAvailable(IType type) throws JavaModelException {
	if (type == null)
		return false;
	if (!type.exists())
		return false;
	return ReorgUtils.isInsideCompilationUnit(type) && type.isClass() && !type.isAnonymous()  && !type.isLambda();
}
 
Example 6
Source File: RefactoringAvailabilityTester.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static boolean isExtractInterfaceAvailable(final IType type) throws JavaModelException {
	return Checks.isAvailable(type) && !type.isBinary() && !type.isReadOnly() && !type.isAnnotation() && !type.isAnonymous() && !type.isLambda();
}
 
Example 7
Source File: RefactoringAvailabilityTester.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static boolean isUseSuperTypeAvailable(final IType type) throws JavaModelException {
	return type != null && type.exists() && !type.isAnnotation() && !type.isAnonymous() && !type.isLambda();
}
 
Example 8
Source File: RefactoringAvailabilityTester.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isExtractInterfaceAvailable(final IType type) throws JavaModelException {
	return Checks.isAvailable(type) && !type.isBinary() && !type.isReadOnly() && !type.isAnnotation() && !type.isAnonymous() && !type.isLambda();
}
 
Example 9
Source File: RefactoringAvailabilityTester.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isUseSuperTypeAvailable(final IType type) throws JavaModelException {
	return type != null && type.exists() && !type.isAnnotation() && !type.isAnonymous() && !type.isLambda();
}
 
Example 10
Source File: AddJavaDocStubAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private IMember[] getSelectedMembers(IStructuredSelection selection) {
	List<?> elements= selection.toList();
	int nElements= elements.size();
	if (nElements > 0) {
		IMember[] res= new IMember[nElements];
		ICompilationUnit cu= null;
		for (int i= 0; i < nElements; i++) {
			Object curr= elements.get(i);
			if (curr instanceof IMethod || curr instanceof IType || curr instanceof IField) {
				IMember member= (IMember)curr; // limit to methods, types & fields
				if (! member.exists()) {
					return null;
				}
				if (i == 0) {
					cu= member.getCompilationUnit();
					if (cu == null) {
						return null;
					}
				} else if (!cu.equals(member.getCompilationUnit())) {
					return null;
				}
				if (member instanceof IMethod && ((IMethod) member).isLambdaMethod()) {
					return null;
				}
				try {
					if (member instanceof IType) {
						IType type= (IType) member;
						if (type.isAnonymous() || type.isLambda()) {
							return null;
						}
					}
				} catch (JavaModelException e) {
					return null;
				}
				res[i]= member;
			} else {
				return null;
			}
		}
		return res;
	}
	return null;
}