Commit 056f57a4 authored by Daniel Honsel's avatar Daniel Honsel
Browse files

added validation for import libraries

parent 5109d2c9
Loading
Loading
Loading
Loading
+76 −4
Original line number Diff line number Diff line
@@ -1630,9 +1630,6 @@ class TTCN3Validator extends AbstractTTCN3Validator {
		return false
	}

	/**
* END: Test Suite Modularization ------------------------------------------------------------------------------
*/
	@Check
	def checkModuleSize(TTCN3Module module) {
		if (!activeProfile.checkModuleSize) {
@@ -1647,7 +1644,7 @@ class TTCN3Validator extends AbstractTTCN3Validator {
				" bytes) than the maximum allowed module size (" + referenceSize + " bytes)!"
			warning(
				message,
				null, //TODO: EStructuralFeature
				TTCN3Package.eINSTANCE.TTCN3Reference_Name,
				MessageClass.MODULARIZATION.toString,
				node.startLine.toString,
				node.endLine.toString,
@@ -1656,6 +1653,81 @@ class TTCN3Validator extends AbstractTTCN3Validator {
		}
	}

	@Check
	def checkTypesAndValuesModuleImportsLibNames(TTCN3Module module) {
		if (!activeProfile.checkTypesAndValuesModuleImportsLibNames)
			return;

		val Pattern typesAndValuesImportsLibNamesExcludedPattern = Pattern.compile(
			activeProfile.getTypesAndValuesImportsLibNamesExcludedRegExp())
		val Matcher typesAndValuesImportsLibNamesExcludedMatcher = typesAndValuesImportsLibNamesExcludedPattern.
			matcher(module.name)

		if (!module.name.contains(ModuleContentHelper.TypesAndValuesModuleIDSubstring) ||
			typesAndValuesImportsLibNamesExcludedMatcher.matches())
			return;

		val Pattern typesAndValuesImportsLibNamesPattern = Pattern.compile(
			activeProfile.getTypesAndValuesImportsLibNamesRegExp());
		var Matcher typesAndValuesImportsLibNamesMatcher = null;
		var libCommonReferenceFound = false;

		for (i : module.getAllContentsOfType(ImportDef)) {
			typesAndValuesImportsLibNamesMatcher = typesAndValuesImportsLibNamesPattern.matcher(i.moduleNamespace)
			if (typesAndValuesImportsLibNamesMatcher.matches()) {
				libCommonReferenceFound = true
			}
		}

		if (!libCommonReferenceFound) {
			val message = "Required import from \"" + activeProfile.getTypesAndValuesImportsLibNamesRegExp() +
				"\" not found!!"
			val INode node = NodeModelUtils.getNode(module)
			warning(
				message,
				TTCN3Package.eINSTANCE.TTCN3Reference_Name,
				MessageClass.MODULARIZATION.toString,
				node.startLine.toString,
				node.endLine.toString,
				"7.3, " + MiscTools.getMethodName()
			);
		}
	}

	@Check
	def checkTestcasesModuleImportsLibCommon_Sync(TTCN3Module module) {
		if (!activeProfile.checkTestcasesModuleImportsLibCommon_Sync)
			return;

		if ((!module.name.contains("Testcases")) || module.name.contains("LibCommon_Sync")) {
			return
		}

		var libCommonReferenceFound = false;

		for (i : module.getAllContentsOfType(ImportDef)) {
			if (i.moduleNamespace.contains("LibCommon_Sync")) {
				libCommonReferenceFound = true
			}
		}

		if (!libCommonReferenceFound) {
			val message = "Required import from \"LibCommon_Sync\" not found!"
			val INode node = NodeModelUtils.getNode(module)
			warning(
				message,
				TTCN3Package.eINSTANCE.TTCN3Reference_Name,
				MessageClass.MODULARIZATION.toString,
				node.startLine.toString,
				node.endLine.toString,
				"7.11, " + MiscTools.getMethodName()
			);
		}
	}

/**
* END: Test Suite Modularization ------------------------------------------------------------------------------
*/
//TODO: update error parameters
/*