Search in sources :

Example 1 with UnusedCodeFix

use of org.eclipse.jdt.ls.core.internal.corext.fix.UnusedCodeFix in project eclipse.jdt.ls by eclipse.

the class LocalCorrectionsSubProcessor method addUnusedMemberProposal.

public static void addUnusedMemberProposal(IInvocationContext context, IProblemLocation problem, Collection<CUCorrectionProposal> proposals) {
    int problemId = problem.getProblemId();
    UnusedCodeFix fix = UnusedCodeFix.createUnusedMemberFix(context.getASTRoot(), problem, false);
    if (fix != null) {
        try {
            CompilationUnitChange change = fix.createChange(null);
            CUCorrectionProposal proposal = new CUCorrectionProposal(change.getName(), change.getCompilationUnit(), change, IProposalRelevance.UNUSED_MEMBER);
            proposals.add(proposal);
        } catch (CoreException e) {
            JavaLanguageServerPlugin.log(e);
        }
    }
    if (problemId == IProblem.ArgumentIsNeverUsed) {
        JavadocTagsSubProcessor.getUnusedAndUndocumentedParameterOrExceptionProposals(context, problem, proposals);
    }
    if (problemId == IProblem.UnusedPrivateField) {
        GetterSetterCorrectionSubProcessor.addGetterSetterProposal(context, problem, proposals);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) UnusedCodeFix(org.eclipse.jdt.ls.core.internal.corext.fix.UnusedCodeFix) CompilationUnitChange(org.eclipse.jdt.core.refactoring.CompilationUnitChange)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 CompilationUnitChange (org.eclipse.jdt.core.refactoring.CompilationUnitChange)1 UnusedCodeFix (org.eclipse.jdt.ls.core.internal.corext.fix.UnusedCodeFix)1