1
0
mirror of https://github.com/1C-Company/v8-code-style.git synced 2025-01-20 21:18:18 +02:00

#457 Проверка ОбменДанными.Загрузка проверяет расширения (#874)

This commit is contained in:
Dmitriy Marmyshev 2021-11-22 14:09:17 +03:00 committed by GitHub
parent 79176b9615
commit 47834d6c8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<Statement> statements = method.allStatements();
List<Statement> 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<String> checkCalls)