Search in sources :

Example 1 with RestRunConfiguration

use of com.jetbrains.rest.run.RestRunConfiguration in project intellij-community by JetBrains.

the class DocutilsConfigurationProducer method findExistingByElement.

@Nullable
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location, @NotNull List<RunnerAndConfigurationSettings> existingConfigurations, ConfigurationContext context) {
    PsiFile script = location.getPsiElement().getContainingFile();
    if (script == null) {
        return null;
    }
    final VirtualFile vFile = script.getVirtualFile();
    if (vFile == null) {
        return null;
    }
    String path = vFile.getPath();
    for (RunnerAndConfigurationSettings configuration : existingConfigurations) {
        final String scriptName = ((RestRunConfiguration) configuration.getConfiguration()).getInputFile();
        if (FileUtil.toSystemIndependentName(scriptName).equals(FileUtil.toSystemIndependentName(path))) {
            return configuration;
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PsiFile(com.intellij.psi.PsiFile) RestRunConfiguration(com.jetbrains.rest.run.RestRunConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with RestRunConfiguration

use of com.jetbrains.rest.run.RestRunConfiguration in project intellij-community by JetBrains.

the class SphinxConfigurationProducer method findExistingByElement.

@Nullable
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location, @NotNull List<RunnerAndConfigurationSettings> existingConfigurations, ConfigurationContext context) {
    PsiElement element = location.getPsiElement();
    if (!(element instanceof PsiDirectory))
        return null;
    final VirtualFile vFile = ((PsiDirectory) element).getVirtualFile();
    String path = vFile.getPath();
    for (RunnerAndConfigurationSettings configuration : existingConfigurations) {
        final String scriptName = ((RestRunConfiguration) configuration.getConfiguration()).getInputFile();
        if (FileUtil.toSystemIndependentName(scriptName).equals(FileUtil.toSystemIndependentName(path))) {
            return configuration;
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiDirectory(com.intellij.psi.PsiDirectory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PsiElement(com.intellij.psi.PsiElement) RestRunConfiguration(com.jetbrains.rest.run.RestRunConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 RestRunConfiguration (com.jetbrains.rest.run.RestRunConfiguration)2 Nullable (org.jetbrains.annotations.Nullable)2 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1