Package: Substitution

Substitution

nameinstructionbranchcomplexitylinemethod
Substitution(ILexNameToken, PExp)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
Substitution(String, PExp)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
containsKey(AVariableExp)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
get(AVariableExp)
M: 2 C: 13
87%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%
getOriginal()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
makeFullKey(ILexNameToken)
M: 0 C: 16
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
toString()
M: 30 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package org.overture.pog.utility;
2:
3: import org.overture.ast.expressions.AVariableExp;
4: import org.overture.ast.expressions.PExp;
5: import org.overture.ast.intf.lex.ILexNameToken;
6:
7: /**
8: * A class for holding variable substitutions to be performed at a later date by the
9: *
10: * @author ldc
11: */
12: public class Substitution
13: {
14:
15:         String original;
16:         PExp newExp;
17:
18:         public String getOriginal()
19:         {
20:                 return original;
21:         }
22:
23:         public Substitution(ILexNameToken var, PExp value)
24:         {
25:                 this.original = makeFullKey(var);
26:                 this.newExp = value.clone();
27:         }
28:
29:         public Substitution(String original, PExp exp)
30:         {
31:                 this.original = original;
32:                 this.newExp = exp.clone();
33:         }
34:
35:         public boolean containsKey(AVariableExp key)
36:         {
37:                 String fullkey = makeFullKey(key.getName());
38:                 return original.equals(fullkey);
39:         }
40:
41:         public PExp get(AVariableExp key)
42:         {
43:                 String fullkey = makeFullKey(key.getName());
44:•                if (original.equals(fullkey))
45:                 {
46:                         return newExp;
47:                 }
48:                 return null;
49:
50:         }
51:
52:         public String makeFullKey(ILexNameToken name)
53:         {
54:•                if (name.isOld())
55:                 {
56:                         return name.getName() + "~";
57:                 } else
58:                 {
59:                         return name.getName();
60:                 }
61:         }
62:
63:         @Override
64:         public String toString()
65:         {
66:                 StringBuilder sb = new StringBuilder();
67:                 sb.append("[");
68:                 sb.append(newExp.toString());
69:                 sb.append("/");
70:                 sb.append(original);
71:                 sb.append("]");
72:                 return sb.toString();
73:         }
74:
75: }