mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJ-CR-100762 moved VirtualFileUtil into core-api, NioPath into utils.io
GitOrigin-RevId: 0fb91d5feed7b864329ae51ad945e40da011967d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8a4b5b30b0
commit
d2bedc471a
+2
-3
@@ -10,12 +10,11 @@ import com.intellij.ide.starters.local.generator.AssetsProcessor
|
||||
import com.intellij.ide.wizard.*
|
||||
import com.intellij.openapi.application.invokeAndWaitIfNeeded
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.file.getResolvedNioPath
|
||||
import com.intellij.openapi.file.toNioPath
|
||||
import com.intellij.openapi.file.findVirtualFile
|
||||
import com.intellij.openapi.util.io.*
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.findVirtualFile
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.ui.UIBundle
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.intellij.ide.starters.local.*
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.file.*
|
||||
import com.intellij.openapi.util.io.*
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.IOException
|
||||
import java.nio.file.Path
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
package com.intellij.ide.starters.local.generator
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.file.*
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.util.io.*
|
||||
import com.intellij.openapi.vfs.*
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.nio.file.Path
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.intellij.jarRepository
|
||||
import com.intellij.application.options.PathMacrosImpl
|
||||
import com.intellij.openapi.application.PathMacros
|
||||
import com.intellij.openapi.application.ex.PathManagerEx
|
||||
import com.intellij.openapi.file.toNioPath
|
||||
import com.intellij.openapi.util.io.toNioPath
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.doNotEnableExternalStorageByDefaultInTests
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||
@file:JvmName("CanonicalPathUtil")
|
||||
package com.intellij.openapi.file
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.PathUtil
|
||||
import com.intellij.util.text.nullize
|
||||
import org.jetbrains.annotations.SystemIndependent
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
|
||||
fun @SystemIndependent String.toNioPath(): Path {
|
||||
return Paths.get(FileUtil.toSystemDependentName(this))
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.toIoFile(): File {
|
||||
return toNioPath().toFile()
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.getFileName(): String {
|
||||
return PathUtil.getFileName(this)
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.getParentPath(): @SystemIndependent String? {
|
||||
return PathUtil.getParentPath(this).nullize()
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.getParentNioPath(): Path? {
|
||||
return getParentPath()?.toNioPath()
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.getResolvedPath(relativePath: @SystemIndependent String): @SystemIndependent String {
|
||||
val path = "$this/$relativePath"
|
||||
return FileUtil.toCanonicalPath(path, '/') // resolve simple symlinks . and ..
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.getResolvedNioPath(relativePath: @SystemIndependent String): Path {
|
||||
return getResolvedPath(relativePath).toNioPath()
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.getRelativePath(path: @SystemIndependent String): @SystemIndependent String? {
|
||||
return FileUtil.getRelativePath(this, path, '/')
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.getRelativeNioPath(path: @SystemIndependent String): Path? {
|
||||
return getRelativePath(path)?.toNioPath()
|
||||
}
|
||||
|
||||
fun @SystemIndependent String.isAncestor(path: @SystemIndependent String, strict: Boolean): Boolean {
|
||||
return FileUtil.isAncestor(this, path, strict)
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.file.converter
|
||||
|
||||
import com.intellij.util.containers.prefix.map.AbstractPrefixTreeFactory
|
||||
import org.jetbrains.annotations.SystemIndependent
|
||||
|
||||
object CanonicalPathPrefixTreeFactory : AbstractPrefixTreeFactory<@SystemIndependent String, String>() {
|
||||
|
||||
override fun convertToList(element: @SystemIndependent String): List<String> {
|
||||
return element.removeSuffix("/").split("/")
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.intellij.openapi.file.converter
|
||||
|
||||
import com.intellij.openapi.file.toCanonicalPath
|
||||
import com.intellij.util.containers.prefix.map.AbstractPrefixTreeFactory
|
||||
import java.nio.file.Path
|
||||
|
||||
object NioPathPrefixTreeFactory : AbstractPrefixTreeFactory<Path, String>() {
|
||||
|
||||
override fun convertToList(element: Path): List<String> {
|
||||
return CanonicalPathPrefixTreeFactory.convertToList(element.toCanonicalPath())
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.intellij.openapi.file.converter
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.util.containers.prefix.map.AbstractPrefixTreeFactory
|
||||
|
||||
object VirtualFilePrefixTreeFactory : AbstractPrefixTreeFactory<VirtualFile, String>() {
|
||||
|
||||
override fun convertToList(element: VirtualFile): List<String> {
|
||||
return CanonicalPathPrefixTreeFactory.convertToList(element.path)
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
@@ -38,11 +37,9 @@ public final class VfsUtil extends VfsUtilCore {
|
||||
*/
|
||||
public static final long NOTIFICATION_DELAY_MILLIS = 300;
|
||||
|
||||
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
|
||||
public static void saveText(@NotNull VirtualFile file, @NotNull String text) throws IOException {
|
||||
Charset charset = file.getCharset();
|
||||
try (OutputStream stream = file.getOutputStream(file)) {
|
||||
stream.write(text.getBytes(charset));
|
||||
}
|
||||
VfsUtilCore.saveText(file, text);
|
||||
}
|
||||
|
||||
public static byte @NotNull [] toByteArray(@NotNull VirtualFile file, @NotNull String text) throws IOException {
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.*;
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -371,6 +372,13 @@ public class VfsUtilCore {
|
||||
return target == null || target.equals(link) || isAncestor(target, link, true);
|
||||
}
|
||||
|
||||
public static void saveText(@NotNull VirtualFile file, @NotNull String text) throws IOException {
|
||||
Charset charset = file.getCharset();
|
||||
try (OutputStream stream = file.getOutputStream(file)) {
|
||||
stream.write(text.getBytes(charset));
|
||||
}
|
||||
}
|
||||
|
||||
public static @NotNull String loadText(@NotNull VirtualFile file) throws IOException {
|
||||
return loadText(file, (int)file.getLength());
|
||||
}
|
||||
|
||||
+14
-14
@@ -1,16 +1,17 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||
@file:JvmName("VirtualFileUtil")
|
||||
package com.intellij.openapi.file
|
||||
|
||||
package com.intellij.openapi.vfs
|
||||
|
||||
import com.intellij.openapi.editor.Document
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.*
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue
|
||||
import com.intellij.openapi.util.io.*
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.util.containers.prefix.map.AbstractPrefixTreeFactory
|
||||
import org.jetbrains.annotations.SystemIndependent
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Path
|
||||
@@ -20,11 +21,11 @@ val VirtualFile.isFile: Boolean
|
||||
get() = isValid && !isDirectory
|
||||
|
||||
fun VirtualFile.readText(): String {
|
||||
return VfsUtil.loadText(this)
|
||||
return VfsUtilCore.loadText(this)
|
||||
}
|
||||
|
||||
fun VirtualFile.writeText(content: String) {
|
||||
VfsUtil.saveText(this, content)
|
||||
VfsUtilCore.saveText(this, content)
|
||||
}
|
||||
|
||||
fun VirtualFile.readBytes(): ByteArray {
|
||||
@@ -75,14 +76,6 @@ fun VirtualFile.getPsiFile(project: Project): PsiFile {
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshVirtualFiles(vararg paths: Path, async: Boolean = false, recursive: Boolean = true, callback: () -> Unit = {}) {
|
||||
RefreshQueue.getInstance().refresh(async, recursive, callback, paths.mapNotNull { it.findVirtualFileOrDirectory() })
|
||||
}
|
||||
|
||||
fun refreshVirtualFiles(vararg files: VirtualFile, async: Boolean = false, recursive: Boolean = true, callback: () -> Unit = {}) {
|
||||
RefreshQueue.getInstance().refresh(async, recursive, callback, files.toList())
|
||||
}
|
||||
|
||||
fun VirtualFile.findVirtualFileOrDirectory(relativePath: @SystemIndependent String): VirtualFile? {
|
||||
return fileSystem.findVirtualFileOrDirectory(path.getResolvedPath(relativePath))
|
||||
}
|
||||
@@ -267,3 +260,10 @@ private fun VirtualFileSystem.findOrCreateParentDirectory(path: @SystemIndepende
|
||||
}
|
||||
return findOrCreateVirtualDirectory(parentPath)
|
||||
}
|
||||
|
||||
object VirtualFilePrefixTreeFactory : AbstractPrefixTreeFactory<VirtualFile, String>() {
|
||||
|
||||
override fun convertToList(element: VirtualFile): List<String> {
|
||||
return CanonicalPathPrefixTreeFactory.convertToList(element.path)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.intellij.openapi.editor.EditorFactory
|
||||
import com.intellij.openapi.externalSystem.autoimport.ExternalSystemModificationType
|
||||
import com.intellij.openapi.externalSystem.autoimport.changes.vfs.VirtualFileChangesListener.Companion.installAsyncVirtualFileListener
|
||||
import com.intellij.openapi.externalSystem.autoimport.settings.AsyncSupplier
|
||||
import com.intellij.openapi.file.converter.CanonicalPathPrefixTreeFactory
|
||||
import com.intellij.openapi.util.io.CanonicalPathPrefixTreeFactory
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.components.StoragePathMacros
|
||||
import com.intellij.openapi.file.converter.CanonicalPathPrefixTreeFactory
|
||||
import com.intellij.openapi.util.io.CanonicalPathPrefixTreeFactory
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.ModuleListener
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ package com.intellij.openapi.externalSystem.service.project.trusted
|
||||
|
||||
import com.intellij.ide.impl.trustedProjects.ProjectLocator
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager
|
||||
import com.intellij.openapi.file.toNioPath
|
||||
import com.intellij.openapi.file.converter.NioPathPrefixTreeFactory
|
||||
import com.intellij.openapi.util.io.toNioPath
|
||||
import com.intellij.openapi.util.io.NioPathPrefixTreeFactory
|
||||
import com.intellij.openapi.project.Project
|
||||
import java.nio.file.Path
|
||||
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@ import com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectTrack
|
||||
import com.intellij.openapi.externalSystem.autoimport.MockProjectAware.ReloadCollisionPassType
|
||||
import com.intellij.openapi.externalSystem.importing.ProjectResolverPolicy
|
||||
import com.intellij.openapi.externalSystem.service.project.autoimport.ProjectAware
|
||||
import com.intellij.openapi.file.*
|
||||
import com.intellij.openapi.util.io.*
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.progress.util.BackgroundTaskUtil
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -90,14 +90,14 @@ abstract class AutoReloadTestCase : ExternalSystemTestCase() {
|
||||
|
||||
protected fun createIoFile(relativePath: String): VirtualFile {
|
||||
val path = getAbsoluteNioPath(relativePath)
|
||||
refreshVirtualFiles(path) // ensure that file is removed from VFS
|
||||
LocalFileSystem.getInstance().findFileByNioFile(path) // ensure that file is removed from VFS
|
||||
createIoFileUnsafe(path)
|
||||
return getFile(relativePath)
|
||||
}
|
||||
|
||||
private fun VirtualFile.updateIoFile(action: File.() -> Unit) {
|
||||
toNioPath().toFile().action()
|
||||
refreshVirtualFiles(this) // ensure that file is updated in VFS
|
||||
LocalFileSystem.getInstance().refreshFiles(listOf(this)) // ensure that file is updated in VFS
|
||||
}
|
||||
|
||||
protected fun VirtualFile.appendLineInIoFile(line: String) =
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright 2000-2021 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.externalSystem.service.project.manage
|
||||
|
||||
import com.intellij.openapi.file.converter.CanonicalPathPrefixTreeFactory
|
||||
import com.intellij.openapi.util.io.CanonicalPathPrefixTreeFactory
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.impl.trustedProjects
|
||||
|
||||
import com.intellij.openapi.file.toNioPath
|
||||
import com.intellij.openapi.util.io.toNioPath
|
||||
import com.intellij.openapi.project.Project
|
||||
import java.nio.file.Path
|
||||
|
||||
|
||||
+6
-6
@@ -5,17 +5,17 @@ import com.intellij.ide.impl.trustedProjects.LocatedProject
|
||||
import com.intellij.ide.impl.trustedProjects.ProjectLocator
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.writeAction
|
||||
import com.intellij.openapi.file.getResolvedNioPath
|
||||
import com.intellij.openapi.file.toNioPath
|
||||
import com.intellij.openapi.file.converter.NioPathPrefixTreeFactory
|
||||
import com.intellij.openapi.file.createVirtualDirectory
|
||||
import com.intellij.openapi.file.findOrCreateVirtualDirectory
|
||||
import com.intellij.openapi.file.getVirtualDirectory
|
||||
import com.intellij.openapi.util.io.getResolvedNioPath
|
||||
import com.intellij.openapi.util.io.toNioPath
|
||||
import com.intellij.openapi.util.io.NioPathPrefixTreeFactory
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx
|
||||
import com.intellij.openapi.project.modules
|
||||
import com.intellij.openapi.project.rootManager
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.createVirtualDirectory
|
||||
import com.intellij.openapi.vfs.findOrCreateVirtualDirectory
|
||||
import com.intellij.openapi.vfs.getVirtualDirectory
|
||||
import com.intellij.testFramework.closeOpenedProjectsIfFailAsync
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
import com.intellij.testFramework.fixtures.TempDirTestFixture
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||
@file:JvmName("CanonicalPathUtil")
|
||||
|
||||
package com.intellij.openapi.util.io
|
||||
|
||||
import com.intellij.util.PathUtilRt
|
||||
import com.intellij.util.containers.prefix.map.AbstractPrefixTreeFactory
|
||||
import com.intellij.util.text.nullize
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
|
||||
fun String.toNioPath(): Path {
|
||||
return Paths.get(FileUtil.toSystemDependentName(this))
|
||||
}
|
||||
|
||||
fun String.toIoFile(): File {
|
||||
return toNioPath().toFile()
|
||||
}
|
||||
|
||||
fun String.getFileName(): String {
|
||||
return PathUtilRt.getFileName(this)
|
||||
}
|
||||
|
||||
fun String.getParentPath(): String? {
|
||||
return PathUtilRt.getParentPath(this).nullize()
|
||||
}
|
||||
|
||||
fun String.getParentNioPath(): Path? {
|
||||
return getParentPath()?.toNioPath()
|
||||
}
|
||||
|
||||
fun String.getResolvedPath(relativePath: String): String {
|
||||
val path = "$this/$relativePath"
|
||||
return FileUtil.toCanonicalPath(path, '/') // resolve simple symlinks . and ..
|
||||
}
|
||||
|
||||
fun String.getResolvedNioPath(relativePath: String): Path {
|
||||
return getResolvedPath(relativePath).toNioPath()
|
||||
}
|
||||
|
||||
fun String.getRelativePath(path: String): String? {
|
||||
return FileUtil.getRelativePath(this, path, '/')
|
||||
}
|
||||
|
||||
fun String.getRelativeNioPath(path: String): Path? {
|
||||
return getRelativePath(path)?.toNioPath()
|
||||
}
|
||||
|
||||
fun String.isAncestor(path: String, strict: Boolean): Boolean {
|
||||
return FileUtil.isAncestor(this, path, strict)
|
||||
}
|
||||
|
||||
object CanonicalPathPrefixTreeFactory : AbstractPrefixTreeFactory<String, String>() {
|
||||
|
||||
override fun convertToList(element: String): List<String> {
|
||||
return element.removeSuffix("/").split("/")
|
||||
}
|
||||
}
|
||||
+16
-14
@@ -1,22 +1,16 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||
@file:JvmName("NioPathUtil")
|
||||
package com.intellij.openapi.file
|
||||
package com.intellij.openapi.util.io
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.io.createDirectories
|
||||
import com.intellij.util.io.createFile
|
||||
import com.intellij.util.io.delete
|
||||
import org.jetbrains.annotations.SystemIndependent
|
||||
import com.intellij.util.containers.prefix.map.AbstractPrefixTreeFactory
|
||||
import java.io.File
|
||||
import java.nio.file.DirectoryStream
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.isRegularFile
|
||||
import kotlin.io.path.*
|
||||
|
||||
fun Path.toCanonicalPath(): @SystemIndependent String {
|
||||
fun Path.toCanonicalPath(): String {
|
||||
return FileUtil.toCanonicalPath(toString())
|
||||
}
|
||||
|
||||
@@ -24,15 +18,15 @@ fun Path.toIoFile(): File {
|
||||
return toFile()
|
||||
}
|
||||
|
||||
fun Path.getResolvedPath(relativePath: @SystemIndependent String): String {
|
||||
fun Path.getResolvedPath(relativePath: String): String {
|
||||
return toCanonicalPath().getResolvedPath(relativePath)
|
||||
}
|
||||
|
||||
fun Path.getResolvedNioPath(relativePath: @SystemIndependent String): Path {
|
||||
fun Path.getResolvedNioPath(relativePath: String): Path {
|
||||
return toCanonicalPath().getResolvedNioPath(relativePath)
|
||||
}
|
||||
|
||||
fun Path.getRelativePath(path: Path): @SystemIndependent String? {
|
||||
fun Path.getRelativePath(path: Path): String? {
|
||||
return toCanonicalPath().getRelativePath(path.toCanonicalPath())
|
||||
}
|
||||
|
||||
@@ -45,6 +39,7 @@ fun Path.isAncestor(path: Path, strict: Boolean): Boolean {
|
||||
}
|
||||
|
||||
fun Path.createNioFile(): Path {
|
||||
parent?.createDirectories()
|
||||
return createFile()
|
||||
}
|
||||
|
||||
@@ -73,7 +68,7 @@ fun Path.findOrCreateNioDirectory(): Path {
|
||||
}
|
||||
|
||||
fun Path.deleteNioFileOrDirectory() {
|
||||
delete(recursively = true)
|
||||
NioFiles.deleteRecursively(this)
|
||||
}
|
||||
|
||||
fun Path.deleteNioChildren(predicate: (Path) -> Boolean = { true }) {
|
||||
@@ -82,3 +77,10 @@ fun Path.deleteNioChildren(predicate: (Path) -> Boolean = { true }) {
|
||||
stream.forEach { it.deleteNioFileOrDirectory() }
|
||||
}
|
||||
}
|
||||
|
||||
object NioPathPrefixTreeFactory : AbstractPrefixTreeFactory<Path, String>() {
|
||||
|
||||
override fun convertToList(element: Path): List<String> {
|
||||
return CanonicalPathPrefixTreeFactory.convertToList(element.toCanonicalPath())
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjec
|
||||
import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalModuleBuilder;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.file.NioPathUtil;
|
||||
import com.intellij.openapi.util.io.NioPathUtil;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.intellij.openapi.editor.RangeMarker
|
||||
import com.intellij.openapi.editor.ex.DocumentEx
|
||||
import com.intellij.openapi.editor.ex.RangeMarkerEx
|
||||
import com.intellij.openapi.externalSystem.util.runInEdtAndWait
|
||||
import com.intellij.openapi.file.readText
|
||||
import com.intellij.openapi.vfs.readText
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.util.asSafely
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.jetbrains.plugins.gradle.dsl
|
||||
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase
|
||||
import com.intellij.openapi.externalSystem.util.runReadAction
|
||||
import com.intellij.openapi.file.readText
|
||||
import com.intellij.openapi.vfs.readText
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.testFramework.assertInstanceOf
|
||||
import org.gradle.util.GradleVersion
|
||||
|
||||
@@ -7,13 +7,13 @@ import com.intellij.ide.impl.trustedProjects.TrustedProjectsListener
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.writeAction
|
||||
import com.intellij.openapi.file.getResolvedNioPath
|
||||
import com.intellij.openapi.file.getResolvedPath
|
||||
import com.intellij.openapi.file.toNioPath
|
||||
import com.intellij.openapi.file.findOrCreateVirtualDirectory
|
||||
import com.intellij.openapi.file.getVirtualDirectory
|
||||
import com.intellij.openapi.util.io.getResolvedNioPath
|
||||
import com.intellij.openapi.util.io.getResolvedPath
|
||||
import com.intellij.openapi.util.io.toNioPath
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.findOrCreateVirtualDirectory
|
||||
import com.intellij.openapi.vfs.getVirtualDirectory
|
||||
import com.intellij.testFramework.common.runAll
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
import com.intellij.testFramework.fixtures.SdkTestFixture
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import com.intellij.openapi.externalSystem.service.notification.NotificationData
|
||||
import com.intellij.openapi.externalSystem.service.notification.NotificationSource;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.Order;
|
||||
import com.intellij.openapi.file.converter.CanonicalPathPrefixTreeFactory;
|
||||
import com.intellij.openapi.util.io.CanonicalPathPrefixTreeFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.roots.DependencyScope;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ package org.jetbrains.plugins.gradle.service.project.open
|
||||
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle
|
||||
import com.intellij.openapi.file.toCanonicalPath
|
||||
import com.intellij.openapi.util.io.toCanonicalPath
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.ui.ValidationInfo
|
||||
|
||||
+1
-2
@@ -2,9 +2,8 @@
|
||||
package org.jetbrains.plugins.gradle.testFramework
|
||||
|
||||
import com.intellij.openapi.externalSystem.util.*
|
||||
import com.intellij.openapi.file.*
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.*
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.plugins.gradle.frameworkSupport.buildscript.isGradleAtLeast
|
||||
import org.jetbrains.plugins.gradle.frameworkSupport.buildscript.isGradleOlderThan
|
||||
|
||||
-1
@@ -2,7 +2,6 @@
|
||||
package org.jetbrains.plugins.gradle.testFramework.configuration
|
||||
|
||||
import com.intellij.openapi.externalSystem.util.*
|
||||
import com.intellij.openapi.file.*
|
||||
import com.intellij.openapi.vfs.*
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.externalSystem.autoimport.changes.vfs.VirtualFileChangesListener
|
||||
import com.intellij.openapi.externalSystem.autoimport.changes.vfs.VirtualFileChangesListener.Companion.installBulkVirtualFileListener
|
||||
import com.intellij.openapi.externalSystem.util.*
|
||||
import com.intellij.openapi.file.*
|
||||
import com.intellij.openapi.util.io.*
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@ package org.jetbrains.plugins.gradle.testFramework.util
|
||||
|
||||
import com.intellij.openapi.externalSystem.util.*
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.file.findOrCreateVirtualFile
|
||||
import com.intellij.openapi.file.getVirtualFile
|
||||
import com.intellij.openapi.file.writeText
|
||||
import com.intellij.openapi.vfs.findOrCreateVirtualFile
|
||||
import com.intellij.openapi.vfs.getVirtualFile
|
||||
import com.intellij.openapi.vfs.writeText
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.plugins.gradle.importing.GradleImportingTestCase
|
||||
import org.jetbrains.plugins.gradle.importing.GradleSettingScriptBuilder
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ import com.intellij.ide.starters.local.generator.AssetsProcessor
|
||||
import com.intellij.ide.starters.local.generator.TestFileSystemLocation
|
||||
import com.intellij.openapi.externalSystem.util.runWriteActionAndWait
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.file.createVirtualFile
|
||||
import com.intellij.openapi.file.writeText
|
||||
import com.intellij.openapi.vfs.createVirtualFile
|
||||
import com.intellij.openapi.vfs.writeText
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.gradle.wrapper.WrapperConfiguration
|
||||
import org.gradle.wrapper.WrapperExecutor.*
|
||||
|
||||
+3
-3
@@ -3,8 +3,8 @@ package org.jetbrains.kotlin.idea.codeInsight.gradle
|
||||
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager
|
||||
import com.intellij.openapi.externalSystem.util.runReadAction
|
||||
import com.intellij.openapi.file.findOrCreateVirtualFile
|
||||
import com.intellij.openapi.file.getPsiFile
|
||||
import com.intellij.openapi.vfs.findOrCreateVirtualFile
|
||||
import com.intellij.openapi.vfs.getPsiFile
|
||||
import com.intellij.testFramework.findReferenceByText
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.plugins.gradle.testFramework.GradleCodeInsightTestCase
|
||||
@@ -14,6 +14,7 @@ import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
|
||||
class GradleBuildNavigationTest: GradleCodeInsightTestCase() {
|
||||
|
||||
@ParameterizedTest
|
||||
@BaseGradleVersionSource
|
||||
fun testBuildGradleWithMppPlugin(gradleVersion: GradleVersion) {
|
||||
@@ -37,5 +38,4 @@ class GradleBuildNavigationTest: GradleCodeInsightTestCase() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
package org.jetbrains.idea.maven.wizards
|
||||
|
||||
import com.intellij.ide.impl.trustedProjects.ProjectLocator
|
||||
import com.intellij.openapi.file.converter.VirtualFilePrefixTreeFactory
|
||||
import com.intellij.openapi.file.toNioPathOrNull
|
||||
import com.intellij.openapi.vfs.VirtualFilePrefixTreeFactory
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.toNioPathOrNull
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||
import java.nio.file.Path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user