mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
+3
-1
@@ -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) :
|
||||
|
||||
-17
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user