Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/CodeStyleValidator.xtend +69 −1 Original line number Diff line number Diff line Loading @@ -78,6 +78,8 @@ import com.google.inject.Inject import de.ugoe.cs.swe.scoping.TTCN3GlobalScopeProvider import de.ugoe.cs.swe.scoping.ImportData import java.util.Set import de.ugoe.cs.swe.tTCN3.TempVarList import de.ugoe.cs.swe.tTCN3.VarList class CheckDefinitionComeFirstParameter { public boolean hasOtherDefinitions Loading Loading @@ -160,6 +162,72 @@ class CodeStyleValidator extends AbstractDeclarativeValidator { } } @Check def checkNestedCalls(FunctionInstance instance) { // TODO: configuration for check and number of allowed nested calls val maxLevel = 3; var depth = 1; var parent = instance; do { parent = parent.findDesiredParent(FunctionInstance) if (parent != null && (parent.ref instanceof FunctionDef || parent.ref instanceof BaseTemplate)) { depth++ } } while (parent != null) val INode node = NodeModelUtils.getNode(instance) if (depth > maxLevel) { statistics.incrementCountStyle val message = "Level of nested functions (" + depth + ") exceeds maximum allowed nesting depth (" + maxLevel + ")!" warning( message, null, MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.20, " + MiscTools.getMethodName() ); } } @Check def checkListedVariableDeclarations(TempVarList list) { // TODO: configuration for check if (list.variables.size > 1) { statistics.incrementCountStyle val message = "Listed variable declarations are used!" val INode node = NodeModelUtils.getNode(list) warning( message, null, MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.21, " + MiscTools.getMethodName() ); } } @Check def checkListedVariableDeclarations(VarList list) { // TODO: configuration for check if (list.variables.size > 1) { statistics.incrementCountStyle val message = "Listed variable declarations are used!" val INode node = NodeModelUtils.getNode(list) warning( message, null, MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.21, " + MiscTools.getMethodName() ); } } private def <T extends EObject> int nestingDepth(EObject o, Class<T> t) { var depth = -1 var parent = o Loading Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/CodeStyleValidator.xtend +69 −1 Original line number Diff line number Diff line Loading @@ -78,6 +78,8 @@ import com.google.inject.Inject import de.ugoe.cs.swe.scoping.TTCN3GlobalScopeProvider import de.ugoe.cs.swe.scoping.ImportData import java.util.Set import de.ugoe.cs.swe.tTCN3.TempVarList import de.ugoe.cs.swe.tTCN3.VarList class CheckDefinitionComeFirstParameter { public boolean hasOtherDefinitions Loading Loading @@ -160,6 +162,72 @@ class CodeStyleValidator extends AbstractDeclarativeValidator { } } @Check def checkNestedCalls(FunctionInstance instance) { // TODO: configuration for check and number of allowed nested calls val maxLevel = 3; var depth = 1; var parent = instance; do { parent = parent.findDesiredParent(FunctionInstance) if (parent != null && (parent.ref instanceof FunctionDef || parent.ref instanceof BaseTemplate)) { depth++ } } while (parent != null) val INode node = NodeModelUtils.getNode(instance) if (depth > maxLevel) { statistics.incrementCountStyle val message = "Level of nested functions (" + depth + ") exceeds maximum allowed nesting depth (" + maxLevel + ")!" warning( message, null, MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.20, " + MiscTools.getMethodName() ); } } @Check def checkListedVariableDeclarations(TempVarList list) { // TODO: configuration for check if (list.variables.size > 1) { statistics.incrementCountStyle val message = "Listed variable declarations are used!" val INode node = NodeModelUtils.getNode(list) warning( message, null, MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.21, " + MiscTools.getMethodName() ); } } @Check def checkListedVariableDeclarations(VarList list) { // TODO: configuration for check if (list.variables.size > 1) { statistics.incrementCountStyle val message = "Listed variable declarations are used!" val INode node = NodeModelUtils.getNode(list) warning( message, null, MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.21, " + MiscTools.getMethodName() ); } } private def <T extends EObject> int nestingDepth(EObject o, Class<T> t) { var depth = -1 var parent = o Loading