Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/ModularizationValidator.xtend +33 −8 Original line number Diff line number Diff line Loading @@ -24,14 +24,23 @@ import org.eclipse.xtext.validation.AbstractDeclarativeValidator import org.eclipse.xtext.validation.Check import org.eclipse.xtext.validation.EValidatorRegistrar import static de.ugoe.cs.swe.scoping.TTCN3GlobalScopeProvider.* import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.* import static extension org.eclipse.xtext.EcoreUtil2.* import org.eclipse.xtext.scoping.IGlobalScopeProvider import com.google.inject.Inject import de.ugoe.cs.swe.scoping.TTCN3GlobalScopeProvider import java.util.List class ModularizationValidator extends AbstractDeclarativeValidator { val ConfigTools configTools = ConfigTools.getInstance; var QualityCheckProfile activeProfile = configTools.selectedProfile as QualityCheckProfile var ModuleContentHelper moduleHelper = new ModuleContentHelper(activeProfile) @Inject private IGlobalScopeProvider globalScopeProvider; @Check def checkModuleContainment(TTCN3Module module) { if (activeProfile.checkTypesAndValuesModuleContainmentCheck && Loading Loading @@ -111,14 +120,30 @@ class ModularizationValidator extends AbstractDeclarativeValidator { } private def boolean functionStartBehavior(FunctionDef function, TTCN3Module module) { // TODO: use alternative for UsageCrossReferencer!!! // This approach does not find all references... val references = UsageCrossReferencer.find(function, module) for (r : references) { val startTC = r.EObject.findDesiredParent(StartTCStatement) val startTimer = r.EObject.findDesiredParent(StartTimerStatement) val nestedParameter = r.EObject.findDesiredParent(FunctionInstance) val List<FunctionInstance> list = newArrayList val TTCN3GlobalScopeProvider scopeProvider = globalScopeProvider as TTCN3GlobalScopeProvider if (scopeProvider == null) { return false } synchronized ( IMPORTED_FROM ) { for (m : IMPORTED_FROM.get(module)) { for (instance : m.eAllOfType(FunctionInstance)) { val reference = instance.ref if (reference instanceof FunctionDef) { if (reference.equals(function)) { list.add(instance) } } } } } for (r : list) { val startTC = r.findDesiredParent(StartTCStatement) val startTimer = r.findDesiredParent(StartTimerStatement) val nestedParameter = r.findDesiredParent(FunctionInstance) var timer = false if (startTimer != null && startTimer.ref.findDesiredParent(TimerInstance) != null) { timer = true Loading Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/ModularizationValidator.xtend +33 −8 Original line number Diff line number Diff line Loading @@ -24,14 +24,23 @@ import org.eclipse.xtext.validation.AbstractDeclarativeValidator import org.eclipse.xtext.validation.Check import org.eclipse.xtext.validation.EValidatorRegistrar import static de.ugoe.cs.swe.scoping.TTCN3GlobalScopeProvider.* import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.* import static extension org.eclipse.xtext.EcoreUtil2.* import org.eclipse.xtext.scoping.IGlobalScopeProvider import com.google.inject.Inject import de.ugoe.cs.swe.scoping.TTCN3GlobalScopeProvider import java.util.List class ModularizationValidator extends AbstractDeclarativeValidator { val ConfigTools configTools = ConfigTools.getInstance; var QualityCheckProfile activeProfile = configTools.selectedProfile as QualityCheckProfile var ModuleContentHelper moduleHelper = new ModuleContentHelper(activeProfile) @Inject private IGlobalScopeProvider globalScopeProvider; @Check def checkModuleContainment(TTCN3Module module) { if (activeProfile.checkTypesAndValuesModuleContainmentCheck && Loading Loading @@ -111,14 +120,30 @@ class ModularizationValidator extends AbstractDeclarativeValidator { } private def boolean functionStartBehavior(FunctionDef function, TTCN3Module module) { // TODO: use alternative for UsageCrossReferencer!!! // This approach does not find all references... val references = UsageCrossReferencer.find(function, module) for (r : references) { val startTC = r.EObject.findDesiredParent(StartTCStatement) val startTimer = r.EObject.findDesiredParent(StartTimerStatement) val nestedParameter = r.EObject.findDesiredParent(FunctionInstance) val List<FunctionInstance> list = newArrayList val TTCN3GlobalScopeProvider scopeProvider = globalScopeProvider as TTCN3GlobalScopeProvider if (scopeProvider == null) { return false } synchronized ( IMPORTED_FROM ) { for (m : IMPORTED_FROM.get(module)) { for (instance : m.eAllOfType(FunctionInstance)) { val reference = instance.ref if (reference instanceof FunctionDef) { if (reference.equals(function)) { list.add(instance) } } } } } for (r : list) { val startTC = r.findDesiredParent(StartTCStatement) val startTimer = r.findDesiredParent(StartTimerStatement) val nestedParameter = r.findDesiredParent(FunctionInstance) var timer = false if (startTimer != null && startTimer.ref.findDesiredParent(TimerInstance) != null) { timer = true Loading