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));
JobTestResultsHandler(Job job, Project project, GeneralTestEventsProcessor testEventsProcessor) { this.job = job; this.project = project; this.testEventsProcessor = testEventsProcessor; testEventsProcessor.setLocator((protocol, path, project1, scope) -> { String[] parts = path.split(CLASS_METHOD_SEPARATOR); String className = parts.length != 0 ? parts[0] : null; String method = parts.length > 1 ? parts[1] : null; PsiClass clazz = find(className, project1); PsiElement element = clazz == null || method == null ? clazz : Arrays.stream(clazz.getMethods()) .filter(m -> method.equals(m.getName())) .findFirst() .map(m -> (PsiElement) m) .orElse(clazz); return clazz == null ? Collections.emptyList() : Collections.singletonList(new PsiLocation<>(element)); }); }
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();