Search in sources :

Example 1 with Java50CleanUp

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

the class ModifierCorrectionSubProcessor method addOverrideAnnotationProposal.

public static void addOverrideAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    IProposableFix fix = Java50Fix.createAddOverrideAnnotationFix(context.getASTRoot(), problem);
    if (fix != null) {
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        Map<String, String> options = new Hashtable<String, String>();
        options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS, CleanUpOptions.TRUE);
        options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE, CleanUpOptions.TRUE);
        options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE_FOR_INTERFACE_METHOD_IMPLEMENTATION, CleanUpOptions.TRUE);
        FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new Java50CleanUp(options), IProposalRelevance.ADD_OVERRIDE_ANNOTATION, image, context);
        proposals.add(proposal);
    }
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) Hashtable(java.util.Hashtable) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) Image(org.eclipse.swt.graphics.Image) Java50CleanUp(org.eclipse.jdt.internal.ui.fix.Java50CleanUp)

Example 2 with Java50CleanUp

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

the class ModifierCorrectionSubProcessor method addDeprecatedAnnotationProposal.

public static void addDeprecatedAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    IProposableFix fix = Java50Fix.createAddDeprectatedAnnotation(context.getASTRoot(), problem);
    if (fix != null) {
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        Map<String, String> options = new Hashtable<String, String>();
        options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS, CleanUpOptions.TRUE);
        options.put(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED, CleanUpOptions.TRUE);
        FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new Java50CleanUp(options), IProposalRelevance.ADD_DEPRECATED_ANNOTATION, image, context);
        proposals.add(proposal);
    }
}
Also used : FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) Hashtable(java.util.Hashtable) IProposableFix(org.eclipse.jdt.internal.corext.fix.IProposableFix) Image(org.eclipse.swt.graphics.Image) Java50CleanUp(org.eclipse.jdt.internal.ui.fix.Java50CleanUp)

Example 3 with Java50CleanUp

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

the class LocalCorrectionsSubProcessor method addTypePrametersToRawTypeReference.

public static void addTypePrametersToRawTypeReference(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    IProposableFix fix = Java50Fix.createRawTypeReferenceFix(context.getASTRoot(), problem);
    if (fix != null) {
        for (Iterator<ICommandAccess> iter = proposals.iterator(); iter.hasNext(); ) {
            Object element = iter.next();
            if (element instanceof FixCorrectionProposal) {
                FixCorrectionProposal fixProp = (FixCorrectionProposal) element;
                if (RAW_TYPE_REFERENCE_ID.equals(fixProp.getCommandId())) {
                    return;
                }
            }
        }
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        Map<String, String> options = new Hashtable<String, String>();
        options.put(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES, CleanUpOptions.TRUE);
        FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new Java50CleanUp(options), IProposalRelevance.RAW_TYPE_REFERENCE, image, context);
        proposal.setCommandId(RAW_TYPE_REFERENCE_ID);
        proposals.add(proposal);
    }
    //Infer Generic Type Arguments... proposal
    boolean hasInferTypeArgumentsProposal = false;
    for (Iterator<ICommandAccess> iterator = proposals.iterator(); iterator.hasNext(); ) {
        Object completionProposal = iterator.next();
        if (completionProposal instanceof ChangeCorrectionProposal) {
            if (IJavaEditorActionDefinitionIds.INFER_TYPE_ARGUMENTS_ACTION.equals(((ChangeCorrectionProposal) completionProposal).getCommandId())) {
                hasInferTypeArgumentsProposal = true;
                break;
            }
        }
    }
    if (!hasInferTypeArgumentsProposal) {
        final ICompilationUnit cu = context.getCompilationUnit();
        ChangeCorrectionProposal proposal = new ChangeCorrectionProposal(CorrectionMessages.LocalCorrectionsSubProcessor_InferGenericTypeArguments, null, IProposalRelevance.INFER_GENERIC_TYPE_ARGUMENTS, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE)) {

            @Override
            public void apply(IDocument document) {
                //							action.run(new StructuredSelection(cu));
                throw new UnsupportedOperationException();
            }

            @Override
            public String getActionId() {
                return "javaInferTypeArguments";
            }

            /**
						 * {@inheritDoc}
						 */
            @Override
            public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
                return CorrectionMessages.LocalCorrectionsSubProcessor_InferGenericTypeArguments_description;
            }
        };
        proposal.setCommandId(IJavaEditorActionDefinitionIds.INFER_TYPE_ARGUMENTS_ACTION);
        proposals.add(proposal);
    }
    addTypeArgumentsFromContext(context, problem, proposals);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) ICommandAccess(org.eclipse.jdt.ui.text.java.correction.ICommandAccess) 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) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) FixCorrectionProposal(org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal) Java50CleanUp(org.eclipse.jdt.internal.ui.fix.Java50CleanUp) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

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