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;
}
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);
}
};
}
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);
}
};
}
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);
}
};
}
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;
}
Aggregations