use of com.intellij.openapi.vfs.ex.http.HttpFileSystem in project intellij-community by JetBrains.
the class HtmlFileImpl method resolveFileReference.
@Nullable
@Override
public PsiFileSystemItem resolveFileReference(@NotNull FileReference reference, @NotNull String name) {
VirtualFile file = getVirtualFile();
if (!(file instanceof HttpVirtualFile)) {
return null;
}
VirtualFile parent = file;
if (!parent.isDirectory()) {
parent = parent.getParent();
if (parent == null) {
parent = file;
}
}
VirtualFile childFile = parent.findChild(name);
HttpFileSystem fileSystem = (HttpFileSystem) parent.getFileSystem();
if (childFile == null) {
childFile = fileSystem.createChild(parent, name, !reference.isLast());
}
if (childFile.isDirectory()) {
// pre create children
VirtualFile childParent = childFile;
FileReference[] references = reference.getFileReferenceSet().getAllReferences();
for (int i = reference.getIndex() + 1, n = references.length; i < n; i++) {
FileReference childReference = references[i];
childParent = fileSystem.createChild(childParent, childReference.decode(childReference.getText()), i != (n - 1));
}
return getManager().findDirectory(childFile);
} else {
return getManager().findFile(childFile);
}
}
use of com.intellij.openapi.vfs.ex.http.HttpFileSystem in project intellij-community by JetBrains.
the class XmlResourceResolver method getBaseFile.
private PsiFile getBaseFile(String baseSystemId) {
PsiFile baseFile = resolve(null, baseSystemId);
if (baseFile != null)
return baseFile;
// Find relative to myFile
File workingFile = new File("");
String workingDir = workingFile.getAbsoluteFile().getAbsolutePath().replace(File.separatorChar, '/');
String id = StringUtil.replace(baseSystemId, workingDir, myFile.getVirtualFile().getParent().getPath());
VirtualFile vFile = UriUtil.findRelative(id, myFile);
if (vFile == null) {
vFile = UriUtil.findRelative(baseSystemId, myFile);
}
if (vFile == null) {
try {
vFile = VirtualFileManager.getInstance().findFileByUrl(VfsUtilCore.convertFromUrl(new URL(baseSystemId)));
} catch (MalformedURLException ignore) {
}
}
if (vFile != null && !vFile.isDirectory() && !(vFile.getFileSystem() instanceof HttpFileSystem)) {
baseFile = PsiManager.getInstance(myProject).findFile(vFile);
}
return baseFile;
}
Aggregations