Commit 70dc2ff7 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added support for considering extends in check no overspecific runs on (#75)

parent ffb71fc0
Loading
Loading
Loading
Loading
+31 −13
Original line number Diff line number Diff line
@@ -1090,39 +1090,57 @@ class CodeStyleValidator extends AbstractDeclarativeValidator {
	}

	private def boolean isReferencedComponentSpec(ComponentDef component, EObject parent) {
		val variables = component.componentMembers
        if (!activeProfile.extendsInCheckNoOverSpecificRunsOnClauses) {
		     variables.addAll(component.inheritedComponentMembers)    
		}
		
		if (parent.isReferenced2(variables)) {
			return true
		} else {
			return false
		}
	}

    private def HashSet<EObject> getInheritedComponentMembers(ComponentDef component) {
        val HashSet<EObject> inheritedVariables = Sets.newHashSet
        for (e : component.extends) {
            inheritedVariables.addAll(e.componentMembers)
            inheritedVariables.addAll(e.inheritedComponentMembers)    
        }
        return inheritedVariables
    }

    private def HashSet<EObject> getComponentMembers(ComponentDef component) {
        val HashSet<EObject> variables = Sets.newHashSet
		for (d : component.defs) {
			val element = d.element
			if (element.port != null) {
			if (element.port !== null) {
				for (p : element.port.instances) {
					variables.add(p)
				}
			} else if (element.const != null) {
			} else if (element.const !== null) {
				for (c : element.const.defs.list) {
					variables.add(c)
				}
			} else if (element.timer != null) {
			} else if (element.timer !== null) {
				for (t : element.timer.list.variables) {
					variables.add(t)
				}
			} else if (element.variable != null) {
				if (element.variable.list != null) {
			} else if (element.variable !== null) {
				if (element.variable.list !== null) {
					for (v : element.variable.list.variables) {
						variables.add(v)
					}
				}
				if (element.variable.tempList != null) {
				if (element.variable.tempList !== null) {
					for (tv : element.variable.tempList.variables) {
						variables.add(tv)
					}
				}
			}
		}
		if (parent.isReferenced2(variables)) {
			return true
		} else {
			return false
		}
        return variables
    }

	private def ArrayList<TTCN3Reference> findAllParameters(EObject parent) {
+9 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public class QualityCheckProfile extends ConfigurationProfile {
	private boolean checkNoInlineTemplates = true;
	private boolean checkNoOverSpecificRunsOnClauses = true;
	boolean recursionInCheckNoOverSpecificRunsOnClauses = true;
	private boolean extendsInCheckNoOverSpecificRunsOnClauses = false;
	private boolean checkNoUnusedImports = true;
	private boolean checkNoUnusedFormalParameters = true;
	private boolean checkNoUnusedLocalDefinitions = true;
@@ -602,6 +603,14 @@ public class QualityCheckProfile extends ConfigurationProfile {
		this.checkNoUninitialisedVariablesExclude = checkNoUninitialisedVariablesExclude;
	}

	public boolean isExtendsInCheckNoOverSpecificRunsOnClauses() {
		return extendsInCheckNoOverSpecificRunsOnClauses;
	}

	public void setExtendsInCheckNoOverSpecificRunsOnClauses(boolean extendsInCheckNoOverSpecificRunsOnClauses) {
		this.extendsInCheckNoOverSpecificRunsOnClauses = extendsInCheckNoOverSpecificRunsOnClauses;
	}

	

}