Changeset 65 in default for v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui
- Timestamp:
- 05/07/14 16:02:46 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/quickfix/EbnfQuickfixProvider.xtend
r64 r65 27 27 */ 28 28 class EbnfQuickfixProvider extends org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider { 29 30 //***************************************************************************************** 29 31 //works 30 32 @Fix(EbnfValidator.ruleReferencedOneDescription) … … 37 39 ) [ element, context | 38 40 var Rule rule = element as Rule; 41 39 42 var IXtextDocument xtextDocument = context.getXtextDocument(); 40 43 var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); … … 50 53 var boolean foundRule = false; 51 54 var EObject r = references.get(0) as EObject; 52 var Rule containingRule =null;55 var Rule containingRule = null; 53 56 while (!foundRule) { 54 57 r = r.eContainer; … … 69 72 } 70 73 } 71 72 73 // delete rule 74 xtextDocument.replace(offset, textLength, ""); 74 // delete rule 75 xtextDocument.replace(offset, textLength, ""); 75 76 ] 76 77 77 78 } 78 79 80 //***************************************************************************************** 81 82 // @Fix(EbnfValidator.passthroughRuleDescription) 83 // def void fixRemovePassthroughRule(Issue issue, IssueResolutionAcceptor acceptor) { 84 // acceptor.accept( 85 // issue, 86 // "Remove passthrough rule", 87 // "Delete the passthrough rule and replace its references with its right side", 88 // "upcase.png", 89 // [ element, context | 90 // var Rule rule = element as Rule; 91 // var IXtextDocument xtextDocument = context.getXtextDocument(); 92 // var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); 93 // var String nodeText = node.text; 94 // var int textLength = nodeText.length - 2; 95 // var int offset = node.textRegion.offset; 96 // var ICompositeNode dList = NodeModelUtils.findActualNodeFor(rule.definitionList); 97 // var String refText = "(" + dList.text + ")"; 98 // var int refLength = rule.name.length; 99 // var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule); 100 // //sort references by offset 101 // var int i = 0; 102 // var List<RuleReference> referenceHleper = new ArrayList<RuleReference>(); 103 // while(i<references.length){ 104 // 105 // i++; 106 // } 107 // for (ruleRef : references) { 108 // var ICompositeNode refNode = NodeModelUtils.findActualNodeFor(ruleRef); 109 // var int refOffset = refNode.textRegion.offset; 110 // 111 // xtextDocument.replace(refOffset, refLength, refText); 112 // if (refOffset < offset) { 113 // offset += refText.length - refLength; 114 // } 115 // } 116 // ] 117 // ); 118 // } 119 120 //***************************************************************************************** 79 121 //works 80 // @Fix(EbnfValidator.passthroughRuleDescription) 81 // def void fixRemovePassthroughRule(Issue issue, IssueResolutionAcceptor acceptor) { 82 // acceptor.accept( 83 // issue, 84 // "Remove passthrough rule", 85 // "Delete the passthrough rule and replace its references with its right side", 86 // "upcase.png", 87 // [ element, context | 88 // var Rule rule = element as Rule; 89 // var IXtextDocument xtextDocument = context.getXtextDocument(); 90 // var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); 91 // var String nodeText = node.text; 92 // var int textLength = nodeText.length - 2; 93 // var int offset = node.textRegion.offset; 94 // var ICompositeNode dList = NodeModelUtils.findActualNodeFor(rule.definitionList); 95 // var String refText = "(" + dList.text + ")"; 96 // var int refLength = rule.name.length; 97 // var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule); 98 // //sort references by offset 99 // var int i = 0; 100 // var List<RuleReference> referenceHleper = new ArrayList<RuleReference>(); 101 // while(i<references.length){ 102 // 103 // i++; 104 // } 105 // for (ruleRef : references) { 106 // var ICompositeNode refNode = NodeModelUtils.findActualNodeFor(ruleRef); 107 // var int refOffset = refNode.textRegion.offset; 108 // 109 // xtextDocument.replace(refOffset, refLength, refText); 110 // if (refOffset < offset) { 111 // offset += refText.length - refLength; 112 // } 113 // } 114 // ] 115 // ); 116 // } 117 118 @Fix(EbnfValidator.unusedRuleDescription) 122 @Fix(EbnfValidator.unusedRuleDescription) 119 123 def void fixUnusedRule(Issue issue, IssueResolutionAcceptor acceptor) { 120 124 … … 131 135 } 132 136 } 133
Note: See TracChangeset
for help on using the changeset viewer.