use of org.intellij.plugins.relaxNG.compact.psi.RncElementVisitor in project intellij-community by JetBrains.
the class RelaxIncludeProvider method getIncludeInfos.
@NotNull
@Override
public FileIncludeInfo[] getIncludeInfos(FileContent content) {
final ArrayList<FileIncludeInfo> infos;
if (content.getFileType() == XmlFileType.INSTANCE) {
CharSequence inputDataContentAsText = content.getContentAsText();
if (CharArrayUtil.indexOf(inputDataContentAsText, ApplicationLoader.RNG_NAMESPACE, 0) == -1)
return FileIncludeInfo.EMPTY;
infos = new ArrayList<>();
NanoXmlUtil.parse(CharArrayUtil.readerFromCharSequence(content.getContentAsText()), new RngBuilderAdapter(infos));
} else if (content.getFileType() == RncFileType.getInstance()) {
infos = new ArrayList<>();
content.getPsiFile().acceptChildren(new RncElementVisitor() {
@Override
public void visitElement(RncElement element) {
element.acceptChildren(this);
}
@Override
public void visitInclude(RncInclude include) {
final String path = include.getFileReference();
if (path != null) {
infos.add(new FileIncludeInfo(path));
}
}
});
} else {
return FileIncludeInfo.EMPTY;
}
return infos.toArray(new FileIncludeInfo[infos.size()]);
}
Aggregations