use of com.intellij.openapi.vfs.impl.http.HttpVirtualFile 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.impl.http.HttpVirtualFile in project intellij-community by JetBrains.
the class XSourcePositionImpl method create.
/**
* do not call this method from plugins, use {@link XDebuggerUtil#createPosition(VirtualFile, int, int)} instead
*/
@Nullable
public static XSourcePositionImpl create(@Nullable VirtualFile file, int line, int column) {
if (file == null) {
return null;
}
AccessToken lock = ApplicationManager.getApplication().acquireReadActionLock();
try {
int offset;
if (file instanceof LightVirtualFile || file instanceof HttpVirtualFile) {
offset = -1;
} else {
Document document = file.isValid() ? FileDocumentManager.getInstance().getDocument(file) : null;
if (document == null) {
return null;
}
if (line < 0) {
line = 0;
}
if (column < 0) {
column = 0;
}
offset = line < document.getLineCount() ? document.getLineStartOffset(line) + column : -1;
if (offset >= document.getTextLength()) {
offset = document.getTextLength() - 1;
}
}
return new XSourcePositionImpl(file, line, offset);
} finally {
lock.finish();
}
}
Aggregations