mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more appropriate solution for name clashing in case of VirtualFilePathWrapper (part of DBE-704)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,7 +55,7 @@ public class ProjectUtil {
|
||||
final boolean includeFilePath,
|
||||
final boolean includeUniqueFilePath,
|
||||
final boolean keepModuleAlwaysOnTheLeft) {
|
||||
if (file instanceof VirtualFilePathWrapper) {
|
||||
if (file instanceof VirtualFilePathWrapper && ((VirtualFilePathWrapper)file).enforcePresentableName()) {
|
||||
return includeFilePath ? ((VirtualFilePathWrapper)file).getPresentablePath() : file.getName();
|
||||
}
|
||||
String url;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
public class UniqueNameEditorTabTitleProvider implements EditorTabTitleProvider {
|
||||
@Override
|
||||
public String getEditorTabTitle(Project project, VirtualFile file) {
|
||||
if (!UISettings.getInstance().SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES || DumbService.isDumb(project) || !file.isInLocalFileSystem()) {
|
||||
if (!UISettings.getInstance().SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES || DumbService.isDumb(project)) {
|
||||
return null;
|
||||
}
|
||||
final String uniqueName = UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePathWithinOpenedFileEditors(project, file);
|
||||
|
||||
+4
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.UniqueNameBuilder;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFilePathWrapper;
|
||||
import com.intellij.psi.search.FilenameIndex;
|
||||
import com.intellij.psi.search.ProjectScope;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -63,6 +64,9 @@ public class UniqueVFilePathBuilderImpl extends UniqueVFilePathBuilder {
|
||||
filesWithSameName = setOfFilesWithTheSameName;
|
||||
|
||||
if (filesWithSameName.size() > 1 && filesWithSameName.contains(file)) {
|
||||
if (file instanceof VirtualFilePathWrapper) {
|
||||
return ((VirtualFilePathWrapper)file).getPresentablePath();
|
||||
}
|
||||
String path = project.getBasePath();
|
||||
path = path == null ? "" : FileUtil.toSystemIndependentName(path);
|
||||
UniqueNameBuilder<VirtualFile> builder = new UniqueNameBuilder<VirtualFile>(path, File.separator, 25);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,4 +29,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface VirtualFilePathWrapper {
|
||||
@NotNull
|
||||
String getPresentablePath();
|
||||
|
||||
boolean enforcePresentableName();
|
||||
}
|
||||
|
||||
@@ -1128,7 +1128,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
if (value instanceof FileInfo) {
|
||||
Project project = mySwitcherPanel.project;
|
||||
VirtualFile virtualFile = ((FileInfo)value).getFirst();
|
||||
String name = virtualFile instanceof VirtualFilePathWrapper
|
||||
String name = virtualFile instanceof VirtualFilePathWrapper && ((VirtualFilePathWrapper)virtualFile).enforcePresentableName()
|
||||
? ((VirtualFilePathWrapper)virtualFile).getPresentablePath()
|
||||
: UISettings.getInstance().SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES
|
||||
? UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(project, virtualFile)
|
||||
|
||||
Reference in New Issue
Block a user