Changeset 19 in default


Ignore:
Timestamp:
10/29/10 10:47:54 (14 years ago)
Author:
zeiss
Message:
 
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  
    2020 
    2121import de.ugoe.cs.swe.bnftools.analysis.EbnfAnalysisUtils; 
     22import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; 
    2223import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList; 
    2324import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf; 
     
    300301                        return; 
    301302 
    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() 
    313308                                .replaceAll("[ \t\n\r]", ""); 
    314309 
    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) 
    317313                                continue; 
    318                         if (root.getChildren().get(i) == null) 
     314                        if (currentNode.getRule() == null) 
    319315                                continue; 
    320                         if (!(root.getChildren().get(i) instanceof CompositeNode)) 
     316                        if (currentNode.getRule() == rule) 
    321317                                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)) { 
    333325                                        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() + ")"; 
    338330                                        warning(description, 1, description); 
    339331                                } 
    340332                        } 
    341                 } 
    342333        } 
    343334         
Note: See TracChangeset for help on using the changeset viewer.