use of com.intellij.javascript.testFramework.qunit.QUnitFileStructureBuilder in project intellij-plugins by JetBrains.
the class KarmaTestLocationProvider method findQUnitElement.
@Nullable
private static PsiElement findQUnitElement(Project project, @NotNull String moduleName, @Nullable String testName) {
String key = JsTestFileByTestNameIndex.createQUnitKey(moduleName, testName);
GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
List<VirtualFile> jsTestVirtualFiles = JsTestFileByTestNameIndex.findJsTestFilesByNameInScope(key, scope);
QUnitFileStructureBuilder builder = QUnitFileStructureBuilder.getInstance();
for (VirtualFile file : jsTestVirtualFiles) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile instanceof JSFile) {
QUnitFileStructure qunitFileStructure = builder.fetchCachedTestFileStructure((JSFile) psiFile);
PsiElement element = qunitFileStructure.findPsiElement(moduleName, testName);
if (element != null && element.isValid()) {
return element;
}
}
}
return null;
}
use of com.intellij.javascript.testFramework.qunit.QUnitFileStructureBuilder in project intellij-plugins by JetBrains.
the class JstdTestLocationProvider method findTestFromQUnitDefaultModule.
@Nullable
private static PsiElement findTestFromQUnitDefaultModule(@NotNull Project project, @NotNull String testMethodName) {
GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
testMethodName = StringUtil.trimStart(testMethodName, "test ");
String key = JsTestFileByTestNameIndex.createQUnitKeyForTestFromDefaultModule(testMethodName);
List<VirtualFile> jsTestVirtualFiles = JsTestFileByTestNameIndex.findJsTestFilesByNameInScope(key, scope);
List<VirtualFile> validJsTestVirtualFiles = filterVirtualFiles(jsTestVirtualFiles);
for (VirtualFile jsTestVirtualFile : validJsTestVirtualFiles) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(jsTestVirtualFile);
if (psiFile instanceof JSFile) {
JSFile jsFile = (JSFile) psiFile;
QUnitFileStructureBuilder builder = QUnitFileStructureBuilder.getInstance();
QUnitFileStructure qunitFileStructure = builder.fetchCachedTestFileStructure(jsFile);
PsiElement element = qunitFileStructure.findPsiElement(DefaultQUnitModuleStructure.NAME, testMethodName);
if (element != null && element.isValid()) {
return element;
}
}
}
return null;
}
Aggregations