- Timestamp:
- 10/26/10 11:53:37 (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/refactoring/autorenumber/AutoRenumberRefactoringProcessor.java
r5 r18 5 5 import org.eclipse.core.runtime.IProgressMonitor; 6 6 import org.eclipse.core.runtime.OperationCanceledException; 7 import org.eclipse.emf.ecore.EObject; 7 8 import org.eclipse.jface.text.BadLocationException; 8 9 import org.eclipse.ltk.core.refactoring.Change; … … 19 20 import org.eclipse.xtext.parsetree.AbstractNode; 20 21 import org.eclipse.xtext.parsetree.CompositeNode; 22 import org.eclipse.xtext.parsetree.NodeUtil; 21 23 import org.eclipse.xtext.ui.editor.XtextEditor; 22 24 import org.eclipse.xtext.ui.editor.model.XtextDocument; 23 25 24 import de.ugoe.cs.swe.bnftools.ebnf. Rule;26 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; 25 27 26 28 public class AutoRenumberRefactoringProcessor extends RefactoringProcessor { … … 113 115 for (int i=0; i < rootNode.getChildren().size(); i++) { 114 116 AbstractNode child = rootNode.getChildren().get(i); 115 if (!(child.getElement() instanceof Rule)) 117 EObject element = child.getElement(); 118 if (!(element instanceof BnfEntry)) 116 119 continue; 120 BnfEntry bnfEntry = (BnfEntry) element; 121 if (bnfEntry.getRule() == null) 122 continue; 123 124 child = NodeUtil.getNodeAdapter(bnfEntry.getRule()).getParserNode(); 125 117 126 String ruleText; 118 127 try { -
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/refactoring/inlinesinglereferencedrules/InlineSingleReferencedRulesRefactoringHandler.java
r5 r18 22 22 import com.google.inject.Inject; 23 23 24 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; 24 25 import de.ugoe.cs.swe.bnftools.ebnf.Rule; 25 26 import de.ugoe.cs.swe.bnftools.ui.quickfix.processors.InlineRulesProcessor; … … 52 53 for (int i=0; i < rootNode.getParserNode().getChildren().size(); i++) { 53 54 AbstractNode currentNode = rootNode.getParserNode().getChildren().get(i); 55 56 EObject element = currentNode.getElement(); 57 if (!(element instanceof BnfEntry)) 58 continue; 59 BnfEntry bnfEntry = (BnfEntry) element; 60 if (bnfEntry.getRule() == null) 61 continue; 62 63 currentNode = NodeUtil.getNodeAdapter(bnfEntry.getRule()).getParserNode(); 64 54 65 if (currentNode.getElement() instanceof Rule) { 55 66 Rule rule = (Rule) currentNode.getElement(); -
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/refactoring/inlinetokenrules/InlineTokenRulesRefactoringHandler.java
r5 r18 23 23 24 24 import de.ugoe.cs.swe.bnftools.analysis.EbnfAnalysisUtils; 25 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; 25 26 import de.ugoe.cs.swe.bnftools.ebnf.Rule; 26 27 import de.ugoe.cs.swe.bnftools.ui.refactoring.generic.GenericRefactoring; … … 51 52 for (int i=0; i < rootNode.getParserNode().getChildren().size(); i++) { 52 53 AbstractNode currentNode = rootNode.getParserNode().getChildren().get(i); 54 55 EObject element = currentNode.getElement(); 56 if (!(element instanceof BnfEntry)) 57 continue; 58 BnfEntry bnfEntry = (BnfEntry) element; 59 if (bnfEntry.getRule() == null) 60 continue; 61 62 currentNode = NodeUtil.getNodeAdapter(bnfEntry.getRule()).getParserNode(); 63 53 64 if (currentNode.getElement() instanceof Rule) { 54 65 Rule rule = (Rule) currentNode.getElement(); -
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/refactoring/removeunusedrules/RemoveUnusedRulesRefactoringHandler.java
r5 r18 22 22 import com.google.inject.Inject; 23 23 24 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; 24 25 import de.ugoe.cs.swe.bnftools.ebnf.Rule; 25 26 import de.ugoe.cs.swe.bnftools.ui.quickfix.processors.RemoveUnusedRulesProcessor; … … 52 53 for (int i=0; i < rootNode.getParserNode().getChildren().size(); i++) { 53 54 AbstractNode currentNode = rootNode.getParserNode().getChildren().get(i); 55 56 EObject element = currentNode.getElement(); 57 if (!(element instanceof BnfEntry)) 58 continue; 59 BnfEntry bnfEntry = (BnfEntry) element; 60 if (bnfEntry.getRule() == null) 61 continue; 62 63 currentNode = NodeUtil.getNodeAdapter(bnfEntry.getRule()).getParserNode(); 64 54 65 if (currentNode.getElement() instanceof Rule) { 55 66 Rule rule = (Rule) currentNode.getElement(); -
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/refactoring/replacepassthroughrules/ReplaceAllPassthroughRulesRefactoringHandler.java
r5 r18 23 23 24 24 import de.ugoe.cs.swe.bnftools.analysis.EbnfAnalysisUtils; 25 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; 25 26 import de.ugoe.cs.swe.bnftools.ebnf.Rule; 26 27 import de.ugoe.cs.swe.bnftools.ui.quickfix.processors.ReplacePassthroughRuleProcessor; … … 55 56 for (int i=0; i < rootNode.getParserNode().getChildren().size(); i++) { 56 57 AbstractNode currentNode = rootNode.getParserNode().getChildren().get(i); 58 59 EObject element = currentNode.getElement(); 60 if (!(element instanceof BnfEntry)) 61 continue; 62 BnfEntry bnfEntry = (BnfEntry) element; 63 if (bnfEntry.getRule() == null) 64 continue; 65 66 currentNode = NodeUtil.getNodeAdapter(bnfEntry.getRule()).getParserNode(); 67 57 68 if (currentNode.getElement() instanceof Rule) { 58 69 Rule rule = (Rule) currentNode.getElement(); -
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/refactoring/uppercasetokenrules/UppercaseTokenRulesRefactoringHandler.java
r5 r18 23 23 24 24 import de.ugoe.cs.swe.bnftools.analysis.EbnfAnalysisUtils; 25 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; 25 26 import de.ugoe.cs.swe.bnftools.ebnf.Rule; 26 27 import de.ugoe.cs.swe.bnftools.ui.refactoring.generic.GenericRefactoring; … … 51 52 for (int i=0; i < rootNode.getParserNode().getChildren().size(); i++) { 52 53 AbstractNode currentNode = rootNode.getParserNode().getChildren().get(i); 54 55 EObject element = currentNode.getElement(); 56 if (!(element instanceof BnfEntry)) 57 continue; 58 BnfEntry bnfEntry = (BnfEntry) element; 59 if (bnfEntry.getRule() == null) 60 continue; 61 62 currentNode = NodeUtil.getNodeAdapter(bnfEntry.getRule()).getParserNode(); 63 64 53 65 if (currentNode.getElement() instanceof Rule) { 54 66 Rule rule = (Rule) currentNode.getElement(); -
trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/validation/EbnfJavaValidator.java
r17 r18 351 351 //TODO: currently compares complete rules and not subrules 352 352 353 CompositeNode node = NodeUtil.getNodeAdapter(rule).getParserNode();354 CompositeNode root = node.getParent();355 356 AbstractNode last = node.getChildren().get(357 node.getChildren().size() - 1);358 359 if (!(last instanceof CompositeNode))360 return;361 362 CompositeNode rightHandSideNode = (CompositeNode) last;363 String rightHandSideText = rightHandSideNode.serialize().trim()364 .replaceAll("[ \t\n\r]", "");365 366 for (int i = 0; i < root.getChildren().size(); i++) {367 if (root.getChildren().get(i) == node)368 continue;369 if (root.getChildren().get(i) == null)370 continue;371 if (!(root.getChildren().get(i) instanceof CompositeNode))372 continue;373 374 CompositeNode child = (CompositeNode) root.getChildren().get(i);375 376 AbstractNode childLastChild = child.getChildren().get(377 child.getChildren().size() - 1);378 if (childLastChild instanceof CompositeNode) {379 CompositeNode childLastChildCompositeNode = (CompositeNode) childLastChild;380 String text = childLastChildCompositeNode.serialize().trim()381 .replaceAll("[ \t\n\r]", "");382 if (text.equals(rightHandSideText)) {383 Rule matchingRule = (Rule) child.getElement();384 String description = EbnfJavaValidator.duplicateSubRulesDescription385 + " with rule "386 + matchingRule.getRulenumber()387 + " (Line "388 + child.getLine() + ")";389 warning(description, 1, description);390 }391 }392 }393 353 } 394 354
Note: See TracChangeset
for help on using the changeset viewer.