source: default/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/quickfix/EbnfQuickfixProvider.java

Last change on this file was 5, checked in by zeiss, 14 years ago
  • Property svn:mime-type set to text/plain
File size: 2.4 KB
Line 
1package de.ugoe.cs.swe.bnftools.ui.quickfix;
2
3import org.eclipse.xtext.resource.IResourceDescriptions;
4import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider;
5import org.eclipse.xtext.ui.editor.quickfix.Fix;
6import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor;
7import org.eclipse.xtext.validation.Issue;
8import com.google.inject.Inject;
9import de.ugoe.cs.swe.bnftools.ui.quickfix.modifications.InlineRuleModification;
10import de.ugoe.cs.swe.bnftools.ui.quickfix.modifications.RemovePassthroughRuleModification;
11import de.ugoe.cs.swe.bnftools.ui.quickfix.modifications.RemoveUnusedRuleModification;
12import de.ugoe.cs.swe.bnftools.validation.EbnfJavaValidator;
13
14public 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}
Note: See TracBrowser for help on using the repository browser.