Search in sources :

Example 1 with RestFile

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

the class SphinxConfigurationProducer method createConfigurationByElement.

protected RunnerAndConfigurationSettings createConfigurationByElement(final Location location, final ConfigurationContext context) {
    PsiElement element = location.getPsiElement();
    if (!(element instanceof PsiDirectory))
        return null;
    mySourceFile = (PsiDirectory) element;
    boolean hasRstFile = false;
    boolean hasConf = false;
    for (PsiFile file : mySourceFile.getFiles()) {
        if ("conf.py".equals(file.getName()))
            hasConf = true;
        if (file instanceof RestFile) {
            hasRstFile = true;
        }
    }
    if (!hasRstFile || !hasConf)
        return null;
    final Project project = mySourceFile.getProject();
    RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, context);
    SphinxRunConfiguration configuration = (SphinxRunConfiguration) settings.getConfiguration();
    final VirtualFile vFile = mySourceFile.getVirtualFile();
    configuration.setInputFile(vFile.getPath());
    configuration.setName(((PsiDirectory) element).getName());
    if (configuration.getTask().isEmpty())
        configuration.setTask("html");
    final VirtualFile parent = vFile.getParent();
    if (parent != null) {
        configuration.setWorkingDirectory(parent.getPath());
    }
    configuration.setName(configuration.suggestedName());
    Module module = ModuleUtil.findModuleForPsiElement(element);
    if (module != null) {
        configuration.setUseModuleSdk(true);
        configuration.setModule(module);
    }
    return settings;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) RestFile(com.jetbrains.rest.RestFile) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) PsiElement(com.intellij.psi.PsiElement)

Example 2 with RestFile

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

the class RestReferenceTargetAnnotator method visitReferenceTarget.

@Override
public void visitReferenceTarget(final RestReferenceTarget node) {
    RestFile file = (RestFile) node.getContainingFile();
    RestReferenceTarget[] targets = PsiTreeUtil.getChildrenOfType(file, RestReferenceTarget.class);
    String quotedName = node.getReferenceName();
    String name = node.getReferenceName(false);
    if (targets != null) {
        if ("__".equals(name) && !node.hasReference()) {
            getHolder().createWarningAnnotation(node, RestBundle.message("ANN.unusable.anonymous.target"));
        }
        for (RestReferenceTarget element : targets) {
            if ((element.getReferenceName().equalsIgnoreCase(name) || element.getReferenceName(false).equalsIgnoreCase(name) || element.getReferenceName().equalsIgnoreCase(quotedName) || element.getReferenceName(false).equalsIgnoreCase(quotedName)) && !element.equals(node) && !"__".equals(name) && !"[#]".equals(quotedName) && !"[*]".equals(quotedName)) {
                getHolder().createWarningAnnotation(element, RestBundle.message("ANN.duplicate.target", name));
            }
        }
    }
}
Also used : RestFile(com.jetbrains.rest.RestFile) RestReferenceTarget(com.jetbrains.rest.psi.RestReferenceTarget)

Aggregations

RestFile (com.jetbrains.rest.RestFile)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 RestReferenceTarget (com.jetbrains.rest.psi.RestReferenceTarget)1