diff --git a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java index 5c655bc3addb..f3b8237bd2ba 100644 --- a/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/actions/GenerateAntBuildAction.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.compiler.actions; import com.intellij.compiler.CompilerConfiguration; @@ -266,14 +252,14 @@ public class GenerateAntBuildAction extends CompileActionBase { } } final ReadonlyStatusHandler.OperationStatus status = - ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(VfsUtil.toVirtualFileArray(toCheck)); + ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(toCheck); if (status.hasReadonlyFiles()) { throw new IOException(status.getReadonlyFilesMessage()); } } public File[] generateMultipleFileBuild(Project project, GenerationOptions genOptions, List filesToRefresh) throws IOException { - final File projectBuildFileDestDir = VfsUtil.virtualToIoFile(project.getBaseDir()); + final File projectBuildFileDestDir = VfsUtilCore.virtualToIoFile(project.getBaseDir()); projectBuildFileDestDir.mkdirs(); final List generated = new ArrayList<>(); final File projectBuildFile = new File(projectBuildFileDestDir, genOptions.getBuildFileName()); diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java index 7a860ca2ec47..3ee2f6c2c721 100644 --- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight; import com.google.common.annotations.VisibleForTesting; @@ -496,7 +496,7 @@ public class ExternalAnnotationsManagerImpl extends ReadableExternalAnnotationsM } @Override - public void elementRenamedOrMoved(@NotNull PsiModifierListOwner element, @NotNull String oldExternalName) { + public void elementRenamedOrMoved(@NotNull PsiModifierListOwner element, @NotNull String oldExternalName) { ApplicationManager.getApplication().assertIsDispatchThread(); try { final List files = findExternalAnnotationsXmlFiles(element); @@ -541,7 +541,7 @@ public class ExternalAnnotationsManagerImpl extends ReadableExternalAnnotationsM } } - + @Override public boolean editExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull final String annotationFQN, @@ -569,7 +569,7 @@ public class ExternalAnnotationsManagerImpl extends ReadableExternalAnnotationsM continue; } if (ReadonlyStatusHandler.getInstance(myPsiManager.getProject()) - .ensureFilesWritable(file.getVirtualFile()).hasReadonlyFiles()) { + .ensureFilesWritable(Collections.singletonList(file.getVirtualFile())).hasReadonlyFiles()) { continue; } final XmlDocument document = file.getDocument(); diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/method/OverrideImplementMethodAction.java b/java/java-impl/src/com/intellij/ide/hierarchy/method/OverrideImplementMethodAction.java index 5100f9265f15..d611ea6fe1e7 100644 --- a/java/java-impl/src/com/intellij/ide/hierarchy/method/OverrideImplementMethodAction.java +++ b/java/java-impl/src/com/intellij/ide/hierarchy/method/OverrideImplementMethodAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.hierarchy.method; import com.intellij.codeInsight.generation.OverrideImplementUtil; @@ -11,7 +11,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.psi.*; @@ -50,7 +49,7 @@ abstract class OverrideImplementMethodAction extends AnAction { } } } - final ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(VfsUtil.toVirtualFileArray(files)); + final ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); if (!status.hasReadonlyFiles()) { for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) { final PsiElement aClass = ((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass(); diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodHandler.java index 38b3d34b9e57..dc1d50cf6148 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodHandler.java @@ -1,19 +1,5 @@ -/* - * Copyright 2000-2009 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.inline; import com.intellij.codeInsight.TargetElementUtil; @@ -30,6 +16,8 @@ import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.refactoring.util.InlineUtil; import com.intellij.refactoring.util.RefactoringUtil; +import java.util.Collections; + class InlineMethodHandler extends JavaInlineActionHandler { private static final String REFACTORING_NAME = RefactoringBundle.message("inline.method.title"); @@ -130,7 +118,7 @@ class InlineMethodHandler extends JavaInlineActionHandler { final boolean invokedOnReference = reference != null; if (!invokedOnReference) { final VirtualFile vFile = method.getContainingFile().getVirtualFile(); - ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(vFile); + ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(Collections.singletonList(vFile)); } PsiJavaCodeReferenceElement refElement = null; diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java index 05df230f18fc..0c09345a7fd7 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/MigrationPanel.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.typeMigration.ui; import com.intellij.CommonBundle; @@ -16,7 +16,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.presentation.java.SymbolPresentationUtil; @@ -191,7 +190,7 @@ public class MigrationPanel extends JPanel implements Disposable { ApplicationManager.getApplication().invokeLater(() -> { if (ReadonlyStatusHandler.getInstance(myProject). - ensureFilesWritable(VfsUtilCore.toVirtualFileArray(files)).hasReadonlyFiles()) { + ensureFilesWritable(files).hasReadonlyFiles()) { return; } WriteCommandAction.writeCommandAction(myProject).run(() -> { diff --git a/java/java-impl/src/com/intellij/refactoring/util/ClsElementWritingAccessProvider.java b/java/java-impl/src/com/intellij/refactoring/util/ClsElementWritingAccessProvider.java index 12ac8fbb884c..297f2f7423b4 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/ClsElementWritingAccessProvider.java +++ b/java/java-impl/src/com/intellij/refactoring/util/ClsElementWritingAccessProvider.java @@ -8,12 +8,11 @@ import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.Collections; -import java.util.List; public class ClsElementWritingAccessProvider extends WritingAccessProvider { @NotNull @Override - public Collection requestWriting(@NotNull List files) { + public Collection requestWriting(@NotNull Collection files) { return Collections.emptyList(); } diff --git a/platform/configuration-store-impl/src/ProjectStoreImpl.kt b/platform/configuration-store-impl/src/ProjectStoreImpl.kt index 7127359d291d..3fcd2084269f 100644 --- a/platform/configuration-store-impl/src/ProjectStoreImpl.kt +++ b/platform/configuration-store-impl/src/ProjectStoreImpl.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.configurationStore import com.intellij.ide.highlighter.ProjectFileType @@ -33,6 +33,7 @@ import com.intellij.util.PathUtilRt import com.intellij.util.SmartList import com.intellij.util.containers.computeIfAny import com.intellij.util.containers.isNullOrEmpty +import com.intellij.util.containers.mapSmart import com.intellij.util.io.* import com.intellij.util.lang.CompoundRuntimeException import com.intellij.util.text.nullize @@ -326,9 +327,9 @@ private open class ProjectStoreImpl(project: Project, private val pathMacroManag throw IComponentStore.SaveCancelledException() } - val status = runReadAction { ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(*getFilesList(readonlyFiles)) } + val status = runReadAction { ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(getFilesList(readonlyFiles)) } if (status.hasReadonlyFiles()) { - dropUnableToSaveProjectNotification(project, status.readonlyFiles) + dropUnableToSaveProjectNotification(project, status.readonlyFiles.toList()) throw IComponentStore.SaveCancelledException() } @@ -350,7 +351,7 @@ private open class ProjectStoreImpl(project: Project, private val pathMacroManag } } -private fun dropUnableToSaveProjectNotification(project: Project, readOnlyFiles: Array) { +private fun dropUnableToSaveProjectNotification(project: Project, readOnlyFiles: List) { val notifications = NotificationsManager.getNotificationsManager().getNotificationsOfType(UnableToSaveProjectNotification::class.java, project) if (notifications.isEmpty()) { Notifications.Bus.notify(UnableToSaveProjectNotification(project, readOnlyFiles), project) @@ -360,7 +361,7 @@ private fun dropUnableToSaveProjectNotification(project: Project, readOnlyFiles: } } -private fun getFilesList(readonlyFiles: List) = Array(readonlyFiles.size) { readonlyFiles[it].file } +private fun getFilesList(readonlyFiles: List) = readonlyFiles.mapSmart { it.file } private class ProjectWithModulesStoreImpl(project: Project, pathMacroManager: PathMacroManager) : ProjectStoreImpl(project, pathMacroManager) { override fun beforeSave(readonlyFiles: MutableList) { diff --git a/platform/core-api/src/com/intellij/openapi/vfs/WritingAccessProvider.java b/platform/core-api/src/com/intellij/openapi/vfs/WritingAccessProvider.java index 00494faf543e..3f5de8eeeaf7 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/WritingAccessProvider.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/WritingAccessProvider.java @@ -20,7 +20,7 @@ public abstract class WritingAccessProvider { * @return set of files that cannot be accessed */ @NotNull - public Collection requestWriting(@NotNull List files) { + public Collection requestWriting(@NotNull Collection files) { //noinspection deprecation return requestWriting(files.toArray(VirtualFile.EMPTY_ARRAY)); } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java index d8b1643bfb2b..8b22fd1bf1ec 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.diff.util; import com.intellij.application.options.CodeStyle; @@ -1430,7 +1430,7 @@ public class DiffUtil { @CalledInAwt public static boolean makeWritable(@Nullable Project project, @NotNull VirtualFile file) { if (project == null) project = ProjectManager.getInstance().getDefaultProject(); - return !ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(file).hasReadonlyFiles(); + return !ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(Collections.singletonList(file)).hasReadonlyFiles(); } public static void putNonundoableOperation(@Nullable Project project, @NotNull Document document) { diff --git a/platform/lang-api/src/com/intellij/refactoring/util/CommonRefactoringUtil.java b/platform/lang-api/src/com/intellij/refactoring/util/CommonRefactoringUtil.java index ba6602564283..41240dd82532 100644 --- a/platform/lang-api/src/com/intellij/refactoring/util/CommonRefactoringUtil.java +++ b/platform/lang-api/src/com/intellij/refactoring/util/CommonRefactoringUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.util; import com.intellij.codeInsight.hint.HintManager; @@ -97,7 +83,7 @@ public class CommonRefactoringUtil { public static boolean checkReadOnlyStatus(@NotNull PsiElement element) { final VirtualFile file = element.getContainingFile().getVirtualFile(); - return file != null && !ReadonlyStatusHandler.getInstance(element.getProject()).ensureFilesWritable(file).hasReadonlyFiles(); + return file != null && !ReadonlyStatusHandler.getInstance(element.getProject()).ensureFilesWritable(Collections.singletonList(file)).hasReadonlyFiles(); } public static boolean checkReadOnlyStatus(@NotNull Project project, @NotNull PsiElement element) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightUtilBase.java b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightUtilBase.java index 8d3d4bd815ca..ba42a5861da3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightUtilBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightUtilBase.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight; @@ -24,7 +10,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -85,8 +70,7 @@ public class CodeInsightUtilBase extends CodeInsightUtilCore { files.add(virtualFile); } if (!files.isEmpty()) { - VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files); - ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(virtualFiles); + ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); return !status.hasReadonlyFiles(); } return true; @@ -97,7 +81,7 @@ public class CodeInsightUtilBase extends CodeInsightUtilCore { ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); return !status.hasReadonlyFiles(); } - + // returns true on success @Deprecated public static boolean prepareEditorForWrite(@NotNull Editor editor) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/OptimizeImportsAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/OptimizeImportsAction.java index 7a63549efe39..9600db437698 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/OptimizeImportsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/OptimizeImportsAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.actions; @@ -24,6 +24,7 @@ import org.jetbrains.annotations.TestOnly; import javax.swing.*; import javax.swing.border.EmptyBorder; +import java.util.Arrays; public class OptimizeImportsAction extends AnAction { private static final @NonNls String HELP_ID = "editing.manageImports"; @@ -58,7 +59,8 @@ public class OptimizeImportsAction extends AnAction { dir = file.getContainingDirectory(); } else if (files != null && ReformatCodeAction.containsAtLeastOneFile(files)) { - final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); + final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable( + Arrays.asList(files)); if (!operationStatus.hasReadonlyFiles()) { new OptimizeImportsProcessor(project, ReformatCodeAction.convertToPsiFiles(files, project), null).run(); } @@ -217,19 +219,19 @@ public class OptimizeImportsAction extends AnAction { if (ApplicationManager.getApplication().isUnitTestMode()) { return myProcessVcsChangedFilesInTests; } - + OptimizeImportsDialog dialog = new OptimizeImportsDialog(project, text, hasChanges); if (!dialog.showAndGet()) { return null; } - + return dialog.isProcessOnlyVcsChangedFiles(); } - + @TestOnly protected static void setProcessVcsChangedFilesInTests(boolean value) { myProcessVcsChangedFilesInTests = value; - } + } private static class OptimizeImportsDialog extends DialogWrapper { private final boolean myContextHasChanges; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java index 861f02f31e97..795926972843 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.actions; @@ -24,7 +24,6 @@ import com.intellij.psi.*; import com.intellij.psi.search.SearchScope; import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.ArrayUtil; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -36,7 +35,6 @@ import java.util.regex.PatternSyntaxException; public class ReformatCodeAction extends AnAction implements DumbAware { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.actions.ReformatCodeAction"); - private static final @NonNls String HELP_ID = "editing.codeReformatting"; protected static ReformatFilesOptions myTestOptions; public ReformatCodeAction() { @@ -55,7 +53,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware { final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext); PsiFile file = null; - PsiDirectory dir = null; + PsiDirectory dir; boolean hasSelection = false; if (editor != null){ @@ -65,7 +63,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware { hasSelection = editor.getSelectionModel().hasSelection(); } else if (containsAtLeastOneFile(files)) { - final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); + final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(Arrays.asList(files)); if (!operationStatus.hasReadonlyFiles()) { ReformatFilesOptions selectedFlags = getReformatFilesOptions(project, files); if (selectedFlags == null) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/InvokeTemplateAction.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/InvokeTemplateAction.java index 5b0724a71627..4b4621212ab0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/InvokeTemplateAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/InvokeTemplateAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.template.impl; import com.intellij.codeInsight.template.TemplateManager; @@ -15,6 +15,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; +import java.util.Collections; import java.util.Set; /** @@ -59,7 +60,7 @@ public class InvokeTemplateAction extends AnAction { final Document document = myEditor.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file != null) { - ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(file); + ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(Collections.singletonList(file)); } CommandProcessor.getInstance().executeCommand(myProject, () -> myEditor.getCaretModel().runForEachCaret(__ -> { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/WrapWithCustomTemplateAction.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/WrapWithCustomTemplateAction.java index 8d41dcabfd8c..a16eca8145f3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/WrapWithCustomTemplateAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/WrapWithCustomTemplateAction.java @@ -1,18 +1,4 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.template.impl; import com.intellij.codeInsight.template.CustomLiveTemplate; @@ -28,6 +14,7 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; +import java.util.Collections; import java.util.Set; public class WrapWithCustomTemplateAction extends AnAction { @@ -55,7 +42,7 @@ public class WrapWithCustomTemplateAction extends AnAction { final Document document = myEditor.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file != null) { - ReadonlyStatusHandler.getInstance(myFile.getProject()).ensureFilesWritable(file); + ReadonlyStatusHandler.getInstance(myFile.getProject()).ensureFilesWritable(Collections.singletonList(file)); } String selection = myEditor.getSelectionModel().getSelectedText(true); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java index 22488c73734a..54fa29968bfe 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInspection.ex; @@ -30,7 +30,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; @@ -272,8 +271,7 @@ public class QuickFixAction extends AnAction implements CustomComponentAction { Set readOnlyFiles = getReadOnlyFiles(refElements); if (!readOnlyFiles.isEmpty()) { final Project project = refElements[0].getRefManager().getProject(); - final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable( - VfsUtilCore.toVirtualFileArray(readOnlyFiles)); + final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(readOnlyFiles); if (operationStatus.hasReadonlyFiles()) return false; } return true; diff --git a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java index cf446c03e04e..f8f6d1c7eec4 100644 --- a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java +++ b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.find.replaceInProject; @@ -30,7 +30,6 @@ import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.StatusBar; @@ -303,7 +302,7 @@ public class ReplaceInProjectManager { putValue(LONG_DESCRIPTION, KeymapUtil.getKeystrokeText(altEnter)); putValue(SHORT_DESCRIPTION, KeymapUtil.getKeystrokeText(altEnter)); } - + @Override public void actionPerformed(ActionEvent e) { replaceUsagesUnderCommand(replaceContext, replaceContext.getUsageView().getSelectedUsages()); @@ -551,7 +550,7 @@ public class ReplaceInProjectManager { } if (readOnlyFiles != null) { - ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(VfsUtilCore.toVirtualFileArray(readOnlyFiles)); + ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(readOnlyFiles); } if (hasReadOnlyUsages(selectedUsages)) { diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/LRUPopupBuilder.java b/platform/lang-impl/src/com/intellij/ide/scratch/LRUPopupBuilder.java index edcf20b87443..f2a4fabfbdfa 100644 --- a/platform/lang-impl/src/com/intellij/ide/scratch/LRUPopupBuilder.java +++ b/platform/lang-impl/src/com/intellij/ide/scratch/LRUPopupBuilder.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.scratch; import com.intellij.ide.util.PropertiesComponent; @@ -45,8 +31,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.io.IOException; -import java.util.*; import java.util.List; +import java.util.*; /** * @author gregsh @@ -281,7 +267,7 @@ public abstract class LRUPopupBuilder { @NotNull Language t, @NotNull VirtualFile[] sortedFiles, @NotNull PerFileMappings mappings) throws UnexpectedUndoException { - ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(sortedFiles); + ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(Arrays.asList(sortedFiles)); if (status.hasReadonlyFiles()) return; final Set matchedExtensions = ContainerUtil.newLinkedHashSet(); diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/IdeaGateway.java b/platform/lvcs-impl/src/com/intellij/history/integration/IdeaGateway.java index a98a1c0f7885..478341330ede 100644 --- a/platform/lvcs-impl/src/com/intellij/history/integration/IdeaGateway.java +++ b/platform/lvcs-impl/src/com/intellij/history/integration/IdeaGateway.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.history.integration; import com.intellij.history.core.LocalHistoryFacade; @@ -22,7 +22,10 @@ import com.intellij.openapi.util.Clock; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.*; +import com.intellij.openapi.vfs.CharsetToolkit; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.ReadonlyStatusHandler; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.encoding.EncodingRegistry; import com.intellij.openapi.vfs.ex.temp.TempFileSystem; import com.intellij.openapi.vfs.newvfs.ManagingFS; @@ -59,7 +62,7 @@ public class IdeaGateway { return false; } } - + VersionedFilterData versionedFilterData = getVersionedFilterData(); boolean isInContent = false; @@ -151,7 +154,7 @@ public class IdeaGateway { public boolean ensureFilesAreWritable(@NotNull Project p, @NotNull List ff) { ReadonlyStatusHandler h = ReadonlyStatusHandler.getInstance(p); - return !h.ensureFilesWritable(VfsUtilCore.toVirtualFileArray(ff)).hasReadonlyFiles(); + return !h.ensureFilesWritable(ff).hasReadonlyFiles(); } @Nullable diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java b/platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java index e1783d0ca11d..87fe52373d30 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/ReadonlyStatusHandler.java @@ -10,11 +10,10 @@ import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.Collection; -import java.util.List; public abstract class ReadonlyStatusHandler { public static boolean ensureFilesWritable(@NotNull Project project, @NotNull VirtualFile... files) { - return !getInstance(project).ensureFilesWritable(files).hasReadonlyFiles(); + return !getInstance(project).ensureFilesWritable(Arrays.asList(files)).hasReadonlyFiles(); } public static boolean ensureDocumentWritable(@NotNull Project project, @NotNull Document document) { @@ -46,18 +45,16 @@ public abstract class ReadonlyStatusHandler { } /** - * @deprecated Use {@link #ensureFilesWritable(List)} + * @deprecated Use {@link #ensureFilesWritable(Collection)} */ @Deprecated + @NotNull public OperationStatus ensureFilesWritable(@NotNull VirtualFile... files) { return ensureFilesWritable(Arrays.asList(files)); } - public abstract OperationStatus ensureFilesWritable(@NotNull List files); - - public OperationStatus ensureFilesWritable(@NotNull Collection files) { - return ensureFilesWritable(VfsUtilCore.toVirtualFileArray(files)); - } + @NotNull + public abstract OperationStatus ensureFilesWritable(@NotNull Collection files); public static ReadonlyStatusHandler getInstance(@NotNull Project project) { return ServiceManager.getService(project, ReadonlyStatusHandler.class); diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java index 12df529ff2da..60a656d6e7cf 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.command.impl; import com.intellij.CommonBundle; @@ -14,7 +14,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; @@ -107,13 +106,11 @@ abstract class UndoRedo { Collection readOnlyFiles = collectReadOnlyAffectedFiles(); if (!readOnlyFiles.isEmpty()) { final Project project = myManager.getProject(); - final VirtualFile[] files = VfsUtil.toVirtualFileArray(readOnlyFiles); - if (project == null) { return false; } - final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); + final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(readOnlyFiles); if (operationStatus.hasReadonlyFiles()) { return false; } @@ -209,7 +206,7 @@ abstract class UndoRedo { private boolean restore(EditorAndState pair, boolean onlyIfDiffers) { // editor can be invalid if underlying file is deleted during undo (e.g. after undoing scratch file creation) if (pair == null || myEditor == null || !myEditor.isValid() || !pair.canBeAppliedTo(myEditor)) return false; - + // If current editor state isn't equals to remembered state then // we have to try to restore previous state. But sometime it's // not possible to restore it. For example, it's not possible to diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessProvider.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessProvider.java index dfbfb42cf20b..7a0de5b31aca 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessProvider.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/NonProjectFileWritingAccessProvider.java @@ -57,7 +57,7 @@ public class NonProjectFileWritingAccessProvider extends WritingAccessProvider { @NotNull @Override - public Collection requestWriting(@NotNull List files) { + public Collection requestWriting(@NotNull Collection files) { if (isAllAccessAllowed()) return Collections.emptyList(); List deniedFiles = new ArrayList<>(); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index 24056c8bfb5c..c70b427edd11 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.project.impl; import com.intellij.configurationStore.StorageUtilKt; @@ -872,10 +872,10 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable { message.append("\n\nRead-only files:\n"); int count = 0; - VirtualFile[] files = notifications[0].myFiles; + List files = notifications[0].myFiles; for (VirtualFile file : files) { if (count == 10) { - message.append('\n').append("and ").append(files.length - count).append(" more").append('\n'); + message.append('\n').append("and ").append(files.size() - count).append(" more").append('\n'); } else { message.append(file.getPath()).append('\n'); @@ -887,9 +887,9 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable { public static class UnableToSaveProjectNotification extends Notification { private Project myProject; - public VirtualFile[] myFiles; + public List myFiles; - public UnableToSaveProjectNotification(@NotNull final Project project, @NotNull VirtualFile[] readOnlyFiles) { + public UnableToSaveProjectNotification(@NotNull final Project project, @NotNull List readOnlyFiles) { super("Project Settings", "Could not save project", "Unable to save project files. Please ensure project files are writable and you have permissions to modify them." + " Try to save project again.", NotificationType.ERROR, (notification, event) -> { diff --git a/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java index fbc41a40cb61..2322173ad4ea 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java @@ -58,8 +58,9 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements myState = state; } + @NotNull @Override - public OperationStatus ensureFilesWritable(@NotNull List files) { + public OperationStatus ensureFilesWritable(@NotNull Collection files) { if (files.isEmpty()) { return new OperationStatusImpl(VirtualFile.EMPTY_ARRAY); } @@ -129,7 +130,7 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements } } - private static OperationStatus createResultStatus(@NotNull List files) { + private static OperationStatus createResultStatus(@NotNull Collection files) { List readOnlyFiles = new ArrayList<>(); for (VirtualFile file : files) { if (file.exists()) { @@ -143,7 +144,7 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements } @NotNull - private List createFileInfos(@NotNull List files) { + private List createFileInfos(@NotNull Collection files) { List fileInfos = new ArrayList<>(); for (final VirtualFile file : files) { if (file != null && !file.isWritable() && file.isInLocalFileSystem()) { diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NonProjectFileAccessTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NonProjectFileAccessTest.java index 526dc183e899..5c97c569f933 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NonProjectFileAccessTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/NonProjectFileAccessTest.java @@ -307,7 +307,7 @@ public class NonProjectFileAccessTest extends HeavyFileEditorManagerTestCase { PlatformTestUtil.registerExtension(Extensions.getArea(getProject()), WritingAccessProvider.EP_NAME, new WritingAccessProvider() { @NotNull @Override - public Collection requestWriting(@NotNull List files) { + public Collection requestWriting(@NotNull Collection files) { requested.addAll(files); HashSet denied = new HashSet<>(Arrays.asList(filesToDeny)); denied.retainAll(files); diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java index f0140293d65d..e49eeebc84b7 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.usages.impl; import com.intellij.concurrency.JobSchedulerImpl; @@ -24,7 +24,6 @@ import com.intellij.openapi.ui.SimpleToolWindowPanel; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.*; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.Navigatable; import com.intellij.psi.*; @@ -1584,7 +1583,7 @@ public class UsageViewImpl implements UsageViewEx { final Set readOnlyUsages = getReadOnlyUsagesFiles(); return readOnlyUsages.isEmpty() || - !ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(VfsUtilCore.toVirtualFileArray(readOnlyUsages)).hasReadonlyFiles(); + !ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(readOnlyUsages).hasReadonlyFiles(); } @NotNull diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictAccessProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictAccessProvider.java index 59d6ac6362da..196eea403b6a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictAccessProvider.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictAccessProvider.java @@ -10,7 +10,10 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.WritingAccessProvider; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; /** * @author Dmitry Avdeev @@ -26,7 +29,7 @@ public class ChangelistConflictAccessProvider extends WritingAccessProvider { @NotNull @Override - public Collection requestWriting(@NotNull List files) { + public Collection requestWriting(@NotNull Collection files) { ChangelistConflictTracker.Options options = myManager.getConflictTracker().getOptions(); if (!options.SHOW_DIALOG) { return Collections.emptyList(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/actions/GetVersionAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/actions/GetVersionAction.java index 1e812959e421..735a234c05d6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/actions/GetVersionAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/actions/GetVersionAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.history.actions; import com.intellij.history.LocalHistory; @@ -38,6 +38,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.util.Collections; public class GetVersionAction extends AnAction implements DumbAware { private static final Logger LOG = Logger.getInstance(GetVersionAction.class); @@ -184,7 +185,7 @@ public class GetVersionAction extends AnAction implements DumbAware { ApplicationManager.getApplication().invokeLater(() -> { try { if (myFile != null && !myFile.isWritable() && - ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(myFile).hasReadonlyFiles()) { + ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(Collections.singletonList(myFile)).hasReadonlyFiles()) { return; } diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/AbstractFileProcessor.java b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/AbstractFileProcessor.java index 47367b91e3aa..9af2e02b7899 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/actions/AbstractFileProcessor.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/actions/AbstractFileProcessor.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.maddyhome.idea.copyright.actions; @@ -44,7 +30,6 @@ import java.util.List; public abstract class AbstractFileProcessor { private final Project myProject; private final Module myModule; - private final PsiDirectory directory = null; private PsiFile file = null; private PsiFile[] files = null; private final String message; @@ -69,10 +54,7 @@ public abstract class AbstractFileProcessor { } public void run() { - if (directory != null) { - process(directory, false); - } - else if (files != null) { + if (files != null) { process(files); } else if (file != null) { @@ -189,12 +171,6 @@ public abstract class AbstractFileProcessor { }); } - private void process(final PsiDirectory dir, final boolean subdirs) { - final List pfiles = new ArrayList<>(); - ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> findFiles(pfiles, dir, subdirs), title, true, myProject); - handleFiles(pfiles); - } - private void process(final Project project) { final List pfiles = new ArrayList<>(); ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> findFiles(project, pfiles), title, true, project); @@ -236,8 +212,11 @@ public abstract class AbstractFileProcessor { } private void handleFiles(final List files) { - final VirtualFile[] vFiles = files.stream().map(PsiFile::getVirtualFile).toArray(VirtualFile[]::new); - if (!ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(vFiles).hasReadonlyFiles()) { + List list = new ArrayList<>(); + for (PsiFile psiFile : files) { + list.add(psiFile.getVirtualFile()); + } + if (!ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(list).hasReadonlyFiles()) { if (!files.isEmpty()) { final Runnable[] resultRunnable = new Runnable[1]; execute(() -> resultRunnable[0] = prepareFiles(files), () -> { @@ -270,9 +249,7 @@ public abstract class AbstractFileProcessor { ProgressManager.getInstance() .runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(readAction), title, true, myProject); - WriteCommandAction.writeCommandAction(myProject).withName(title).run(() -> { - writeAction.run(); - }); + WriteCommandAction.writeCommandAction(myProject).withName(title).run(() -> writeAction.run()); } private static final Logger logger = Logger.getInstance(AbstractFileProcessor.class.getName()); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/MergeAction.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/MergeAction.java index 1a66fddcabb8..523c94450575 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/MergeAction.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/MergeAction.java @@ -1,18 +1,4 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.cvsSupport2.actions.merge; import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility; @@ -63,8 +49,7 @@ public class MergeAction extends AnAction { final VirtualFile[] files = context.getSelectedFiles(); if (files.length == 0) return; final Project project = context.getProject(); - final ReadonlyStatusHandler.OperationStatus operationStatus = - ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); + final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(Arrays.asList(files)); if (operationStatus.hasReadonlyFiles()) { return; } diff --git a/plugins/devkit/devkit-core/src/build/PrepareToDeployAction.java b/plugins/devkit/devkit-core/src/build/PrepareToDeployAction.java index fcb0d2b93ac9..d97d52c8e516 100644 --- a/plugins/devkit/devkit-core/src/build/PrepareToDeployAction.java +++ b/plugins/devkit/devkit-core/src/build/PrepareToDeployAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.idea.devkit.build; import com.intellij.compiler.server.CompileServerPlugin; @@ -201,7 +201,7 @@ public class PrepareToDeployAction extends AnAction { return true; } final VirtualFile vfile = VfsUtil.findFileByURL(url); - return vfile == null || !ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(vfile).hasReadonlyFiles(); + return vfile == null || !ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(Collections.singletonList(vfile)).hasReadonlyFiles(); } private static FileFilter createFilter(final ProgressIndicator progressIndicator, @Nullable final FileTypeManager fileTypeManager) { diff --git a/plugins/devkit/devkit-core/src/inspections/quickfix/BaseFix.java b/plugins/devkit/devkit-core/src/inspections/quickfix/BaseFix.java index a8f860c2e103..f56cd4c99ddf 100644 --- a/plugins/devkit/devkit-core/src/inspections/quickfix/BaseFix.java +++ b/plugins/devkit/devkit-core/src/inspections/quickfix/BaseFix.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.idea.devkit.inspections.quickfix; import com.intellij.codeInspection.LocalQuickFix; @@ -7,7 +7,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.psi.SmartPsiElementPointer; @@ -16,6 +15,8 @@ import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.devkit.DevKitBundle; +import java.util.Collections; + abstract class BaseFix implements LocalQuickFix { protected final SmartPsiElementPointer myPointer; protected final boolean myOnTheFly; @@ -36,8 +37,7 @@ abstract class BaseFix implements LocalQuickFix { if (external) { PsiClass clazz = PsiTreeUtil.getParentOfType(element, PsiClass.class, false); ReadonlyStatusHandler readonlyStatusHandler = ReadonlyStatusHandler.getInstance(project); - VirtualFile[] files = new VirtualFile[]{element.getContainingFile().getVirtualFile()}; - ReadonlyStatusHandler.OperationStatus status = readonlyStatusHandler.ensureFilesWritable(files); + ReadonlyStatusHandler.OperationStatus status = readonlyStatusHandler.ensureFilesWritable(Collections.singletonList(element.getContainingFile().getVirtualFile())); if (status.hasReadonlyFiles()) { String className = clazz != null ? clazz.getQualifiedName() : element.getContainingFile().getName(); diff --git a/plugins/devkit/devkit-core/src/util/DescriptorUtil.java b/plugins/devkit/devkit-core/src/util/DescriptorUtil.java index dec123b7d8a4..37653dad2329 100644 --- a/plugins/devkit/devkit-core/src/util/DescriptorUtil.java +++ b/plugins/devkit/devkit-core/src/util/DescriptorUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.idea.devkit.util; import com.intellij.openapi.application.WriteAction; @@ -57,7 +57,7 @@ public final class DescriptorUtil { VirtualFile file = pluginXml.getVirtualFile(); final ReadonlyStatusHandler readonlyStatusHandler = ReadonlyStatusHandler.getInstance(project); - final ReadonlyStatusHandler.OperationStatus status = readonlyStatusHandler.ensureFilesWritable(file); + final ReadonlyStatusHandler.OperationStatus status = readonlyStatusHandler.ensureFilesWritable(Collections.singletonList(file)); if (status.hasReadonlyFiles()) { throw new IncorrectOperationException(DevKitBundle.message("error.plugin.xml.readonly", status.getReadonlyFiles()[0])); } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderEditor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderEditor.java index a5ae0b9d19d6..1ba963134561 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderEditor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/sceneBuilder/SceneBuilderEditor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.javaFX.sceneBuilder; import com.intellij.codeHighlighting.BackgroundEditorHighlighter; @@ -142,7 +142,7 @@ public class SceneBuilderEditor extends UserDataHolderBase implements FileEditor ApplicationManager.getApplication().invokeLater(() -> { if (mySceneBuilder != null) { - if (!myDocument.isWritable() && ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(myFile).hasReadonlyFiles()) { + if (!myDocument.isWritable() && ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(Collections.singletonList(myFile)).hasReadonlyFiles()) { return; } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java index 9f5a79016f63..95aca29b74d3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.idea.maven.dom.refactorings.introduce; import com.intellij.find.FindManager; @@ -18,7 +18,6 @@ import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; @@ -160,7 +159,8 @@ public class IntroducePropertyAction extends BaseRefactoringAction { showFindUsages(project, propertyName, selectedString, replaceWith, selectedProject); } - private static VirtualFile[] getFiles(PsiFile file, MavenDomProjectModel model) { + @NotNull + private static List getFiles(PsiFile file, MavenDomProjectModel model) { Set virtualFiles = new HashSet<>(); VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { @@ -173,7 +173,7 @@ public class IntroducePropertyAction extends BaseRefactoringAction { if (vf != null) virtualFiles.add(vf); } - return VfsUtilCore.toVirtualFileArray(virtualFiles); + return new ArrayList<>(virtualFiles); } private static void createMavenProperty(@NotNull MavenDomProjectModel model, diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java b/plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java index d21637239014..a0564c570818 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/NewPropertyAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.lang.properties.editor; import com.intellij.icons.AllIcons; @@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; +import java.util.Collections; /** * @author Dmitry Batkovich @@ -74,7 +75,8 @@ class NewPropertyAction extends AnAction { final ResourceBundle bundle = resourceBundleEditor.getResourceBundle(); final VirtualFile file = bundle.getDefaultPropertiesFile().getVirtualFile(); - final ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(file); + final ReadonlyStatusHandler.OperationStatus status = + ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(Collections.singletonList(file)); if (status.hasReadonlyFiles()) { Messages.showErrorDialog(bundle.getProject(), String.format("Resource bundle '%s' has read-only default properties file", bundle.getBaseName()), diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java index 27f36ae4a5d7..eddc10da7b38 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.lang.properties.editor; @@ -82,8 +82,8 @@ import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.beans.PropertyChangeListener; -import java.util.*; import java.util.List; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; public class ResourceBundleEditor extends UserDataHolderBase implements DocumentsEditor { @@ -411,7 +411,8 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document @Override public void keyTyped(KeyEvent e) { if (editor.isViewer()) { - editor.setViewer( ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(propertiesFile.getVirtualFile()).hasReadonlyFiles()); + editor.setViewer(ReadonlyStatusHandler.getInstance(myProject) + .ensureFilesWritable(Collections.singletonList(propertiesFile.getVirtualFile())).hasReadonlyFiles()); } } }); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ChangeFormComponentTypeFix.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ChangeFormComponentTypeFix.java index 9a7f88751465..a4a0ee9fa917 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ChangeFormComponentTypeFix.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/ChangeFormComponentTypeFix.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.uiDesigner.binding; import com.intellij.codeInsight.daemon.QuickFixBundle; @@ -12,6 +12,8 @@ import com.intellij.psi.util.ClassUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; +import java.util.Collections; + /** * @author Eugene Zhuravlev */ @@ -58,7 +60,8 @@ public class ChangeFormComponentTypeFix implements IntentionAction { public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { CommandProcessor.getInstance().executeCommand(file.getProject(), () -> { final ReadonlyStatusHandler readOnlyHandler = ReadonlyStatusHandler.getInstance(myFormFile.getProject()); - final ReadonlyStatusHandler.OperationStatus status = readOnlyHandler.ensureFilesWritable(myFormFile.getVirtualFile()); + final ReadonlyStatusHandler.OperationStatus status = + readOnlyHandler.ensureFilesWritable(Collections.singletonList(myFormFile.getVirtualFile())); if (!status.hasReadonlyFiles()) { FormReferenceProvider.setGUIComponentType(myFormFile, myFieldName, myComponentTypeToSet); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java index 6629c9f83783..8601bd6156e0 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.uiDesigner.designSurface; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; @@ -76,9 +76,7 @@ import java.awt.event.FocusListener; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; +import java.util.*; /** * {@code GuiEditor} is a panel with border layout. It has palette at the north, @@ -451,10 +449,10 @@ public final class GuiEditor extends JPanel implements DesignerEditorPanelFacade final ReadonlyStatusHandler.OperationStatus status; if (sourceFileToCheckOut != null) { - status = ReadonlyStatusHandler.getInstance(getProject()).ensureFilesWritable(myFile, sourceFileToCheckOut); + status = ReadonlyStatusHandler.getInstance(getProject()).ensureFilesWritable(Arrays.asList(myFile, sourceFileToCheckOut)); } else { - status = ReadonlyStatusHandler.getInstance(getProject()).ensureFilesWritable(myFile); + status = ReadonlyStatusHandler.getInstance(getProject()).ensureFilesWritable(Collections.singletonList(myFile)); } return !status.hasReadonlyFiles(); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/StringEditorDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/StringEditorDialog.java index 27736eb78a36..8e3839aa9f5a 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/StringEditorDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/editors/string/StringEditorDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.uiDesigner.propertyInspector.editors.string; import com.intellij.CommonBundle; @@ -151,7 +151,7 @@ public final class StringEditorDialog extends DialogWrapper{ } } final ReadonlyStatusHandler.OperationStatus operationStatus = - ReadonlyStatusHandler.getInstance(module.getProject()).ensureFilesWritable(propFile.getVirtualFile()); + ReadonlyStatusHandler.getInstance(module.getProject()).ensureFilesWritable(Collections.singletonList(propFile.getVirtualFile())); if (operationStatus.hasReadonlyFiles()) { return null; } @@ -225,7 +225,7 @@ public final class StringEditorDialog extends DialogWrapper{ public static boolean saveCreatedProperty(final PropertiesFile bundle, final String name, final String value, final PsiFile formFile) { final ReadonlyStatusHandler.OperationStatus operationStatus = - ReadonlyStatusHandler.getInstance(bundle.getProject()).ensureFilesWritable(bundle.getVirtualFile()); + ReadonlyStatusHandler.getInstance(bundle.getProject()).ensureFilesWritable(Collections.singletonList(bundle.getVirtualFile())); if (operationStatus.hasReadonlyFiles()) { return false; } diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetUpdateTagAction.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetUpdateTagAction.java index 8f38e2f9c15a..a0d620a6792e 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetUpdateTagAction.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetUpdateTagAction.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.template.emmet; import com.intellij.application.options.emmet.EmmetOptions; @@ -171,7 +157,7 @@ public class EmmetUpdateTagAction extends BaseCodeInsightAction implements DumbA @NotNull final Map attributes) { return ()->{ if (tag.isValid()) { - if (!ReadonlyStatusHandler.getInstance(file.getProject()).ensureFilesWritable(file.getVirtualFile()).hasReadonlyFiles()) { + if (!ReadonlyStatusHandler.getInstance(file.getProject()).ensureFilesWritable(Collections.singletonList(file.getVirtualFile())).hasReadonlyFiles()) { tag.setAttribute(HtmlUtil.CLASS_ATTRIBUTE_NAME, StringUtil.join(classes, " ").trim()); for (Map.Entry attribute : attributes.entrySet()) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java index 452479d37925..5fc7530c14b6 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java @@ -38,6 +38,8 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Collections; + public abstract class BaseInspection extends XmlSuppressableInspectionTool { @Override @Nls @@ -148,7 +150,7 @@ public abstract class BaseInspection extends XmlSuppressableInspectionTool { private static void suppress(PsiFile file, @NotNull PsiElement location, String suppressComment, Function replace) { final Project project = file.getProject(); final VirtualFile vfile = file.getVirtualFile(); - if (vfile == null || ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(vfile).hasReadonlyFiles()) { + if (vfile == null || ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(Collections.singletonList(vfile)).hasReadonlyFiles()) { return; }