ProjectStructureElement (PackagingElement<?> packagingElement, final StructureConfigurableContext context, final ArtifactsStructureConfigurableContext artifactsStructureContext) { if (packagingElement instanceof ModulePackagingElement) { final Module module = ((ModulePackagingElement)packagingElement).findModule(artifactsStructureContext); if (module != null) { return new ModuleProjectStructureElement(context, module); } } else if (packagingElement instanceof LibraryPackagingElement) { final Library library = ((LibraryPackagingElement)packagingElement).findLibrary(artifactsStructureContext); if (library != null) { return new LibraryProjectStructureElement(context, library); } } else if (packagingElement instanceof ArtifactPackagingElement) { final Artifact usedArtifact = ((ArtifactPackagingElement)packagingElement).findArtifact(artifactsStructureContext); if (usedArtifact != null) { return artifactsStructureContext.getOrCreateArtifactElement(usedArtifact); } } else if (packagingElement instanceof FacetBasedPackagingElement) { Facet facet = ((FacetBasedPackagingElement)packagingElement).findFacet(artifactsStructureContext); if (facet != null) { return new FacetProjectStructureElement(context, facet); } } return null; }