@Override public boolean shouldAccept(AbstractTestProxy test) { Location location = test.getLocation(project, searchScope); return location instanceof PsiLocation && location.getPsiElement() instanceof GoFunctionOrMethodDeclaration; } });
@Nullable @Override protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext configurationContext) { sourceFile = location.getPsiElement().getContainingFile(); if (sourceFile != null && sourceFile.getFileType().getName().toLowerCase().contains("javascript")) { Project project = sourceFile.getProject(); VirtualFile file = sourceFile.getVirtualFile(); RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, configurationContext); MongoRunConfiguration runConfiguration = (MongoRunConfiguration) settings.getConfiguration(); runConfiguration.setName(file.getName()); runConfiguration.setScriptPath(file.getPath()); Module module = ModuleUtil.findModuleForPsiElement(location.getPsiElement()); if (module != null) { runConfiguration.setModule(module); } return settings; } return null; }
private static boolean isTestMethod(Location<? extends MonkeyFunctionDeclaration> location, boolean checkAbstract, boolean checkRunWith) { MonkeyFunctionDeclaration functionDeclaration = location.getPsiElement(); MonkeyAnnotation annotation = functionDeclaration.getModifiers().getAnnotation(); if (annotation == null) { return false; } String symbolName = Optional.ofNullable(annotation.getSymbol().getReferenceExpression()) .map(MonkeyReferenceExpression::getId) .map(MonkeyId::getIdentifier) .map(PsiElement::getText).orElse(null); return TEST_ANNOTATION_NAME.equals(symbolName); }
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(); }
final Location location = failedTest.getLocation(project, searchScope); if (location != null) { final PsiElement psiElement = location.getPsiElement();
@Override protected boolean setupConfigurationFromContext(AbstractMonkeyModuleBasedConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) { final Location location = context.getLocation(); if (location == null) { return false; } if (!(location.getPsiElement().getLanguage() instanceof MonkeyLanguage)) { return false; } final Module contextModule = context.getModule(); if (contextModule != null) { configuration.setModule(contextModule); configuration.setName(contextModule.getName()); } configuration.setTargetDeviceId(TargetDevice.DEFAULT_DEVICE.getId()); return true; }
PsiClass aClass = classLocation.getPsiElement(); Module module = JavaExecutionUtil.findModule(aClass);
PsiElement psiElement = location.getPsiElement(); if (!psiElement.isValid()) { return false;