mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup and EA-47890 - assert: FileManagerImpl.findFile
This commit is contained in:
@@ -20,8 +20,6 @@ import com.intellij.openapi.fileEditor.impl.EditorTabColorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.FileColorManager;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -34,8 +32,7 @@ public class EditorTabColorProviderImpl implements EditorTabColorProvider {
|
||||
@Override
|
||||
@Nullable
|
||||
public Color getEditorTabColor(Project project, VirtualFile file) {
|
||||
final FileColorManager colorManager = FileColorManagerImpl.getInstance(project);
|
||||
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
|
||||
return psiFile != null && colorManager.isEnabledForTabs() ? colorManager.getFileColor(psiFile) : null;
|
||||
FileColorManager colorManager = FileColorManager.getInstance(project);
|
||||
return colorManager.isEnabledForTabs() ? colorManager.getFileColor(file) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,23 +125,7 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent
|
||||
|
||||
public Element getState(final boolean shared) {
|
||||
Element element = new Element("state");
|
||||
//if (!shared) {
|
||||
// element.setAttribute("enabled", Boolean.toString(myEnabled));
|
||||
// element.setAttribute("enabledForTabs", Boolean.toString(myEnabledForTabs));
|
||||
//}
|
||||
|
||||
myModel.save(element, shared);
|
||||
//if (!shared) {
|
||||
// final boolean exists = findConfigurationByName(NonProjectFilesScope.NAME, myModel.getLocalConfigurations()) != null;
|
||||
// if (myEnabledForNonProject && !exists) {
|
||||
// myEnabledForNonProject = false;
|
||||
// } else if (!myEnabledForNonProject && exists) {
|
||||
// myEnabledForNonProject = true;
|
||||
// }
|
||||
//
|
||||
// element.setAttribute("showNonProject", Boolean.toString(myEnabledForNonProject));
|
||||
//}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -161,22 +145,7 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent
|
||||
|
||||
@SuppressWarnings({"AutoUnboxing"})
|
||||
void loadState(Element state, final boolean shared) {
|
||||
if (!shared) {
|
||||
//final String enabled = state.getAttributeValue("enabled");
|
||||
//myEnabled = enabled == null ? true : Boolean.valueOf(enabled);
|
||||
//
|
||||
//final String enabledForTabs = state.getAttributeValue("enabledForTabs");
|
||||
//myEnabledForTabs = enabledForTabs == null ? true : Boolean.valueOf(enabledForTabs);
|
||||
|
||||
//final String showNonProject = state.getAttributeValue("showNonProject");
|
||||
//myEnabledForNonProject = showNonProject == null ? true : Boolean.valueOf(showNonProject);
|
||||
}
|
||||
|
||||
myModel.load(state, shared);
|
||||
//final List<FileColorConfiguration> local = myModel.getLocalConfigurations();
|
||||
//if (!shared && myEnabledForNonProject && findConfigurationByName(NonProjectFilesScope.NAME, local) == null) {
|
||||
// local.add(new FileColorConfiguration(NonProjectFilesScope.NAME, NonProjectFilesScope.DEFAULT_COLOR));
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,13 +205,9 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent
|
||||
@Nullable
|
||||
public Color getFileColor(@NotNull final VirtualFile file) {
|
||||
initSharedConfigurations();
|
||||
final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
|
||||
if (psiFile != null) {
|
||||
return getFileColor(psiFile);
|
||||
} else {
|
||||
final String colorName = myModel.getColor(file, getProject());
|
||||
return colorName == null ? null : getColor(colorName);
|
||||
}
|
||||
|
||||
final String colorName = myModel.getColor(file, getProject());
|
||||
return colorName == null ? null : getColor(colorName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -254,10 +219,6 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent
|
||||
return myModel;
|
||||
}
|
||||
|
||||
boolean isShared(FileColorConfiguration configuration) {
|
||||
return myModel.isShared(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
@@ -281,16 +242,6 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static FileColorConfiguration findConfigurationByName(String name, List<FileColorConfiguration> configurations) {
|
||||
for (FileColorConfiguration configuration : configurations) {
|
||||
if (name.equals(configuration.getScopeName())) {
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static String getAlias(String text) {
|
||||
if (UIUtil.isUnderDarcula()) {
|
||||
if (text.equals("Yellow")) return "Brown";
|
||||
|
||||
@@ -121,7 +121,7 @@ public class FileColorsModel implements Cloneable {
|
||||
|
||||
configurations.clear();
|
||||
|
||||
final List<Element> list = (List<Element>)e.getChildren(FILE_COLOR);
|
||||
final List<Element> list = e.getChildren(FILE_COLOR);
|
||||
final Map<String, String> global = new HashMap<String, String>(globalScopes);
|
||||
for (Element child : list) {
|
||||
final FileColorConfiguration configuration = FileColorConfiguration.load(child);
|
||||
@@ -198,12 +198,8 @@ public class FileColorsModel implements Cloneable {
|
||||
if (!psiFile.isValid()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final FileColorConfiguration configuration = findConfiguration(psiFile);
|
||||
if (configuration != null && configuration.isValid(psiFile.getProject())) {
|
||||
return configuration.getColorName();
|
||||
}
|
||||
return null;
|
||||
VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
return virtualFile == null? null : getColor(virtualFile, psiFile.getProject());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -219,31 +215,6 @@ public class FileColorsModel implements Cloneable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FileColorConfiguration findConfiguration(@NotNull final PsiFile colored) {
|
||||
for (final FileColorConfiguration configuration : myConfigurations) {
|
||||
final NamedScope scope = NamedScopeManager.getScope(myProject, configuration.getScopeName());
|
||||
if (scope != null) {
|
||||
final NamedScopesHolder namedScopesHolder = NamedScopeManager.getHolder(myProject, configuration.getScopeName(), null);
|
||||
if (scope.getValue() != null && namedScopesHolder != null && scope.getValue().contains(colored, namedScopesHolder)) {
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (FileColorConfiguration configuration : mySharedConfigurations) {
|
||||
final NamedScope scope = NamedScopeManager.getScope(myProject, configuration.getScopeName());
|
||||
if (scope != null) {
|
||||
final NamedScopesHolder namedScopesHolder = NamedScopeManager.getHolder(myProject, configuration.getScopeName(), null);
|
||||
if (scope.getValue() != null && namedScopesHolder != null && scope.getValue().contains(colored, namedScopesHolder)) {
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FileColorConfiguration findConfiguration(@NotNull final VirtualFile colored) {
|
||||
for (final FileColorConfiguration configuration : myConfigurations) {
|
||||
|
||||
Reference in New Issue
Block a user