Changeset 19 in default for trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/validation
- Timestamp:
- 10/29/10 10:47:54 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/validation/EbnfJavaValidator.java
r18 r19 20 20 21 21 import de.ugoe.cs.swe.bnftools.analysis.EbnfAnalysisUtils; 22 import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; 22 23 import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList; 23 24 import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf; … … 300 301 return; 301 302 302 CompositeNode node = NodeUtil.getNodeAdapter(rule).getParserNode(); 303 CompositeNode root = node.getParent(); 304 305 AbstractNode last = node.getChildren().get( 306 node.getChildren().size() - 1); 307 308 if (!(last instanceof CompositeNode)) 309 return; 310 311 CompositeNode rightHandSideNode = (CompositeNode) last; 312 String rightHandSideText = rightHandSideNode.serialize().trim() 303 EtsiBnf etsiBnfNode = (EtsiBnf) rule.eContainer().eContainer(); 304 305 CompositeNode definitionList = NodeUtil.getNodeAdapter(rule.getDefinitionList()).getParserNode(); 306 307 String rightHandSideText = definitionList.serialize().trim() 313 308 .replaceAll("[ \t\n\r]", ""); 314 309 315 for (int i = 0; i < root.getChildren().size(); i++) { 316 if (root.getChildren().get(i) == node) 310 for (int i = 0; i < etsiBnfNode.getBnfEntry().size(); i++) { 311 BnfEntry currentNode = etsiBnfNode.getBnfEntry().get(i); 312 if (currentNode == null) 317 313 continue; 318 if ( root.getChildren().get(i) == null)314 if (currentNode.getRule() == null) 319 315 continue; 320 if ( !(root.getChildren().get(i) instanceof CompositeNode))316 if (currentNode.getRule() == rule) 321 317 continue; 322 323 CompositeNode child = (CompositeNode) root.getChildren().get(i); 324 325 AbstractNode childLastChild = child.getChildren().get( 326 child.getChildren().size() - 1); 327 if (childLastChild instanceof CompositeNode) { 328 CompositeNode childLastChildCompositeNode = (CompositeNode) childLastChild; 329 String text = childLastChildCompositeNode.serialize().trim() 330 .replaceAll("[ \t\n\r]", ""); 331 if (text.equals(rightHandSideText)) { 332 Rule matchingRule = (Rule) child.getElement(); 318 319 Rule currentRule = currentNode.getRule(); 320 CompositeNode currentRuleDefinitionList = NodeUtil.getNodeAdapter(currentRule.getDefinitionList()).getParserNode(); 321 String currentRuleRightHandSideText = currentRuleDefinitionList.serialize().trim() 322 .replaceAll("[ \t\n\r]", ""); 323 324 if (currentRuleRightHandSideText.equals(rightHandSideText)) { 333 325 String description = EbnfJavaValidator.duplicateRulesDescription 334 + " with rule "335 + matchingRule.getRulenumber()336 + " (Line "337 + child.getLine() + ")";326 + " with rule \"" 327 + currentRule.getName() 328 + "\" (Line " 329 + NodeUtil.getNodeAdapter(currentRule).getParserNode().getLine() + ")"; 338 330 warning(description, 1, description); 339 331 } 340 332 } 341 }342 333 } 343 334
Note: See TracChangeset
for help on using the changeset viewer.