List of usage examples for org.eclipse.jdt.core ITypeRoot isConsistent
boolean isConsistent() throws JavaModelException;
From source file:org.jboss.tools.arquillian.ui.internal.utils.ArquillianUIUtil.java
License:Open Source License
public static IType getActiveType() { IWorkbenchPage page = getActivePage(); if (page == null) { return null; }/*from w w w . j a v a 2 s.c om*/ IEditorPart editor = page.getActiveEditor(); if (editor instanceof CompilationUnitEditor) { CompilationUnitEditor cue = (CompilationUnitEditor) editor; IEditorInput editorInput = cue.getEditorInput(); if (editorInput == null) { return null; } IJavaElement javaElement = (IJavaElement) editorInput.getAdapter(IJavaElement.class); if (javaElement != null && !javaElement.exists()) return null; try { ITypeRoot rootType = EditorUtility.getEditorInputJavaElement(editor, true); if (rootType != null && rootType.isConsistent()) { IJavaElement element = SelectionConverter.getElementAtOffset(cue); if (element == null) { return null; } return SelectionConverter.getTypeAtOffset(cue); } } catch (JavaModelException e) { ArquillianUIActivator.log(e); } } return null; }