mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
compare virtual files by equals, not ==
This commit is contained in:
+1
-1
@@ -70,7 +70,7 @@ public abstract class JavaRuntimeConfigurationProducerBase extends RuntimeConfig
|
||||
else {
|
||||
final VirtualFile virtualFile = directory.getVirtualFile();
|
||||
//choose default package when selection on content root
|
||||
if (fileIndex.getContentRootForFile(virtualFile) == virtualFile) {
|
||||
if (virtualFile.equals(fileIndex.getContentRootForFile(virtualFile))) {
|
||||
final Module module = ModuleUtilCore.findModuleForFile(virtualFile, project);
|
||||
if (module != null) {
|
||||
for (ContentEntry entry : ModuleRootManager.getInstance(module).getContentEntries()) {
|
||||
|
||||
@@ -168,10 +168,10 @@ public class ClassTreeNode extends BasePsiMemberNode<PsiClass>{
|
||||
}
|
||||
|
||||
private boolean canRepresent(final PsiClass psiClass, final Object element) {
|
||||
if (psiClass == null || !psiClass.isValid()) return false;
|
||||
if (psiClass == null || !psiClass.isValid() || element == null) return false;
|
||||
|
||||
final PsiFile parentFile = parentFileOf(psiClass);
|
||||
if (parentFile != null && (parentFile == element || parentFile.getVirtualFile() == element)) return true;
|
||||
if (parentFile != null && (parentFile == element || element.equals(parentFile.getVirtualFile()))) return true;
|
||||
|
||||
if (!getSettings().isShowMembers()) {
|
||||
if (element instanceof PsiElement && ((PsiElement)element).isValid()) {
|
||||
|
||||
@@ -201,7 +201,7 @@ public class PsiFileNode extends BasePsiNode<PsiFile> implements NavigatableWith
|
||||
|
||||
@Override
|
||||
public boolean canRepresent(final Object element) {
|
||||
return super.canRepresent(element) || getValue() != null && getValue().getVirtualFile() == element;
|
||||
return super.canRepresent(element) || getValue() != null && element != null && element.equals(getValue().getVirtualFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -236,8 +236,9 @@ public class SymlinkHandlingTest extends SymlinkTestCase {
|
||||
refresh();
|
||||
assertTrue(vLink1.isValid());
|
||||
VirtualFile vLink2 = myFileSystem.findFileByIoFile(link);
|
||||
assertEquals(vLink1, vLink2);
|
||||
assertTrue("link=" + link + ", vLink=" + vLink2,
|
||||
vLink2 == vLink1 && vLink2.isDirectory() && vLink2.is(VFileProperty.SYMLINK));
|
||||
vLink2.isDirectory() && vLink2.is(VFileProperty.SYMLINK));
|
||||
assertEquals(2, vLink2.getChildren().length);
|
||||
assertPathsEqual(targetDir2.getPath(), vLink1.getCanonicalPath());
|
||||
}
|
||||
@@ -261,8 +262,9 @@ public class SymlinkHandlingTest extends SymlinkTestCase {
|
||||
refresh();
|
||||
assertTrue(vLink1.isValid());
|
||||
VirtualFile vLink2 = myFileSystem.findFileByIoFile(link);
|
||||
assertEquals(vLink1, vLink2);
|
||||
assertTrue("link=" + link + ", vLink=" + vLink2,
|
||||
vLink2 == vLink1 && !vLink2.isDirectory() && vLink2.is(VFileProperty.SYMLINK));
|
||||
!vLink2.isDirectory() && vLink2.is(VFileProperty.SYMLINK));
|
||||
assertEquals(FileUtil.loadFile(target2), VfsUtilCore.loadText(vLink2));
|
||||
assertPathsEqual(target2.getPath(), vLink1.getCanonicalPath());
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ public class RootIndex extends DirectoryIndex {
|
||||
}
|
||||
DirectoryInfo info = myInfoCache.get(root);
|
||||
if (info != null) {
|
||||
if (dir != root) {
|
||||
if (!dir.equals(root)) {
|
||||
cacheInfos(dir, root, info);
|
||||
}
|
||||
return info == NULL_INFO ? null : info;
|
||||
@@ -490,7 +490,7 @@ public class RootIndex extends DirectoryIndex {
|
||||
VirtualFile librarySourceRoot) {
|
||||
VirtualFile packageRoot = findPackageRootInfo(hierarchy, moduleContentRoot, libraryClassRoot, librarySourceRoot);
|
||||
String prefix = packagePrefix.get(packageRoot);
|
||||
if (prefix != null && packageRoot != root) {
|
||||
if (prefix != null && !root.equals(packageRoot)) {
|
||||
assert packageRoot != null;
|
||||
String relative = VfsUtilCore.getRelativePath(root, packageRoot, '.');
|
||||
prefix = StringUtil.isEmpty(prefix) ? relative : prefix + '.' + relative;
|
||||
@@ -509,10 +509,10 @@ public class RootIndex extends DirectoryIndex {
|
||||
librarySourceRoot == null) {
|
||||
return root;
|
||||
}
|
||||
if (root == libraryClassRoot || root == librarySourceRoot) {
|
||||
if (root.equals(libraryClassRoot) || root.equals(librarySourceRoot)) {
|
||||
return root;
|
||||
}
|
||||
if (root == moduleContentRoot && !sourceRootOf.containsKey(root) && librarySourceRoot == null && libraryClassRoot == null) {
|
||||
if (root.equals(moduleContentRoot) && !sourceRootOf.containsKey(root) && librarySourceRoot == null && libraryClassRoot == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -527,10 +527,10 @@ public class RootIndex extends DirectoryIndex {
|
||||
@NotNull MultiMap<VirtualFile, OrderEntry> libSourceRootEntries) {
|
||||
LinkedHashSet<OrderEntry> orderEntries = ContainerUtil.newLinkedHashSet();
|
||||
for (VirtualFile root : hierarchy) {
|
||||
if (root == libraryClassRoot && !sourceRootOf.containsKey(root)) {
|
||||
if (root.equals(libraryClassRoot) && !sourceRootOf.containsKey(root)) {
|
||||
orderEntries.addAll(libClassRootEntries.get(root));
|
||||
}
|
||||
if (root == librarySourceRoot && libraryClassRoot == null) {
|
||||
if (root.equals(librarySourceRoot) && libraryClassRoot == null) {
|
||||
orderEntries.addAll(libSourceRootEntries.get(root));
|
||||
}
|
||||
if (libClassRootEntries.containsKey(root) || sourceRootOf.containsKey(root) && librarySourceRoot == null) {
|
||||
|
||||
@@ -67,7 +67,7 @@ public class DumpCleanHighlightingTestdataAction extends AnAction implements Dum
|
||||
targetDescriptor.setTitle("Choose Directory");
|
||||
targetDescriptor.setDescription("Directory where highlighting-markup-free copies would be placed");
|
||||
final VirtualFile destinationFolder = FileChooser.chooseFile(targetDescriptor, project, null);
|
||||
if (destinationFolder == dirToProcess) {
|
||||
if (dirToProcess.equals(destinationFolder)) {
|
||||
Messages.showErrorDialog(project, "Source and destination roots should differ", "Reject to Proceed");
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class GradleEditorTabTitleProvider implements EditorTabTitleProvider {
|
||||
|
||||
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
for (VirtualFile virtualFile : moduleRootManager.getContentRoots()) {
|
||||
if (virtualFile == file.getParent()) return module.getName();
|
||||
if (virtualFile.equals(file.getParent())) return module.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -905,7 +905,7 @@ public class MavenProjectsTree {
|
||||
Module module = fileIndex.getModuleForFile(pomFile);
|
||||
if (module == null) continue;
|
||||
|
||||
if (fileIndex.getContentRootForFile(pomFile) != pomFile.getParent()) continue;
|
||||
if (!Comparing.equal(fileIndex.getContentRootForFile(pomFile), pomFile.getParent())) continue;
|
||||
|
||||
updateCrc(crc, module.getName());
|
||||
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -96,7 +97,7 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
Module module = fileIndex.getModuleForFile(pomXml);
|
||||
if (module == null) continue;
|
||||
|
||||
if (mavenProject.getDirectoryFile() != fileIndex.getContentRootForFile(pomXml)) continue;
|
||||
if (!Comparing.equal(mavenProject.getDirectoryFile(), fileIndex.getContentRootForFile(pomXml))) continue;
|
||||
|
||||
MavenModuleResourceConfiguration resourceConfig = new MavenModuleResourceConfiguration();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user