Source:
private void createPresenterModuleLinkForGin() { PsiClass unit = packageHierarchy.findInterfaceTypeInPackage( presenterConfigModel.getSelectedPackageRoot().getParentPackage(), "GinModule"); String selectedPackageElementName = presenterConfigModel.getSelectedPackageRoot().getQualifiedName(); if (unit == null && packageHierarchy.isParentTheClientPackage(selectedPackageElementName)) { PackageHierarchyElement hierarchyElement = packageHierarchy.findParentClientAndAddPackage( selectedPackageElementName, "gin"); if (hierarchyElement != null) { PsiPackage clienPackage = hierarchyElement.getPackageFragment(); unit = packageHierarchy.findInterfaceTypeInPackage(clienPackage, "GinModule"); } if (unit == null) { unit = packageHierarchy.findFirstInterfaceType("GinModule"); logger.info( "Warning: This didn't find a ideal place to put the gin install for the new presenter module"); } } if (unit == null) { if (selectedPackageElementName.contains("client")) { PackageHierarchyElement hierarchyElement = packageHierarchy.findParent(selectedPackageElementName); if (hierarchyElement.getPackageFragment() != null) { PsiPackage parentParentPackage = hierarchyElement.getPackageFragment(); unit = packageHierarchy.findInterfaceTypeInPackage(parentParentPackage, "GinModule"); } } } if (unit == null) { unit = packageHierarchy.findFirstInterfaceType("GinModule"); logger.info("Warning: This didn't find a ideal place to put the gin install for the new presenter module"); } if (unit != null) { createPresenterGinlink(unit); } else { logger.warning("Error: Wasn't able to install Module"); warn("Could not create install module."); } }

Target:
private void createPresenterModuleLinkForGin() { PsiClass unit = packageHierarchy.findInterfaceTypeInPackage( createdPresenterPackage.getParentPackage(), ABSTRACT_GIN_MODULE); String selectedPackageElementName = createdPresenterPackage.getQualifiedName(); if (unit == null && packageHierarchy.isParentTheClientPackage(selectedPackageElementName)) { PackageHierarchyElement hierarchyElement = packageHierarchy.findParentClientAndAddPackage( selectedPackageElementName, "gin"); if (hierarchyElement != null) { PsiPackage clienPackage = hierarchyElement.getPackageFragment(); unit = packageHierarchy.findInterfaceTypeInPackage(clienPackage, ABSTRACT_GIN_MODULE); } if (unit == null) { unit = packageHierarchy.findFirstInterfaceType(ABSTRACT_GIN_MODULE); logger.info( "Warning: This didn't find a ideal place to put the gin install for the new presenter module"); } } if (unit == null) { if (selectedPackageElementName.contains("client")) { PackageHierarchyElement hierarchyElement = packageHierarchy.findParent(selectedPackageElementName); if (hierarchyElement.getPackageFragment() != null) { PsiPackage parentParentPackage = hierarchyElement.getPackageFragment(); unit = packageHierarchy.findInterfaceTypeInPackage(parentParentPackage, ABSTRACT_GIN_MODULE); } } } if (unit == null) { unit = packageHierarchy.findFirstInterfaceType(ABSTRACT_GIN_MODULE); logger.info("Warning: This didn't find a ideal place to put the gin install for the new presenter module"); } if (unit != null) { createPresenterGinlink(unit); } else { logger.warning("Error: Wasn't able to install Module"); warn("Could not create install module."); } }