use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class NoNamespaceConfigImpl method setMapping.
@Override
public void setMapping(@NotNull PsiFile file, String location) {
final VirtualFile virtualFile = file.getVirtualFile();
assert virtualFile != null;
final String url = virtualFile.getUrl();
final VirtualFilePointerManager manager = VirtualFilePointerManager.getInstance();
for (VirtualFilePointer pointer : myMappings.keySet()) {
if (url.equals(pointer.getUrl())) {
if (location == null) {
myMappings.remove(pointer);
return;
} else if (!location.equals(myMappings.get(pointer).getUrl())) {
myMappings.remove(pointer);
myMappings.put(pointer, manager.create(location, myProject, null));
return;
}
}
}
if (location != null) {
myMappings.put(manager.create(url, myProject, null), manager.create(location, myProject, null));
}
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class NoNamespaceConfigImpl method getMappedPointer.
private VirtualFilePointer getMappedPointer(@NotNull PsiFile file) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null)
return null;
final String url = virtualFile.getUrl();
for (VirtualFilePointer pointer : myMappings.keySet()) {
if (url.equals(pointer.getUrl())) {
return myMappings.get(pointer);
}
}
return null;
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class FileAssociationsManagerImpl method removeAssociations.
public void removeAssociations(PsiFile file) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null)
return;
for (VirtualFilePointer pointer : myAssociations.keySet()) {
if (pointer.getUrl().equals(virtualFile.getUrl())) {
myAssociations.remove(pointer);
touch();
return;
}
}
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class FileAssociationsManagerImpl method getAssociationsFor.
public PsiFile[] getAssociationsFor(PsiFile file, FileType... fileTypes) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null)
return PsiFile.EMPTY_ARRAY;
for (VirtualFilePointer pointer : myAssociations.keySet()) {
if (pointer.isValid() && pointer.getUrl().equals(virtualFile.getUrl())) {
final VirtualFilePointerContainer container = myAssociations.get(pointer);
if (container != null) {
final VirtualFile[] files = container.getFiles();
final Set<PsiFile> list = new HashSet<>();
final PsiManager psiManager = PsiManager.getInstance(myProject);
for (VirtualFile assoc : files) {
final PsiFile psiFile = psiManager.findFile(assoc);
if (psiFile != null && (fileTypes.length == 0 || matchesFileType(psiFile, fileTypes))) {
list.add(psiFile);
}
}
return PsiUtilCore.toPsiFileArray(list);
} else {
return PsiFile.EMPTY_ARRAY;
}
}
}
return PsiFile.EMPTY_ARRAY;
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class FileAssociationsManagerImpl method getAssociations.
public Map<VirtualFile, VirtualFile[]> getAssociations() {
final HashMap<VirtualFile, VirtualFile[]> map = new LinkedHashMap<>();
final Set<VirtualFilePointer> set = myAssociations.keySet();
for (VirtualFilePointer pointer : set) {
if (pointer.isValid()) {
final VirtualFile file = pointer.getFile();
map.put(file, myAssociations.get(pointer).getFiles());
}
}
return map;
}
Aggregations