diff --git a/python/src/com/jetbrains/python/psi/PsiReferenceEx.java b/python/openapi/src/com/jetbrains/python/psi/PsiReferenceEx.java similarity index 100% rename from python/src/com/jetbrains/python/psi/PsiReferenceEx.java rename to python/openapi/src/com/jetbrains/python/psi/PsiReferenceEx.java diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReference.java b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReference.java new file mode 100644 index 000000000000..9b811c9ee132 --- /dev/null +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReference.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.jetbrains.python.templateLanguages; + +import com.intellij.lang.annotation.HighlightSeverity; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; +import com.jetbrains.python.psi.PsiReferenceEx; +import com.jetbrains.python.psi.types.TypeEvalContext; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author yole + */ +public class TemplateFileReference extends FileReference implements PsiReferenceEx { + public TemplateFileReference(@NotNull FileReferenceSet fileReferenceSet, TextRange range, int index, String text) { + super(fileReferenceSet, range, index, text); + } + + @Nullable + @Override + public HighlightSeverity getUnresolvedHighlightSeverity(TypeEvalContext context) { + return HighlightSeverity.WARNING; + } + + @Nullable + @Override + public String getUnresolvedDescription() { + return "Template file '" + getCanonicalText() + "' not found"; + } +} diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReferenceSet.java b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReferenceSet.java index 6bbe8fb9a064..44ac74b3be13 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReferenceSet.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReferenceSet.java @@ -4,8 +4,10 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference; import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; import com.intellij.util.containers.ContainerUtil; import com.jetbrains.python.PythonStringUtil; @@ -92,4 +94,9 @@ public class TemplateFileReferenceSet extends FileReferenceSet { protected List getRoots(Module module) { return TemplatesService.getInstance(module).getTemplateFolders(); } + + @Override + public FileReference createFileReference(TextRange range, int index, String text) { + return new TemplateFileReference(this, range, index, text); + } }