Search in sources :

Example 1 with JSPushDownProcessor

use of com.intellij.lang.javascript.refactoring.memberPushDown.JSPushDownProcessor in project intellij-plugins by JetBrains.

the class FlexPushDownTest method performAction.

private void performAction(String from, int docCommentPolicy, boolean makeAbstract, final String[] toPushDown) {
    final JSClass sourceClass = (JSClass) JSDialectSpecificHandlersFactory.forLanguage(JavaScriptSupportLoader.ECMA_SCRIPT_L4).getClassResolver().findClassByQName(from, GlobalSearchScope.projectScope(getProject()));
    assertNotNull("source class not found: " + from, sourceClass);
    assertTrue(sourceClass.getQualifiedName() + " has no inheritors", !JSInheritanceUtil.findDirectSubClasses(sourceClass, false).isEmpty());
    final List<JSMemberInfo> memberInfos = FlexPullUpTest.getMemberInfos(toPushDown, sourceClass, makeAbstract);
    JSMemberInfo[] infosArray = JSMemberInfo.getSelected(memberInfos, sourceClass, Conditions.alwaysTrue());
    new JSPushDownProcessor(myProject, infosArray, sourceClass, docCommentPolicy) {

        @Override
        @NotNull
        protected UsageInfo[] findUsages() {
            // ensure stable order
            final UsageInfo[] usages = super.findUsages();
            Arrays.sort(usages, (o1, o2) -> ((JSClass) o1.getElement()).getQualifiedName().compareTo(((JSClass) o2.getElement()).getQualifiedName()));
            return usages;
        }
    }.run();
    myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
    FileDocumentManager.getInstance().saveAllDocuments();
}
Also used : VfsRootAccess(com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess) VfsUtilCore.urlToPath(com.intellij.openapi.vfs.VfsUtilCore.urlToPath) Arrays(java.util.Arrays) JavaScriptSupportLoader(com.intellij.lang.javascript.JavaScriptSupportLoader) JSTestOption(com.intellij.lang.javascript.JSTestOption) FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) VirtualFile(com.intellij.openapi.vfs.VirtualFile) JSPushDownProcessor(com.intellij.lang.javascript.refactoring.memberPushDown.JSPushDownProcessor) JSMemberInfo(com.intellij.lang.javascript.refactoring.util.JSMemberInfo) DocCommentPolicy(com.intellij.refactoring.util.DocCommentPolicy) UsageInfo(com.intellij.usageView.UsageInfo) BaseRefactoringProcessor(com.intellij.refactoring.BaseRefactoringProcessor) FlexStylesIndexableSetContributor(com.intellij.javascript.flex.css.FlexStylesIndexableSetContributor) Conditions(com.intellij.openapi.util.Conditions) ModuleType(com.intellij.openapi.module.ModuleType) FlexTestUtils(com.intellij.flex.util.FlexTestUtils) StringUtil(com.intellij.openapi.util.text.StringUtil) MultiFileTestCase(com.intellij.refactoring.MultiFileTestCase) FlexSchemaHandler(com.intellij.javascript.flex.mxml.schema.FlexSchemaHandler) JSDialectSpecificHandlersFactory(com.intellij.lang.javascript.dialects.JSDialectSpecificHandlersFactory) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) List(java.util.List) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) VfsUtilCore.convertFromUrl(com.intellij.openapi.vfs.VfsUtilCore.convertFromUrl) JSTestOptions(com.intellij.lang.javascript.JSTestOptions) NotNull(org.jetbrains.annotations.NotNull) JSInheritanceUtil(com.intellij.lang.javascript.psi.resolve.JSInheritanceUtil) PostprocessReformattingAspect(com.intellij.psi.impl.source.PostprocessReformattingAspect) PostprocessReformattingAspect(com.intellij.psi.impl.source.PostprocessReformattingAspect) JSPushDownProcessor(com.intellij.lang.javascript.refactoring.memberPushDown.JSPushDownProcessor) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) JSMemberInfo(com.intellij.lang.javascript.refactoring.util.JSMemberInfo) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FlexTestUtils (com.intellij.flex.util.FlexTestUtils)1 FlexStylesIndexableSetContributor (com.intellij.javascript.flex.css.FlexStylesIndexableSetContributor)1 FlexSchemaHandler (com.intellij.javascript.flex.mxml.schema.FlexSchemaHandler)1 JSTestOption (com.intellij.lang.javascript.JSTestOption)1 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)1 JavaScriptSupportLoader (com.intellij.lang.javascript.JavaScriptSupportLoader)1 JSDialectSpecificHandlersFactory (com.intellij.lang.javascript.dialects.JSDialectSpecificHandlersFactory)1 FlexModuleType (com.intellij.lang.javascript.flex.FlexModuleType)1 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 JSInheritanceUtil (com.intellij.lang.javascript.psi.resolve.JSInheritanceUtil)1 JSPushDownProcessor (com.intellij.lang.javascript.refactoring.memberPushDown.JSPushDownProcessor)1 JSMemberInfo (com.intellij.lang.javascript.refactoring.util.JSMemberInfo)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 ModuleType (com.intellij.openapi.module.ModuleType)1 Conditions (com.intellij.openapi.util.Conditions)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 VfsUtilCore.convertFromUrl (com.intellij.openapi.vfs.VfsUtilCore.convertFromUrl)1 VfsUtilCore.urlToPath (com.intellij.openapi.vfs.VfsUtilCore.urlToPath)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 VfsRootAccess (com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess)1