use of com.intellij.lang.javascript.psi.ecmal4.JSPackage in project intellij-plugins by JetBrains.
the class FlexUnitRunConfiguration method getRefactoringElementListener.
@Override
public RefactoringElementListener getRefactoringElementListener(final PsiElement element) {
final FlexUnitRunnerParameters params = getRunnerParameters();
final Module module = ModuleManager.getInstance(getProject()).findModuleByName(params.getModuleName());
if (!(element instanceof PsiDirectoryContainer) && !(element instanceof JSPackage) && !(element instanceof JSPackageStatement) && (module == null || !module.equals(ModuleUtilCore.findModuleForPsiElement(element)))) {
return null;
}
switch(params.getScope()) {
case Method:
if (element instanceof JSFunction) {
final PsiElement parent = element.getParent();
if (parent instanceof JSClass && Comparing.strEqual(((JSClass) parent).getQualifiedName(), params.getClassName()) && Comparing.strEqual(((JSFunction) element).getName(), params.getMethodName())) {
return new FlexRunConfigRefactoringListener.JSFunctionRefactoringListener(this);
}
}
// no break here!
case Class:
if (element instanceof PsiDirectory && FlashRunConfiguration.containsClass(module, ((PsiDirectory) element), params.getClassName())) {
return new FlexRunConfigRefactoringListener.PsiDirectoryRefactoringListener(this);
}
final JSClass jsClass = FlexRefactoringListenerProvider.getJSClass(element);
if (jsClass != null && Comparing.strEqual(jsClass.getQualifiedName(), params.getClassName())) {
return new FlexRunConfigRefactoringListener.JSClassRefactoringListener(this);
}
// no break here!
case Package:
final String currentPackage = params.getScope() == FlexUnitRunnerParameters.Scope.Package ? params.getPackageName() : StringUtil.getPackageName(params.getClassName());
if ((element instanceof PsiDirectoryContainer || element instanceof JSPackage || element instanceof JSPackageStatement) && Comparing.strEqual(FlexRefactoringListenerProvider.getPackageName(element), currentPackage)) {
return new FlexRunConfigRefactoringListener.PackageRefactoringListener(this);
}
}
return null;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSPackage in project intellij-plugins by JetBrains.
the class FlashRunConfiguration method getRefactoringElementListener.
@Override
public RefactoringElementListener getRefactoringElementListener(final PsiElement element) {
if (!myRunnerParameters.isOverrideMainClass()) {
return null;
}
final Module module = ModuleManager.getInstance(getProject()).findModuleByName(myRunnerParameters.getModuleName());
if (!(element instanceof PsiDirectoryContainer) && !(element instanceof JSPackage) && !(element instanceof JSPackageStatement) && (module == null || !module.equals(ModuleUtilCore.findModuleForPsiElement(element)))) {
return null;
}
final String currentPackage = StringUtil.getPackageName(myRunnerParameters.getOverriddenMainClass());
if ((element instanceof PsiDirectoryContainer || element instanceof JSPackage || element instanceof JSPackageStatement) && Comparing.strEqual(FlexRefactoringListenerProvider.getPackageName(element), currentPackage)) {
return new FlexRunConfigRefactoringListener.PackageRefactoringListener(this);
}
if (element instanceof PsiDirectory && containsClass(module, ((PsiDirectory) element), myRunnerParameters.getOverriddenMainClass())) {
return new FlexRunConfigRefactoringListener.PsiDirectoryRefactoringListener(this);
}
final JSClass jsClass = FlexRefactoringListenerProvider.getJSClass(element);
if (jsClass != null && Comparing.strEqual(jsClass.getQualifiedName(), myRunnerParameters.getOverriddenMainClass())) {
return new FlexRunConfigRefactoringListener.JSClassRefactoringListener(this);
}
return null;
}
Aggregations