use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer 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.VirtualFilePointerContainer in project intellij-community by JetBrains.
the class FileAssociationsManagerImpl method readExternal.
@SuppressWarnings({ "unchecked" })
public void readExternal(Element element) throws InvalidDataException {
final List<Element> children = element.getChildren("file");
for (Element child : children) {
final String url = child.getAttributeValue("url");
if (url != null) {
final VirtualFilePointer pointer = myFilePointerManager.create(url, myProject, null);
final VirtualFilePointerContainer container = myFilePointerManager.createContainer(myProject);
container.readExternal(child, "association");
myAssociations.put(pointer, container);
}
}
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.
the class DetectionExcludesConfigurationImpl method addExcludedFramework.
@Override
public void addExcludedFramework(@NotNull FrameworkType type) {
convert();
myExcludedFrameworks.add(type.getId());
final VirtualFilePointerContainer container = myExcludedFiles.remove(type.getId());
if (container != null) {
container.clear();
}
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.
the class DetectionExcludesConfigurationImpl method getActualState.
@NotNull
public ExcludesConfigurationState getActualState() {
ensureOldSettingsLoaded();
final ExcludesConfigurationState state = new ExcludesConfigurationState();
state.setDetectionEnabled(myDetectionEnabled);
state.getFrameworkTypes().addAll(myExcludedFrameworks);
Collections.sort(state.getFrameworkTypes(), String.CASE_INSENSITIVE_ORDER);
for (String typeId : myExcludedFiles.keySet()) {
final VirtualFilePointerContainer container = myExcludedFiles.get(typeId);
for (String url : container.getUrls()) {
state.getFiles().add(new ExcludedFileState(url, typeId));
}
}
Collections.sort(state.getFiles(), (o1, o2) -> StringUtil.comparePairs(o1.getFrameworkType(), o1.getUrl(), o2.getFrameworkType(), o2.getUrl(), true));
return state;
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.
the class JavaModuleExternalPathsImpl method isChanged.
@Override
public boolean isChanged() {
if (myOrderRootPointerContainers.size() != mySource.myOrderRootPointerContainers.size())
return true;
for (final OrderRootType type : myOrderRootPointerContainers.keySet()) {
final VirtualFilePointerContainer container = myOrderRootPointerContainers.get(type);
final VirtualFilePointerContainer otherContainer = mySource.myOrderRootPointerContainers.get(type);
if (container == null || otherContainer == null) {
if (container != otherContainer)
return true;
} else {
final String[] urls = container.getUrls();
final String[] otherUrls = otherContainer.getUrls();
if (urls.length != otherUrls.length)
return true;
for (int i = 0; i < urls.length; i++) {
if (!Comparing.strEqual(urls[i], otherUrls[i]))
return true;
}
}
}
return false;
}
Aggregations