Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ReferenceHelper.java +39 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,12 @@ import org.eclipse.emf.ecore.util.InternalEList; import com.google.common.collect.Lists; import de.ugoe.cs.swe.tTCN3.Assignment; import de.ugoe.cs.swe.tTCN3.Enumeration; import de.ugoe.cs.swe.tTCN3.FormalTemplatePar; import de.ugoe.cs.swe.tTCN3.FormalValuePar; import de.ugoe.cs.swe.tTCN3.Head; public class TTCN3ReferenceHelper { /** Loading Loading @@ -95,8 +100,12 @@ public class TTCN3ReferenceHelper { return results.size()>0; } @SuppressWarnings("unchecked") public static boolean isReferenced2(EObject rootElement, Set<? extends EObject> targets) { return isReferenced2(rootElement, targets, true); } @SuppressWarnings("unchecked") public static boolean isReferenced2(EObject rootElement, Set<? extends EObject> targets, boolean ignoreAssignment) { boolean found = false; for(EReference ref: rootElement.eClass().getEAllReferences()) { Loading @@ -112,12 +121,12 @@ public class TTCN3ReferenceHelper { for(int i=0; i<contentList.size(); ++i) { EObject childElement = contentList.basicGet(i); if(!childElement.eIsProxy()) found |= isReferenced2(childElement, targets); found |= isReferenced2(childElement, targets, ignoreAssignment); } } else { EObject childElement = (EObject) content; if(!childElement.eIsProxy()) found |= isReferenced2(childElement, targets); found |= isReferenced2(childElement, targets, ignoreAssignment); } } else if (!ref.isContainer()) { Object value = rootElement.eGet(ref, true); Loading @@ -135,6 +144,9 @@ public class TTCN3ReferenceHelper { if (refElement instanceof Enumeration) { return false; } if (ignoreAssignment) { return checkAssignment(rootElement, refElement); } return true; } } Loading @@ -143,4 +155,28 @@ public class TTCN3ReferenceHelper { } return found; } private static boolean checkAssignment(EObject rootElement, EObject refElement) { //handle use within assignments //assignment //TODO: variable redirection as well? if (rootElement instanceof Head && rootElement .eContainer() .eContainer() .eContainer() instanceof Assignment ) { if ((refElement instanceof FormalValuePar && ((FormalValuePar)refElement).getInOut().equals("out")) || (refElement instanceof FormalTemplatePar && ((FormalTemplatePar)refElement).getInOut().equals("out")) ) { return true; } else { return false; } } return true; } } de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/CodeStyleValidator.xtend +2 −2 Original line number Diff line number Diff line Loading @@ -1097,7 +1097,7 @@ class CodeStyleValidator extends AbstractDeclarativeValidator { } } if (parent.isReferenced2(variables)) { if (parent.isReferenced2(variables, false)) { return true } else { return false Loading Loading @@ -1440,7 +1440,7 @@ class CodeStyleValidator extends AbstractDeclarativeValidator { } val Set<EObject> target = newHashSet(d.exportedObjects.map[getEObjectOrProxy]); var boolean found = module.isReferenced2(target) var boolean found = module.isReferenced2(target, false) if (!found && d.module != null) { statistics.incrementCountStyle Loading Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ReferenceHelper.java +39 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,12 @@ import org.eclipse.emf.ecore.util.InternalEList; import com.google.common.collect.Lists; import de.ugoe.cs.swe.tTCN3.Assignment; import de.ugoe.cs.swe.tTCN3.Enumeration; import de.ugoe.cs.swe.tTCN3.FormalTemplatePar; import de.ugoe.cs.swe.tTCN3.FormalValuePar; import de.ugoe.cs.swe.tTCN3.Head; public class TTCN3ReferenceHelper { /** Loading Loading @@ -95,8 +100,12 @@ public class TTCN3ReferenceHelper { return results.size()>0; } @SuppressWarnings("unchecked") public static boolean isReferenced2(EObject rootElement, Set<? extends EObject> targets) { return isReferenced2(rootElement, targets, true); } @SuppressWarnings("unchecked") public static boolean isReferenced2(EObject rootElement, Set<? extends EObject> targets, boolean ignoreAssignment) { boolean found = false; for(EReference ref: rootElement.eClass().getEAllReferences()) { Loading @@ -112,12 +121,12 @@ public class TTCN3ReferenceHelper { for(int i=0; i<contentList.size(); ++i) { EObject childElement = contentList.basicGet(i); if(!childElement.eIsProxy()) found |= isReferenced2(childElement, targets); found |= isReferenced2(childElement, targets, ignoreAssignment); } } else { EObject childElement = (EObject) content; if(!childElement.eIsProxy()) found |= isReferenced2(childElement, targets); found |= isReferenced2(childElement, targets, ignoreAssignment); } } else if (!ref.isContainer()) { Object value = rootElement.eGet(ref, true); Loading @@ -135,6 +144,9 @@ public class TTCN3ReferenceHelper { if (refElement instanceof Enumeration) { return false; } if (ignoreAssignment) { return checkAssignment(rootElement, refElement); } return true; } } Loading @@ -143,4 +155,28 @@ public class TTCN3ReferenceHelper { } return found; } private static boolean checkAssignment(EObject rootElement, EObject refElement) { //handle use within assignments //assignment //TODO: variable redirection as well? if (rootElement instanceof Head && rootElement .eContainer() .eContainer() .eContainer() instanceof Assignment ) { if ((refElement instanceof FormalValuePar && ((FormalValuePar)refElement).getInOut().equals("out")) || (refElement instanceof FormalTemplatePar && ((FormalTemplatePar)refElement).getInOut().equals("out")) ) { return true; } else { return false; } } return true; } }
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/CodeStyleValidator.xtend +2 −2 Original line number Diff line number Diff line Loading @@ -1097,7 +1097,7 @@ class CodeStyleValidator extends AbstractDeclarativeValidator { } } if (parent.isReferenced2(variables)) { if (parent.isReferenced2(variables, false)) { return true } else { return false Loading Loading @@ -1440,7 +1440,7 @@ class CodeStyleValidator extends AbstractDeclarativeValidator { } val Set<EObject> target = newHashSet(d.exportedObjects.map[getEObjectOrProxy]); var boolean found = module.isReferenced2(target) var boolean found = module.isReferenced2(target, false) if (!found && d.module != null) { statistics.incrementCountStyle Loading