Search in sources :

Example 1 with JSVoidType

use of com.intellij.lang.javascript.psi.types.primitives.JSVoidType in project intellij-plugins by JetBrains.

the class FlexUnitMethodReturnTypeInspection method visitPotentialTestMethod.

protected void visitPotentialTestMethod(JSFunction method, ProblemsHolder holder, FlexUnitSupport support) {
    if (FlexUnitSupport.getCustomRunner((JSClass) method.getParent()) != null)
        return;
    if (method.getKind() != JSFunction.FunctionKind.SIMPLE)
        return;
    if (support.isFlexUnit1Subclass((JSClass) method.getParent()) || support.isFlunitSubclass((JSClass) method.getParent())) {
        return;
    }
    final JSType returnType = method.getReturnType();
    if (returnType != null && !(returnType instanceof JSVoidType)) {
        final ASTNode nameIdentifier = method.findNameIdentifier();
        if (nameIdentifier != null) {
            LocalQuickFix[] fix = canFix(method) ? new LocalQuickFix[] { new ChangeTypeFix(method, "void", "javascript.fix.set.method.return.type") } : LocalQuickFix.EMPTY_ARRAY;
            holder.registerProblem(nameIdentifier.getPsi(), FlexBundle.message("flexunit.inspection.testmethodreturntype.message"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fix);
        }
    }
}
Also used : ChangeTypeFix(com.intellij.lang.javascript.validation.fixes.ChangeTypeFix) JSType(com.intellij.lang.javascript.psi.JSType) ASTNode(com.intellij.lang.ASTNode) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) JSVoidType(com.intellij.lang.javascript.psi.types.primitives.JSVoidType)

Aggregations

LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)1 ASTNode (com.intellij.lang.ASTNode)1 JSType (com.intellij.lang.javascript.psi.JSType)1 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 JSVoidType (com.intellij.lang.javascript.psi.types.primitives.JSVoidType)1 ChangeTypeFix (com.intellij.lang.javascript.validation.fixes.ChangeTypeFix)1