/** * Returns the primary type of a compilation unit (has the same * name as the compilation unit). * * @param compilationUnit the compilation unit * @return returns the primary type of the compilation unit, or * <code>null</code> if is does not have one */ private IType getMainType(ICompilationUnit compilationUnit) { if (compilationUnit == null) return null; return compilationUnit.findPrimaryType(); }
private static boolean isPrimaryType(IType type){ return type.equals(type.getCompilationUnit().findPrimaryType()); }
protected boolean isEntityBean(ICompilationUnit unit) { try { IType type = unit.findPrimaryType(); String[] inter = type.getSuperInterfaceNames(); for (int i = 0; i < inter.length; i++) { if (inter[i].endsWith("EntityBean")) { return true; } } } catch (JavaModelException e) { } return false; }
private static boolean isPrimaryType(IType type){ return type.equals(type.getCompilationUnit().findPrimaryType()); }
protected boolean isMDBBean(ICompilationUnit unit) { try { IType type = unit.findPrimaryType(); String[] inter = type.getSuperInterfaceNames(); for (int i = 0; i < inter.length; i++) { if (inter[i].endsWith("MessageDrivenBean")) { return true; } } } catch (JavaModelException e) { } return false; }
private static boolean isPrimaryType(IType type){ return type.equals(type.getCompilationUnit().findPrimaryType()); }
protected IType getTypeForCU(ICompilationUnit cu) { // Use primary type if possible IType primaryType= cu.findPrimaryType(); if (primaryType != null) return primaryType; // Use first top-level type try { IType[] types= cu.getTypes(); if (types.length > 0) return types[0]; else return null; } catch (JavaModelException ex) { return null; } }
private static boolean isPrimaryType(IType type){ return type.equals(type.getCompilationUnit().findPrimaryType()); }
protected IType getTypeForCU(ICompilationUnit cu) { // Use primary type if possible IType primaryType= cu.findPrimaryType(); if (primaryType != null) return primaryType; // Use first top-level type try { IType[] types= cu.getTypes(); if (types.length > 0) return types[0]; else return null; } catch (JavaModelException ex) { return null; } }
private static IType convertToEnclosingOrPrimaryType(IJavaElement element) throws JavaModelException { if (element instanceof IType) return (IType)element; IType result= (IType)element.getAncestor(IJavaElement.TYPE); if (result != null) return result; if (element instanceof ICompilationUnit) return ((ICompilationUnit)element).findPrimaryType(); if (element instanceof IClassFile) return ((IClassFile)element).getType(); return null; }
private static IType convertToEnclosingOrPrimaryType(IJavaElement element) throws JavaModelException { if (element instanceof IType) return (IType)element; IType result= (IType)element.getAncestor(IJavaElement.TYPE); if (result != null) return result; if (element instanceof ICompilationUnit) return ((ICompilationUnit)element).findPrimaryType(); if (element instanceof IOrdinaryClassFile) return ((IOrdinaryClassFile)element).getType(); return null; }
private static IType convertToEnclosingOrPrimaryType(IJavaElement element) throws JavaModelException { if (element instanceof IType) return (IType)element; IType result= (IType)element.getAncestor(IJavaElement.TYPE); if (result != null) return result; if (element instanceof ICompilationUnit) return ((ICompilationUnit)element).findPrimaryType(); if (element instanceof IClassFile) return ((IClassFile)element).getType(); return null; }
public static IType getTypeAtOffset(JavaEditor editor) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(editor); IType type= (IType)element.getAncestor(IJavaElement.TYPE); if (type == null) { ICompilationUnit unit= SelectionConverter.getInputAsCompilationUnit(editor); if (unit != null) type= unit.findPrimaryType(); } return type; }
public static IType getTypeAtOffset(JavaEditor editor) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(editor); IType type= (IType)element.getAncestor(IJavaElement.TYPE); if (type == null) { ICompilationUnit unit= SelectionConverter.getInputAsCompilationUnit(editor); if (unit != null) type= unit.findPrimaryType(); } return type; }
public static IType getTypeAtOffset(JavaEditor editor) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(editor); IType type= (IType)element.getAncestor(IJavaElement.TYPE); if (type == null) { ICompilationUnit unit= SelectionConverter.getInputAsCompilationUnit(editor); if (unit != null) type= unit.findPrimaryType(); } return type; }
private IType getSelectedType(IStructuredSelection selection) throws JavaModelException { Object[] elements= selection.toArray(); if (elements.length == 1 && (elements[0] instanceof IType)) { IType type= (IType) elements[0]; if (type.getCompilationUnit() != null && !type.isInterface() && !type.isAnnotation()) { return type; } } else if (elements[0] instanceof ICompilationUnit) { ICompilationUnit unit= (ICompilationUnit) elements[0]; IType type= unit.findPrimaryType(); if (type != null && !type.isInterface() && !type.isAnnotation()) return type; } else if (elements[0] instanceof IField) { return ((IField) elements[0]).getCompilationUnit().findPrimaryType(); } return null; }
private IType getSelectedType(IStructuredSelection selection) throws JavaModelException { final Object[] elements= selection.toArray(); if (elements.length == 1 && (elements[0] instanceof IType)) { final IType type= (IType) elements[0]; if (type.getCompilationUnit() != null && !type.isInterface()) { return type; } } else if (elements[0] instanceof ICompilationUnit) { final IType type= ((ICompilationUnit) elements[0]).findPrimaryType(); if (type != null && !type.isInterface()) return type; } return null; }
private IType getSelectedType(IStructuredSelection selection) throws JavaModelException { final Object[] elements= selection.toArray(); if (elements.length == 1 && (elements[0] instanceof IType)) { final IType type= (IType) elements[0]; if (type.getCompilationUnit() != null && !type.isInterface()) { return type; } } else if (elements[0] instanceof ICompilationUnit) { final IType type= ((ICompilationUnit) elements[0]).findPrimaryType(); if (type != null && !type.isInterface()) return type; } return null; }
private IType getSelectedType(IStructuredSelection selection) throws JavaModelException { final Object[] elements= selection.toArray(); if (elements.length == 1 && (elements[0] instanceof IType)) { final IType type= (IType) elements[0]; if (type.getCompilationUnit() != null && !type.isInterface()) { return type; } } else if (elements[0] instanceof ICompilationUnit) { final IType type= ((ICompilationUnit) elements[0]).findPrimaryType(); if (type != null && !type.isInterface()) return type; } return null; }
private IType getSelectedType(IStructuredSelection selection) throws JavaModelException { Object[] elements= selection.toArray(); if (elements.length == 1 && (elements[0] instanceof IType)) { IType type= (IType) elements[0]; if (type.getCompilationUnit() != null && !type.isInterface() && !type.isEnum()) { return type; } } else if (elements[0] instanceof ICompilationUnit) { ICompilationUnit cu= (ICompilationUnit) elements[0]; IType type= cu.findPrimaryType(); if (type != null && !type.isInterface() && !type.isEnum()) return type; } return null; }