-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code action for unused pattern variable / unused lambda parameter.
- Also add as clean up - Add testcase for clean up functionality Signed-off-by: Roland Grunberg <[email protected]>
- Loading branch information
Showing
5 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...s.core/src/org/eclipse/jdt/ls/core/internal/cleanup/RenameUnusedLocalVariableCleanup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.ls.core.internal.cleanup; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.jdt.core.JavaCore; | ||
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; | ||
import org.eclipse.jdt.internal.corext.fix.RenameUnusedVariableFixCore; | ||
import org.eclipse.jdt.ui.cleanup.CleanUpContext; | ||
import org.eclipse.jdt.ui.cleanup.ICleanUpFix; | ||
|
||
public class RenameUnusedLocalVariableCleanup implements ISimpleCleanUp { | ||
|
||
private static final List<String> COMPILER_OPTS = Arrays.asList(JavaCore.COMPILER_PB_UNUSED_LAMBDA_PARAMETER); | ||
|
||
@Override | ||
public Collection<String> getIdentifiers() { | ||
return List.of("removeUnusedLambdaParameters", CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES); | ||
} | ||
|
||
@Override | ||
public ICleanUpFix createFix(CleanUpContext context) throws CoreException { | ||
return RenameUnusedVariableFixCore.createCleanUp(context.getAST(), true); | ||
} | ||
|
||
@Override | ||
public List<String> getRequiredCompilerMarkers() { | ||
return COMPILER_OPTS; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters