diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/check/EventDataExchangeLoadCheck.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/check/EventDataExchangeLoadCheck.java index 2b5205f3..61e35851 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/check/EventDataExchangeLoadCheck.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/check/EventDataExchangeLoadCheck.java @@ -12,6 +12,7 @@ *******************************************************************************/ package com.e1c.v8codestyle.bsl.check; +import static com._1c.g5.v8.dt.bsl.common.Symbols.ANNOTATION_SYMBOLS; import static com._1c.g5.v8.dt.bsl.model.BslPackage.Literals.CONDITIONAL__PREDICATE; import static com._1c.g5.v8.dt.bsl.model.BslPackage.Literals.PROCEDURE; import static com._1c.g5.v8.dt.mcore.McorePackage.Literals.NAMED_ELEMENT__NAME; @@ -36,13 +37,15 @@ import com._1c.g5.v8.dt.bsl.model.Expression; import com._1c.g5.v8.dt.bsl.model.FeatureAccess; import com._1c.g5.v8.dt.bsl.model.IfStatement; import com._1c.g5.v8.dt.bsl.model.Invocation; -import com._1c.g5.v8.dt.bsl.model.Method; import com._1c.g5.v8.dt.bsl.model.Module; import com._1c.g5.v8.dt.bsl.model.ModuleType; +import com._1c.g5.v8.dt.bsl.model.Pragma; import com._1c.g5.v8.dt.bsl.model.Procedure; import com._1c.g5.v8.dt.bsl.model.ReturnStatement; import com._1c.g5.v8.dt.bsl.model.Statement; import com._1c.g5.v8.dt.bsl.model.StaticFeatureAccess; +import com._1c.g5.v8.dt.common.StringUtils; +import com._1c.g5.v8.dt.lcore.util.CaseInsensitiveString; import com.e1c.g5.v8.dt.check.CheckComplexity; import com.e1c.g5.v8.dt.check.ICheckParameters; import com.e1c.g5.v8.dt.check.components.BasicCheck; @@ -113,22 +116,21 @@ public class EventDataExchangeLoadCheck protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters, IProgressMonitor monitor) { - if (monitor.isCanceled() || !(object instanceof Procedure) || !((Procedure)object).isEvent() - || !isNecessaryMethod((Procedure)object)) + Procedure procedure = (Procedure)object; + + if (!isNecessaryEventHandler(procedure)) { return; } - Procedure method = (Procedure)object; - - Module module = EcoreUtil2.getContainerOfType(method, Module.class); + Module module = EcoreUtil2.getContainerOfType(procedure, Module.class); if (!checkModuleType(module)) { return; } - List statements = method.allStatements(); + List statements = procedure.allStatements(); if (statements.isEmpty()) { return; @@ -165,15 +167,29 @@ public class EventDataExchangeLoadCheck String message = MessageFormat.format( Messages.EventDataExchangeLoadCheck_Mandatory_checking_of_DataExchangeLoad_is_absent_in_event_handler_0, - method.getName()); + procedure.getName()); resultAceptor.addIssue(message, NAMED_ELEMENT__NAME); } - private boolean isNecessaryMethod(Method method) + private boolean isNecessaryEventHandler(Procedure procedure) { - return DEFAULT_NAMES.contains(method.getName()); + if (!procedure.isEvent()) + { + return false; + } + + for (Pragma pragma : procedure.getPragmas()) + { + if (ANNOTATION_SYMBOLS.contains(new CaseInsensitiveString(pragma.getSymbol())) + && StringUtils.isNotEmpty(pragma.getValue()) + && DEFAULT_NAMES.contains(pragma.getValue().replace("\"", ""))) //$NON-NLS-1$ //$NON-NLS-2$ + { + return true; + } + } + return DEFAULT_NAMES.contains(procedure.getName()); } private boolean isDataExchangeLoadChecking(IfStatement statementMethod, Set checkCalls)