Commit 91eec5d5 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ fixes for != and == warnings -> !== and === when using null

parent ad47a4d3
Loading
Loading
Loading
Loading
+98 −98
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ import de.ugoe.cs.swe.tTCN3.ExtConstDef
import de.ugoe.cs.swe.tTCN3.NamedObject

class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	private final static Logger LOG = Logger.getLogger(TTCN3LocalScopeProvider);
	final static Logger LOG = Logger.getLogger(TTCN3LocalScopeProvider);

	def IScope scope_FieldSpec_ref(FieldSpec spec, EReference ref) {
		spec.scopeFieldExpressionList
@@ -83,27 +83,27 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	private def Iterable<EObject> scopeFieldReferences(FieldReference fieldRef) {
		if (fieldRef instanceof StructFieldDef) {
			if (fieldRef.type != null && fieldRef.type.ref != null) {
			if (fieldRef.type !== null && fieldRef.type.ref !== null) {
				fieldRef.type.ref.scopeReferencedFields
			} else if (fieldRef.nestedType != null) {
				if (fieldRef.nestedType != null) {
			} else if (fieldRef.nestedType !== null) {
				if (fieldRef.nestedType !== null) {
					val nType = fieldRef.nestedType.findUsedType
					if (nType != null) {
					if (nType !== null) {
						nType.scopeReferencedFields
					}
				}
			}
		} else if (fieldRef instanceof FormalValuePar) {
			if (fieldRef.type != null && fieldRef.type.ref != null) {
			if (fieldRef.type !== null && fieldRef.type.ref !== null) {
				fieldRef.type.ref.scopeReferencedFields
			}
		} else if (fieldRef instanceof UnionFieldDef) {
			if (fieldRef.type != null && fieldRef.type.ref != null) {
			if (fieldRef.type !== null && fieldRef.type.ref !== null) {
				fieldRef.type.ref.scopeReferencedFields
			} else if (fieldRef.nestedType != null) {
				if (fieldRef.nestedType != null) {
			} else if (fieldRef.nestedType !== null) {
				if (fieldRef.nestedType !== null) {
					val nType = fieldRef.nestedType.findUsedType
					if (nType != null) {
					if (nType !== null) {
						nType.scopeReferencedFields
					}
				}
@@ -113,27 +113,27 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	private def void scopeFieldReferences(FieldReference fieldRef, ArrayList<EObject> list) {
		if (fieldRef instanceof StructFieldDef) {
			if (fieldRef.type != null && fieldRef.type.ref != null) {
			if (fieldRef.type !== null && fieldRef.type.ref !== null) {
				list.addAll(fieldRef.type.ref.scopeReferencedFields)
			} else if (fieldRef.nestedType != null) {
				if (fieldRef.nestedType != null) {
			} else if (fieldRef.nestedType !== null) {
				if (fieldRef.nestedType !== null) {
					val nType = fieldRef.nestedType.findUsedType
					if (nType != null) {
					if (nType !== null) {
						list.addAll(nType.scopeReferencedFields)
					}
				}
			}
		} else if (fieldRef instanceof FormalValuePar) {
			if (fieldRef.type != null && fieldRef.type.ref != null) {
			if (fieldRef.type !== null && fieldRef.type.ref !== null) {
				list.addAll(fieldRef.type.ref.scopeReferencedFields)
			}
		} else if (fieldRef instanceof UnionFieldDef) {
			if (fieldRef.type != null && fieldRef.type.ref != null) {
			if (fieldRef.type !== null && fieldRef.type.ref !== null) {
				list.addAll(fieldRef.type.ref.scopeReferencedFields)
			} else if (fieldRef.nestedType != null) {
				if (fieldRef.nestedType != null) {
			} else if (fieldRef.nestedType !== null) {
				if (fieldRef.nestedType !== null) {
					val nType = fieldRef.nestedType.findUsedType
					if (nType != null) {
					if (nType !== null) {
						list.addAll(nType.scopeReferencedFields)
					}
				}
@@ -147,30 +147,30 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		list.addAll(field.scopeListFieldExpressionList)

		val instance = field.findDesiredParent(FunctionInstance)
		if (instance != null) {
		if (instance !== null) {
			val reference = instance.ref
			if (reference instanceof BaseTemplate) {
				for (p : reference.parList.params) {
					var TypeReference type = null
					if (p.template != null) {
					if (p.template !== null) {
						type = p.template.findVariableType
					} else if (p.value != null) {
					} else if (p.value !== null) {
						type = p.value.findVariableType
					}
					if (type != null) {
					if (type !== null) {
						list.addAll(type.scopeReferencedFields)
					}
				}
			} else if (reference instanceof FunctionDef) {
				if (reference.parameterList != null) {
				if (reference.parameterList !== null) {
					for (p : reference.parameterList.params) {
						var TypeReference type = null
						if (p.template != null) {
						if (p.template !== null) {
							type = p.template.findVariableType
						} else if (p.value != null) {
						} else if (p.value !== null) {
							type = p.value.findVariableType
						}
						if (type != null) {
						if (type !== null) {
							list.addAll(type.scopeReferencedFields)
						}
					}
@@ -194,34 +194,34 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		val cField = field.findDesiredParent(FieldConstExpressionSpec)
		val sField = field.findDesiredParent(FieldSpec)
		val constDef = field.findDesiredParent(ConstDef)
		val hasArrayAsParent = field.findDesiredParent(ArrayExpression) != null
		val hasArrayAsParent = field.findDesiredParent(ArrayExpression) !== null
		var ArrayList<EObject> list = newArrayList
		var nestedFields = newArrayList

		if (eField != null) {
		if (eField !== null) {
			list.addAll(eField.fieldRef.scopeFieldReferences)
		} else if (cField != null) {
		} else if (cField !== null) {
			list.addAll(cField.fieldRef.scopeFieldReferences)
		} else if (sField != null) {
			if (sField.ref != null) {
		} else if (sField !== null) {
			if (sField.ref !== null) {
				list.addAll(sField.ref.scopeFieldReferences)
			}
		} else if (constDef != null) {
			if (constDef.type.ref != null) {
		} else if (constDef !== null) {
			if (constDef.type.ref !== null) {
				list.addAll(constDef.type.ref.scopeReferencedFields)
			}
		} else if (inlineTemplate != null) {
			if (inlineTemplate.type != null && inlineTemplate.type.ref != null) {
		} else if (inlineTemplate !== null) {
			if (inlineTemplate.type !== null && inlineTemplate.type.ref !== null) {
				list.addAll(inlineTemplate.type.ref.templateFieldScope)
			}
		} else if (template != null) {
			if (template.base.type != null && template.base.type.ref != null) {
		} else if (template !== null) {
			if (template.base.type !== null && template.base.type.ref !== null) {
				list.addAll(template.base.type.ref.templateFieldScope)
			}
		} else if (variable != null) {
			if (variable.type != null && variable.type.ref != null) {
		} else if (variable !== null) {
			if (variable.type !== null && variable.type.ref !== null) {
				list.addAll(variable.type.ref.scopeReferencedFields)
			} else if (variable.listType != null && variable.listType.ref != null) {
			} else if (variable.listType !== null && variable.listType.ref !== null) {
				list.addAll(variable.listType.ref.scopeReferencedFields)
			}
		}
@@ -283,45 +283,45 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		val ArrayList<EObject> list = newArrayList
		var parent = variable.eContainer

		while (parent != null) {
		while (parent !== null) {
			if (parent instanceof AltstepDef) {
				if (parent.spec != null) {
				if (parent.spec !== null) {
					componentScopeValueRefs(parent.spec.component, list, true, false, false)
				}
				if (parent.params != null) {
				if (parent.params !== null) {
					list.addAll(parent.params.eAllOfType(FormalTimerPar))
				}
				for (AltstepLocalDef d : parent.local.defs) {
					if (d.timer != null) {
					if (d.timer !== null) {
						for (SingleVarInstance v : d.timer.list.variables) {
							list.add(v)
						}
					}
				}
			} else if (parent instanceof FunctionDef) {
				if (parent.runsOn != null) {
				if (parent.runsOn !== null) {
					componentScopeValueRefs(parent.runsOn.component, list, true, false, false)
				}
				if (parent.mtc != null) {
				if (parent.mtc !== null) {
					componentScopeValueRefs(parent.mtc.component, list, true, false, false)
				}
				if (parent.system != null) {
				if (parent.system !== null) {
					componentScopeValueRefs(parent.system.component, list, true, false, false)
				}
				list.addAll(parent.eAllOfType(SingleVarInstance))
				list.addAll(parent.functionLocalParameter)
            } else if (parent instanceof TestcaseDef) {
                if (parent.spec.runsOn != null) {
                if (parent.spec.runsOn !== null) {
                    componentScopeValueRefs(parent.spec.runsOn.component, list, true, false, false)
                }
                if (parent.spec.systemSpec != null) {
                if (parent.spec.systemSpec !== null) {
                    componentScopeValueRefs(parent.spec.systemSpec.component, list, true, false, false)
                }
                list.addAll(parent.eAllOfType(SingleVarInstance))
                list.addAll(parent.testcaseLocalParameter)
			} else if (parent instanceof ComponentDef) {
				for (ComponentDefList l : parent.defs) {
					if (l.element.timer != null) {
					if (l.element.timer !== null) {
						for (SingleVarInstance v : l.element.timer.list.variables) {
							list.add(v)
						}
@@ -329,7 +329,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
				}
			} else if (parent instanceof ModuleControlBody) {
				for (i : parent.list.localInst) {
					if (i.timer != null) {
					if (i.timer !== null) {
						for (SingleVarInstance v : i.timer.list.variables) {
							list.add(v)
						}
@@ -342,7 +342,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		//but why is it even necessary?
		//val function = parent.findDesiredParent(FunctionDef) // - wrong parent is already null
		//val function = variable.findDesiredParent(FunctionDef)
		//if (function != null) {
		//if (function !== null) {
			//list.addAll(function.functionLocalParameter)
		//}
		scopeFor(list)
@@ -368,7 +368,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		val ArrayList<EObject> list = newArrayList
		//TODO: does this ever hit?
		val function = altstep.findDesiredParent(FunctionDef)
		if (function != null) {
		if (function !== null) {
			list.addAll(function.functionLocalParameter)
		}
		list.addAll(altstep.altstepLocalParameter)
@@ -379,7 +379,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	def scope_StartTimerStatement_ref(AltstepDef altstep, EReference ref) {
		val ArrayList<EObject> list = newArrayList
		val function = altstep.findDesiredParent(FunctionDef)
		if (function != null) {
		if (function !== null) {
			list.addAll(function.functionLocalParameter)
		}
		list.addAll(altstep.eAllOfType(SingleVarInstance))
@@ -389,7 +389,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	def IScope scope_TimerRefOrAll_ref(TestcaseDef testcase, EReference ref) {
		val ArrayList<EObject> list = newArrayList
		val function = testcase.findDesiredParent(FunctionDef)
		if (function != null) {
		if (function !== null) {
			list.addAll(function.functionLocalParameter)
		}
		list.addAll(testcase.eAllOfType(SingleVarInstance))
@@ -399,7 +399,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	def scope_StartTimerStatement_ref(TestcaseDef testcase, EReference ref) {
		val ArrayList<EObject> list = newArrayList
		val function = testcase.findDesiredParent(FunctionDef)
		if (function != null) {
		if (function !== null) {
			list.addAll(function.functionLocalParameter)
		}
		list.addAll(testcase.eAllOfType(SingleVarInstance))
@@ -432,31 +432,31 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

		// ports from parent altsteps
		val altstep = statement.findDesiredParent(AltstepDef)
		if (altstep != null) {
		if (altstep !== null) {
			list.addAll(altstep.params.scopeParameterList)
			if (altstep.spec != null) {
			if (altstep.spec !== null) {
				componentScopePorts(altstep.spec.component, list)
			}
		}

		// ports from parent function
		val function = statement.findDesiredParent(FunctionDef)
		if (function != null) {
		if (function !== null) {
			list.addAll(function.parameterList.scopeParameterList)
			list.addAll(function.functionLocalParameter)
			if (function.runsOn != null) {
			if (function.runsOn !== null) {
				function.runsOn.component.componentScopePorts(list)
			}
			if (function.mtc != null) {
			if (function.mtc !== null) {
				function.mtc.component.componentScopePorts(list)
			}
		}

		// ports from parent testcase
		val testcase = statement.findDesiredParent(TestcaseDef)
		if (testcase != null) {
		if (testcase !== null) {
			testcase.spec.runsOn.component.componentScopePorts(list)
			if (testcase.spec.systemSpec != null) {
			if (testcase.spec.systemSpec !== null) {
				testcase.spec.systemSpec.component.componentScopePorts(list)
			}
		}
@@ -466,14 +466,14 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	private def Iterable<EObject> scopeParameterList(FunctionFormalParList parList) {
		val List<EObject> res = newArrayList

		if (parList == null)
		if (parList === null)
			return res;

		for (parameter : parList.params) {
			if (parameter.port != null) {
			if (parameter.port !== null) {
				res.add(parameter.port)
			} else if (parameter.value != null) { // TODO: FormatlValuePar and FormalPortPar are ambiguous, this hack resolves FormalValuePars as Ports too
				if (getReferencedType(parameter.value.type.ref) != null &&
			} else if (parameter.value !== null) { // TODO: FormatlValuePar and FormalPortPar are ambiguous, this hack resolves FormalValuePars as Ports too
				if (getReferencedType(parameter.value.type.ref) !== null &&
					getReferencedType(parameter.value.type.ref) instanceof PortDef) {
					res.add(parameter.value)
				}
@@ -486,11 +486,11 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

		// TODO: find type of ComponentRef
		val list = newArrayList
		if (pRef.component.ref != null) {
		if (pRef.component.ref !== null) {
			val variable = pRef.component.ref.variable.ref.referencedValue
			val reference = variable.findVariableType

			if (reference != null) {
			if (reference !== null) {
				list.addAll(reference.scopeReferencedFields)
			}
		}
@@ -538,7 +538,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	private def Iterable<EObject> directGroupTypes(GroupDef it) {
		val List<EObject> res = newArrayList
		if (list == null)
		if (list === null)
			return res

		for (ModuleDefinition g : list.definitions) {
@@ -554,19 +554,19 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	private def Iterable<EObject> directFieldTypeElements(FieldReference field) {
		if (field instanceof StructFieldDef) {
			if (field.type != null) {
			if (field.type !== null) {
				field.type.ref.scopeReferencedFields
			}
		} else if (field instanceof FormalValuePar) {
			if (field.type != null) {
			if (field.type !== null) {
				field.type.ref.scopeReferencedFields
			}
		} else if (field instanceof FormalTemplatePar) {
			if (field.type != null) {
			if (field.type !== null) {
				field.type.ref.scopeReferencedFields
			}
		} else if (field instanceof UnionFieldDef) {
			if (field.type != null) {
			if (field.type !== null) {
				field.type.ref.scopeReferencedFields
			}
		}
@@ -588,14 +588,14 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	private def IScope scope_ReferencedValueHead(EObject value, EReference ref) {
		val list = newArrayList();

		if (value == null)
		if (value === null)
			return IScope.NULLSCOPE
		
		if (value instanceof TTCN3Module) {
			value.defs.scopeModuleVariable(list)
			for (ModuleDefinition g : value.defs.definitions.filter[it.def instanceof GroupDef]) {
				val GroupDef group = g.def as GroupDef
				if (group.list != null) {
				if (group.list !== null) {
					group.list.scopeModuleVariable(list)
				}
			}
@@ -610,8 +610,8 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
			value.init.scopeInitial(list)
			scopeFor(list, value.eContainer.scope_ReferencedValueHead(ref))
		} else if (value instanceof FunctionDef) {
			if(value.parameterList != null) value.parameterList.scopeFunctionParameterValue(list)
			if (value.runsOn != null) {
			if(value.parameterList !== null) value.parameterList.scopeFunctionParameterValue(list)
			if (value.runsOn !== null) {
				value.runsOn.component.componentScopeValueRefs(list, false, true, true)
			}
			scopeFor(list, value.eContainer.scope_ReferencedValueHead(ref))
@@ -623,13 +623,13 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
			scopeFor(list, value.eContainer.scope_ReferencedValueHead(ref))
		} else if (value instanceof TestcaseDef) {
			val ComponentDef comp = value.spec.runsOn.component
			if (value.parList != null) {
			if (value.parList !== null) {
				value.parList.scopeTemplateOrValueFormalParList(list)
			}
			comp.componentScopeValueRefs(list, false, true, true)
			scopeFor(list, value.eContainer.scope_ReferencedValueHead(ref))
		} else if (value instanceof AltstepDef) {
			if (value.params != null) {
			if (value.params !== null) {
				value.params.scopeFunctionParameterValue(list)
			}
			value.scopeAltstepExtendedDefList(list)
@@ -685,45 +685,45 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	private def Iterable<EObject> directValueElements(RefValue value) {
		if (value instanceof SingleTempVarInstance) {
			val variable = value.findDesiredParent(VarInstance)
			if (variable != null && variable.type.ref != null) {
			if (variable !== null && variable.type.ref !== null) {
				variable.type.ref.scopeReferencedFields
			}
		} else if (value instanceof BaseTemplate) {
			value.type.ref.scopeReferencedFields
		} else if (value instanceof SingleVarInstance) {
			val variable = value.findDesiredParent(VarInstance)
			if (variable.listType != null && variable.listType.ref != null) {
			if (variable.listType !== null && variable.listType.ref !== null) {
				variable.listType.ref.scopeReferencedFields
			}
		} else if (value instanceof StructFieldDef) {
			if (value.type != null) {
			if (value.type !== null) {
				value.type.ref.scopeReferencedFields
			}
		} else if (value instanceof FormalValuePar) {
			if (value.type != null) {
			if (value.type !== null) {
				value.type.ref.scopeReferencedFields
			}
		} else if (value instanceof FormalTemplatePar) {
			if (value.type != null) {
			if (value.type !== null) {
				value.type.ref.scopeReferencedFields
			}
		} else if (value instanceof UnionFieldDef) {
			if (value.type != null) {
			if (value.type !== null) {
				value.type.ref.scopeReferencedFields
			}
		} else if (value instanceof ModuleParameter) {
			val variable = value.findDesiredParent(ModulePar)
			if (variable.type.ref != null) {
			if (variable.type.ref !== null) {
				variable.type.ref.scopeReferencedFields
			}
		} else if (value instanceof SingleConstDef) {
			val variable = value.findDesiredParent(ConstDef)
			if (variable.type.ref != null) {
			if (variable.type.ref !== null) {
				variable.type.ref.scopeReferencedFields
			}
        } else if (value instanceof NamedObject) {
            val variable = value.findDesiredParent(ExtConstDef)
            if (variable.type.ref != null) {
            if (variable.type.ref !== null) {
                variable.type.ref.scopeReferencedFields
            }
		}
@@ -731,19 +731,19 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	private def Iterable<EObject> directFieldElements(FieldReference field) {
		if (field instanceof StructFieldDef) {
			if (field.type != null) {
			if (field.type !== null) {
				field.type.ref.scopeReferencedFields
			}
		} else if (field instanceof FormalValuePar) {
			if (field.type != null) {
			if (field.type !== null) {
				field.type.ref.scopeReferencedFields
			}
		} else if (field instanceof FormalTemplatePar) {
			if (field.type != null) {
			if (field.type !== null) {
				field.type.ref.scopeReferencedFields
			}
		} else if (field instanceof UnionFieldDef) {
			if (field.type != null) {
			if (field.type !== null) {
				field.type.ref.scopeReferencedFields
			}
		}
@@ -754,7 +754,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		module.defs.scopeModuleVariable(list)
		for (ModuleDefinition g : module.defs.definitions.filter[it.def instanceof GroupDef]) {
			val GroupDef group = g.def as GroupDef
			if (group.list != null) {
			if (group.list !== null) {
				group.list.scopeModuleVariable(list)
			}
		}		
@@ -763,7 +763,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	
	private def Iterable<EObject> directGroupElements(GroupDef it) {
		val List<EObject> res = newArrayList
		if (list == null)
		if (list === null)
			return res

		for (ModuleDefinition g : list.definitions) {
@@ -785,11 +785,11 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	private def Iterable<RefValue> directModulePrams(ModuleParDef it) {
		val list = newArrayList
		if (it.param != null) {
		if (it.param !== null) {
			for (ModuleParameter p : param.list.params) {
				list.add(p)
			}
		} else if (it.multitypeParam != null) {
		} else if (it.multitypeParam !== null) {
			for (ModulePar p : multitypeParam.params) {
				for (ModuleParameter pa : p.list.params) {
					list.add(pa)