Search in sources :

Example 1 with RncElement

use of org.intellij.plugins.relaxNG.compact.psi.RncElement 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()]);
}
Also used : RncElementVisitor(org.intellij.plugins.relaxNG.compact.psi.RncElementVisitor) FileIncludeInfo(com.intellij.psi.impl.include.FileIncludeInfo) RncInclude(org.intellij.plugins.relaxNG.compact.psi.RncInclude) ArrayList(java.util.ArrayList) RncElement(org.intellij.plugins.relaxNG.compact.psi.RncElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FileIncludeInfo (com.intellij.psi.impl.include.FileIncludeInfo)1 ArrayList (java.util.ArrayList)1 RncElement (org.intellij.plugins.relaxNG.compact.psi.RncElement)1 RncElementVisitor (org.intellij.plugins.relaxNG.compact.psi.RncElementVisitor)1 RncInclude (org.intellij.plugins.relaxNG.compact.psi.RncInclude)1 NotNull (org.jetbrains.annotations.NotNull)1