From 67c8554b94b35d1a9203993a61983ac7a7c02f99 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 4 May 2017 16:23:48 +0200 Subject: [PATCH] cleanup (default impl, simplify code) --- .../src/com/intellij/openapi/project/Project.java | 6 ++++-- .../core-impl/src/com/intellij/mock/MockProject.java | 9 +-------- .../src/com/intellij/openapi/project/ProjectUtil.kt | 5 ++--- .../com/intellij/openapi/command/impl/DummyProject.java | 8 +------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/project/Project.java b/platform/core-api/src/com/intellij/openapi/project/Project.java index 49a6ff9f0d8c..5b26daecad15 100644 --- a/platform/core-api/src/com/intellij/openapi/project/Project.java +++ b/platform/core-api/src/com/intellij/openapi/project/Project.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * 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. @@ -88,7 +88,9 @@ public interface Project extends ComponentManager, AreaInstance { * @return presentable project path */ @Nullable - String getPresentableUrl(); + default String getPresentableUrl() { + return null; + } /** *

Returns a workspace file: diff --git a/platform/core-impl/src/com/intellij/mock/MockProject.java b/platform/core-impl/src/com/intellij/mock/MockProject.java index 05af9f2db1ca..9d3309999ebf 100644 --- a/platform/core-impl/src/com/intellij/mock/MockProject.java +++ b/platform/core-impl/src/com/intellij/mock/MockProject.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * 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. @@ -80,13 +80,6 @@ public class MockProject extends MockComponentManager implements Project { return ""; } - @Override - @Nullable - @NonNls - public String getPresentableUrl() { - return null; - } - @Override @NotNull @NonNls diff --git a/platform/platform-api/src/com/intellij/openapi/project/ProjectUtil.kt b/platform/platform-api/src/com/intellij/openapi/project/ProjectUtil.kt index 8fb65f4d3643..eb4dcd7f8ad4 100644 --- a/platform/platform-api/src/com/intellij/openapi/project/ProjectUtil.kt +++ b/platform/platform-api/src/com/intellij/openapi/project/ProjectUtil.kt @@ -33,7 +33,7 @@ import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtilRt import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFilePathWrapper -import com.intellij.util.PathUtil +import com.intellij.util.PathUtilRt import com.intellij.util.io.exists import java.nio.file.InvalidPathException import java.nio.file.Path @@ -143,8 +143,7 @@ private fun Project.getPresentableFileName(): String { return name } - val location = presentableUrl!! - val projectName = PathUtil.getFileName(FileUtilRt.toSystemIndependentName(location)) + val projectName = FileUtilRt.toSystemIndependentName(PathUtilRt.getFileName(presentableUrl!!)) .toLowerCase(Locale.US) .removeSuffix(ProjectFileType.DOT_DEFAULT_EXTENSION) return FileUtil.sanitizeFileName(projectName, false) diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/DummyProject.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/DummyProject.java index 39afcbe552e0..bdf54d9c3f07 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/DummyProject.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/DummyProject.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * 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. @@ -53,12 +53,6 @@ public class DummyProject extends UserDataHolderBase implements Project { return ""; } - @Override - @Nullable - public String getPresentableUrl() { - return null; - } - @Override @NotNull public String getLocationHash() {