use of com.intellij.lang.javascript.psi.JSCallExpression in project intellij-plugins by JetBrains.
the class JsTestDriverTestCaseWithoutTestsInspection method createVisitor.
@NotNull
@Override
protected PsiElementVisitor createVisitor(ProblemsHolder holder, LocalInspectionToolSession session) {
JSFile jsFile = ObjectUtils.tryCast(holder.getFile(), JSFile.class);
if (jsFile == null) {
return JSElementVisitor.NOP_ELEMENT_VISITOR;
}
Project project = holder.getProject();
if (!ApplicationManager.getApplication().isUnitTestMode()) {
if (!JstdSettingsUtil.areJstdConfigFilesInProjectCached(project)) {
return JSElementVisitor.NOP_ELEMENT_VISITOR;
}
}
VirtualFile virtualFile = jsFile.getVirtualFile();
if (virtualFile != null) {
boolean inScope = JstdLibraryUtil.isFileInJstdLibScope(project, virtualFile);
if (!inScope) {
return JSElementVisitor.NOP_ELEMENT_VISITOR;
}
}
JstdTestFileStructure testFileStructure = JstdTestFileStructureBuilder.getInstance().fetchCachedTestFileStructure(jsFile);
for (JstdTestCaseStructure structure : testFileStructure.getTestCaseStructures()) {
if (structure.getTestCount() == 0) {
JSCallExpression callExpression = structure.getEnclosingCallExpression();
if (callExpression.isValid()) {
JSReferenceExpression methodExpression = ObjectUtils.tryCast(callExpression.getMethodExpression(), JSReferenceExpression.class);
if (methodExpression != null) {
int startOffset = methodExpression.getStartOffsetInParent();
TextRange rangeInElement = TextRange.create(startOffset, startOffset + methodExpression.getTextLength());
holder.registerProblem(callExpression, "TestCase has no tests. Tests names should have 'test' prefix.", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, rangeInElement, LocalQuickFix.EMPTY_ARRAY);
}
}
}
}
return JSElementVisitor.NOP_ELEMENT_VISITOR;
}
use of com.intellij.lang.javascript.psi.JSCallExpression in project intellij-plugins by JetBrains.
the class JstdAssertionFrameworkLineMarkerProvider method getQUnitLineMarkerInfo.
@Nullable
private static LineMarkerInfo getQUnitLineMarkerInfo(@NotNull JSFile jsFile, @NotNull PsiElement element) {
QUnitFileStructure qunitFileStructure = QUnitFileStructureBuilder.getInstance().fetchCachedTestFileStructure(jsFile);
if (element instanceof JSCallExpression) {
JSCallExpression callExpression = (JSCallExpression) element;
String testElementName = qunitFileStructure.getNameByPsiElement(callExpression);
if (testElementName == null) {
return null;
}
return createLineMarkerFromElement(element, testElementName);
}
return null;
}
Aggregations