Ignore:
Timestamp:
09/24/10 12:14:04 (14 years ago)
Author:
phdmakk
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/t3e-tools/t3q/src/org/etsi/t3q/visitor/QualityChecker.java

    r16 r28  
    21852185        } 
    21862186 
    2187         // ------------------------------------------------------------------------------------------- 
    2188  
     2187        //TODO: extract, duplicate of nested alt statements 
     2188        public void checkNoNestedModes(LocationAST node) { 
     2189 
     2190                LinkedList<LocationAST> nestedNodes = ASTUtil.findTypeNodes(node 
     2191//                              .getFirstChild() 
     2192                                , TTCN3ParserTokenTypes.ModeSpecification); 
     2193                if (nestedNodes != null && nestedNodes.size() > 0) { 
     2194                        LocationAST nestedNode; 
     2195 
     2196                        int[] nodeTypes = new int[] {TTCN3ParserTokenTypes.ModeSpecification}; 
     2197                        for (int n = 0; n < nestedNodes.size(); n++) { 
     2198                                nestedNode = nestedNodes.get(n); 
     2199                                int nestingDepth = getConstructNesting(nestedNode, nodeTypes);  
     2200                                if (nestingDepth > T3Q.activeProfile.getEmbeddedExtensionConfig().getAllowedModeNestingDepth()) { 
     2201                                        this.getLoggingInterface().logWarning(nestedNode.getLine(), nestedNode.getEndLine(), MessageClass.STYLE, "Mode nesting depth ("+nestingDepth+") exceeds maximum allowed nesting depth ("+T3Q.activeProfile.getEmbeddedExtensionConfig().getAllowedModeNestingDepth()+")!", "EC.XX, "+MiscTools.getMethodName()); 
     2202                                } 
     2203                        } 
     2204                } 
     2205 
     2206        } 
     2207         
     2208        // ------------------------------------------------------------------------------------------- 
     2209 
     2210        //TODO: further potential for reuse? 
    21892211        public void checkNoNestedAltStatements(LocationAST node) { 
    21902212 
     
    21932215//                              .getFirstChild() 
    21942216                                , TTCN3ParserTokenTypes.AltConstruct); 
    2195  
    21962217                if (nestedAltConstructNodes != null && nestedAltConstructNodes.size() > 0) { 
    21972218                        LocationAST nestedAltConstructNode; 
    21982219 
     2220                        int[] nodeTypes = new int[] {TTCN3ParserTokenTypes.AltConstruct, TTCN3ParserTokenTypes.AltstepDef}; 
    21992221                        for (int n = 0; n < nestedAltConstructNodes.size(); n++) { 
    22002222                                nestedAltConstructNode = nestedAltConstructNodes.get(n); 
    2201                                 int nestingDepth = getAltConstructNesting(nestedAltConstructNode);  
     2223                                int nestingDepth = getConstructNesting(nestedAltConstructNode, nodeTypes);  
    22022224                                if (nestingDepth > T3Q.activeProfile.getMaximumAllowedNestingDepth()) { 
    22032225                                        this.getLoggingInterface().logWarning(nestedAltConstructNode.getLine(), nestedAltConstructNode.getEndLine(), MessageClass.STYLE, "Alt statement nesting depth ("+nestingDepth+") exceeds maximum allowed nesting depth ("+T3Q.activeProfile.getMaximumAllowedNestingDepth()+")!", "6.3, "+MiscTools.getMethodName()); 
     
    22102232        // ------------------------------------------------------------------------------------------- 
    22112233 
    2212         private int getAltConstructNesting(LocationAST node){ 
     2234        private int getConstructNesting(LocationAST node, int[] nodeTypes){ 
    22132235                int nestingDepth = 1; 
    2214                 LocationAST containingAltConstructNode = LocationAST.resolveParentsUntilType(node.getParent(), new int[] {TTCN3ParserTokenTypes.AltConstruct, TTCN3ParserTokenTypes.AltstepDef}); 
     2236                LocationAST containingConstructNode = LocationAST.resolveParentsUntilType(node.getParent(), nodeTypes); 
    22152237                 
    2216                 if (containingAltConstructNode != null){ 
    2217                         nestingDepth += getAltConstructNesting(containingAltConstructNode); 
     2238                if (containingConstructNode != null){ 
     2239                        nestingDepth += getConstructNesting(containingConstructNode, nodeTypes); 
    22182240                } else { 
    22192241                        nestingDepth = 0; 
Note: See TracChangeset for help on using the changeset viewer.