mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-139856 Generate XML Document From XSD Schema: error message could be more sensible
This commit is contained in:
+1
-1
@@ -69,7 +69,7 @@ public class GenerateInstanceDocumentFromSchemaAction extends AnAction {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private static void doAction(final Project project, final GenerateInstanceDocumentFromSchemaDialog dialog) {
|
||||
public static void doAction(final Project project, final GenerateInstanceDocumentFromSchemaDialog dialog) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
|
||||
@NonNls List<String> parameters = new LinkedList<>();
|
||||
|
||||
@@ -94,7 +94,6 @@ public class Xsd2InstanceUtils {
|
||||
SchemaTypeSystem sts = null;
|
||||
if (schemas.length > 0)
|
||||
{
|
||||
Collection errors = new ArrayList();
|
||||
XmlOptions compileOptions = new XmlOptions();
|
||||
if (dl)
|
||||
compileOptions.setCompileDownloadUrls();
|
||||
@@ -105,10 +104,12 @@ public class Xsd2InstanceUtils {
|
||||
|
||||
try {
|
||||
sts = XmlBeans.compileXsd(schemas, XmlBeans.getBuiltinTypeSystem(), compileOptions);
|
||||
} catch (XmlException e) {
|
||||
String out = "Schema compilation errors: ";
|
||||
for (Object error : errors) out += "\n" + error;
|
||||
throw new IllegalArgumentException(out);
|
||||
}
|
||||
catch (XmlException e) {
|
||||
StringBuilder out = new StringBuilder("Schema compilation errors: ");
|
||||
Collection errors = e.getErrors();
|
||||
for (Object error : errors) out.append("\n").append(error);
|
||||
throw new IllegalArgumentException(out.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.xml
|
||||
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.xml.actions.xmlbeans.GenerateInstanceDocumentFromSchemaAction
|
||||
import com.intellij.xml.actions.xmlbeans.GenerateInstanceDocumentFromSchemaDialog
|
||||
import junit.framework.TestCase
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
class GenerateXmlFromXsdTest: LightCodeInsightFixtureTestCase() {
|
||||
fun testErrorMessage() {
|
||||
val file = LocalFileSystem.getInstance().findFileByPath(testDataPath + "/vast4.xsd")
|
||||
val dialog = GenerateInstanceDocumentFromSchemaDialog(project, file)
|
||||
try {
|
||||
GenerateInstanceDocumentFromSchemaAction.doAction(project, dialog)
|
||||
TestCase.fail()
|
||||
}
|
||||
catch (e: Exception) {
|
||||
TestCase.assertTrue(e.message!!.contains("vast4.xsd:192:13: error: src-resolve.a: Could not find type 'VideoClicks_Base_type'"))
|
||||
}
|
||||
Disposer.dispose(dialog.disposable)
|
||||
}
|
||||
|
||||
|
||||
override fun getBasePath(): String = "/xml/tests/testData/generate"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user