Search in sources :

Example 1 with UnusedCodeCleanUp

use of org.eclipse.jdt.internal.ui.fix.UnusedCodeCleanUp in project che by eclipse.

the class ReorgCorrectionsSubProcessor method removeImportStatementProposals.

public static void removeImportStatementProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    IProposableFix fix = UnusedCodeFix.createRemoveUnusedImportFix(context.getASTRoot(), problem);
    if (fix != null) {
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_DELETE_IMPORT);
        Map<String, String> options = new Hashtable<String, String>();
        options.put(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS, CleanUpOptions.TRUE);
        FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new UnusedCodeCleanUp(options), IProposalRelevance.REMOVE_UNUSED_IMPORT, image, context);
        proposals.add(proposal);
    }
    final ICompilationUnit cu = context.getCompilationUnit();
    String name = CorrectionMessages.ReorgCorrectionsSubProcessor_organizeimports_description;
    ChangeCorrectionProposal proposal = new ChangeCorrectionProposal(name, null, IProposalRelevance.ORGANIZE_IMPORTS, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)) {

        @Override
        public void apply(IDocument document) {
            //				}
            throw new UnsupportedOperationException("apply doesn't supported for action proposal");
        }

        @Override
        public String getActionId() {
            return "javaOrganizeImports";
        }
    };
    proposals.add(proposal);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) UnusedCodeCleanUp(org.eclipse.jdt.internal.ui.fix.UnusedCodeCleanUp) Hashtable(java.util.Hashtable) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) Image(org.eclipse.swt.graphics.Image) ChangeCorrectionProposal(org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

Hashtable (java.util.Hashtable)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 IProposableFix (org.eclipse.jdt.internal.corext.fix.IProposableFix)1 UnusedCodeCleanUp (org.eclipse.jdt.internal.ui.fix.UnusedCodeCleanUp)1 FixCorrectionProposal (org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal)1 ChangeCorrectionProposal (org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal)1 IDocument (org.eclipse.jface.text.IDocument)1 Image (org.eclipse.swt.graphics.Image)1