mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-13993 "settings.py" can't be found if website name differs from project folder name
(TODO: Add tests)
This commit is contained in:
@@ -26,6 +26,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
@@ -278,6 +279,22 @@ public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil {
|
||||
return virtualFile != null && virtualFile.is(VFileProperty.SYMLINK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PSI file from virtual file
|
||||
* @param virtualFile virtual file
|
||||
* @param project project where conversion takes place
|
||||
* @return psi file or null if failed to load
|
||||
*/
|
||||
@Nullable
|
||||
public static PsiFile asPsiFile(@NotNull final VirtualFile virtualFile,
|
||||
@NotNull final Project project) {
|
||||
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
|
||||
if (document == null) {
|
||||
return null;
|
||||
}
|
||||
return PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile asVirtualFile(@Nullable PsiElement element) {
|
||||
if (element instanceof PsiFileSystemItem) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.jetbrains.python;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Python function arguments
|
||||
*
|
||||
* @author Ilya.Kazakevich
|
||||
*/
|
||||
public enum PythonFunctionParameters implements FunctionParameter {
|
||||
/**
|
||||
* environment.setdevault(key, failobj) # key
|
||||
*/
|
||||
ENV_SET_DEFAULT_KEY("key", 0),
|
||||
|
||||
/**
|
||||
* environment.setdevault(key, failobj) # failobj
|
||||
*/
|
||||
ENV_SET_DEFAULT_FAILOBJ("failobj",1);
|
||||
|
||||
|
||||
@Nullable
|
||||
private final String myName;
|
||||
private final int myPosition;
|
||||
|
||||
PythonFunctionParameters(@Nullable String name, final int position) {
|
||||
myName = name;
|
||||
myPosition = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPosition() {
|
||||
return myPosition;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user