mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
moved all configurations in Python Integrated Tools to module base
fixed PY-9018 Cannot create test run configuration from editor
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.jetbrains.rest;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.LanguageSubstitutor;
|
||||
@@ -13,7 +15,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class RestLanguageSubstitutor extends LanguageSubstitutor {
|
||||
@Override
|
||||
public Language getLanguage(@NotNull final VirtualFile vFile, @NotNull final Project project) {
|
||||
boolean txtIsRst = ReSTService.getInstance(project).txtIsRst();
|
||||
final Module module = ModuleUtilCore.findModuleForFile(vFile, project);
|
||||
if (module == null) return null;
|
||||
boolean txtIsRst = ReSTService.getInstance(module).txtIsRst();
|
||||
if (txtIsRst)
|
||||
return RestLanguage.INSTANCE;
|
||||
return null;
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.jetbrains.rest.inspections;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.codeInspection.ui.ListEditForm;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
@@ -62,7 +64,9 @@ public class RestRoleInspection extends RestInspection {
|
||||
super(holder);
|
||||
myIgnoredRoles = ImmutableSet.copyOf(ignoredRoles);
|
||||
Project project = holder.getProject();
|
||||
String dir = ReSTService.getInstance(project).getWorkdir();
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(holder.getFile());
|
||||
if (module == null) return;
|
||||
String dir = ReSTService.getInstance(module).getWorkdir();
|
||||
if (!dir.isEmpty())
|
||||
fillSphinxRoles(dir, project);
|
||||
}
|
||||
@@ -101,7 +105,8 @@ public class RestRoleInspection extends RestInspection {
|
||||
RestFile file = (RestFile)node.getContainingFile();
|
||||
|
||||
if (PsiTreeUtil.getParentOfType(node, RestDirectiveBlock.class) != null) return;
|
||||
if (node.getNextSibling() == null || node.getNextSibling().getNode().getElementType() != RestTokenTypes.INTERPRETED) return;
|
||||
final PsiElement sibling = node.getNextSibling();
|
||||
if (sibling == null || sibling.getNode().getElementType() != RestTokenTypes.INTERPRETED) return;
|
||||
if (RestUtil.PREDEFINED_ROLES.contains(node.getText()) || myIgnoredRoles.contains(node.getRoleName()))
|
||||
return;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import static com.jetbrains.python.sdk.PythonEnvUtil.setPythonUnbuffered;
|
||||
public class SphinxBaseCommand {
|
||||
|
||||
protected boolean setWorkDir(Module module) {
|
||||
ReSTService service = ReSTService.getInstance(module.getProject());
|
||||
final ReSTService service = ReSTService.getInstance(module);
|
||||
String workDir = service.getWorkdir();
|
||||
if (workDir.isEmpty()) {
|
||||
AskForWorkDir dialog = new AskForWorkDir(module.getProject());
|
||||
@@ -62,7 +62,7 @@ public class SphinxBaseCommand {
|
||||
private AskForWorkDir(Project project) {
|
||||
super(project);
|
||||
|
||||
setTitle("Set sphinx working directory: ");
|
||||
setTitle("Set Sphinx Working Directory: ");
|
||||
init();
|
||||
VirtualFile baseDir = project.getBaseDir();
|
||||
String path = baseDir != null? baseDir.getPath() : "";
|
||||
@@ -84,7 +84,7 @@ public class SphinxBaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
protected final String myCommand = "sphinx-quickstart"+ (SystemInfo.isWindows ? ".exe" : "");
|
||||
protected static final String ourCommand = "sphinx-quickstart"+ (SystemInfo.isWindows ? ".exe" : "");
|
||||
|
||||
public void execute(@NotNull final Module module) {
|
||||
final Project project = module.getProject();
|
||||
@@ -105,7 +105,7 @@ public class SphinxBaseCommand {
|
||||
.run();
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
Messages.showErrorDialog(e.getMessage(), "Restructuredtext error");
|
||||
Messages.showErrorDialog(e.getMessage(), "ReStructuredText Error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class SphinxBaseCommand {
|
||||
protected Runnable getAfterTask(final Module module) {
|
||||
return new Runnable() {
|
||||
public void run() {
|
||||
ReSTService service = ReSTService.getInstance(module.getProject());
|
||||
final ReSTService service = ReSTService.getInstance(module);
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByPath(service.getWorkdir());
|
||||
}
|
||||
};
|
||||
@@ -134,7 +134,7 @@ public class SphinxBaseCommand {
|
||||
throw new ExecutionException("No sdk specified");
|
||||
}
|
||||
|
||||
ReSTService service = ReSTService.getInstance(module.getProject());
|
||||
ReSTService service = ReSTService.getInstance(module);
|
||||
cmd.setWorkDirectory(service.getWorkdir().isEmpty()? module.getProject().getBaseDir().getPath(): service.getWorkdir());
|
||||
PythonCommandLineState.createStandardGroupsIn(cmd);
|
||||
ParamsGroup script_params = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
|
||||
@@ -170,7 +170,7 @@ public class SphinxBaseCommand {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getCommandPath(Sdk sdk) {
|
||||
return RestUtil.findRunner(sdk.getHomePath(), myCommand);
|
||||
private static String getCommandPath(Sdk sdk) {
|
||||
return RestUtil.findRunner(sdk.getHomePath(), ourCommand);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user