use of com.intellij.javascript.testFramework.jasmine.JasmineFileStructureBuilder in project intellij-plugins by JetBrains.
the class KarmaTestLocationProvider method findJasmineElement.
@Nullable
private static PsiElement findJasmineElement(Project project, @NotNull List<String> suiteNames, @Nullable String testName) {
String key = JsTestFileByTestNameIndex.createJasmineKey(suiteNames);
GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
List<VirtualFile> jsTestVirtualFiles = JsTestFileByTestNameIndex.findJsTestFilesByNameInScope(key, scope);
JasmineFileStructureBuilder builder = JasmineFileStructureBuilder.getInstance();
for (VirtualFile file : jsTestVirtualFiles) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile instanceof JSFile) {
JasmineFileStructure jasmineFileStructure = builder.fetchCachedTestFileStructure((JSFile) psiFile);
PsiElement element = jasmineFileStructure.findPsiElement(suiteNames, testName);
if (element != null && element.isValid()) {
return element;
}
}
}
return null;
}
use of com.intellij.javascript.testFramework.jasmine.JasmineFileStructureBuilder in project intellij-plugins by JetBrains.
the class JstdTestLocationProvider method findJasmineTestLocation.
@Nullable
private static PsiElement findJasmineTestLocation(@NotNull Project project, @NotNull String testCaseName, @Nullable String testMethodName) {
VirtualFile file = findJasmineTestFileSource(project, testCaseName);
if (file == null) {
return null;
}
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile instanceof JSFile) {
JSFile jsFile = (JSFile) psiFile;
JasmineFileStructureBuilder builder = JasmineFileStructureBuilder.getInstance();
JasmineFileStructure jasmineFileStructure = builder.fetchCachedTestFileStructure(jsFile);
Map<String, JasmineSuiteStructure> map = Maps.newHashMap();
for (JasmineSuiteStructure suite : jasmineFileStructure.getSuites()) {
visitSuite("", map, suite);
}
JasmineSuiteStructure suite = map.get(testCaseName);
if (suite != null) {
if (testMethodName == null) {
return suite.getEnclosingCallExpression();
}
JasmineSpecStructure spec = suite.getInnerSpecByName(testMethodName);
if (spec != null) {
return spec.getEnclosingCallExpression();
}
}
}
return null;
}
Aggregations