mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SaveAsDirectoryBasedFormatAction — do not use DIRECTORY_STORE_FOLDER
This commit is contained in:
@@ -9,8 +9,12 @@ import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.refreshVfs
|
||||
import com.intellij.testFramework.*
|
||||
import com.intellij.util.io.*
|
||||
import com.intellij.util.io.createDirectories
|
||||
import com.intellij.util.io.systemIndependentPath
|
||||
import com.intellij.util.io.write
|
||||
import com.intellij.util.io.writeChild
|
||||
import io.netty.handler.codec.http.HttpResponseStatus
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.ClassRule
|
||||
|
||||
@@ -19,13 +19,13 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream
|
||||
import com.intellij.openapi.vfs.CharsetToolkit
|
||||
import com.intellij.openapi.vfs.refreshVfs
|
||||
import com.intellij.testFramework.EdtRule
|
||||
import com.intellij.testFramework.ProjectRule
|
||||
import com.intellij.testFramework.TemporaryDirectory
|
||||
import com.intellij.testFramework.runInEdtAndWait
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.io.lastModified
|
||||
import com.intellij.util.io.refreshVfs
|
||||
import com.intellij.util.io.systemIndependentPath
|
||||
import com.intellij.util.io.writeChild
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil
|
||||
|
||||
@@ -9,9 +9,9 @@ import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.refreshVfs
|
||||
import com.intellij.testFramework.*
|
||||
import com.intellij.util.io.delete
|
||||
import com.intellij.util.io.refreshVfs
|
||||
import com.intellij.util.io.systemIndependentPath
|
||||
import com.intellij.util.isEmpty
|
||||
import com.intellij.util.loadElement
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.wm.impl.SystemDock;
|
||||
import com.intellij.project.ProjectKt;
|
||||
import com.intellij.ui.IconDeferrer;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.IconUtil;
|
||||
@@ -505,11 +506,6 @@ public abstract class RecentProjectsManagerBase extends RecentProjectsManager im
|
||||
|
||||
protected abstract void doOpenProject(@NotNull String projectPath, @Nullable Project projectToClose, boolean forceOpenInNewFrame);
|
||||
|
||||
public static boolean isValidProjectPath(String projectPath) {
|
||||
final File file = new File(projectPath);
|
||||
return file.exists() && (!file.isDirectory() || new File(file, Project.DIRECTORY_STORE_FOLDER).exists());
|
||||
}
|
||||
|
||||
private class MyProjectListener extends ProjectManagerAdapter {
|
||||
@Override
|
||||
public void projectOpened(final Project project) {
|
||||
@@ -613,7 +609,7 @@ public abstract class RecentProjectsManagerBase extends RecentProjectsManager im
|
||||
}
|
||||
}
|
||||
for (String openPath : openPaths) {
|
||||
if (isValidProjectPath(openPath)) {
|
||||
if (ProjectKt.isValidProjectPath(openPath)) {
|
||||
doOpenProject(openPath, null, forceNewFrame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.openapi.vfs
|
||||
|
||||
import com.intellij.util.io.systemIndependentPath
|
||||
import java.nio.file.Path
|
||||
|
||||
fun Path.refreshVfs() {
|
||||
LocalFileSystem.getInstance()?.let { fs ->
|
||||
// If a temp directory is reused from some previous test run, there might be cached children in its VFS. Ensure they're removed.
|
||||
val virtualFile = fs.refreshAndFindFileByPath(systemIndependentPath)
|
||||
if (virtualFile != null) {
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, virtualFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ import com.intellij.openapi.components.impl.stores.IProjectStore
|
||||
import com.intellij.openapi.components.stateStore
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.util.io.basicAttributesIfExists
|
||||
import com.intellij.util.io.exists
|
||||
import java.nio.file.Paths
|
||||
|
||||
val Project.isDirectoryBased: Boolean
|
||||
get() {
|
||||
@@ -35,4 +38,10 @@ val Project.stateStore: IProjectStore
|
||||
|
||||
fun getProjectStoreDirectory(file: VirtualFile): VirtualFile? {
|
||||
return if (file.isDirectory) file.findChild(Project.DIRECTORY_STORE_FOLDER) else null
|
||||
}
|
||||
|
||||
fun isValidProjectPath(projectPath: String): Boolean {
|
||||
val file = Paths.get(projectPath)
|
||||
val attributes = file.basicAttributesIfExists() ?: return false
|
||||
return !attributes.isDirectory /* ipr */ || file.resolve(Project.DIRECTORY_STORE_FOLDER).exists()
|
||||
}
|
||||
-13
@@ -17,8 +17,6 @@ package com.intellij.util.io
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
@@ -28,7 +26,6 @@ import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.nio.file.attribute.FileTime
|
||||
import java.util.*
|
||||
|
||||
|
||||
fun Path.exists() = Files.exists(this)
|
||||
|
||||
fun Path.createDirectories(): Path = Files.createDirectories(this)
|
||||
@@ -208,16 +205,6 @@ fun Path.createFile() {
|
||||
Files.createFile(this)
|
||||
}
|
||||
|
||||
fun Path.refreshVfs() {
|
||||
LocalFileSystem.getInstance()?.let { fs ->
|
||||
// If a temp directory is reused from some previous test run, there might be cached children in its VFS. Ensure they're removed.
|
||||
val virtualFile = fs.refreshAndFindFileByPath(systemIndependentPath)
|
||||
if (virtualFile != null) {
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, virtualFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <R> Path.directoryStreamIfExists(task: (stream: DirectoryStream<Path>) -> R): R? {
|
||||
try {
|
||||
return Files.newDirectoryStream(this).use(task)
|
||||
@@ -20,8 +20,12 @@ import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.refreshVfs
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.io.*
|
||||
import com.intellij.util.io.createDirectories
|
||||
import com.intellij.util.io.delete
|
||||
import com.intellij.util.io.exists
|
||||
import com.intellij.util.io.systemIndependentPath
|
||||
import com.intellij.util.lang.CompoundRuntimeException
|
||||
import org.junit.rules.ExternalResource
|
||||
import org.junit.runner.Description
|
||||
|
||||
Reference in New Issue
Block a user