use of org.eclipse.jdt.ls.core.internal.corext.fix.IProposableFix in project eclipse.jdt.ls by eclipse.
the class ReorgCorrectionsSubProcessor method removeImportStatementProposals.
public static void removeImportStatementProposals(IInvocationContext context, IProblemLocation problem, Collection<CUCorrectionProposal> proposals) {
IProposableFix fix = UnusedCodeFix.createRemoveUnusedImportFix(context.getASTRoot(), problem);
if (fix != null) {
try {
CompilationUnitChange change = fix.createChange(null);
CUCorrectionProposal proposal = new CUCorrectionProposal(change.getName(), change.getCompilationUnit(), change, IProposalRelevance.REMOVE_UNUSED_IMPORT);
proposals.add(proposal);
} catch (CoreException e) {
JavaLanguageServerPlugin.log(e);
}
}
final ICompilationUnit cu = context.getCompilationUnit();
String name = CorrectionMessages.ReorgCorrectionsSubProcessor_organizeimports_description;
CUCorrectionProposal proposal = new CUCorrectionProposal(name, cu, IProposalRelevance.ORGANIZE_IMPORTS) {
@Override
protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
CompilationUnit astRoot = context.getASTRoot();
OrganizeImportsOperation op = new OrganizeImportsOperation(cu, astRoot, true, false, true, null);
editRoot.addChild(op.createTextEdit(null));
}
};
proposals.add(proposal);
}
use of org.eclipse.jdt.ls.core.internal.corext.fix.IProposableFix in project eclipse.jdt.ls by eclipse.
the class LocalCorrectionsSubProcessor method addUnimplementedMethodsProposals.
public static void addUnimplementedMethodsProposals(IInvocationContext context, IProblemLocation problem, Collection<CUCorrectionProposal> proposals) {
IProposableFix fix = UnimplementedCodeFix.createAddUnimplementedMethodsFix(context.getASTRoot(), problem);
if (fix != null) {
try {
CompilationUnitChange change = fix.createChange(null);
CUCorrectionProposal proposal = new CUCorrectionProposal(change.getName(), change.getCompilationUnit(), change, IProposalRelevance.ADD_UNIMPLEMENTED_METHODS);
proposals.add(proposal);
} catch (CoreException e) {
JavaLanguageServerPlugin.log(e);
}
}
}
use of org.eclipse.jdt.ls.core.internal.corext.fix.IProposableFix in project eclipse.jdt.ls by eclipse.
the class SerialVersionSubProcessor method getSerialVersionProposals.
/**
* Determines the serial version quickfix proposals.
*
* @param context
* the invocation context
* @param location
* the problem location
* @param proposals
* the proposal collection to extend
*/
public static final void getSerialVersionProposals(final IInvocationContext context, final IProblemLocation location, final Collection<CUCorrectionProposal> proposals) {
Assert.isNotNull(context);
Assert.isNotNull(location);
Assert.isNotNull(proposals);
IProposableFix[] fixes = PotentialProgrammingProblemsFix.createMissingSerialVersionFixes(context.getASTRoot(), location);
if (fixes != null) {
proposals.add(new SerialVersionProposal(fixes[0], IProposalRelevance.MISSING_SERIAL_VERSION_DEFAULT, context, true));
ICompilationUnit unit = context.getCompilationUnit();
if (unit != null && unit.getJavaProject() != null && !ProjectsManager.DEFAULT_PROJECT_NAME.equals(unit.getJavaProject().getProject().getName())) {
proposals.add(new SerialVersionProposal(fixes[1], IProposalRelevance.MISSING_SERIAL_VERSION, context, false));
}
}
}
Aggregations