Commit 74b2676f authored by Philip Makedonski's avatar Philip Makedonski
Browse files

* refinements to checkNoValueOfForValue

parent 1345e46f
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ import de.ugoe.cs.swe.tTCN3.TimerRefOrAny
import de.ugoe.cs.swe.tTCN3.Type
import de.ugoe.cs.swe.tTCN3.TypeDef
import de.ugoe.cs.swe.tTCN3.UnionDefNamed
import de.ugoe.cs.swe.tTCN3.Value
import de.ugoe.cs.swe.tTCN3.ValueofOp
import de.ugoe.cs.swe.tTCN3.VarList
import java.util.ArrayList
import java.util.HashMap
@@ -86,8 +88,8 @@ import static extension de.ugoe.cs.swe.common.TTCN3ReferenceHelper.*
import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.*
import static extension org.eclipse.emf.ecore.util.EcoreUtil.*
import static extension org.eclipse.xtext.EcoreUtil2.*
import de.ugoe.cs.swe.tTCN3.ValueofOp
import de.ugoe.cs.swe.tTCN3.Value
import org.eclipse.xtext.EcoreUtil2.ElementReferenceAcceptor
import org.eclipse.emf.ecore.EReference

class CheckDefinitionComeFirstParameter {
	public boolean hasOtherDefinitions
@@ -870,13 +872,19 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {
	@Check
	def checkNoValueOfForValues(ValueofOp templateOp) {
		//TODO: add property, update version
//		if (!activeProfile.checkNoValueOfForValues)
//			return;
		if (!activeProfile.checkNoValueOfForValues)
			return;

		// only consider templates with a type
		
//		if (template.type == null)
//			return;
		//guards
		if (templateOp.template.template.simple === null ||
			templateOp.template.template.simple.expr === null
		) {
			return
		}
		//TODO: overly specific.. 
		val expr = templateOp.template.template.simple.expr
//		.ref.head
@@ -885,13 +893,16 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {
				if (expr.ref.referencedValue instanceof SingleTempVarInstance) {
					return
				}
				if (expr.ref.referencedValue instanceof FormalTemplatePar) {
					return
				}
				//TODO: other conditions?
			} else {
				//TODO: check further?
				return
			}
		} else {
			//TODO: check further?
			//TODO: check further? e.g. function return types?
			return
		}
		statistics.incrementCountStyle
@@ -1017,6 +1028,7 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {
				info(
					message,
					f,
//					consideredAltOrFunc.first,
					null,
					MessageClass.STYLE.toString,
					node.startLine.toString,