Java Code Examples for org.eclipse.lsp4j.CodeActionKind#RefactorInline
The following examples show how to use
org.eclipse.lsp4j.CodeActionKind#RefactorInline .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JDTLanguageServer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private CodeActionOptions getCodeActionOptions() { String[] kinds = { CodeActionKind.QuickFix, CodeActionKind.Refactor, CodeActionKind.RefactorExtract, CodeActionKind.RefactorInline, CodeActionKind.RefactorRewrite, CodeActionKind.Source, CodeActionKind.SourceOrganizeImports }; List<String> codeActionKinds = new ArrayList<>(); for (String kind : kinds) { if (preferenceManager.getClientPreferences().isSupportedCodeActionKind(kind)) { codeActionKinds.add(kind); } } CodeActionOptions options = new CodeActionOptions(codeActionKinds); return options; }
Example 2
Source File: InlineVariableTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testInlineLocalVariable() throws Exception { IPackageFragment pack1 = testSourceFolder.createPackageFragment("test", false, null); StringBuilder buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String[] parameters, int j) {\n"); buf.append(" int /*]*/temp/*[*/ = parameters.length + j;\n"); buf.append(" int temp1 = temp;\n"); buf.append(" System.out.println(temp);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String[] parameters, int j) {\n"); buf.append(" int temp1 = parameters.length + j;\n"); buf.append(" System.out.println(parameters.length + j);\n"); buf.append(" }\n"); buf.append("}\n"); Expected expected = new Expected(INLINE_LOCAL_VARIABLE, buf.toString(), CodeActionKind.RefactorInline); assertCodeActions(cu, expected); }
Example 3
Source File: InlineMethodTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testInlineMethod_DeclarationSelected() throws Exception { IPackageFragment pack1 = testSourceFolder.createPackageFragment("test", false, null); StringBuilder buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" public String /*]*/foo/*[*/() {\n"); buf.append(" String temp = \"method declaration\";\n"); buf.append(" return temp;\n"); buf.append(" }\n"); buf.append(" public void bar() {\n"); buf.append(" String value = foo();\n"); buf.append(" }\n"); buf.append(" public void bar2() {\n"); buf.append(" String value = foo();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" public void bar() {\n"); buf.append(" String temp = \"method declaration\";\n"); buf.append(" String value = temp;\n"); buf.append(" }\n"); buf.append(" public void bar2() {\n"); buf.append(" String temp = \"method declaration\";\n"); buf.append(" String value = temp;\n"); buf.append(" }\n"); buf.append("}\n"); Expected expected = new Expected(INLINE_METHOD, buf.toString(), CodeActionKind.RefactorInline); assertCodeActions(cu, expected); }
Example 4
Source File: InlineMethodTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testInlineMethod_InvocationSelected() throws Exception { IPackageFragment pack1 = testSourceFolder.createPackageFragment("test", false, null); StringBuilder buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" public String foo() {\n"); buf.append(" String temp = \"method declaration\";\n"); buf.append(" return temp;\n"); buf.append(" }\n"); buf.append(" public void bar() {\n"); buf.append(" String value = /*]*/foo/*[*/();\n"); buf.append(" }\n"); buf.append(" public void bar2() {\n"); buf.append(" String value = foo();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" public String foo() {\n"); buf.append(" String temp = \"method declaration\";\n"); buf.append(" return temp;\n"); buf.append(" }\n"); buf.append(" public void bar() {\n"); buf.append(" String temp = \"method declaration\";\n"); buf.append(" String value = /*]*/temp;\n"); buf.append(" }\n"); buf.append(" public void bar2() {\n"); buf.append(" String value = foo();\n"); buf.append(" }\n"); buf.append("}\n"); Expected expected = new Expected(INLINE_METHOD, buf.toString(), CodeActionKind.RefactorInline); assertCodeActions(cu, expected); }
Example 5
Source File: InlineConstantTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testInlineConstant_DeclarationSelected() throws Exception { IPackageFragment pack1 = testSourceFolder.createPackageFragment("test", false, null); StringBuilder buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" private static final String /*]*/LOGGER_NAME/*[*/ = \"TEST.E\";\n"); buf.append(" public void foo() {\n"); buf.append(" System.out.println(LOGGER_NAME);\n"); buf.append(" }\n"); buf.append(" public void bar() {\n"); buf.append(" String value = LOGGER_NAME;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" System.out.println(\"TEST.E\");\n"); buf.append(" }\n"); buf.append(" public void bar() {\n"); buf.append(" String value = \"TEST.E\";\n"); buf.append(" }\n"); buf.append("}\n"); Expected expected = new Expected(INLINE_CONSTANT, buf.toString(), CodeActionKind.RefactorInline); assertCodeActions(cu, expected); }
Example 6
Source File: InlineConstantTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testInlineConstant_InvocationSelected() throws Exception { IPackageFragment pack1 = testSourceFolder.createPackageFragment("test", false, null); StringBuilder buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" private static final String LOGGER_NAME = \"TEST.E\";\n"); buf.append(" public void foo() {\n"); buf.append(" System.out.println(/*]*/LOGGER_NAME/*[*/);\n"); buf.append(" }\n"); buf.append(" public void bar() {\n"); buf.append(" String value = LOGGER_NAME;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf = new StringBuilder(); buf.append("package test;\n"); buf.append("public class E {\n"); buf.append(" private static final String LOGGER_NAME = \"TEST.E\";\n"); buf.append(" public void foo() {\n"); buf.append(" System.out.println(/*]*/\"TEST.E\"/*[*/);\n"); buf.append(" }\n"); buf.append(" public void bar() {\n"); buf.append(" String value = LOGGER_NAME;\n"); buf.append(" }\n"); buf.append("}\n"); Expected expected = new Expected(INLINE_CONSTANT, buf.toString(), CodeActionKind.RefactorInline); assertCodeActions(cu, expected); }