clarifiy APP_CONFIG deprecation note
[idea/community.git] / python / educational-python / src / com / jetbrains / python / edu / PyEduUtils.java
1 package com.jetbrains.python.edu;
2
3 import com.intellij.psi.PsiDirectory;
4 import com.intellij.psi.PsiFile;
5 import com.jetbrains.python.psi.PyQualifiedExpression;
6 import com.jetbrains.python.psi.resolve.ImportedResolveResult;
7 import com.jetbrains.python.psi.resolve.RatedResolveResult;
8 import org.jetbrains.annotations.NotNull;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 public class PyEduUtils {
14   private PyEduUtils() {
15   }
16
17   public static List<RatedResolveResult> getResolveResultFromContainingDirectory(@NotNull PyQualifiedExpression element) {
18     final List<RatedResolveResult> result = new ArrayList<RatedResolveResult>();
19     final PsiFile containingFile = element.getContainingFile();
20     if (containingFile == null) return result;
21     final PsiDirectory directory = containingFile.getContainingDirectory();
22     if (directory == null) return result;
23     final String elementName = element.getName();
24     final PsiFile file = directory.findFile(elementName + ".py");
25     if (file != null) {
26       result.add(new ImportedResolveResult(file, RatedResolveResult.RATE_NORMAL, null));
27     }
28     return result;
29   }
30 }