Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-11-21 09:44:46 +0000
committerHenrik Rentz-Reichert2012-11-21 09:44:46 +0000
commitc0e2f108621b51571be3327aa77d32625de7a99a (patch)
tree51c27535f219fde43a733e9bca425212528a41cb /plugins/org.eclipse.etrice.core.etmap
parentdc0682eebdbd0d1d21400a7efbe8ea1dbcb98e88 (diff)
downloadorg.eclipse.etrice-c0e2f108621b51571be3327aa77d32625de7a99a.tar.gz
org.eclipse.etrice-c0e2f108621b51571be3327aa77d32625de7a99a.tar.xz
org.eclipse.etrice-c0e2f108621b51571be3327aa77d32625de7a99a.zip
[core.etmap] validation and quick fixes
Diffstat (limited to 'plugins/org.eclipse.etrice.core.etmap')
-rw-r--r--plugins/org.eclipse.etrice.core.etmap/src/org/eclipse/etrice/core/etmap/validation/ETMapJavaValidator.java57
1 files changed, 54 insertions, 3 deletions
diff --git a/plugins/org.eclipse.etrice.core.etmap/src/org/eclipse/etrice/core/etmap/validation/ETMapJavaValidator.java b/plugins/org.eclipse.etrice.core.etmap/src/org/eclipse/etrice/core/etmap/validation/ETMapJavaValidator.java
index 2f1dc13dd..aff5d0872 100644
--- a/plugins/org.eclipse.etrice.core.etmap/src/org/eclipse/etrice/core/etmap/validation/ETMapJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.etmap/src/org/eclipse/etrice/core/etmap/validation/ETMapJavaValidator.java
@@ -15,27 +15,78 @@ package org.eclipse.etrice.core.etmap.validation;
import java.util.HashSet;
import org.eclipse.etrice.core.etmap.eTMap.ETMapPackage;
+import org.eclipse.etrice.core.etmap.eTMap.Mapping;
import org.eclipse.etrice.core.etmap.eTMap.SubSystemMapping;
import org.eclipse.etrice.core.etmap.eTMap.ThreadMapping;
import org.eclipse.etrice.core.room.LogicalThread;
+import org.eclipse.etrice.core.room.SubSystemRef;
import org.eclipse.xtext.validation.Check;
public class ETMapJavaValidator extends AbstractETMapJavaValidator {
+ public static final String DUPLICATE_SUBSYS_MAPPING = "ETMapJavaValidator.DulicateSubSysMapping";
+ public static final String UNMAPPED_SUBSYS_REFS = "ETMapJavaValidator.UnmappedSubSysRefs";
+ public static final String DUPLICATE_THREAD_MAPPING = "ETMapJavaValidator.DulicateThreadMapping";
+ public static final String UNMAPPED_THREAD_REFS = "ETMapJavaValidator.UnmappedThreadRefs";
+ public static final String NOT_EMPTY = "empty";
+ public static final String EMPTY = "not-empty";
+
+ @Check
+ public void checkMapping(Mapping mp) {
+ HashSet<SubSystemRef> mapped = new HashSet<SubSystemRef>();
+ for (SubSystemMapping ssm : mp.getSubsysMappings()) {
+ if (!mapped.add(ssm.getLogicalSubSys())) {
+ int idx = mp.getSubsysMappings().indexOf(ssm);
+ error("duplicate mapping", ETMapPackage.Literals.MAPPING__SUBSYS_MAPPINGS, idx, DUPLICATE_SUBSYS_MAPPING);
+ }
+ }
+
+ StringBuilder msg = new StringBuilder();
+ StringBuilder fix = new StringBuilder();
+ for (SubSystemRef ssr : mp.getLogicalSys().getSubSystems()) {
+ if (!mapped.contains(ssr)) {
+ msg.append("unmapped sub system reference '"+ssr.getName()+"'\n");
+ String nodeRef = mp.getPhysicalSys().getNodeRefs().isEmpty()?
+ "no_node_ref_defined" : mp.getPhysicalSys().getNodeRefs().get(0).getName();
+ fix.append("\t\tSubSystemMapping "+ssr.getName()+" -> "+nodeRef+" {}\n");
+ }
+ }
+ if (msg.length()>0)
+ error(
+ msg.substring(0, msg.length()-2),
+ ETMapPackage.Literals.MAPPING__SUBSYS_MAPPINGS,
+ UNMAPPED_SUBSYS_REFS,
+ fix.toString(),
+ mapped.isEmpty()? EMPTY:NOT_EMPTY);
+ }
+
@Check
public void checkSubSystemMapping(SubSystemMapping ssm) {
HashSet<LogicalThread> mapped = new HashSet<LogicalThread>();
for (ThreadMapping tm : ssm.getThreadMappings()) {
- mapped.add(tm.getLogicalThread());
+ if (!mapped.add(tm.getLogicalThread())) {
+ int idx = ssm.getThreadMappings().indexOf(tm);
+ error("duplicate mapping", ETMapPackage.Literals.SUB_SYSTEM_MAPPING__THREAD_MAPPINGS, idx, DUPLICATE_THREAD_MAPPING);
+ }
}
StringBuilder sb = new StringBuilder();
+ StringBuilder fix = new StringBuilder();
for (LogicalThread lt : ssm.getLogicalSubSys().getType().getThreads()) {
- if (!mapped.contains(lt))
+ if (!mapped.contains(lt)) {
sb.append("unmapped logical thread '"+lt.getName()+"'\n");
+ String pthread = ssm.getNode().getType().getThreads().isEmpty()?
+ "no_physical_thread_defined" : ssm.getNode().getType().getThreads().get(0).getName();
+ fix.append("\t\t\tThreadMapping "+lt.getName()+" -> "+pthread+"\n");
+ }
}
if (sb.length()>0)
- error(sb.substring(0, sb.length()-2), ETMapPackage.Literals.SUB_SYSTEM_MAPPING__THREAD_MAPPINGS);
+ error(
+ sb.substring(0, sb.length()-2),
+ ETMapPackage.Literals.SUB_SYSTEM_MAPPING__THREAD_MAPPINGS,
+ UNMAPPED_THREAD_REFS,
+ fix.toString(),
+ mapped.isEmpty()? EMPTY:NOT_EMPTY);
}
}

Back to the top