Changeset 69 in default for v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui
- Timestamp:
- 05/26/14 11:48:28 (10 years ago)
- Location:
- v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/plugin.xml
r68 r69 248 248 </extension> 249 249 250 <!-- 250 <!----> 251 251 <extension 252 252 point="org.eclipse.xtext.builder.participant"> … … 255 255 </participant> 256 256 </extension> 257 -->258 259 <!--this is for using a button for generation -->257 258 259 <!--this is for using a button for generation 260 260 <extension 261 261 point="org.eclipse.ui.handlers"> 262 262 <handler 263 class="de.ugoe.cs.swe.bnftools.ui.E bnfExecutableExtensionFactory:de.ugoe.cs.swe.bnftools.ui.helper.GenerationHandler"263 class="de.ugoe.cs.swe.bnftools.ui.EBnfExecutableExtensionFactory:de.ugoe.cs.swe.bnftools.ui.helper.GenerationHandler" 264 264 commandId="de.ugoe.cs.swe.bnftools.ui.handler.GenerationCommand"> 265 265 </handler> … … 291 291 </menuContribution> 292 292 </extension> 293 <!---->293 --> 294 294 295 295 -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/handler/GenerationHandler.java
r68 r69 66 66 generator.doGenerate(r, fsa); 67 67 68 68 69 } 69 70 } -
v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/quickfix/EbnfQuickfixProvider.xtend
r66 r69 42 42 //***************************************************************************************** 43 43 //works but only in one file 44 @Fix(EbnfValidator.ruleReferencedOneDescription)45 def void fixInlineRuleReferencedOnce(Issue issue, IssueResolutionAcceptor acceptor) {46 acceptor.accept(47 issue,48 "Inline the rule",49 "Delete the rule and replace its single reference by the rule's right side",50 "upcase.png"51 ) [ element, context |52 var Rule rule = element as Rule;53 var IXtextDocument xtextDocument = context.getXtextDocument();54 var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule);55 var String nodeText = node.text;56 var int textLength = nodeText.length - 2;57 var int offset = node.textRegion.offset;58 //rename references59 var ICompositeNode dList = NodeModelUtils.findActualNodeFor(rule.definitionList);60 var String refText = "(" + dList.text + ")";61 var int refLength = rule.name.length;62 var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule);63 //*********************************64 //is the reference in the rule itself?65 var boolean foundRule = false;66 var EObject r = references.get(0) as EObject;67 var Rule containingRule = null;68 while (!foundRule) {69 r = r.eContainer;70 if (r instanceof Rule) {71 containingRule = r as Rule;72 foundRule = true;73 }74 }75 if (!rule.equals(containingRule)) {76 77 for (ruleRef : references) {78 var ICompositeNode refNode = NodeModelUtils.findActualNodeFor(ruleRef);79 var int refOffset = refNode.textRegion.offset;80 81 xtextDocument.replace(refOffset, refLength, refText);82 if (refOffset < offset) {83 offset += refText.length - refLength;84 }85 }86 87 // delete rule88 }89 90 xtextDocument.replace(offset, textLength, "");91 ]92 93 }44 // @Fix(EbnfValidator.ruleReferencedOneDescription) 45 // def void fixInlineRuleReferencedOnce(Issue issue, IssueResolutionAcceptor acceptor) { 46 // acceptor.accept( 47 // issue, 48 // "Inline the rule", 49 // "Delete the rule and replace its single reference by the rule's right side", 50 // "upcase.png" 51 // ) [ element, context | 52 // var Rule rule = element as Rule; 53 // var IXtextDocument xtextDocument = context.getXtextDocument(); 54 // var ICompositeNode node = NodeModelUtils.findActualNodeFor(rule); 55 // var String nodeText = node.text; 56 // var int textLength = nodeText.length - 2; 57 // var int offset = node.textRegion.offset; 58 // //rename references 59 // var ICompositeNode dList = NodeModelUtils.findActualNodeFor(rule.definitionList); 60 // var String refText = "(" + dList.text + ")"; 61 // var int refLength = rule.name.length; 62 // var List<RuleReference> references = EbnfAnalysisUtils.findReferences(rule); 63 // //********************************* 64 // //is the reference in the rule itself? 65 // var boolean foundRule = false; 66 // var EObject r = references.get(0) as EObject; 67 // var Rule containingRule = null; 68 // while (!foundRule) { 69 // r = r.eContainer; 70 // if (r instanceof Rule) { 71 // containingRule = r as Rule; 72 // foundRule = true; 73 // } 74 // } 75 // if (!rule.equals(containingRule)) { 76 // 77 // for (ruleRef : references) { 78 // var ICompositeNode refNode = NodeModelUtils.findActualNodeFor(ruleRef); 79 // var int refOffset = refNode.textRegion.offset; 80 // 81 // xtextDocument.replace(refOffset, refLength, refText); 82 // if (refOffset < offset) { 83 // offset += refText.length - refLength; 84 // } 85 // } 86 // 87 // // delete rule 88 // } 89 // 90 // xtextDocument.replace(offset, textLength, ""); 91 // ] 92 // 93 // } 94 94 95 95 // // this is not working by unknown reasons 96 96 // @Fix(EbnfValidator.ruleReferencedOneDescription) 97 97 // def void fixInlineRuleReferencedOnce(Issue issue, IssueResolutionAcceptor acceptor) { 98 // System.out.println("test"); 98 99 // acceptor.accept( 99 100 // issue, … … 105 106 // var DefinitionList dlist = rule.definitionList; 106 107 // var List<Rule> rules=EbnfAnalysisUtils.getAllRules(rule.eContainer().eContainer() as EtsiBnf); 107 // var SingleDefinition sDef = rules.get(1).definitionList.singleDefinition.get(1); 108 // var SingleDefinition sDef = rules.get(0).definitionList.singleDefinition.get(0); 109 // 110 // System.out.println(dlist.singleDefinition); 108 111 // dlist.singleDefinition.add(sDef); 112 // System.out.println(dlist.singleDefinition); 113 // 109 114 // rule.name="bla"; 110 // ]111 // 115 // ] 116 112 117 // } 113 118
Note: See TracChangeset
for help on using the changeset viewer.