Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-08-08 16:40:51 +0000
committerHenrik Rentz-Reichert2012-08-08 16:40:51 +0000
commite5da4053e089692eb27ebe0ae87c998b934f2081 (patch)
tree48e9b2bae65b2b3d85e5c331c0c9df6cbc29d58b /plugins
parent885508c947b49c382360697017c72de0df5483ab (diff)
downloadorg.eclipse.etrice-e5da4053e089692eb27ebe0ae87c998b934f2081.tar.gz
org.eclipse.etrice-e5da4053e089692eb27ebe0ae87c998b934f2081.tar.xz
org.eclipse.etrice-e5da4053e089692eb27ebe0ae87c998b934f2081.zip
[core.room] checking names for valid IDs
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
index 571c0d163..ff6f76e1b 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
@@ -840,6 +840,9 @@ public class ValidationUtil {
if (name.isEmpty())
return Result.error("name must not be empty");
+ if (!isValidID(name))
+ return Result.error("name is no valid ID");
+
if (item.eContainer() instanceof ActorClass) {
ArrayList<InterfaceItem> all = new ArrayList<InterfaceItem>();
ActorClass ac = (ActorClass) item.eContainer();
@@ -882,9 +885,12 @@ public class ValidationUtil {
}
public static Result isUniqueName(StateGraphItem s, String name) {
- if (name.isEmpty())
+ if (name.trim().isEmpty())
return Result.error("name must not be empty");
+ if (!isValidID(name))
+ return Result.error("name is no valid ID");
+
StateGraph sg = (StateGraph) s.eContainer();
Set<String> names = RoomHelpers.getAllNames(sg, s);
@@ -980,4 +986,8 @@ public class ValidationUtil {
return errors;
}
+
+ public static boolean isValidID(String name) {
+ return !name.matches("\\^?[a-zA-Z_][a-zA-Z_0-9]*");
+ }
}

Back to the top