mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-208504 First xi:include tag in *Plugin.xml file is highlighted as error
do not highlight problem with "xpointer" scheme not supported by Xerces
This commit is contained in:
@@ -8,9 +8,25 @@ import com.intellij.xml.util.CheckXmlFileWithXercesValidatorInspection;
|
||||
public class XmlSimpleHighlightingTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
|
||||
public void testCannotFindDeclaration() {
|
||||
checkValidation("<idea-plugin xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n" +
|
||||
"</idea-plugin>");
|
||||
}
|
||||
|
||||
public void testUnsupportedIncludeScheme() {
|
||||
checkValidation("<idea-plugin xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n" +
|
||||
" <xi:include href=\"extensionPoints.xml\" xpointer=\"xpointer(/extensionPoints/*)\"/>\n" +
|
||||
"</idea-plugin>");
|
||||
}
|
||||
|
||||
public void testSupportedIncludeScheme() {
|
||||
checkValidation("<idea-plugin xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n" +
|
||||
" <<error descr=\"An 'include' failed, and no 'fallback' element was found.\">xi:include</error> href=\"extensionPoints.xml\" xpointer=\"element(/1111)\"/>\n" +
|
||||
"</idea-plugin>");
|
||||
}
|
||||
|
||||
private void checkValidation(String text) {
|
||||
myFixture.enableInspections(CheckXmlFileWithXercesValidatorInspection.class);
|
||||
myFixture.configureByText(XmlFileType.INSTANCE, "<idea-plugin xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n" +
|
||||
"</idea-plugin>");
|
||||
myFixture.configureByText(XmlFileType.INSTANCE, text);
|
||||
myFixture.testHighlighting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +127,8 @@ public class ExternalDocumentValidator {
|
||||
};
|
||||
|
||||
myHandler.setErrorReporter(new ErrorReporter(myHandler) {
|
||||
|
||||
int unsupportedSchemeAt = -1;
|
||||
@Override
|
||||
public boolean isStopOnUndeclaredResource() {
|
||||
return true;
|
||||
@@ -159,7 +161,7 @@ public class ExternalDocumentValidator {
|
||||
if (elementText.equals("</")) {
|
||||
currentElement = currentElement.getNextSibling();
|
||||
}
|
||||
else if (elementText.equals(">") || elementText.equals("=")) {
|
||||
else if (elementText.equals(">") || elementText.equals("/>") || elementText.equals("=")) {
|
||||
currentElement = currentElement.getPrevSibling();
|
||||
}
|
||||
|
||||
@@ -180,7 +182,15 @@ public class ExternalDocumentValidator {
|
||||
// "Cannot find the declaration of element" is not helpful without schema
|
||||
return;
|
||||
}
|
||||
} else if ("SchemeUnsupported".equals(messageId)) {
|
||||
unsupportedSchemeAt = offset;
|
||||
return;
|
||||
} else if (unsupportedSchemeAt == offset &&
|
||||
("An 'include' failed, and no 'fallback' element was found.".equals(localizedMessage) ||
|
||||
(e.getLocalizedMessage().startsWith("Include operation failed, reverting to fallback.")))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (localizedMessage.startsWith(CANNOT_FIND_DECLARATION_ERROR_PREFIX) ||
|
||||
localizedMessage.startsWith(ELEMENT_ERROR_PREFIX) ||
|
||||
localizedMessage.startsWith(ROOT_ELEMENT_ERROR_PREFIX) ||
|
||||
|
||||
Reference in New Issue
Block a user