mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IDEA-78840 generate xml from xsd fails
This commit is contained in:
@@ -26,6 +26,7 @@ import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.xml.XmlElementDescriptor;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
import com.intellij.xml.impl.schema.XmlNSDescriptorImpl;
|
||||
@@ -200,8 +201,9 @@ public class Xsd2InstanceUtils {
|
||||
} else if ("schemaLocation".equals(xmlAttribute.getName())) {
|
||||
final PsiReference[] references = xmlAttribute.getValueElement().getReferences();
|
||||
|
||||
if (references.length > 0) {
|
||||
PsiElement psiElement = references[0].resolve();
|
||||
PsiReference reference = ArrayUtil.getLastElement(references);
|
||||
if (reference != null) {
|
||||
PsiElement psiElement = reference.resolve();
|
||||
|
||||
if (psiElement instanceof XmlFile) {
|
||||
final String s = processAndSaveAllSchemas(((XmlFile) psiElement), scannedToFileName, schemaReferenceProcessor);
|
||||
|
||||
@@ -39,6 +39,12 @@ class GenerateXmlFromXsdTest: LightCodeInsightFixtureTestCase() {
|
||||
Disposer.dispose(dialog.disposable)
|
||||
}
|
||||
|
||||
fun testRelativePath() {
|
||||
val file = LocalFileSystem.getInstance().findFileByPath("$testDataPath/top/top.xsd")
|
||||
val dialog = GenerateInstanceDocumentFromSchemaDialog(project, file)
|
||||
GenerateInstanceDocumentFromSchemaAction.doAction(project, dialog)
|
||||
Disposer.dispose(dialog.disposable)
|
||||
}
|
||||
|
||||
override fun getBasePath(): String = "/xml/tests/testData/generate"
|
||||
}
|
||||
2
xml/tests/testData/generate/foo.xsd
Normal file
2
xml/tests/testData/generate/foo.xsd
Normal file
@@ -0,0 +1,2 @@
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
</schema>
|
||||
5
xml/tests/testData/generate/top/top.xsd
Normal file
5
xml/tests/testData/generate/top/top.xsd
Normal file
@@ -0,0 +1,5 @@
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="test">
|
||||
<import schemaLocation="../foo.xsd"/>
|
||||
<element name="root"/>
|
||||
</schema>
|
||||
Reference in New Issue
Block a user