void (final PsiJavaFile javaFile, boolean okToLoadTree) { final PsiImportList importList = javaFile.getImportList(); assertNotNull(importList); final PsiImportStatementBase[] allImportStatements = importList.getAllImportStatements(); assertEquals(6, allImportStatements.length); final PsiImportStatement[] importStatements = importList.getImportStatements(); assertEquals(2, importStatements.length); final PsiImportStaticStatement[] importStaticStatements = importList.getImportStaticStatements(); assertEquals(4, importStaticStatements.length); assertFalse(importStatements[0].isOnDemand()); assertTrue(importStaticStatements[0].isOnDemand()); assertFalse(importStatements[0].isOnDemand()); assertTrue(importStaticStatements[1].isOnDemand()); assertFalse(importStaticStatements[2].isOnDemand()); assertFalse(importStaticStatements[3].isOnDemand()); assertEquals("sort", importStaticStatements[2].getReferenceName()); assertEquals("sort", importStaticStatements[3].getReferenceName()); final PsiImportStaticStatement classReference1 = importStaticStatements[1]; final PsiClass element1 = classReference1.resolveTargetClass(); assertNotNull(element1); assertEquals("java.util.Arrays", element1.getQualifiedName()); final PsiImportStaticStatement classReference3 = importStaticStatements[3]; final PsiClass element3 = classReference3.resolveTargetClass(); assertNotNull(element3); assertEquals("java.util.Arrays", element3.getQualifiedName()); if (okToLoadTree) { assertEquals("java.util.Collections", getText(importStaticStatements[0])); assertEquals("java.util.Arrays", getText(importStaticStatements[1])); assertEquals("java.util.Collections.sort", getText(importStaticStatements[2])); assertEquals("java.util.Arrays.sort", getText(importStaticStatements[3])); } }