You've already forked v8-code-style
mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2025-12-01 01:05:51 +02:00
проверка Оператор "Перейти" не поддерживается платформой режиме веб-клиента
This commit is contained in:
@@ -387,6 +387,10 @@
|
||||
category="com.e1c.v8codestyle.bsl"
|
||||
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.comment.check.ExportProcedureCommentDescriptionCheck">
|
||||
</check>
|
||||
<check
|
||||
category="com.e1c.v8codestyle.bsl"
|
||||
class="com.e1c.v8codestyle.bsl.check.NotSupportGotoOperatorWebCheck">
|
||||
</check>
|
||||
<check
|
||||
category="com.e1c.v8codestyle.bsl"
|
||||
class="com.e1c.v8codestyle.bsl.check.OptionalFormParameterAccessCheck">
|
||||
|
||||
@@ -311,6 +311,10 @@ final class Messages
|
||||
public static String StructureCtorTooManyKeysCheck_Maximum_structure_constructor_keys;
|
||||
public static String StructureCtorTooManyKeysCheck_Structure_constructor_has_more_than__0__keys;
|
||||
public static String StructureCtorTooManyKeysCheck_title;
|
||||
|
||||
public static String NotSupportGotoOperatorWebCheck_Title;
|
||||
public static String NotSupportGotoOperatorWebCheck_Description;
|
||||
public static String NotSupportGotoOperatorWebCheck_Issue;
|
||||
|
||||
public static String NewColorCheck_Use_style_elements;
|
||||
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2025, 1C-Soft LLC and others.
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* 1C-Soft LLC - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package com.e1c.v8codestyle.bsl.check;
|
||||
|
||||
import static com._1c.g5.v8.dt.bsl.model.BslPackage.Literals.GOTO_STATEMENT;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.xtext.EcoreUtil2;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
|
||||
import com._1c.g5.v8.dt.bsl.model.GotoStatement;
|
||||
import com._1c.g5.v8.dt.bsl.model.IfPreprocessor;
|
||||
import com._1c.g5.v8.dt.bsl.model.IfPreprocessorDeclareStatement;
|
||||
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.util.BslUtil;
|
||||
import com._1c.g5.v8.dt.mcore.util.Environments;
|
||||
import com.e1c.g5.v8.dt.check.CheckComplexity;
|
||||
import com.e1c.g5.v8.dt.check.ICheckParameters;
|
||||
import com.e1c.g5.v8.dt.check.components.ModuleTopObjectNameFilterExtension;
|
||||
import com.e1c.g5.v8.dt.check.settings.IssueSeverity;
|
||||
import com.e1c.g5.v8.dt.check.settings.IssueType;
|
||||
import com.e1c.v8codestyle.check.CommonSenseCheckExtension;
|
||||
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
|
||||
|
||||
/**
|
||||
* The check Goto operator in client code
|
||||
* @author Ivan Sergeev
|
||||
*/
|
||||
|
||||
public class NotSupportGotoOperatorWebCheck
|
||||
extends AbstractModuleStructureCheck
|
||||
{
|
||||
|
||||
private static final String CHECK_ID = "not-support-goto-operator"; //$NON-NLS-1$
|
||||
|
||||
public NotSupportGotoOperatorWebCheck()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
{
|
||||
return CHECK_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCheck(CheckConfigurer builder)
|
||||
{
|
||||
builder.title(Messages.NotSupportGotoOperatorWebCheck_Title)
|
||||
.description(Messages.NotSupportGotoOperatorWebCheck_Description)
|
||||
.complexity(CheckComplexity.NORMAL)
|
||||
.severity(IssueSeverity.CRITICAL)
|
||||
.issueType(IssueType.CODE_STYLE)
|
||||
.extension(new ModuleTopObjectNameFilterExtension())
|
||||
.extension(new CommonSenseCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
|
||||
.module()
|
||||
.checkedObjectType(GOTO_STATEMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void check(Object object, ResultAcceptor resultAcceptor, ICheckParameters parameters,
|
||||
IProgressMonitor monitor)
|
||||
{
|
||||
if (object instanceof GotoStatement)
|
||||
{
|
||||
EObject eObject = (EObject)object;
|
||||
Module module = EcoreUtil2.getContainerOfType(eObject, Module.class);
|
||||
Method method = EcoreUtil2.getContainerOfType(eObject, Method.class);
|
||||
String pragmas = method.getPragmas().get(0).getSymbol();
|
||||
|
||||
if (module.getModuleType() == ModuleType.COMMON_MODULE)
|
||||
{
|
||||
if (module.environments().containsAll(Environments.ORDINARY_CLIENTS))
|
||||
{
|
||||
resultAcceptor.addIssue(Messages.NotSupportGotoOperatorWebCheck_Issue, object);
|
||||
}
|
||||
}
|
||||
else if (pragmas.toLowerCase().contains("AtClient".toLowerCase()) //$NON-NLS-1$
|
||||
|| pragmas.toLowerCase().contains("НаКлиенте".toLowerCase())) //$NON-NLS-1$
|
||||
{
|
||||
List<IfPreprocessor> allItems = BslUtil.getAllIfPreprocessorsFromBlock(method);
|
||||
if (allItems.isEmpty())
|
||||
{
|
||||
resultAcceptor.addIssue(Messages.NotSupportGotoOperatorWebCheck_Issue, object);
|
||||
return;
|
||||
}
|
||||
for (IfPreprocessor ifPreprocessor : allItems)
|
||||
{
|
||||
if (ifPreprocessor instanceof IfPreprocessorDeclareStatement)
|
||||
{
|
||||
ICompositeNode node = NodeModelUtils.findActualNodeFor(ifPreprocessor);
|
||||
if (node == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (node.getText().toLowerCase().contains("Перейти".toLowerCase())) //$NON-NLS-1$
|
||||
{
|
||||
checkPreprocessorIf(ifPreprocessor, resultAcceptor, object);
|
||||
}
|
||||
else
|
||||
{
|
||||
resultAcceptor.addIssue(Messages.NotSupportGotoOperatorWebCheck_Issue, object);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resultAcceptor.addIssue(Messages.NotSupportGotoOperatorWebCheck_Issue, object);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkPreprocessorIf(IfPreprocessor ifPreprocessor, ResultAcceptor resultAcceptor, Object object)
|
||||
{
|
||||
EList<EObject> listStatement = ifPreprocessor.eContents();
|
||||
for (EObject eObject : listStatement)
|
||||
{
|
||||
ICompositeNode node = NodeModelUtils.findActualNodeFor(eObject);
|
||||
if (node == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (node.getText().toLowerCase().contains("Перейти".toLowerCase())) //$NON-NLS-1$
|
||||
{
|
||||
if (!node.getText().toLowerCase().contains("НЕ ВебКлиент".toLowerCase()) //$NON-NLS-1$
|
||||
& !node.getText().toLowerCase().contains("NOT WebClient".toLowerCase())) //$NON-NLS-1$
|
||||
{
|
||||
resultAcceptor.addIssue(Messages.NotSupportGotoOperatorWebCheck_Issue, object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,6 +376,12 @@ NewFontCheck_Issue = To change the font you should use style elements
|
||||
|
||||
NewFontCheck_Title = Using the "New Font" construction
|
||||
|
||||
NotSupportGotoOperatorWebCheck_Title = Check not support GoTo operator in web client
|
||||
|
||||
NotSupportGotoOperatorWebCheck_Description = Check not support GoTo operator in web client
|
||||
|
||||
NotSupportGotoOperatorWebCheck_Issue = GoTo operator is not supported in the web client
|
||||
|
||||
NotifyDescriptionToServerProcedureCheck_Notify_description_procedure_should_be_export = Notify description procedure should exist and be export
|
||||
|
||||
NotifyDescriptionToServerProcedureCheck_Notify_description_to_Server_procedure = Notify description to Server procedure
|
||||
|
||||
@@ -376,6 +376,12 @@ NewFontCheck_Issue = Для изменения шрифта следует ис
|
||||
|
||||
NewFontCheck_Title = Использование конструкции "Новый Шрифт"
|
||||
|
||||
NotSupportGotoOperatorWebCheck_Title = Проверка не поддерживающегося оператора "Перейти" в веб-клиенте
|
||||
|
||||
NotSupportGotoOperatorWebCheck_Description = Проверка не поддерживающегося оператора "Перейти" в веб-клиенте
|
||||
|
||||
NotSupportGotoOperatorWebCheck_Issue = Оператор "Перейти" не поддерживается в режиме веб-клиента
|
||||
|
||||
NotifyDescriptionToServerProcedureCheck_Notify_description_procedure_should_be_export = Процедура описания оповещения должна существовать и быть экспортной
|
||||
|
||||
NotifyDescriptionToServerProcedureCheck_Notify_description_to_Server_procedure = Описание оповещения на серверную процедуру
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
#Region Abcd
|
||||
|
||||
&AtClient
|
||||
Procedure Aaaa()
|
||||
|
||||
Test = 2;
|
||||
|
||||
Goto ~Label;
|
||||
|
||||
EndProcedure
|
||||
|
||||
#EndRegion
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
#Region Abcd
|
||||
|
||||
&AtClient
|
||||
Procedure Aaaa()
|
||||
|
||||
Goto ~Label;
|
||||
A = 1;
|
||||
|
||||
EndProcedure
|
||||
|
||||
#EndRegion
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
#Region Abcd
|
||||
|
||||
&AtClient
|
||||
Procedure Aaaa()
|
||||
|
||||
#If NOT MobileClient Then
|
||||
|
||||
Goto ~Label;
|
||||
|
||||
#EndIf;
|
||||
|
||||
EndProcedure
|
||||
|
||||
#EndRegion
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
#Region Abcd
|
||||
|
||||
&AtClient
|
||||
Procedure Aaaa()
|
||||
|
||||
Goto ~Label;
|
||||
|
||||
EndProcedure
|
||||
|
||||
#EndRegion
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
#Region Abcd
|
||||
|
||||
&AtServer
|
||||
Procedure Aaaa()
|
||||
|
||||
Goto ~Label;
|
||||
|
||||
EndProcedure
|
||||
|
||||
#EndRegion
|
||||
Reference in New Issue
Block a user