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;
}
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));
}
}
}
}
Aggregations