mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Project.baseDir — add javadoc link to recommended method
This commit is contained in:
@@ -35,6 +35,7 @@ public interface Project extends ComponentManager, AreaInstance {
|
||||
* Returns a project base directory - a parent directory of a {@code .ipr} file or {@code .idea} directory.<br/>
|
||||
* Returns {@code null} for default project.
|
||||
*
|
||||
* @see com.intellij.openapi.project.ProjectUtil#guessProjectDir
|
||||
* @deprecated Use {@link #getBasePath()}
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -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-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.
|
||||
@file:JvmName("ProjectUtil")
|
||||
package com.intellij.openapi.project
|
||||
|
||||
@@ -31,6 +17,7 @@ import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.vfs.VirtualFilePathWrapper
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
@@ -129,7 +116,7 @@ fun isProjectDirectoryExistsUsingIo(parent: VirtualFile): Boolean {
|
||||
*
|
||||
* @throws IllegalStateException if called on the default project, since there is no sense in "project dir" in that case.
|
||||
*/
|
||||
fun Project.guessProjectDir() : VirtualFile {
|
||||
fun Project.guessProjectDir() : VirtualFile? {
|
||||
if (isDefault) {
|
||||
throw IllegalStateException("Not applicable for default project")
|
||||
}
|
||||
@@ -139,7 +126,7 @@ fun Project.guessProjectDir() : VirtualFile {
|
||||
module?.rootManager?.contentRoots?.firstOrNull()?.let {
|
||||
return it
|
||||
}
|
||||
return this.baseDir!!
|
||||
return LocalFileSystem.getInstance().findFileByPath(basePath!!)
|
||||
}
|
||||
|
||||
fun Project.getProjectCacheFileName(forceNameUse: Boolean, hashSeparator: String): String {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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-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.
|
||||
package com.intellij.usages.impl.rules;
|
||||
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
@@ -23,6 +9,7 @@ import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
@@ -87,7 +74,7 @@ public class DirectoryGroupingRule extends SingleParentUsageGroupingRule impleme
|
||||
private Icon myIcon;
|
||||
|
||||
private DirectoryGroup(@NotNull VirtualFile dir) {
|
||||
myDir = dir;
|
||||
myDir = dir;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -106,7 +93,7 @@ public class DirectoryGroupingRule extends SingleParentUsageGroupingRule impleme
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText(UsageView view) {
|
||||
VirtualFile baseDir = myProject.getBaseDir();
|
||||
VirtualFile baseDir = ProjectUtil.guessProjectDir(myProject);
|
||||
String relativePath = baseDir == null ? null : VfsUtilCore.getRelativePath(myDir, baseDir, File.separatorChar);
|
||||
return relativePath == null ? myDir.getPresentableUrl() : relativePath;
|
||||
}
|
||||
|
||||
+3
-12
@@ -7,7 +7,7 @@ import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.project.guessProjectDir
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import java.io.File
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
@@ -54,16 +54,7 @@ class TerminalProjectOptionsProvider(val project: Project) : PersistentStateComp
|
||||
}
|
||||
|
||||
|
||||
private fun currentProjectFolder(): String? {
|
||||
val projectRootManager = ProjectRootManager.getInstance(project)
|
||||
|
||||
val roots = projectRootManager.contentRoots
|
||||
if (roots.size == 1) {
|
||||
roots[0].canonicalPath
|
||||
}
|
||||
val baseDir = project.baseDir
|
||||
return baseDir?.canonicalPath
|
||||
}
|
||||
private fun currentProjectFolder() = project.guessProjectDir()?.canonicalPath
|
||||
|
||||
val defaultShellPath: String
|
||||
get() {
|
||||
@@ -97,7 +88,7 @@ class TerminalProjectOptionsProvider(val project: Project) : PersistentStateComp
|
||||
|
||||
}
|
||||
|
||||
// TODO: In Kotlin 1.1 it will be possible to pass references to instance properties. Until then we need 'state' argument as a reciever for
|
||||
// TODO: In Kotlin 1.1 it will be possible to pass references to instance properties. Until then we need 'state' argument as a receiver for
|
||||
// to property to apply
|
||||
class ValueWithDefault<S>(val prop: KMutableProperty1<S, String?>, val state: S, val default: () -> String?) {
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): String? {
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
/*
|
||||
* 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-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.
|
||||
package com.intellij.xml.actions.xmlbeans;
|
||||
|
||||
import com.intellij.javaee.ExternalResourceManager;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
@@ -62,7 +49,7 @@ public class UIUtils {
|
||||
|
||||
fileChooserDescriptor.setTitle(selectFileDialogTitle);
|
||||
|
||||
VirtualFile initialFile = myProject.getBaseDir();
|
||||
VirtualFile initialFile = ProjectUtil.guessProjectDir(myProject);
|
||||
String selectedItem = wsdlUrl.getTextField().getText();
|
||||
if (selectedItem != null && selectedItem.startsWith(LocalFileSystem.PROTOCOL_PREFIX)) {
|
||||
VirtualFile fileByPath = VfsUtilCore
|
||||
|
||||
Reference in New Issue
Block a user