Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/TTCN3Validator.xtend +73 −1 Original line number Diff line number Diff line Loading @@ -86,6 +86,9 @@ import de.ugoe.cs.swe.tTCN3.AllOrSignatureList import de.ugoe.cs.swe.tTCN3.AllOrTypeList import de.ugoe.cs.swe.tTCN3.GotoStatement import de.ugoe.cs.swe.tTCN3.LabelStatement import de.ugoe.cs.swe.tTCN3.AltConstruct import de.ugoe.cs.swe.tTCN3.PermutationMatch import de.ugoe.cs.swe.tTCN3.impl.TTCN3PackageImpl class TTCN3Validator extends AbstractTTCN3Validator { val ConfigTools configTools = ConfigTools.getInstance; Loading Loading @@ -643,6 +646,75 @@ class TTCN3Validator extends AbstractTTCN3Validator { ); } @Check def checkNoNestedAltStatements(AltConstruct alt) { if (!activeProfile.checkNoNestedAltStatements) return; val depth = alt.nestingDepth(AltConstruct) val INode node = NodeModelUtils.getNode(alt) if (depth > activeProfile.maximumAllowedNestingDepth) { val message = "Alt statement nesting depth (" + depth + ") exceeds maximum allowed nesting depth (" + activeProfile.maximumAllowedNestingDepth + ")!" warning( message, null, //TODO: add pseudo feature to mark this warning correct in eclipse editor MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.2, " + MiscTools.getMethodName() ); } } private def <T extends EObject> int nestingDepth(EObject o, Class<T> t) { var depth = -1 var parent = o do { parent = parent.findDesiredParent(t) depth++ } while (parent != null) return depth } @Check def checkNoPermutationKeyword(PermutationMatch permutation) { if (!activeProfile.checkNoPermutationKeyword) return; val INode node = NodeModelUtils.getNode(permutation) val message = "Keyword \"permutation\" is used!" warning( message, null, //TODO: add pseudo feature to mark this warning correct in eclipse editor MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.4, " + MiscTools.getMethodName() ); } @Check def checkNoAnyTypeKeyword(Type type) { if (!activeProfile.checkNoAnyTypeKeyword) return; if (type.pre != null && type.pre == 'anytype') { val INode node = NodeModelUtils.getNode(type) val message = "Keyword \"anytype\" is used!" warning( message, null, //TODO: add pseudo feature to mark this warning correct in eclipse editor MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.5, " + MiscTools.getMethodName() ); } } /** * END: Code Style ------------------------------------------------------------------------------ */ Loading Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/validation/TTCN3Validator.xtend +73 −1 Original line number Diff line number Diff line Loading @@ -86,6 +86,9 @@ import de.ugoe.cs.swe.tTCN3.AllOrSignatureList import de.ugoe.cs.swe.tTCN3.AllOrTypeList import de.ugoe.cs.swe.tTCN3.GotoStatement import de.ugoe.cs.swe.tTCN3.LabelStatement import de.ugoe.cs.swe.tTCN3.AltConstruct import de.ugoe.cs.swe.tTCN3.PermutationMatch import de.ugoe.cs.swe.tTCN3.impl.TTCN3PackageImpl class TTCN3Validator extends AbstractTTCN3Validator { val ConfigTools configTools = ConfigTools.getInstance; Loading Loading @@ -643,6 +646,75 @@ class TTCN3Validator extends AbstractTTCN3Validator { ); } @Check def checkNoNestedAltStatements(AltConstruct alt) { if (!activeProfile.checkNoNestedAltStatements) return; val depth = alt.nestingDepth(AltConstruct) val INode node = NodeModelUtils.getNode(alt) if (depth > activeProfile.maximumAllowedNestingDepth) { val message = "Alt statement nesting depth (" + depth + ") exceeds maximum allowed nesting depth (" + activeProfile.maximumAllowedNestingDepth + ")!" warning( message, null, //TODO: add pseudo feature to mark this warning correct in eclipse editor MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.2, " + MiscTools.getMethodName() ); } } private def <T extends EObject> int nestingDepth(EObject o, Class<T> t) { var depth = -1 var parent = o do { parent = parent.findDesiredParent(t) depth++ } while (parent != null) return depth } @Check def checkNoPermutationKeyword(PermutationMatch permutation) { if (!activeProfile.checkNoPermutationKeyword) return; val INode node = NodeModelUtils.getNode(permutation) val message = "Keyword \"permutation\" is used!" warning( message, null, //TODO: add pseudo feature to mark this warning correct in eclipse editor MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.4, " + MiscTools.getMethodName() ); } @Check def checkNoAnyTypeKeyword(Type type) { if (!activeProfile.checkNoAnyTypeKeyword) return; if (type.pre != null && type.pre == 'anytype') { val INode node = NodeModelUtils.getNode(type) val message = "Keyword \"anytype\" is used!" warning( message, null, //TODO: add pseudo feature to mark this warning correct in eclipse editor MessageClass.STYLE.toString, node.startLine.toString, node.endLine.toString, "6.5, " + MiscTools.getMethodName() ); } } /** * END: Code Style ------------------------------------------------------------------------------ */ Loading