Commit 6a1976ab authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ initial implementation for checkNoValueOfForValues, #7

parent fa020b70
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -86,6 +86,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

class CheckDefinitionComeFirstParameter {
	public boolean hasOtherDefinitions
@@ -865,6 +867,48 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {
		return !found
	}

	@Check
	def checkNoValueOfForValues(ValueofOp templateOp) {
		//TODO: add property, update version
//		if (!activeProfile.checkNoValueOfForValues)
//			return;

		// only consider templates with a type
		
//		if (template.type == null)
//			return;
		//TODO: overly specific.. 
		val expr = templateOp.template.template.simple.expr
//		.ref.head
		if (expr instanceof Value) {
			if (expr.ref !== null) {
				if (expr.ref.referencedValue instanceof SingleTempVarInstance) {
					return
				}
				//TODO: other conditions?
			} else {
				//TODO: check further?
				return
			}
		} else {
			//TODO: check further?
			return
		}
		statistics.incrementCountStyle

		val message = "ValueOf operation is used on a value!"
		val INode node = NodeModelUtils.getNode(templateOp)
		warning(
			message,
			null,
			MessageClass.STYLE.toString,
			node.startLine.toString,
			node.endLine.toString,
			//TODO: add proper section id
			"6.XX, " + MiscTools.getMethodName()
		);
	}

	@Check
	def checkNoInlineTemplates(InLineTemplate template) {
		if (!activeProfile.checkNoInlineTemplates)