void (AntDomTypeDef typedef, final String uri, AntDomProject antProject, ClassLoader loader) { final XmlElement xmlElement = antProject.getXmlElement(); final Project project = xmlElement != null? xmlElement.getProject() : null; if (project == null) { return; } XmlFile xmlFile = null; PropertiesFile propFile = null; final String resource = typedef.getResource().getStringValue(); if (resource != null) { if (loader == null) { loader = getClassLoader(typedef, antProject); } final InputStream stream = loader.getResourceAsStream(resource); if (stream != null) { try { if (isXmlFormat(typedef, resource)) { xmlFile = (XmlFile)loadContentAsFile(project, stream, XmlFileType.INSTANCE); } else { propFile = (PropertiesFile)loadContentAsFile(project, stream, PropertiesFileType.INSTANCE); } } catch (IOException e) { LOG.info(e); } } else { myTypeDefErrors.put(typedef, "Resource \"" + resource + "\" not found in the classpath"); } } else { final PsiFileSystemItem file = typedef.getFile().getValue(); if (file instanceof PsiFile) { if (isXmlFormat(typedef, file.getName())) { xmlFile = file instanceof XmlFile ? (XmlFile)file : (XmlFile)loadContentAsFile((PsiFile)file, XmlFileType.INSTANCE); } else { // assume properties format propFile = file instanceof PropertiesFile ? (PropertiesFile)file : (PropertiesFile)loadContentAsFile((PsiFile)file, PropertiesFileType.INSTANCE); } } } if (propFile != null) { if (loader == null) { // if not initialized yet loader = getClassLoader(typedef, antProject); } for (final IProperty property : propFile.getProperties()) { addCustomDefinition(typedef, property.getUnescapedKey(), uri, ClassProvider.create(property.getUnescapedValue(), loader)); } } if (xmlFile != null) { if (loader == null) { // if not initialized yet loader = getClassLoader(typedef, antProject); } loadDefinitionsFromAntlib(xmlFile, uri, loader, typedef, antProject); } }