use of com.intellij.psi.impl.include.FileIncludeInfo 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()]);
}
use of com.intellij.psi.impl.include.FileIncludeInfo in project intellij-community by JetBrains.
the class XsltIncludeProvider method getIncludeInfos.
@NotNull
public FileIncludeInfo[] getIncludeInfos(FileContent content) {
CharSequence contentAsText = content.getContentAsText();
if (CharArrayUtil.indexOf(contentAsText, XsltSupport.XSLT_NS, 0) == -1)
return FileIncludeInfo.EMPTY;
final ArrayList<FileIncludeInfo> infos = new ArrayList<>();
NanoXmlUtil.IXMLBuilderAdapter builder = new NanoXmlUtil.IXMLBuilderAdapter() {
boolean isXslt;
boolean isInclude;
@Override
public void startElement(String name, String nsPrefix, String nsURI, String systemID, int lineNr) throws Exception {
boolean isXsltTag = XsltSupport.XSLT_NS.equals(nsURI);
if (!isXslt) {
// analyzing start tag
if (!isXsltTag) {
stop();
} else {
isXslt = true;
}
}
isInclude = isXsltTag && ("include".equals(name) || "import".equals(name));
}
@Override
public void addAttribute(String key, String nsPrefix, String nsURI, String value, String type) throws Exception {
if (isInclude && "href".equals(key)) {
infos.add(new FileIncludeInfo(value));
}
}
@Override
public void endElement(String name, String nsPrefix, String nsURI) throws Exception {
isInclude = false;
}
};
NanoXmlUtil.parse(CharArrayUtil.readerFromCharSequence(contentAsText), builder);
return infos.toArray(new FileIncludeInfo[infos.size()]);
}
use of com.intellij.psi.impl.include.FileIncludeInfo in project intellij-community by JetBrains.
the class FilePathResolveTest method testResolveFileReference.
public void testResolveFileReference() throws Exception {
configureByFile(BASE_PATH + "C.java", BASE_PATH);
FileIncludeManager fileIncludeManager = FileIncludeManager.getManager(getProject());
PsiFileSystemItem item = fileIncludeManager.resolveFileInclude(new FileIncludeInfo("x/MyFile.txt"), getFile());
assertNotNull(item);
assertEquals("MyFile.txt", item.getName());
}
use of com.intellij.psi.impl.include.FileIncludeInfo in project intellij-plugins by JetBrains.
the class DartPackageAwareFileIncludeProvider method getIncludeInfos.
private static FileIncludeInfo[] getIncludeInfos(@NotNull final XmlFile xmlFile) {
final List<FileIncludeInfo> result = new ArrayList<>();
xmlFile.acceptChildren(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlTag(XmlTag tag) {
final String path = "link".equalsIgnoreCase(tag.getName()) ? getPathRelativeToPackageRoot(tag.getAttributeValue("href")) : "script".equalsIgnoreCase(tag.getName()) ? getPathRelativeToPackageRoot(tag.getAttributeValue("src")) : null;
if (!StringUtil.isEmptyOrSpaces(path)) {
result.add(new FileIncludeInfo(path));
}
super.visitXmlTag(tag);
}
@Override
public void visitElement(PsiElement element) {
if (element.getLanguage() instanceof XMLLanguage) {
super.visitElement(element);
}
}
});
return ContainerUtil.toArray(result, FileIncludeInfo.EMPTY);
}
Aggregations