Package: OldNameRenamer

OldNameRenamer

nameinstructionbranchcomplexitylinemethod
OldNameRenamer()
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseILexNameToken(ILexNameToken)
M: 11 C: 51
82%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 12
92%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.trans;
2:
3: import java.util.List;
4:
5: import org.apache.log4j.Logger;
6: import org.overture.ast.analysis.AnalysisException;
7: import org.overture.ast.analysis.DepthFirstAnalysisAdaptor;
8: import org.overture.ast.intf.lex.ILexLocation;
9: import org.overture.ast.intf.lex.ILexNameToken;
10: import org.overture.ast.lex.LexNameToken;
11: import org.overture.ast.types.PType;
12:
13: public class OldNameRenamer extends DepthFirstAnalysisAdaptor
14: {
15:         private char OLD_PREFIX = '_';
16:
17:         private Logger log = Logger.getLogger(this.getClass().getName());
18:
19:         @Override
20:         public void caseILexNameToken(ILexNameToken node) throws AnalysisException
21:         {
22:•                if (node.getOld())
23:                 {
24:                         String module = node.getModule();
25:                         String name = OLD_PREFIX + node.getName();
26:                         ILexLocation loc = node.getLocation();
27:                         boolean old = node.getOld();
28:                         boolean expl = node.getExplicit();
29:
30:                         ILexNameToken oldRepl = new LexNameToken(module, name, loc, old, expl);
31:
32:                         List<PType> typeQualifier = node.getTypeQualifier();
33:                         oldRepl.setTypeQualifier(typeQualifier);
34:
35:•                        if (node.parent() != null)
36:                         {
37:                                 node.parent().replaceChild(node, oldRepl);
38:                         } else
39:                         {
40:                                 log.error("Could not find parent of lex name token: " + node);
41:                         }
42:                 }
43:         }
44: }