1 | package de.ugoe.cs.swe.bnftools.ui.quickfix; |
---|
2 | |
---|
3 | import org.eclipse.xtext.resource.IResourceDescriptions; |
---|
4 | import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider; |
---|
5 | import org.eclipse.xtext.ui.editor.quickfix.Fix; |
---|
6 | import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor; |
---|
7 | import org.eclipse.xtext.validation.Issue; |
---|
8 | import com.google.inject.Inject; |
---|
9 | import de.ugoe.cs.swe.bnftools.ui.quickfix.modifications.InlineRuleModification; |
---|
10 | import de.ugoe.cs.swe.bnftools.ui.quickfix.modifications.RemovePassthroughRuleModification; |
---|
11 | import de.ugoe.cs.swe.bnftools.ui.quickfix.modifications.RemoveUnusedRuleModification; |
---|
12 | import de.ugoe.cs.swe.bnftools.validation.EbnfJavaValidator; |
---|
13 | |
---|
14 | public class EbnfQuickfixProvider extends DefaultQuickfixProvider { |
---|
15 | |
---|
16 | @Inject |
---|
17 | IResourceDescriptions resourceDescriptions; |
---|
18 | |
---|
19 | // ---------------------------------------------------------------------------------------------------- |
---|
20 | |
---|
21 | @Fix(value = EbnfJavaValidator.ruleReferencedOneDescription) |
---|
22 | public void fixInlineRuleReferencedOnce(final Issue issue, IssueResolutionAcceptor acceptor) { |
---|
23 | InlineRuleModification inlineRuleModification = new InlineRuleModification( |
---|
24 | resourceDescriptions); |
---|
25 | |
---|
26 | acceptor.accept( |
---|
27 | issue, |
---|
28 | "Inline the rule", |
---|
29 | "Delete the rule and replace its single reference by the rule's right side", |
---|
30 | "upcase.png", inlineRuleModification); |
---|
31 | } |
---|
32 | |
---|
33 | // ---------------------------------------------------------------------------------------------------- |
---|
34 | |
---|
35 | @Fix(value = EbnfJavaValidator.passthroughRuleDescription) |
---|
36 | public void fixRemovePassthroughRule(final Issue issue, IssueResolutionAcceptor acceptor) { |
---|
37 | RemovePassthroughRuleModification removePassthroughRuleModification = new RemovePassthroughRuleModification( |
---|
38 | resourceDescriptions); |
---|
39 | |
---|
40 | acceptor.accept( |
---|
41 | issue, |
---|
42 | "Remove passthrough rule", |
---|
43 | "Delete the passthrough rule and replace its references with its right side", |
---|
44 | "upcase.png", removePassthroughRuleModification); |
---|
45 | } |
---|
46 | |
---|
47 | // ---------------------------------------------------------------------------------------------------- |
---|
48 | |
---|
49 | @Fix(value = EbnfJavaValidator.unusedRuleDescription) |
---|
50 | public void fixUnusedRule(final Issue issue, IssueResolutionAcceptor acceptor) { |
---|
51 | RemoveUnusedRuleModification removeUnusedRuleModification = new RemoveUnusedRuleModification( |
---|
52 | resourceDescriptions); |
---|
53 | |
---|
54 | acceptor.accept( |
---|
55 | issue, |
---|
56 | "Remove unused rule", |
---|
57 | "Delete the unused rule", |
---|
58 | "upcase.png", removeUnusedRuleModification); |
---|
59 | } |
---|
60 | |
---|
61 | } |
---|