Search in sources :

Example 1 with JSExtractSuperProcessor

use of com.intellij.lang.javascript.refactoring.extractSuper.JSExtractSuperProcessor in project intellij-plugins by JetBrains.

the class FlexExtractSuperTest method performAction.

private void performAction(boolean classNotInterface, String from, final String extractedSuperName, int docCommentPolicy, JSExtractSuperProcessor.Mode mode, String[] members, String[] conflicts) {
    JSClass sourceClass = JSTestUtils.findClassByQName(from, GlobalSearchScope.moduleScope(myModule));
    final List<JSMemberInfo> memberInfos = FlexPullUpTest.getMemberInfos(members, sourceClass, false);
    JSMemberInfo.sortByOffset(memberInfos);
    JSMemberInfo[] infosArray = JSMemberInfo.getSelected(memberInfos, sourceClass, Conditions.alwaysTrue());
    try {
        final PsiElement finalSourceClass = sourceClass;
        PsiDirectory dir = WriteCommandAction.runWriteCommandAction(null, (Computable<PsiDirectory>) () -> ActionScriptCreateClassOrInterfaceFix.findOrCreateDirectory(StringUtil.getPackageName(extractedSuperName), finalSourceClass));
        new JSExtractSuperProcessor(sourceClass, infosArray, StringUtil.getShortName(extractedSuperName), StringUtil.getPackageName(extractedSuperName), docCommentPolicy, mode, classNotInterface, dir).run();
        assertEquals("Conflicts expected:\n" + StringUtil.join(conflicts, "\n"), 0, conflicts.length);
        myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
        FileDocumentManager.getInstance().saveAllDocuments();
    } catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
        assertNotNull("Conflicts not expected but found:" + e.getMessage(), conflicts);
        assertSameElements(e.getMessages(), conflicts);
        myDoCompare = false;
    }
}
Also used : PostprocessReformattingAspect(com.intellij.psi.impl.source.PostprocessReformattingAspect) BaseRefactoringProcessor(com.intellij.refactoring.BaseRefactoringProcessor) PsiDirectory(com.intellij.psi.PsiDirectory) JSExtractSuperProcessor(com.intellij.lang.javascript.refactoring.extractSuper.JSExtractSuperProcessor) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) JSMemberInfo(com.intellij.lang.javascript.refactoring.util.JSMemberInfo) PsiElement(com.intellij.psi.PsiElement)

Aggregations

JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 JSExtractSuperProcessor (com.intellij.lang.javascript.refactoring.extractSuper.JSExtractSuperProcessor)1 JSMemberInfo (com.intellij.lang.javascript.refactoring.util.JSMemberInfo)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiElement (com.intellij.psi.PsiElement)1 PostprocessReformattingAspect (com.intellij.psi.impl.source.PostprocessReformattingAspect)1 BaseRefactoringProcessor (com.intellij.refactoring.BaseRefactoringProcessor)1