Skip to content

Commit 6a92417

Browse files
committed
Add validators for component and system files
1 parent f659718 commit 6a92417

2 files changed

Lines changed: 296 additions & 118 deletions

File tree

plugins/de.fraunhofer.ipa.ros.xtext/src/de/fraunhofer/ipa/ros/validation/RosValidator.xtend

Lines changed: 111 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -24,124 +24,117 @@ import ros.ParameterDate
2424
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
2525
*/
2626
class RosValidator extends AbstractRosValidator {
27-
//
28-
// public static val INVALID_NAME = 'invalidName'
29-
// public static val PARAMETER_HELP = 'paramInfo'
30-
//
31-
// /* CAPITAL LETTERS */
32-
// @Check
33-
// def void checkNameConventionsNode (Node node) {
34-
// for (char c : node.name.toCharArray){
35-
// if (Character.isUpperCase(c)){
36-
// warning("The name of a node should follow the ROS naming conventions: Capital letters are not recommended", null, INVALID_NAME);
37-
// }
38-
// }}
39-
// @Check
40-
// def void checkNameConventionsArtifact (Artifact artifact) {
41-
// for (char c : artifact.name.toCharArray){
42-
// if (Character.isUpperCase(c)){
43-
// warning("The name of a artifact should follow the ROS naming conventions: Capital letters are not recommended", null, INVALID_NAME);
44-
// }
45-
// }}
46-
// @Check
47-
// def void checkNameConventionsPackage (Package rospackage) {
48-
// for (char c : rospackage.name.toCharArray){
49-
// if (Character.isUpperCase(c)){
50-
// error("The name of a package has to follow the ROS naming conventions: Capital letters are not allowed", null, INVALID_NAME);
51-
// }
52-
// }
53-
// }
54-
// @Check
55-
// def void checkNameConventionsParameters (Parameter parameter) {
56-
// for (char c : parameter.name.toCharArray){
57-
// if (Character.isUpperCase(c)){
58-
// warning("The name of a parameter has to follow the ROS naming conventions: Capital letters are not recommended", null, INVALID_NAME);
59-
// }
60-
// }
61-
// }
62-
//
63-
// /* Customize Syntax Error Messages */
64-
//
65-
// public static val INVALID_SPEC = 'invalidSpecRef'
66-
// public static String SpecWarning = "## Quick Fixes available ##-
67-
// - Add the dependency to the specifications project
68-
// - Generate the .ros model for the specifications
69-
// ->https://github.com/ipa320/ros-model/blob/master/docu/NewCommunicationObjects.md"
70-
//
71-
// /* For Topics */
72-
// @Check
73-
// def void CheckMsgsRefPublisher(Publisher pub){
74-
// if(pub.message.eContainer === null){
75-
// warning( SpecWarning, null, INVALID_SPEC)
76-
// }
77-
// }
78-
//
79-
// @Check
80-
// def void CheckMsgsRefSubscriber(Subscriber sub){
81-
// if(sub.message.eContainer === null){
82-
// warning( SpecWarning, null, INVALID_SPEC)
83-
// }
84-
// }
85-
//
86-
// /* For Actions */
87-
// @Check
88-
// def void CheckMsgsRefActionClient(ActionClient act){
89-
// if(act.action.eContainer === null){
90-
// warning( SpecWarning, null, INVALID_SPEC)
91-
// }
92-
// }
93-
//
94-
// @Check
95-
// def void CheckMsgsRefActionServer(ActionServer act){
96-
// if(act.action.eContainer === null){
97-
// warning( SpecWarning, null, INVALID_SPEC)
98-
// }
99-
// }
100-
//
101-
// /* For Services */
102-
// @Check
103-
// def void CheckMsgsRefServiceServer (ServiceServer ser){
104-
// if(ser.service.eContainer === null){
105-
// warning( SpecWarning, null, INVALID_SPEC)
106-
// }
107-
// }
108-
//
109-
// @Check
110-
// def void CheckMsgsRefServiceClient (ServiceClient ser){
111-
// if(ser.service.eContainer === null){
112-
// warning( SpecWarning, null, INVALID_SPEC)
113-
// }
114-
// }
115-
//
116-
//
117-
// /*Parameters Helper*/
118-
// @Check
119-
// def void BinaryHelp (Parameter param){
120-
// if(param.type.toString.contains("Base64") && !(param.toString.contains('0b') ||param.toString.contains('0B'))){
121-
// info("HELP: A binary value must start with '0b'", null, PARAMETER_HELP)
122-
// }
123-
// }
124-
//
125-
// @Check
126-
// def void ArrayHelp (Parameter param){
127-
// if(param.type.toString.contains("Array")){
128-
// info("HELP: Array parameter format:\n { type TYPE default {VALUE, VALUE} \n example:\n type Boolean default true, true} ", null, PARAMETER_HELP)
129-
// }
130-
// }
131-
//
132-
// @Check
133-
// def void ListHelp (Parameter param){
134-
// if(param.type.toString.contains("List")){
135-
// info("HELP: List parameter format:\n { TYPE default VALUE,TYPE default VALUE }\n example:\n Integer default 5, Boolean default true ", null, PARAMETER_HELP)
136-
// }
137-
// }
138-
//
139-
// @Check
140-
// def void StructHelp (Parameter param){
141-
// if(param.type.toString.contains("Struct")){
142-
// info("HELP: Struct parameter format:\n { NAME TYPE default VALUE, NAME TYPE default VALUE }\n example:\n my_int Integer {default 5}, my_bool Boolean default true ", null, PARAMETER_HELP)
143-
// }
144-
// }
27+
28+
public static val INVALID_NAME = 'invalidName'
29+
public static val PARAMETER_HELP = 'paramInfo'
30+
31+
/* CAPITAL LETTERS */
32+
@Check
33+
def void checkNameConventionsNode (Node node) {
34+
for (char c : node.name.toCharArray){
35+
if (Character.isUpperCase(c)){
36+
warning("The name of a node should follow the ROS naming conventions: Capital letters are not recommended", null, INVALID_NAME);
37+
}
38+
}}
39+
@Check
40+
def void checkNameConventionsArtifact (Artifact artifact) {
41+
for (char c : artifact.name.toCharArray){
42+
if (Character.isUpperCase(c)){
43+
warning("The name of a artifact should follow the ROS naming conventions: Capital letters are not recommended", null, INVALID_NAME);
44+
}
45+
}}
46+
@Check
47+
def void checkNameConventionsPackage (Package rospackage) {
48+
for (char c : rospackage.name.toCharArray){
49+
if (Character.isUpperCase(c)){
50+
error("The name of a package has to follow the ROS naming conventions: Capital letters are not allowed", null, INVALID_NAME);
51+
}
52+
}
53+
}
54+
@Check
55+
def void checkNameConventionsParameters (Parameter parameter) {
56+
for (char c : parameter.name.toCharArray){
57+
if (Character.isUpperCase(c)){
58+
warning("The name of a parameter has to follow the ROS naming conventions: Capital letters are not recommended", null, INVALID_NAME);
59+
}
60+
}
61+
}
62+
63+
/* Customize Syntax Error Messages */
64+
65+
public static val INVALID_SPEC = 'invalidSpecRef'
66+
public static String SpecWarning = "## Quick Fixes available ##-
67+
- Add the dependency to the specifications project
68+
- Generate the .ros model for the specifications
69+
->https://github.com/ipa320/ros-model/blob/master/docu/NewCommunicationObjects.md"
70+
71+
/* For Topics */
72+
@Check
73+
def void CheckMsgsRefPublisher(Publisher pub){
74+
if(pub.message.eContainer === null){
75+
warning( SpecWarning, null, INVALID_SPEC)
76+
}
77+
}
78+
79+
@Check
80+
def void CheckMsgsRefSubscriber(Subscriber sub){
81+
if(sub.message.eContainer === null){
82+
warning( SpecWarning, null, INVALID_SPEC)
83+
}
84+
}
85+
86+
/* For Actions */
87+
@Check
88+
def void CheckMsgsRefActionClient(ActionClient act){
89+
if(act.action.eContainer === null){
90+
warning( SpecWarning, null, INVALID_SPEC)
91+
}
92+
}
93+
94+
@Check
95+
def void CheckMsgsRefActionServer(ActionServer act){
96+
if(act.action.eContainer === null){
97+
warning( SpecWarning, null, INVALID_SPEC)
98+
}
99+
}
100+
101+
/* For Services */
102+
@Check
103+
def void CheckMsgsRefServiceServer (ServiceServer ser){
104+
if(ser.service.eContainer === null){
105+
warning( SpecWarning, null, INVALID_SPEC)
106+
}
107+
}
108+
109+
@Check
110+
def void CheckMsgsRefServiceClient (ServiceClient ser){
111+
if(ser.service.eContainer === null){
112+
warning( SpecWarning, null, INVALID_SPEC)
113+
}
114+
}
115+
116+
117+
/*Parameters Helper*/
118+
@Check
119+
def void BinaryHelp (Parameter param){
120+
if(param.type.toString.contains("Base64") && !(param.toString.contains('0b') ||param.toString.contains('0B'))){
121+
info("HELP: A binary value must start with '0b'", null, PARAMETER_HELP)
122+
}
123+
}
124+
125+
@Check
126+
def void ListHelp (Parameter param){
127+
if(param.type.toString.contains("List")){
128+
info("HELP: List parameter format:\n [ TYPE , TYPE ]\n example:\n [ Integer , Boolean ]", null, PARAMETER_HELP)
129+
}
130+
}
131+
132+
@Check
133+
def void StructHelp (Parameter param){
134+
if(param.type.toString.contains("Struct")){
135+
info("HELP: Struct parameter format:\n [ NAME TYPE , NAME TYPE ]\n example:\n [my_int Integer, my_bool Boolean]", null, PARAMETER_HELP)
136+
}
137+
}
145138
//
146139
// //The RULE_ID impose the rest of the ROS naming convention rules : bin/de/fraunhofer/ipa/ros/parser/antlr/internal/InternalRos.g
147140
// // allow the use only of the symbol: "_"

0 commit comments

Comments
 (0)