Commit 7882c56a authored by Daniel Honsel's avatar Daniel Honsel
Browse files

improved log validation

parent 742d29f7
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -7,13 +7,13 @@ import de.ugoe.cs.swe.common.logging.LoggingInterface.LogLevel
import de.ugoe.cs.swe.common.logging.LoggingInterface.MessageClass
import de.ugoe.cs.swe.tTCN3.AltstepDef
import de.ugoe.cs.swe.tTCN3.ControlStatement
import de.ugoe.cs.swe.tTCN3.ControlStatementOrDefList
import de.ugoe.cs.swe.tTCN3.ExtFunctionDef
import de.ugoe.cs.swe.tTCN3.FunctionDef
import de.ugoe.cs.swe.tTCN3.FunctionInstance
import de.ugoe.cs.swe.tTCN3.FunctionStatement
import de.ugoe.cs.swe.tTCN3.FunctionStatementList
import de.ugoe.cs.swe.tTCN3.LogStatement
import de.ugoe.cs.swe.tTCN3.ModuleControlBody
import de.ugoe.cs.swe.tTCN3.PredefinedValue
import de.ugoe.cs.swe.tTCN3.SetLocalVerdict
import de.ugoe.cs.swe.tTCN3.TTCN3Reference
@@ -33,7 +33,6 @@ import org.eclipse.xtext.validation.EValidatorRegistrar
import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.*
import static extension org.eclipse.xtext.EcoreUtil2.*

// TODO: check not resolved external function references
class LogValidator extends AbstractDeclarativeValidator {
	val ConfigTools configTools = ConfigTools.getInstance;
	var QualityCheckProfile activeProfile = configTools.selectedProfile as QualityCheckProfile
@@ -60,11 +59,11 @@ class LogValidator extends AbstractDeclarativeValidator {
	}

	@Check
	def checkLogStatementFormat(ModuleControlBody ctrl) {
	def checkLogStatementFormat(ControlStatementOrDefList ctrlStmList) {
		if (!activeProfile.checkLogStatementFormat) 
			return;

		ctrl.eContents.checkStatementList(null)
		ctrlStmList.eContents.checkStatementList(null)
	}

	private def checkStatementList(EList<EObject> statements, TTCN3Reference parent) {
@@ -173,6 +172,22 @@ class LogValidator extends AbstractDeclarativeValidator {
		val INode node = NodeModelUtils.getNode(function)
		var problemsOccured = false
		
		if (function.ref.name == null) {
			TTCN3StatisticsProvider.getInstance.incrementCountLog
			val INode functionNode = NodeModelUtils.getNode(function)
			val message = "Function definition for \"" + functionNode.text.trim +
					"\" cannot be resolved! It cannot be determined if it is an external function call!"
			info(
				message,
				null,
				MessageClass.LOGGING.toString,
				functionNode.startLine.toString,
				functionNode.endLine.toString,
				"5.3, " + MiscTools.getMethodName(),
				LogLevel.INFORMATION.toString
			);			
		}
		
		if (function.ref instanceof ExtFunctionDef) {
			val parent = function.findDesiredParent(FunctionStatement)
			val parentList = function.findDesiredParent(FunctionStatementList)