diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/codemanipulation/OverrideMethodsOperation.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/codemanipulation/OverrideMethodsOperation.java index 27082068dc..55f80aa174 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/codemanipulation/OverrideMethodsOperation.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/codemanipulation/OverrideMethodsOperation.java @@ -12,7 +12,6 @@ package org.eclipse.jdt.ls.core.internal.codemanipulation; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; @@ -52,9 +51,9 @@ public class OverrideMethodsOperation { - public static List getOverridableMethods(IType type) { + public static OverridableMethodsResponse getOverridableMethods(IType type) { if (type == null || type.getCompilationUnit() == null) { - return Collections.emptyList(); + return new OverridableMethodsResponse(); } List overridables = new ArrayList<>(); @@ -63,7 +62,7 @@ public static List getOverridableMethods(IType type) { try { ITypeBinding typeBinding = ASTNodes.getTypeBinding(astRoot, type); if (typeBinding == null) { - return overridables; + return new OverridableMethodsResponse(); } IMethodBinding cloneMethod = null; @@ -84,11 +83,11 @@ public static List getOverridableMethods(IType type) { JavaLanguageServerPlugin.logException("List overridable methods", e); } - return overridables; + return new OverridableMethodsResponse(type.getElementName(), overridables); } public static TextEdit addOverridableMethods(IType type, OverridableMethod[] overridableMethods) { - if (type == null || type.getCompilationUnit() == null) { + if (type == null || type.getCompilationUnit() == null || overridableMethods == null || overridableMethods.length == 0) { return null; } @@ -185,6 +184,20 @@ private static String[] getMethodParameterTypes(IMethodBinding binding, boolean return parameterTypes.toArray(new String[0]); } + public static class OverridableMethodsResponse { + public String type; + public List methods; + + public OverridableMethodsResponse() { + + } + + public OverridableMethodsResponse(String typeName, List methods) { + this.type = typeName; + this.methods = methods; + } + } + public static class OverridableMethod { public String bindingKey; public String name; diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java index 82f9c19299..6b3601a44a 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java @@ -52,7 +52,7 @@ import org.eclipse.jdt.ls.core.internal.JobHelpers; import org.eclipse.jdt.ls.core.internal.LanguageServerWorkingCopyOwner; import org.eclipse.jdt.ls.core.internal.ServiceStatus; -import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation.OverridableMethod; +import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation.OverridableMethodsResponse; import org.eclipse.jdt.ls.core.internal.handlers.OverrideMethodsHandler.AddOverridableMethodParams; import org.eclipse.jdt.ls.core.internal.lsp.JavaProtocolExtensions; import org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager; @@ -762,7 +762,7 @@ public CompletableFuture> implementation(TextDocumentPo } @Override - public CompletableFuture> overridableMethods(CodeActionParams params) { + public CompletableFuture overridableMethods(CodeActionParams params) { logInfo(">> java/overridableMethods"); return computeAsync((monitor) -> OverrideMethodsHandler.getOverridableMethods(params)); } diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/OverrideMethodsHandler.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/OverrideMethodsHandler.java index f2dbeeda96..ae8186bc71 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/OverrideMethodsHandler.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/OverrideMethodsHandler.java @@ -11,8 +11,6 @@ package org.eclipse.jdt.ls.core.internal.handlers; -import java.util.List; - import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IType; @@ -21,6 +19,7 @@ import org.eclipse.jdt.ls.core.internal.JDTUtils; import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation; import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation.OverridableMethod; +import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation.OverridableMethodsResponse; import org.eclipse.jdt.ls.core.internal.corrections.DiagnosticsHelper; import org.eclipse.jdt.ls.core.internal.corrections.InnovationContext; import org.eclipse.jdt.ls.core.internal.text.correction.SourceAssistProcessor; @@ -30,7 +29,7 @@ public class OverrideMethodsHandler { - public static List getOverridableMethods(CodeActionParams params) { + public static OverridableMethodsResponse getOverridableMethods(CodeActionParams params) { IType type = getSelectionType(params); return OverrideMethodsOperation.getOverridableMethods(type); } diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/lsp/JavaProtocolExtensions.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/lsp/JavaProtocolExtensions.java index 3e7f4014cd..2e6edb4963 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/lsp/JavaProtocolExtensions.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/lsp/JavaProtocolExtensions.java @@ -10,11 +10,10 @@ *******************************************************************************/ package org.eclipse.jdt.ls.core.internal.lsp; -import java.util.List; import java.util.concurrent.CompletableFuture; import org.eclipse.jdt.ls.core.internal.BuildWorkspaceStatus; -import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation.OverridableMethod; +import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation.OverridableMethodsResponse; import org.eclipse.jdt.ls.core.internal.handlers.OverrideMethodsHandler.AddOverridableMethodParams; import org.eclipse.lsp4j.CodeActionParams; import org.eclipse.lsp4j.TextDocumentIdentifier; @@ -46,7 +45,7 @@ public interface JavaProtocolExtensions { CompletableFuture buildWorkspace(boolean forceReBuild); @JsonRequest - CompletableFuture> overridableMethods(CodeActionParams params); + CompletableFuture overridableMethods(CodeActionParams params); @JsonRequest CompletableFuture addOverridableMethods(AddOverridableMethodParams params); diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java index a94585da5b..3d1a8f7498 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java @@ -165,6 +165,10 @@ public boolean isClassFileContentSupported() { return Boolean.parseBoolean(extendedClientCapabilities.getOrDefault("classFileContentsSupport", "false").toString()); } + public boolean isOverrideMethodsPromptSupported() { + return Boolean.parseBoolean(extendedClientCapabilities.getOrDefault("overrideMethodsPromptSupport", "false").toString()); + } + public boolean isSupportsCompletionDocumentationMarkdown() { //@formatter:off return v3supported && capabilities.getTextDocument().getCompletion() != null diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/text/correction/SourceAssistProcessor.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/text/correction/SourceAssistProcessor.java index 178e9a8c24..c32c7f5898 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/text/correction/SourceAssistProcessor.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/text/correction/SourceAssistProcessor.java @@ -15,6 +15,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.OperationCanceledException; @@ -28,7 +29,6 @@ import org.eclipse.jdt.core.dom.TypeDeclaration; import org.eclipse.jdt.core.manipulation.OrganizeImportsOperation; import org.eclipse.jdt.internal.ui.text.correction.IProblemLocationCore; -import org.eclipse.jdt.ls.core.internal.ChangeUtil; import org.eclipse.jdt.ls.core.internal.JDTUtils; import org.eclipse.jdt.ls.core.internal.JavaCodeActionKind; import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin; @@ -47,9 +47,15 @@ import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.eclipse.text.edits.TextEdit; +import com.google.common.collect.Sets; + public class SourceAssistProcessor { + + private static final Set UNSUPPORTED_RESOURCES = Sets.newHashSet("module-info.java", "package-info.java"); + public static final String COMMAND_ID_ACTION_OVERRIDEMETHODSPROMPT = "java.action.overrideMethodsPrompt"; + private PreferenceManager preferenceManager; public SourceAssistProcessor(PreferenceManager preferenceManager) { @@ -59,15 +65,19 @@ public SourceAssistProcessor(PreferenceManager preferenceManager) { public List> getSourceActionCommands(CodeActionParams params, IInvocationContext context, IProblemLocationCore[] locations) { List> $ = new ArrayList<>(); + ICompilationUnit cu = context.getCompilationUnit(); + // Organize Imports TextEdit organizeImportsEdit = getOrganizeImportsProposal(context); Optional> organizeImports = convertToWorkspaceEditAction(params.getContext(), context.getCompilationUnit(), CorrectionMessages.ReorgCorrectionsSubProcessor_organizeimports_description, CodeActionKind.SourceOrganizeImports, organizeImportsEdit); addSourceActionCommand($, params.getContext(), organizeImports); - // Override/Implement Methods - Optional> overrideMethods = getOverrideMethodsAction(params); - addSourceActionCommand($, params.getContext(), overrideMethods); + if (!UNSUPPORTED_RESOURCES.contains(cu.getResource().getName())) { + // Override/Implement Methods + Optional> overrideMethods = getOverrideMethodsAction(params); + addSourceActionCommand($, params.getContext(), overrideMethods); + } // Generate Getter and Setter TextEdit getterSetterEdit = getGetterSetterProposal(context); @@ -109,6 +119,10 @@ private TextEdit getOrganizeImportsProposal(IInvocationContext context) { } private Optional> getOverrideMethodsAction(CodeActionParams params) { + if (!preferenceManager.getClientPreferences().isOverrideMethodsPromptSupported()) { + return Optional.empty(); + } + Command command = new Command(ActionMessages.OverrideMethodsAction_label, COMMAND_ID_ACTION_OVERRIDEMETHODSPROMPT, Collections.singletonList(params)); if (preferenceManager.getClientPreferences().isSupportedCodeActionKind(JavaCodeActionKind.SOURCE_OVERRIDE_METHODS)) { CodeAction codeAction = new CodeAction(ActionMessages.OverrideMethodsAction_label); @@ -144,9 +158,6 @@ private TextEdit getGetterSetterProposal(IInvocationContext context) { private Optional> convertToWorkspaceEditAction(CodeActionContext context, ICompilationUnit cu, String name, String kind, TextEdit edit) { WorkspaceEdit workspaceEdit = convertToWorkspaceEdit(cu, edit); - if (!ChangeUtil.hasChanges(workspaceEdit)) { - return Optional.empty(); - } Command command = new Command(name, CodeActionHandler.COMMAND_ID_APPLY_EDIT, Collections.singletonList(workspaceEdit)); if (preferenceManager.getClientPreferences().isSupportedCodeActionKind(kind)) { diff --git a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/codemanipulation/OverrideMethodsTestCase.java b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/codemanipulation/OverrideMethodsTestCase.java index a037f6b7c0..b410dc692e 100644 --- a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/codemanipulation/OverrideMethodsTestCase.java +++ b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/codemanipulation/OverrideMethodsTestCase.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.ICompilationUnit; @@ -31,6 +30,7 @@ import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.ValidateEditException; import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation.OverridableMethod; +import org.eclipse.jdt.ls.core.internal.codemanipulation.OverrideMethodsOperation.OverridableMethodsResponse; import org.eclipse.text.edits.TextEdit; import org.junit.Test; @@ -79,10 +79,10 @@ public void test1() throws Exception { ICompilationUnit cu = fPackageP.getCompilationUnit("Test1.java"); IType testClass = cu.createType("public class Test1 extends A implements B {\n}\n", null, true, null); - OverridableMethod[] overridableMethods = getOverridableMethods(testClass); - checkUnimplementedMethods(new String[] { "a()", "b(Vector)", "c(Hashtable)" }, overridableMethods); + OverridableMethodsResponse response = getOverridableMethods(testClass); + checkUnimplementedMethods(new String[] { "a()", "b(Vector)", "c(Hashtable)" }, response.methods); - AddAndApplyOverridableMethods(testClass, overridableMethods); + addAndApplyOverridableMethods(testClass, response.methods); IMethod[] methods = testClass.getMethods(); checkMethods(new String[] { "a", "b", "c", "equals", "clone", "toString", "finalize", "hashCode" }, methods); @@ -99,11 +99,11 @@ public void test2() throws Exception { ICompilationUnit cu = fPackageP.getCompilationUnit("Test2.java"); IType testClass = cu.createType("public class Test2 extends C implements B {\n}\n", null, true, null); - OverridableMethod[] overridableMethods = getOverridableMethods(testClass); - checkUnimplementedMethods(new String[] { "d(Hashtable)" }, overridableMethods); - checkOverridableMethods(new String[] { "c(Hashtable)" }, overridableMethods); + OverridableMethodsResponse response = getOverridableMethods(testClass); + checkUnimplementedMethods(new String[] { "d(Hashtable)" }, response.methods); + checkOverridableMethods(new String[] { "c(Hashtable)" }, response.methods); - AddAndApplyOverridableMethods(testClass, overridableMethods); + addAndApplyOverridableMethods(testClass, response.methods); IMethod[] methods = testClass.getMethods(); checkMethods(new String[] { "c", "d", "equals", "clone", "toString", "finalize", "hashCode" }, methods); @@ -120,10 +120,10 @@ public void test3() throws Exception { ICompilationUnit cu = fPackageP.getCompilationUnit("Test3.java"); IType testClass = cu.createType("public class Test3 extends D {\n}\n", null, true, null); - OverridableMethod[] overridableMethods = getOverridableMethods(testClass); - checkUnimplementedMethods(new String[] { "c(Hashtable)", "d(Hashtable)" }, overridableMethods); + OverridableMethodsResponse response = getOverridableMethods(testClass); + checkUnimplementedMethods(new String[] { "c(Hashtable)", "d(Hashtable)" }, response.methods); - AddAndApplyOverridableMethods(testClass, overridableMethods); + addAndApplyOverridableMethods(testClass, response.methods); IMethod[] methods = testClass.getMethods(); checkMethods(new String[] { "c", "d", "equals", "clone", "toString", "finalize", "hashCode" }, methods); @@ -140,10 +140,10 @@ public void test4() throws Exception { ICompilationUnit cu = fPackageP.getCompilationUnit("Test4.java"); IType testClass = cu.createType("public class Test4 implements B, E {\n}\n", null, true, null); - OverridableMethod[] overridableMethods = getOverridableMethods(testClass); - checkUnimplementedMethods(new String[] { "c(Hashtable)", "e()" }, overridableMethods); + OverridableMethodsResponse response = getOverridableMethods(testClass); + checkUnimplementedMethods(new String[] { "c(Hashtable)", "e()" }, response.methods); - AddAndApplyOverridableMethods(testClass, overridableMethods); + addAndApplyOverridableMethods(testClass, response.methods); IMethod[] methods = testClass.getMethods(); checkMethods(new String[] { "c", "e", "equals", "clone", "toString", "finalize", "hashCode" }, methods); @@ -157,10 +157,10 @@ public void testCloneable() throws Exception { ICompilationUnit cu = fPackageP.getCompilationUnit("Test4.java"); IType testClass = cu.createType("public class Test4 implements Cloneable {\n}\n", null, true, null); - OverridableMethod[] overridableMethods = getOverridableMethods(testClass); - checkUnimplementedMethods(new String[] { "clone()" }, overridableMethods); + OverridableMethodsResponse response = getOverridableMethods(testClass); + checkUnimplementedMethods(new String[] { "clone()" }, response.methods); - AddAndApplyOverridableMethods(testClass, overridableMethods); + addAndApplyOverridableMethods(testClass, response.methods); IMethod[] methods = testClass.getMethods(); checkMethods(new String[] { "equals", "clone", "toString", "finalize", "hashCode" }, methods); @@ -192,8 +192,8 @@ public void testBug119171() throws Exception { buf.append("}\n"); ICompilationUnit cu = fPackageP.getCompilationUnit("Test5.java"); IType testClass = cu.createType(buf.toString(), null, true, null); - OverridableMethod[] overridableMethods = getOverridableMethods(testClass); - AddAndApplyOverridableMethods(testClass, overridableMethods); + OverridableMethodsResponse response = getOverridableMethods(testClass); + addAndApplyOverridableMethods(testClass, response.methods); IMethod[] methods = testClass.getMethods(); checkMethods(new String[] { "foo", "b", "clone", "equals", "finalize", "hashCode", "toString" }, methods); @@ -229,10 +229,10 @@ public void testBug297183() throws Exception { ICompilationUnit cu = fPackageP.getCompilationUnit("DefaultCircle.java"); IType testClass = cu.createType(buf.toString(), null, true, null); - OverridableMethod[] overridableMethods = getOverridableMethods(testClass); - checkUnimplementedMethods(new String[] { "getX()", "getY()", "getEdges()", "getArea()", "getR()" }, overridableMethods); - OverridableMethod[] unimplementedMethods = Stream.of(overridableMethods).filter((method) -> method.unimplemented).collect(Collectors.toList()).toArray(new OverridableMethod[0]); - AddAndApplyOverridableMethods(testClass, unimplementedMethods); + OverridableMethodsResponse response = getOverridableMethods(testClass); + checkUnimplementedMethods(new String[] { "getX()", "getY()", "getEdges()", "getArea()", "getR()" }, response.methods); + List unimplementedMethods = response.methods.stream().filter((method) -> method.unimplemented).collect(Collectors.toList()); + addAndApplyOverridableMethods(testClass, unimplementedMethods); IMethod[] methods = testClass.getMethods(); checkMethods(new String[] { "getX", "getY", "getEdges", "getArea", "getR" }, methods); @@ -258,45 +258,47 @@ public void testBug480682() throws Exception { ICompilationUnit cu = fPackageP.createCompilationUnit("Test480682.java", buf.toString(), true, null); IType testClass = cu.createType(buf.toString(), null, true, null); - OverridableMethod[] overridableMethods = getOverridableMethods(testClass); - checkUnimplementedMethods(new String[] { "method2()" }, overridableMethods); - checkUnoverridableMethods(new String[] { "method1()" }, overridableMethods); + OverridableMethodsResponse response = getOverridableMethods(testClass); + checkUnimplementedMethods(new String[] { "method2()" }, response.methods); + checkUnoverridableMethods(new String[] { "method1()" }, response.methods); - OverridableMethod[] unimplementedMethods = Stream.of(overridableMethods).filter((method) -> method.unimplemented).collect(Collectors.toList()).toArray(new OverridableMethod[0]); - AddAndApplyOverridableMethods(testClass, unimplementedMethods); + List unimplementedMethods = response.methods.stream().filter((method) -> method.unimplemented).collect(Collectors.toList()); + addAndApplyOverridableMethods(testClass, unimplementedMethods); IMethod[] methods = testClass.getMethods(); checkMethods(new String[] { "method2" }, methods); } - private OverridableMethod[] getOverridableMethods(IType type) { - List overridableMethods = OverrideMethodsOperation.getOverridableMethods(type); - return overridableMethods.toArray(new OverridableMethod[0]); + private OverridableMethodsResponse getOverridableMethods(IType type) { + return OverrideMethodsOperation.getOverridableMethods(type); } - private void AddAndApplyOverridableMethods(IType type, OverridableMethod[] overridableMethods) throws ValidateEditException, CoreException { - TextEdit edit = OverrideMethodsOperation.addOverridableMethods(type, overridableMethods); + private void addAndApplyOverridableMethods(IType type, List overridableMethods) throws ValidateEditException, CoreException { + TextEdit edit = OverrideMethodsOperation.addOverridableMethods(type, overridableMethods.toArray(new OverridableMethod[overridableMethods.size()])); + if (edit == null) { + return; + } ICompilationUnit unit = type.getCompilationUnit(); JavaModelUtil.applyEdit(unit, edit, true, null); // JavaModelUtil.reconcile(unit); } - private void checkUnimplementedMethods(String[] expected, OverridableMethod[] methods) { - Set methodSet = Stream.of(methods).map((method) -> method.unimplemented ? method.name + "(" + String.join(",", method.parameters) + ")" : "").collect(Collectors.toSet()); + private void checkUnimplementedMethods(String[] expected, List methods) { + Set methodSet = methods.stream().map((method) -> method.unimplemented ? method.name + "(" + String.join(",", method.parameters) + ")" : "").collect(Collectors.toSet()); for (String nExpected : expected) { assertTrue("unimplemented method " + nExpected + " expected", methodSet.contains(nExpected)); } } - private void checkOverridableMethods(String[] expected, OverridableMethod[] methods) { - Set methodSet = Stream.of(methods).map((method) -> method.unimplemented ? "" : method.name + "(" + String.join(",", method.parameters) + ")").collect(Collectors.toSet()); + private void checkOverridableMethods(String[] expected, List methods) { + Set methodSet = methods.stream().map((method) -> method.unimplemented ? "" : method.name + "(" + String.join(",", method.parameters) + ")").collect(Collectors.toSet()); for (String nExpected : expected) { assertTrue("override method " + nExpected + " expected", methodSet.contains(nExpected)); } } - private void checkUnoverridableMethods(String[] expected, OverridableMethod[] methods) { - Set methodSet = Stream.of(methods).map((method) -> method.name + "(" + String.join(",", method.parameters) + ")").collect(Collectors.toSet()); + private void checkUnoverridableMethods(String[] expected, List methods) { + Set methodSet = methods.stream().map((method) -> method.name + "(" + String.join(",", method.parameters) + ")").collect(Collectors.toSet()); for (String nExpected : expected) { assertFalse("cannot override method " + nExpected + " expected", methodSet.contains(nExpected)); } diff --git a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/handlers/CodeActionHandlerTest.java b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/handlers/CodeActionHandlerTest.java index f98dbae4e6..6a7c698337 100644 --- a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/handlers/CodeActionHandlerTest.java +++ b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/handlers/CodeActionHandlerTest.java @@ -86,7 +86,7 @@ public void testCodeAction_removeUnusedImport() throws Exception{ Assert.assertEquals(codeActions.get(0).getRight().getKind(), CodeActionKind.QuickFix); Assert.assertEquals(codeActions.get(1).getRight().getKind(), CodeActionKind.QuickFix); Assert.assertEquals(codeActions.get(2).getRight().getKind(), CodeActionKind.SourceOrganizeImports); - Assert.assertEquals(codeActions.get(3).getRight().getKind(), JavaCodeActionKind.SOURCE_OVERRIDE_METHODS); + Assert.assertEquals(codeActions.get(3).getRight().getKind(), JavaCodeActionKind.SOURCE_GENERATE_ACCESSORS); Command c = codeActions.get(0).getRight().getCommand(); Assert.assertEquals(CodeActionHandler.COMMAND_ID_APPLY_EDIT, c.getCommand()); } @@ -192,8 +192,6 @@ public void test_noUnnecessaryCodeActions() throws Exception{ params.setContext(new CodeActionContext(Collections.emptyList())); List> codeActions = getCodeActions(params); Assert.assertNotNull(codeActions); - Assert.assertFalse("No need of organize imports action", containsKind(codeActions, CodeActionKind.SourceOrganizeImports)); - Assert.assertFalse("No need of generate getter and setter action", containsKind(codeActions, JavaCodeActionKind.SOURCE_GENERATE_ACCESSORS)); } private Range getRange(ICompilationUnit unit, String search) throws JavaModelException {