Package: Violation

Violation

nameinstructionbranchcomplexitylinemethod
Violation(String, ILexLocation, LocationAssistantIR)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
compareTo(Violation)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
equals(Object)
M: 2 C: 22
92%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 4
80%
M: 0 C: 1
100%
getDescripton()
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%
getLocation()
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%
toString()
M: 0 C: 37
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * VDM Code Generator
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.codegen.analysis.violations;
23:
24: import org.overture.ast.intf.lex.ILexLocation;
25: import org.overture.codegen.assistant.LocationAssistantIR;
26:
27: public class Violation implements Comparable<Violation>
28: {
29:         private ILexLocation location;
30:         private String description;
31:         private LocationAssistantIR locationAssistant;
32:
33:         public Violation(String description, ILexLocation location,
34:                         LocationAssistantIR locationAssistant)
35:         {
36:                 super();
37:                 this.description = description;
38:                 this.location = location;
39:                 this.locationAssistant = locationAssistant;
40:         }
41:
42:         public String getDescripton()
43:         {
44:                 return description;
45:         }
46:
47:         public ILexLocation getLocation()
48:         {
49:                 return location;
50:         }
51:
52:         @Override
53:         public String toString()
54:         {
55:                 return "[Violation in module " + location.getModule() + ": '"
56:                                 + description + "'. Location: line " + location.getStartLine()
57:                                 + " at position: " + location.getStartPos() + " in "
58:                                 + location.getFile().getName() + "]";
59:         }
60:
61:         @Override
62:         public boolean equals(Object obj)
63:         {
64:•                if (!(obj instanceof Violation))
65:                 {
66:                         return false;
67:                 }
68:
69:                 Violation other = (Violation) obj;
70:
71:•                return this.description.equals(other.description)
72:•                                && this.location.equals(other.location);
73:         }
74:
75:         @Override
76:         public int compareTo(Violation other)
77:         {
78:                 return locationAssistant.compareLocations(this.location, other.location);
79:         }
80: }