Search in sources :

Example 6 with RefactorWorkspaceEdit

use of org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit in project eclipse.jdt.ls by eclipse.

the class MoveHandler method moveStaticMember.

private static RefactorWorkspaceEdit moveStaticMember(CodeActionParams params, String destinationTypeName, IProgressMonitor monitor) {
    final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(params.getTextDocument().getUri());
    if (unit == null) {
        return new RefactorWorkspaceEdit("Failed to move static member because cannot find the compilation unit associated with " + params.getTextDocument().getUri());
    }
    BodyDeclaration bodyDeclaration = getSelectedMemberDeclaration(unit, params);
    List<IJavaElement> elements = new ArrayList<>();
    if (bodyDeclaration instanceof MethodDeclaration) {
        elements.add(((MethodDeclaration) bodyDeclaration).resolveBinding().getJavaElement());
    } else if (bodyDeclaration instanceof FieldDeclaration) {
        for (Object fragment : ((FieldDeclaration) bodyDeclaration).fragments()) {
            elements.add(((VariableDeclarationFragment) fragment).resolveBinding().getJavaElement());
        }
    } else if (bodyDeclaration instanceof AbstractTypeDeclaration) {
        elements.add(((AbstractTypeDeclaration) bodyDeclaration).resolveBinding().getJavaElement());
    }
    IMember[] members = elements.stream().filter(element -> element instanceof IMember).map(element -> (IMember) element).toArray(IMember[]::new);
    return moveStaticMember(members, destinationTypeName, monitor);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringAvailabilityTesterCore(org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTesterCore) Arrays(java.util.Arrays) IMethodBinding(org.eclipse.jdt.core.dom.IMethodBinding) AbstractTypeDeclaration(org.eclipse.jdt.core.dom.AbstractTypeDeclaration) CreateChangeOperation(org.eclipse.ltk.core.refactoring.CreateChangeOperation) ProjectUtils(org.eclipse.jdt.ls.core.internal.ProjectUtils) CoreException(org.eclipse.core.runtime.CoreException) StringUtils(org.apache.commons.lang3.StringUtils) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) JavaMoveProcessor(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.JavaMoveProcessor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) DiagnosticsHelper(org.eclipse.jdt.ls.core.internal.corrections.DiagnosticsHelper) IPath(org.eclipse.core.runtime.IPath) Gson(com.google.gson.Gson) Change(org.eclipse.ltk.core.refactoring.Change) URI(java.net.URI) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ASTNode(org.eclipse.jdt.core.dom.ASTNode) JDTUtils(org.eclipse.jdt.ls.core.internal.JDTUtils) IJavaProject(org.eclipse.jdt.core.IJavaProject) Collection(java.util.Collection) Set(java.util.Set) IReorgDestination(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgDestination) BodyDeclaration(org.eclipse.jdt.core.dom.BodyDeclaration) Collectors(java.util.stream.Collectors) IConfirmQuery(org.eclipse.jdt.internal.corext.refactoring.reorg.IConfirmQuery) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Objects(java.util.Objects) IType(org.eclipse.jdt.core.IType) List(java.util.List) Stream(java.util.stream.Stream) ReorgPolicyFactory(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.ReorgPolicyFactory) InnovationContext(org.eclipse.jdt.ls.core.internal.corrections.InnovationContext) Optional(java.util.Optional) ChangeUtil(org.eclipse.jdt.ls.core.internal.ChangeUtil) MoveInstanceMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor) MethodDeclaration(org.eclipse.jdt.core.dom.MethodDeclaration) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) RefactorWorkspaceEdit(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit) JavaModelException(org.eclipse.jdt.core.JavaModelException) SubMonitor(org.eclipse.core.runtime.SubMonitor) CodeGenerationSettings(org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings) MoveStaticMembersProcessor(org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcessor) IMember(org.eclipse.jdt.core.IMember) CheckConditionsOperation(org.eclipse.ltk.core.refactoring.CheckConditionsOperation) MoveRefactoring(org.eclipse.ltk.core.refactoring.participants.MoveRefactoring) ArrayList(java.util.ArrayList) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) IContainer(org.eclipse.core.resources.IContainer) CodeActionParams(org.eclipse.lsp4j.CodeActionParams) ProjectsManager(org.eclipse.jdt.ls.core.internal.managers.ProjectsManager) IProject(org.eclipse.core.resources.IProject) JdtFlags(org.eclipse.jdt.internal.corext.util.JdtFlags) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding) ReorgDestinationFactory(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.ReorgDestinationFactory) LinkedHashSet(java.util.LinkedHashSet) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) ResourceUtils(org.eclipse.jdt.ls.core.internal.ResourceUtils) JSONUtility(org.eclipse.jdt.ls.core.internal.JSONUtility) JavaCore(org.eclipse.jdt.core.JavaCore) LspVariableBinding(org.eclipse.jdt.ls.core.internal.handlers.JdtDomModels.LspVariableBinding) JavaLanguageServerPlugin(org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin) PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager) ReorgUtils(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.ReorgUtils) IJavaElement(org.eclipse.jdt.core.IJavaElement) WorkspaceEdit(org.eclipse.lsp4j.WorkspaceEdit) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IReorgQueries(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgQueries) IResource(org.eclipse.core.resources.IResource) IMethod(org.eclipse.jdt.core.IMethod) MoveInnerToTopRefactoring(org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring) FieldDeclaration(org.eclipse.jdt.core.dom.FieldDeclaration) VariableDeclarationFragment(org.eclipse.jdt.core.dom.VariableDeclarationFragment) Comparator(java.util.Comparator) IMovePolicy(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IJavaElement(org.eclipse.jdt.core.IJavaElement) MethodDeclaration(org.eclipse.jdt.core.dom.MethodDeclaration) ArrayList(java.util.ArrayList) IMember(org.eclipse.jdt.core.IMember) FieldDeclaration(org.eclipse.jdt.core.dom.FieldDeclaration) RefactorWorkspaceEdit(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit) BodyDeclaration(org.eclipse.jdt.core.dom.BodyDeclaration) AbstractTypeDeclaration(org.eclipse.jdt.core.dom.AbstractTypeDeclaration)

Example 7 with RefactorWorkspaceEdit

use of org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit in project eclipse.jdt.ls by eclipse.

the class GetRefactorEditHandlerTest method testExtractVariable.

@Test
public void testExtractVariable() throws Exception {
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuilder buf = new StringBuilder();
    buf.append("package test1;\n");
    buf.append("class A{\n");
    buf.append("	void m(int i){\n");
    buf.append("		int x= /*]*/0/*[*/;\n");
    buf.append("	}\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
    Range selection = getRange(cu, null);
    CodeActionParams params = CodeActionUtil.constructCodeActionParams(cu, selection);
    GetRefactorEditParams editParams = new GetRefactorEditParams(RefactorProposalUtility.EXTRACT_VARIABLE_COMMAND, params);
    RefactorWorkspaceEdit refactorEdit = GetRefactorEditHandler.getEditsForRefactor(editParams);
    Assert.assertNotNull(refactorEdit);
    Assert.assertNotNull(refactorEdit.edit);
    String actual = AbstractQuickFixTest.evaluateWorkspaceEdit(refactorEdit.edit);
    buf = new StringBuilder();
    buf.append("package test1;\n");
    buf.append("class A{\n");
    buf.append("	void m(int i){\n");
    buf.append("		int j = 0;\n");
    buf.append("        int x= /*]*/j/*[*/;\n");
    buf.append("	}\n");
    buf.append("}\n");
    AbstractSourceTestCase.compareSource(buf.toString(), actual);
    Assert.assertNotNull(refactorEdit.command);
    Assert.assertEquals(GetRefactorEditHandler.RENAME_COMMAND, refactorEdit.command.getCommand());
    Assert.assertNotNull(refactorEdit.command.getArguments());
    Assert.assertEquals(1, refactorEdit.command.getArguments().size());
}
Also used : CodeActionParams(org.eclipse.lsp4j.CodeActionParams) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) GetRefactorEditParams(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.GetRefactorEditParams) RefactorWorkspaceEdit(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit) Range(org.eclipse.lsp4j.Range) Test(org.junit.Test) AbstractSelectionTest(org.eclipse.jdt.ls.core.internal.correction.AbstractSelectionTest) AbstractQuickFixTest(org.eclipse.jdt.ls.core.internal.correction.AbstractQuickFixTest)

Example 8 with RefactorWorkspaceEdit

use of org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit in project eclipse.jdt.ls by eclipse.

the class GetRefactorEditHandlerTest method testExtractMethod.

@Test
public void testExtractMethod() throws Exception {
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuilder buf = new StringBuilder();
    buf.append("package test1;\n");
    buf.append("\n");
    buf.append("public class E {\n");
    buf.append("    public int foo(boolean b1, boolean b2) {\n");
    buf.append("        int n = 0;\n");
    buf.append("        int i = 0;\n");
    buf.append("        /*[*/\n");
    buf.append("        if (b1)\n");
    buf.append("            i = 1;\n");
    buf.append("        if (b2)\n");
    buf.append("            n = n + i;\n");
    buf.append("        /*]*/\n");
    buf.append("        return n;\n");
    buf.append("    }\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
    Range selection = getRange(cu, null);
    CodeActionParams params = CodeActionUtil.constructCodeActionParams(cu, selection);
    GetRefactorEditParams editParams = new GetRefactorEditParams(RefactorProposalUtility.EXTRACT_METHOD_COMMAND, params);
    RefactorWorkspaceEdit refactorEdit = GetRefactorEditHandler.getEditsForRefactor(editParams);
    Assert.assertNotNull(refactorEdit);
    Assert.assertNotNull(refactorEdit.edit);
    String actual = AbstractQuickFixTest.evaluateWorkspaceEdit(refactorEdit.edit);
    buf = new StringBuilder();
    buf.append("package test1;\n");
    buf.append("\n");
    buf.append("public class E {\n");
    buf.append("    public int foo(boolean b1, boolean b2) {\n");
    buf.append("        int n = 0;\n");
    buf.append("        int i = 0;\n");
    buf.append("        n = extracted(b1, b2, n, i);\n");
    buf.append("        return n;\n");
    buf.append("    }\n");
    buf.append("\n");
    buf.append("    private int extracted(boolean b1, boolean b2, int n, int i) {\n");
    buf.append("        /*[*/\n");
    buf.append("        if (b1)\n");
    buf.append("            i = 1;\n");
    buf.append("        if (b2)\n");
    buf.append("            n = n + i;\n");
    buf.append("        /*]*/\n");
    buf.append("        return n;\n");
    buf.append("    }\n");
    buf.append("}\n");
    AbstractSourceTestCase.compareSource(buf.toString(), actual);
    Assert.assertNotNull(refactorEdit.command);
    Assert.assertEquals(GetRefactorEditHandler.RENAME_COMMAND, refactorEdit.command.getCommand());
    Assert.assertNotNull(refactorEdit.command.getArguments());
    Assert.assertEquals(1, refactorEdit.command.getArguments().size());
}
Also used : CodeActionParams(org.eclipse.lsp4j.CodeActionParams) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) GetRefactorEditParams(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.GetRefactorEditParams) RefactorWorkspaceEdit(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit) Range(org.eclipse.lsp4j.Range) Test(org.junit.Test) AbstractSelectionTest(org.eclipse.jdt.ls.core.internal.correction.AbstractSelectionTest) AbstractQuickFixTest(org.eclipse.jdt.ls.core.internal.correction.AbstractQuickFixTest)

Example 9 with RefactorWorkspaceEdit

use of org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit in project eclipse.jdt.ls by eclipse.

the class GetRefactorEditHandlerTest method testExtractConstant.

@Test
public void testExtractConstant() throws Exception {
    IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
    StringBuilder buf = new StringBuilder();
    buf.append("package test1;\n");
    buf.append("class A{\n");
    buf.append("	void m(int i){\n");
    buf.append("		int x= /*]*/0/*[*/;\n");
    buf.append("	}\n");
    buf.append("}\n");
    ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
    Range selection = getRange(cu, null);
    CodeActionParams params = CodeActionUtil.constructCodeActionParams(cu, selection);
    GetRefactorEditParams editParams = new GetRefactorEditParams(RefactorProposalUtility.EXTRACT_CONSTANT_COMMAND, params);
    RefactorWorkspaceEdit refactorEdit = GetRefactorEditHandler.getEditsForRefactor(editParams);
    Assert.assertNotNull(refactorEdit);
    Assert.assertNotNull(refactorEdit.edit);
    String actual = AbstractQuickFixTest.evaluateWorkspaceEdit(refactorEdit.edit);
    buf = new StringBuilder();
    buf.append("package test1;\n");
    buf.append("class A{\n");
    buf.append("	private static final int _0 = /*]*/0/*[*/;\n");
    buf.append("\n");
    buf.append("    void m(int i){\n");
    buf.append("		int x= _0;\n");
    buf.append("	}\n");
    buf.append("}\n");
    AbstractSourceTestCase.compareSource(buf.toString(), actual);
    Assert.assertNotNull(refactorEdit.command);
    Assert.assertEquals(GetRefactorEditHandler.RENAME_COMMAND, refactorEdit.command.getCommand());
    Assert.assertNotNull(refactorEdit.command.getArguments());
    Assert.assertEquals(1, refactorEdit.command.getArguments().size());
}
Also used : CodeActionParams(org.eclipse.lsp4j.CodeActionParams) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) GetRefactorEditParams(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.GetRefactorEditParams) RefactorWorkspaceEdit(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit) Range(org.eclipse.lsp4j.Range) Test(org.junit.Test) AbstractSelectionTest(org.eclipse.jdt.ls.core.internal.correction.AbstractSelectionTest) AbstractQuickFixTest(org.eclipse.jdt.ls.core.internal.correction.AbstractQuickFixTest)

Example 10 with RefactorWorkspaceEdit

use of org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit in project eclipse.jdt.ls by eclipse.

the class MoveHandler method moveInstanceMethod.

private static RefactorWorkspaceEdit moveInstanceMethod(CodeActionParams params, LspVariableBinding destination, IProgressMonitor monitor) {
    final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(params.getTextDocument().getUri());
    if (unit == null) {
        return new RefactorWorkspaceEdit("Failed to move instance method because cannot find the compilation unit associated with " + params.getTextDocument().getUri());
    }
    MethodDeclaration methodDeclaration = getSelectedMethodDeclaration(unit, params);
    if (methodDeclaration == null || destination == null) {
        return new RefactorWorkspaceEdit("Failed to move instance method because no method is selected or no destination is specified.");
    }
    IMethodBinding methodBinding = methodDeclaration.resolveBinding();
    if (methodBinding == null || !(methodBinding.getJavaElement() instanceof IMethod)) {
        return new RefactorWorkspaceEdit("Failed to move instance method because the selected element is not a method.");
    }
    SubMonitor subMonitor = SubMonitor.convert(monitor, "Moving instance method...", 100);
    IMethod method = (IMethod) methodBinding.getJavaElement();
    MoveInstanceMethodProcessor processor = new MoveInstanceMethodProcessor(method, PreferenceManager.getCodeGenerationSettings(unit));
    Refactoring refactoring = new MoveRefactoring(processor);
    CheckConditionsOperation check = new CheckConditionsOperation(refactoring, CheckConditionsOperation.INITIAL_CONDITONS);
    try {
        check.run(subMonitor.split(20));
        if (check.getStatus().getSeverity() >= RefactoringStatus.FATAL) {
            JavaLanguageServerPlugin.logError("Failed to execute the 'move' refactoring.");
            JavaLanguageServerPlugin.logError(check.getStatus().toString());
            return new RefactorWorkspaceEdit("Failed to move instance method. Reason: " + check.getStatus().toString());
        }
        IVariableBinding[] possibleTargets = processor.getPossibleTargets();
        Optional<IVariableBinding> target = Stream.of(possibleTargets).filter(possibleTarget -> Objects.equals(possibleTarget.getKey(), destination.bindingKey)).findFirst();
        if (target.isPresent()) {
            processor.setTarget(target.get());
            processor.setDeprecateDelegates(false);
            processor.setInlineDelegator(true);
            processor.setRemoveDelegator(true);
            check = new CheckConditionsOperation(refactoring, CheckConditionsOperation.FINAL_CONDITIONS);
            check.run(subMonitor.split(60));
            if (check.getStatus().getSeverity() >= RefactoringStatus.FATAL) {
                JavaLanguageServerPlugin.logError("Failed to execute the 'move' refactoring.");
                JavaLanguageServerPlugin.logError(check.getStatus().toString());
                return new RefactorWorkspaceEdit("Failed to move instance method. Reason: " + check.getStatus().toString());
            }
            Change change = processor.createChange(subMonitor.split(20));
            return new RefactorWorkspaceEdit(ChangeUtil.convertToWorkspaceEdit(change));
        } else {
            return new RefactorWorkspaceEdit("Failed to move instance method because cannot find the target " + destination.name);
        }
    } catch (CoreException e) {
        JavaLanguageServerPlugin.log(e);
        return new RefactorWorkspaceEdit("Failed to move instance method because of " + e.toString());
    } finally {
        subMonitor.done();
    }
}
Also used : IMethodBinding(org.eclipse.jdt.core.dom.IMethodBinding) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringAvailabilityTesterCore(org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTesterCore) Arrays(java.util.Arrays) IMethodBinding(org.eclipse.jdt.core.dom.IMethodBinding) AbstractTypeDeclaration(org.eclipse.jdt.core.dom.AbstractTypeDeclaration) CreateChangeOperation(org.eclipse.ltk.core.refactoring.CreateChangeOperation) ProjectUtils(org.eclipse.jdt.ls.core.internal.ProjectUtils) CoreException(org.eclipse.core.runtime.CoreException) StringUtils(org.apache.commons.lang3.StringUtils) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) JavaMoveProcessor(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.JavaMoveProcessor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) DiagnosticsHelper(org.eclipse.jdt.ls.core.internal.corrections.DiagnosticsHelper) IPath(org.eclipse.core.runtime.IPath) Gson(com.google.gson.Gson) Change(org.eclipse.ltk.core.refactoring.Change) URI(java.net.URI) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ASTNode(org.eclipse.jdt.core.dom.ASTNode) JDTUtils(org.eclipse.jdt.ls.core.internal.JDTUtils) IJavaProject(org.eclipse.jdt.core.IJavaProject) Collection(java.util.Collection) Set(java.util.Set) IReorgDestination(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgDestination) BodyDeclaration(org.eclipse.jdt.core.dom.BodyDeclaration) Collectors(java.util.stream.Collectors) IConfirmQuery(org.eclipse.jdt.internal.corext.refactoring.reorg.IConfirmQuery) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Objects(java.util.Objects) IType(org.eclipse.jdt.core.IType) List(java.util.List) Stream(java.util.stream.Stream) ReorgPolicyFactory(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.ReorgPolicyFactory) InnovationContext(org.eclipse.jdt.ls.core.internal.corrections.InnovationContext) Optional(java.util.Optional) ChangeUtil(org.eclipse.jdt.ls.core.internal.ChangeUtil) MoveInstanceMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor) MethodDeclaration(org.eclipse.jdt.core.dom.MethodDeclaration) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) RefactorWorkspaceEdit(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit) JavaModelException(org.eclipse.jdt.core.JavaModelException) SubMonitor(org.eclipse.core.runtime.SubMonitor) CodeGenerationSettings(org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings) MoveStaticMembersProcessor(org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcessor) IMember(org.eclipse.jdt.core.IMember) CheckConditionsOperation(org.eclipse.ltk.core.refactoring.CheckConditionsOperation) MoveRefactoring(org.eclipse.ltk.core.refactoring.participants.MoveRefactoring) ArrayList(java.util.ArrayList) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) IContainer(org.eclipse.core.resources.IContainer) CodeActionParams(org.eclipse.lsp4j.CodeActionParams) ProjectsManager(org.eclipse.jdt.ls.core.internal.managers.ProjectsManager) IProject(org.eclipse.core.resources.IProject) JdtFlags(org.eclipse.jdt.internal.corext.util.JdtFlags) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding) ReorgDestinationFactory(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.ReorgDestinationFactory) LinkedHashSet(java.util.LinkedHashSet) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) ResourceUtils(org.eclipse.jdt.ls.core.internal.ResourceUtils) JSONUtility(org.eclipse.jdt.ls.core.internal.JSONUtility) JavaCore(org.eclipse.jdt.core.JavaCore) LspVariableBinding(org.eclipse.jdt.ls.core.internal.handlers.JdtDomModels.LspVariableBinding) JavaLanguageServerPlugin(org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin) PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager) ReorgUtils(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.ReorgUtils) IJavaElement(org.eclipse.jdt.core.IJavaElement) WorkspaceEdit(org.eclipse.lsp4j.WorkspaceEdit) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IReorgQueries(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgQueries) IResource(org.eclipse.core.resources.IResource) IMethod(org.eclipse.jdt.core.IMethod) MoveInnerToTopRefactoring(org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring) FieldDeclaration(org.eclipse.jdt.core.dom.FieldDeclaration) VariableDeclarationFragment(org.eclipse.jdt.core.dom.VariableDeclarationFragment) Comparator(java.util.Comparator) IMovePolicy(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) MethodDeclaration(org.eclipse.jdt.core.dom.MethodDeclaration) SubMonitor(org.eclipse.core.runtime.SubMonitor) Change(org.eclipse.ltk.core.refactoring.Change) IVariableBinding(org.eclipse.jdt.core.dom.IVariableBinding) MoveRefactoring(org.eclipse.ltk.core.refactoring.participants.MoveRefactoring) CoreException(org.eclipse.core.runtime.CoreException) CheckConditionsOperation(org.eclipse.ltk.core.refactoring.CheckConditionsOperation) RefactorWorkspaceEdit(org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit) IMethod(org.eclipse.jdt.core.IMethod) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) MoveRefactoring(org.eclipse.ltk.core.refactoring.participants.MoveRefactoring) MoveInnerToTopRefactoring(org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring) MoveInstanceMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor)

Aggregations

RefactorWorkspaceEdit (org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.RefactorWorkspaceEdit)19 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)18 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)14 CodeActionParams (org.eclipse.lsp4j.CodeActionParams)12 Test (org.junit.Test)12 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 MoveParams (org.eclipse.jdt.ls.core.internal.handlers.MoveHandler.MoveParams)7 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)7 TextDocumentEdit (org.eclipse.lsp4j.TextDocumentEdit)7 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)7 ArrayList (java.util.ArrayList)5 CoreException (org.eclipse.core.runtime.CoreException)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 AbstractQuickFixTest (org.eclipse.jdt.ls.core.internal.correction.AbstractQuickFixTest)5 AbstractSelectionTest (org.eclipse.jdt.ls.core.internal.correction.AbstractSelectionTest)5 GetRefactorEditParams (org.eclipse.jdt.ls.core.internal.handlers.GetRefactorEditHandler.GetRefactorEditParams)5 Range (org.eclipse.lsp4j.Range)5 Gson (com.google.gson.Gson)3 URI (java.net.URI)3 IType (org.eclipse.jdt.core.IType)3