Search in sources :

Example 1 with FlexUnitSupport

use of com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport in project intellij-plugins by JetBrains.

the class FlexImplicitUsageProvider method isImplicitUsage.

@Override
public boolean isImplicitUsage(PsiElement element) {
    if (element instanceof XmlAttribute && ((XmlAttribute) element).isNamespaceDeclaration() && JavaScriptSupportLoader.isLanguageNamespace(((XmlAttribute) element).getValue())) {
        return true;
    }
    if (element instanceof JSClass) {
        JSClass clazz = (JSClass) element;
        final Module module = ModuleUtilCore.findModuleForPsiElement(clazz);
        if (module == null || ModuleType.get(module) != FlexModuleType.getInstance())
            return false;
        if (FlashRunConfigurationProducer.isAcceptedMainClass(clazz, module))
            return true;
        if (ActionScriptClassResolver.isParentClass(clazz, FlashRunConfigurationForm.MODULE_BASE_CLASS_NAME))
            return true;
        FlexUnitSupport flexUnitSupport = FlexUnitSupport.getSupport(module);
        if (flexUnitSupport != null && flexUnitSupport.isTestClass(clazz, true))
            return true;
    } else if (element instanceof JSFunction) {
        if (isTestMethod((JSFunction) element))
            return true;
        if (isAnnotatedByUnknownAttribute((JSAttributeListOwner) element))
            return true;
    } else if (element instanceof JSVariable) {
        if (isAnnotatedByUnknownAttribute((JSAttributeListOwner) element))
            return true;
        if (JSResolveUtil.findParent(element) instanceof JSClass) {
            final JSAttributeList varAttrList = ((JSVariable) element).getAttributeList();
            if (varAttrList != null && varAttrList.findAttributeByName(FlexAnnotationNames.EMBED) != null) {
                return true;
            }
        }
    }
    if (element instanceof JSParameter) {
        JSFunction function = PsiTreeUtil.getParentOfType(element, JSFunction.class);
        if (function != null) {
            final JSParameter[] params = function.getParameterVariables();
            if (params.length == 1 && element == params[0]) {
                @NonNls String type = ((JSParameter) element).getTypeString();
                if (type != null)
                    type = JSImportHandlingUtil.resolveTypeName(type, element);
                if (type != null) {
                    if (FlexCommonTypeNames.FLASH_EVENT_FQN.equals(type) || FlexCommonTypeNames.STARLING_EVENT_FQN.equals(type)) {
                        return true;
                    }
                    boolean b = JSResolveUtil.processHierarchy(type, element.getContainingFile(), jsClass -> !FlexCommonTypeNames.FLASH_EVENT_FQN.equals(jsClass.getQualifiedName()) && !FlexCommonTypeNames.STARLING_EVENT_FQN.equals(jsClass.getQualifiedName()), false);
                    if (!b)
                        return true;
                }
            }
        }
    }
    return false;
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) NonNls(org.jetbrains.annotations.NonNls) XmlAttribute(com.intellij.psi.xml.XmlAttribute) JSVariable(com.intellij.lang.javascript.psi.JSVariable) JSFunction(com.intellij.lang.javascript.psi.JSFunction) FlexUnitSupport(com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport) Module(com.intellij.openapi.module.Module) JSAttributeListOwner(com.intellij.lang.javascript.psi.ecmal4.JSAttributeListOwner) JSParameter(com.intellij.lang.javascript.psi.JSParameter) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 2 with FlexUnitSupport

use of com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport in project intellij-plugins by JetBrains.

the class FlexUnitClassInspectionBase method buildVisitor.

@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new FlexUnitInspectionVisitor() {

        @Override
        public void visitJSClass(JSClass aClass) {
            FlexUnitSupport support = getFlexUnitSupport(aClass);
            if (support == null || !support.isPotentialTestClass(aClass))
                return;
            visitPotentialTestClass(aClass, holder, support);
        }
    };
}
Also used : FlexUnitSupport(com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with FlexUnitSupport

use of com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport in project intellij-plugins by JetBrains.

the class FlexUnitMethodInspectionBase method buildVisitor.

@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new FlexUnitInspectionVisitor() {

        @Override
        public void visitJSFunctionDeclaration(JSFunction function) {
            if (!(function.getParent() instanceof JSClass))
                return;
            FlexUnitSupport support = getFlexUnitSupport(function);
            if (support == null || !support.isPotentialTestMethod(function))
                return;
            visitPotentialTestMethod(function, holder, support);
        }
    };
}
Also used : JSFunction(com.intellij.lang.javascript.psi.JSFunction) FlexUnitSupport(com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with FlexUnitSupport

use of com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport in project intellij-plugins by JetBrains.

the class FlexUnitSuiteInspectionBase method buildVisitor.

@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new FlexUnitInspectionVisitor() {

        @Override
        public void visitJSClass(JSClass aClass) {
            FlexUnitSupport support = getFlexUnitSupport(aClass);
            if (support == null || !support.isSuite(aClass))
                return;
            visitSuite(aClass, holder, support);
        }
    };
}
Also used : FlexUnitSupport(com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with FlexUnitSupport

use of com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport in project intellij-plugins by JetBrains.

the class FlexImplicitUsageProvider method isTestMethod.

private static boolean isTestMethod(JSFunction function) {
    Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement(function);
    FlexUnitSupport flexUnitSupport = FlexUnitSupport.getSupport(moduleForPsiElement);
    if (flexUnitSupport != null && flexUnitSupport.isTestMethod(function))
        return true;
    return false;
}
Also used : FlexUnitSupport(com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport) Module(com.intellij.openapi.module.Module)

Aggregations

FlexUnitSupport (com.intellij.lang.javascript.flex.flexunit.FlexUnitSupport)5 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)4 NotNull (org.jetbrains.annotations.NotNull)3 JSFunction (com.intellij.lang.javascript.psi.JSFunction)2 Module (com.intellij.openapi.module.Module)2 JSParameter (com.intellij.lang.javascript.psi.JSParameter)1 JSVariable (com.intellij.lang.javascript.psi.JSVariable)1 JSAttributeList (com.intellij.lang.javascript.psi.ecmal4.JSAttributeList)1 JSAttributeListOwner (com.intellij.lang.javascript.psi.ecmal4.JSAttributeListOwner)1 XmlAttribute (com.intellij.psi.xml.XmlAttribute)1 NonNls (org.jetbrains.annotations.NonNls)1