function -> PsiLocation.fromPsiElement(project, function)); for (GoMethodDeclaration method : typeSpec.getMethods()) { if (locationDataItems.get(1).equals(method.getName())) { ContainerUtil.addIfNotNull(locations, PsiLocation.fromPsiElement(method)); IdFilter idFilter = GoIdFilter.getTestsFilter(project); return ContainerUtil.mapNotNull(GoTypesIndex.find(path, project, scope, idFilter), spec -> PsiLocation.fromPsiElement(project, spec));
public static ConfigurationContext createContext( @NotNull Project project, @NotNull PsiElement psiClass, @NotNull MapDataContext dataContext) { dataContext.put(CommonDataKeys.PROJECT, project); if (LangDataKeys.MODULE.getData(dataContext) == null) { dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(psiClass)); } dataContext.put(Location.DATA_KEY, PsiLocation.fromPsiElement(psiClass)); return ConfigurationContext.getFromContext(dataContext); }
public static MonkeyFunctionDeclaration getTestMethod(PsiElement element, boolean checkAbstract, boolean checkRunWith) { PsiManager manager = element.getManager(); Location<PsiElement> location = PsiLocation.fromPsiElement(manager.getProject(), element); Iterator<Location<MonkeyFunctionDeclaration>> iterator = location.getAncestors(MonkeyFunctionDeclaration.class, false); Location<MonkeyFunctionDeclaration> methodLocation; do { if (!iterator.hasNext()) { return null; } methodLocation = iterator.next(); } while (!isTestMethod(methodLocation, checkAbstract, checkRunWith)); return methodLocation.getPsiElement(); }
Location<PsiElement> el = PsiLocation.fromPsiElement(project, element); Location<PsiClass> classLocation = el.getAncestorOrSelf(PsiClass.class); PsiClass aClass = classLocation.getPsiElement();