allow 'Mark as plain text' on excluded files (IDEA-195199)

We show excluded files in Project View and user can edit them, so it makes sense to allow users mark them as plain text files for consistency.
This commit is contained in:
nik
2018-07-11 10:37:48 +03:00
parent d250874644
commit d749bc6013
2 changed files with 3 additions and 18 deletions
@@ -25,6 +25,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileWithId;
import com.intellij.util.FileContentUtilCore;
@@ -93,8 +94,9 @@ public class EnforcedPlainTextFileTypeManager implements ProjectManagerListener
private void setPlainTextStatus(@NotNull final Project project, final boolean isAdded, @NotNull final VirtualFile... files) {
ApplicationManager.getApplication().runWriteAction(() -> {
ProjectPlainTextFileTypeManager projectManager = ProjectPlainTextFileTypeManager.getInstance(project);
ProjectFileIndex fileIndex = ProjectFileIndex.getInstance(project);
for (VirtualFile file : files) {
if (projectManager.isInContent(file) || projectManager.isInLibrarySource(file)) {
if (fileIndex.isInContent(file) || fileIndex.isInLibrarySource(file) || fileIndex.isExcluded(file)) {
ensureProjectFileSetAdded(project, projectManager);
if (isAdded ?
projectManager.addFile(file) :
@@ -18,29 +18,12 @@ package com.intellij.openapi.file.exclude;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
/**
* @author Rustam Vishnyakov
*/
@State(name = "ProjectPlainTextFileTypeManager")
public class ProjectPlainTextFileTypeManager extends PersistentFileSetManager {
private final ProjectFileIndex myIndex;
public ProjectPlainTextFileTypeManager(ProjectFileIndex projectFileIndex) {
myIndex = projectFileIndex;
}
boolean isInContent(@NotNull VirtualFile file) {
return myIndex.isInContent(file);
}
boolean isInLibrarySource(@NotNull final VirtualFile file) {
return myIndex.isInLibrarySource(file);
}
public static ProjectPlainTextFileTypeManager getInstance(Project project) {
return ServiceManager.getService(project, ProjectPlainTextFileTypeManager.class);
}