use of org.eclipse.jdt.internal.corext.fix.NullAnnotationsFix in project che by eclipse.
the class NullAnnotationsCorrectionProcessor method addRemoveRedundantAnnotationProposal.
public static void addRemoveRedundantAnnotationProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
NullAnnotationsFix fix = NullAnnotationsFix.createRemoveRedundantNullAnnotationsFix(context.getASTRoot(), problem);
if (fix == null)
return;
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
Map<String, String> options = new Hashtable<String, String>();
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new NullAnnotationsCleanUp(options, problem.getProblemId()), IProposalRelevance.REMOVE_REDUNDANT_NULLNESS_ANNOTATION, image, context);
proposals.add(proposal);
}
use of org.eclipse.jdt.internal.corext.fix.NullAnnotationsFix in project che by eclipse.
the class NullAnnotationsCorrectionProcessor method addNullAnnotationInSignatureProposal.
public static void addNullAnnotationInSignatureProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals, ChangeKind changeKind, boolean isArgumentProblem) {
NullAnnotationsFix fix = NullAnnotationsFix.createNullAnnotationInSignatureFix(context.getASTRoot(), problem, changeKind, isArgumentProblem);
if (fix != null) {
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
Map<String, String> options = new Hashtable<String, String>();
if (fix.getCu() != context.getASTRoot()) {
// workaround: adjust the unit to operate on, depending on the findings of RewriteOperations.createAddAnnotationOperation(..)
final CompilationUnit cu = fix.getCu();
final IInvocationContext originalContext = context;
context = new IInvocationContext() {
public int getSelectionOffset() {
return originalContext.getSelectionOffset();
}
public int getSelectionLength() {
return originalContext.getSelectionLength();
}
public ASTNode getCoveringNode() {
return originalContext.getCoveringNode();
}
public ASTNode getCoveredNode() {
return originalContext.getCoveredNode();
}
public ICompilationUnit getCompilationUnit() {
return (ICompilationUnit) cu.getJavaElement();
}
public CompilationUnit getASTRoot() {
return cu;
}
};
}
//raise local change above change in overridden method
int relevance = (changeKind == ChangeKind.OVERRIDDEN) ? IProposalRelevance.CHANGE_NULLNESS_ANNOTATION_IN_OVERRIDDEN_METHOD : IProposalRelevance.CHANGE_NULLNESS_ANNOTATION;
FixCorrectionProposal proposal = new FixCorrectionProposal(fix, new NullAnnotationsCleanUp(options, problem.getProblemId()), relevance, image, context);
proposals.add(proposal);
}
}
Aggregations