mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-64075 Automatic XML Schema discovery: adding DTDs to index
This commit is contained in:
@@ -42,7 +42,7 @@ public abstract class XmlIndex<V> extends FileBasedIndexExtension<String, V> {
|
||||
private static final FileBasedIndex.InputFilter INPUT_FILTER = new FileBasedIndex.InputFilter() {
|
||||
public boolean acceptInput(final VirtualFile file) {
|
||||
@NonNls final String extension = file.getExtension();
|
||||
return extension != null && extension.equals("xsd");
|
||||
return "xsd".equals(extension) || "dtd".equals(extension);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -75,13 +75,19 @@ public class XmlNamespaceIndex extends XmlIndex<XsdNamespaceBuilder> {
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<String, XsdNamespaceBuilder> map(final FileContent inputData) {
|
||||
final XsdNamespaceBuilder
|
||||
final XsdNamespaceBuilder builder;
|
||||
if ("dtd".equals(inputData.getFile().getExtension())) {
|
||||
builder = new XsdNamespaceBuilder(inputData.getFileName(), "", Collections.<String>emptyList());
|
||||
}
|
||||
else {
|
||||
builder = XsdNamespaceBuilder.computeNamespace(CharArrayUtil.readerFromCharSequence(inputData.getContentAsText()));
|
||||
}
|
||||
final HashMap<String, XsdNamespaceBuilder> map = new HashMap<String, XsdNamespaceBuilder>(2);
|
||||
String namespace = builder.getNamespace();
|
||||
if (namespace != null) {
|
||||
map.put(namespace, builder);
|
||||
}
|
||||
// so that we could get ns by file url (see getNamespace method above)
|
||||
map.put(inputData.getFile().getUrl(), builder);
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user