1
0
mirror of https://github.com/1C-Company/v8-code-style.git synced 2025-01-06 00:33:23 +02:00

#310: Проверка избыточного обращения внутри модуля к самому себе

This commit is contained in:
Maxim Galios 2022-04-20 15:15:38 +07:00
parent 76bf42235c
commit 2a64ca5dcc
84 changed files with 2064 additions and 3 deletions

View File

@ -21,7 +21,7 @@
#### Код модулей
- Избыточное обращение внутри модуля через его имя или псевдоним ЭтотОбъект (к методу, свойству или реквизиту)
#### Запросы

View File

@ -349,6 +349,18 @@
<fix class="com.e1c.v8codestyle.internal.bsl.ui.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.ui.qfix.UndefinedMethodFix"/>
<fix class="com.e1c.v8codestyle.internal.bsl.ui.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.ui.qfix.UndefinedFunctionFix"/>
<fix class="com.e1c.v8codestyle.internal.bsl.ui.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.ui.qfix.UndefinedVariableFix"/>
<fix
class="com.e1c.v8codestyle.internal.bsl.ui.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.ui.qfix.SelfReferenceFix">
</fix>
<fix
class="com.e1c.v8codestyle.internal.bsl.ui.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.ui.qfix.FormSelfReferenceOutdatedFix">
</fix>
<fix
class="com.e1c.v8codestyle.internal.bsl.ui.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.ui.qfix.CommonModuleNamedSelfReferenceFix">
</fix>
<fix
class="com.e1c.v8codestyle.internal.bsl.ui.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.ui.qfix.ManagerModuleNamedSelfReferenceFix">
</fix>
</extension>
</plugin>

View File

@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (C) 2022, 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.ui.qfix;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.resource.XtextResource;
import com._1c.g5.v8.dt.bsl.model.StaticFeatureAccess;
import com.e1c.g5.v8.dt.check.qfix.components.QuickFix;
import com.e1c.v8codestyle.bsl.qfix.external.IXtextBslModuleFixModel;
import com.e1c.v8codestyle.bsl.qfix.external.SingleVariantXtextBslModuleFix;
/**
* Quick fix for check com.e1c.v8codestyle.bsl.check:common-module-named-self-reference
*
* @author Maxim Galios
*
*/
@QuickFix(checkId = "common-module-named-self-reference", supplierId = "com.e1c.v8codestyle.bsl")
public class CommonModuleNamedSelfReferenceFix
extends SingleVariantXtextBslModuleFix
{
@Override
protected void configureFix(FixConfigurer configurer)
{
configurer.interactive(true)
.description(Messages.CommonModuleNamedSelfReferenceFix_description)
.details(Messages.CommonModuleNamedSelfReferenceFix_details);
}
@Override
protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException
{
EObject element = model.getElement();
if (!(element instanceof StaticFeatureAccess))
{
return null;
}
INode node = NodeModelUtils.findActualNodeFor(element);
return new DeleteEdit(node.getOffset(), node.getLength() + 1);
}
}

View File

@ -0,0 +1,67 @@
/*******************************************************************************
* Copyright (C) 2022, 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.ui.qfix;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.resource.XtextResource;
import com._1c.g5.v8.dt.bsl.model.StaticFeatureAccess;
import com.e1c.g5.v8.dt.check.qfix.components.QuickFix;
import com.e1c.v8codestyle.bsl.qfix.external.IXtextBslModuleFixModel;
import com.e1c.v8codestyle.bsl.qfix.external.SingleVariantXtextBslModuleFix;
/**
* Quick fix for check com.e1c.v8codestyle.bsl.check:form-self-reference-outdated
*
* @author Maxim Galios
*
*/
@QuickFix(checkId = "form-self-reference", supplierId = "com.e1c.v8codestyle.bsl")
public class FormSelfReferenceOutdatedFix
extends SingleVariantXtextBslModuleFix
{
private static final String OUTDATED_SELF_REFERENCE = "ThisForm"; //$NON-NLS-1$
private static final String SELF_REFERENCE = "ThisObject"; //$NON-NLS-1$
private static final String SELF_REFERENCE_RU = "ЭтотОбъект"; //$NON-NLS-1$
@Override
protected void configureFix(FixConfigurer configurer)
{
configurer.interactive(true)
.description(Messages.FormSelfReferenceOutdatedFix_description)
.details(Messages.FormSelfReferenceOutdatedFix_details);
}
@Override
protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException
{
EObject element = model.getElement();
if (!(element instanceof StaticFeatureAccess))
{
return null;
}
StaticFeatureAccess staticFeatureAccess = (StaticFeatureAccess) element;
String name = staticFeatureAccess.getName();
String replacement = name.equals(OUTDATED_SELF_REFERENCE) ? SELF_REFERENCE : SELF_REFERENCE_RU;
INode node = NodeModelUtils.findActualNodeFor(element);
return new ReplaceEdit(node.getOffset(), node.getLength(), replacement);
}
}

View File

@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (C) 2022, 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.ui.qfix;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.resource.XtextResource;
import com._1c.g5.v8.dt.bsl.model.DynamicFeatureAccess;
import com.e1c.g5.v8.dt.check.qfix.components.QuickFix;
import com.e1c.v8codestyle.bsl.qfix.external.IXtextBslModuleFixModel;
import com.e1c.v8codestyle.bsl.qfix.external.SingleVariantXtextBslModuleFix;
/**
* Quick fix for check com.e1c.v8codestyle.bsl.check:common-module-named-self-reference
*
* @author Maxim Galios
*
*/
@QuickFix(checkId = "manager-module-named-self-reference", supplierId = "com.e1c.v8codestyle.bsl")
public class ManagerModuleNamedSelfReferenceFix
extends SingleVariantXtextBslModuleFix
{
@Override
protected void configureFix(FixConfigurer configurer)
{
configurer.interactive(true)
.description(Messages.ManagerModuleNamedSelfReferenceFix_description)
.details(Messages.ManagerModuleNamedSelfReferenceFix_details);
}
@Override
protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException
{
EObject element = model.getElement();
if (!(element instanceof DynamicFeatureAccess))
{
return null;
}
INode node = NodeModelUtils.findActualNodeFor(element);
return new DeleteEdit(node.getOffset(), node.getLength() + 1);
}
}

View File

@ -24,10 +24,26 @@ final class Messages
{
private static final String BUNDLE_NAME = "com.e1c.v8codestyle.bsl.ui.qfix.messages"; //$NON-NLS-1$
public static String CommonModuleNamedSelfReferenceFix_description;
public static String CommonModuleNamedSelfReferenceFix_details;
public static String FormSelfReferenceOutdatedFix_description;
public static String FormSelfReferenceOutdatedFix_details;
public static String ManagerModuleNamedSelfReferenceFix_description;
public static String ManagerModuleNamedSelfReferenceFix_details;
public static String OpenBslDocCommentViewFix_Description;
public static String OpenBslDocCommentViewFix_Details;
public static String SelfReferenceFix_description;
public static String SelfReferenceFix_details;
public static String UndefinedMethodFix_func_title;
public static String UndefinedMethodFix_func_desc;
public static String UndefinedMethodFix_proc_title;

View File

@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (C) 2022, 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.ui.qfix;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.resource.XtextResource;
import com._1c.g5.v8.dt.bsl.model.StaticFeatureAccess;
import com.e1c.g5.v8.dt.check.qfix.components.QuickFix;
import com.e1c.v8codestyle.bsl.qfix.external.IXtextBslModuleFixModel;
import com.e1c.v8codestyle.bsl.qfix.external.SingleVariantXtextBslModuleFix;
/**
* Quick fix for check com.e1c.v8codestyle.bsl.check:self-reference
*
* @author Maxim Galios
*
*/
@QuickFix(checkId = "module-self-reference", supplierId = "com.e1c.v8codestyle.bsl")
public class SelfReferenceFix
extends SingleVariantXtextBslModuleFix
{
@Override
protected void configureFix(FixConfigurer configurer)
{
configurer.interactive(true)
.description(Messages.SelfReferenceFix_description)
.details(Messages.SelfReferenceFix_details);
}
@Override
protected TextEdit fixIssue(XtextResource state, IXtextBslModuleFixModel model) throws BadLocationException
{
EObject element = model.getElement();
if (!(element instanceof StaticFeatureAccess))
{
return null;
}
INode node = NodeModelUtils.findActualNodeFor(element);
return new DeleteEdit(node.getOffset(), node.getLength() + 1);
}
}

View File

@ -1,5 +1,3 @@
OpenBslDocCommentViewFix_Details=Open documentation comment data structure view and show current probleme object.
#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
###############################################################################
# Copyright (C) 2022, 1C-Soft LLC and others.
@ -15,7 +13,16 @@ OpenBslDocCommentViewFix_Details=Open documentation comment data structure view
# Vadim Geraskin - initial contibution
###############################################################################
CommonModuleNamedSelfReferenceFix_details=Remove excessive named self reference in common module
CommonModuleNamedSelfReferenceFix_description=Remove excessive named self reference
FormSelfReferenceOutdatedFix_description=Replace outdated self reference
FormSelfReferenceOutdatedFix_details=Replace outdated "ThisForm" alias with "ThisObject" alias
ManagerModuleNamedSelfReferenceFix_description=Remove excessive named self reference
ManagerModuleNamedSelfReferenceFix_details=Remove excessive named self reference from manager module
OpenBslDocCommentViewFix_Details=Open documentation comment data structure view and show current probleme object.
OpenBslDocCommentViewFix_Description=Open documentation comment structure view
SelfReferenceFix_description=Remove excessive self reference
SelfReferenceFix_details=Remove excessive self reference
UndefinedMethodFix_func_title=Create function
UndefinedMethodFix_func_desc=Create a new function in the module
UndefinedMethodFix_proc_title=Create procedure

View File

@ -13,10 +13,22 @@
# Vadim Geraskin - initial contibution
###############################################################################
CommonModuleNamedSelfReferenceFix_details=Удалить избыточное обращение внутри общего модуля по имени
CommonModuleNamedSelfReferenceFix_description=Удалить избыточное обращение внутри модуля по имени
FormSelfReferenceOutdatedFix_description=Заменить устаревшее обращение
FormSelfReferenceOutdatedFix_details=Заменить устаревший псевдоним "ЭтаФорма" на псевдоним "ЭтотОбъект"
OpenBslDocCommentViewFix_Description = Открыть панель структуры документирующего комментария
OpenBslDocCommentViewFix_Details = Открыть панель структуры документирующего комментария и показать текущий проблемный объект.
SelfReferenceFix_description=Удалить избыточное обращение внутри модуля через псевдоним "ЭтотОбъект"
SelfReferenceFix_details=Удалить избыточное обращение внутри модуля через псевдоним "ЭтотОбъект"
UndefinedMethodFix_func_desc = Создать новую функцию в модуле
UndefinedMethodFix_func_title = Создать функцию

View File

@ -0,0 +1,47 @@
# Excessive named self reference in common module
Excessive usage of named self reference in common module (when referencing method, property or attribute).
For cached modules self reference is allowed.
## Noncompliant Code Example
Inside common module named "MyModule":
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
MyModule.myParam = MyModule.test();
```
## Compliant Solution
Inside common module named "MyModule":
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
myParam = test();
```
Inside common module named "MyModuleCached":
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
myParam = MyModuleCached.test();
```
## See

View File

@ -0,0 +1,30 @@
# Outdated alias used
Usage of outdated self reference `ThisForm` (when referencing method, property or attribute)
## Noncompliant Code Example
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
ThisForm.myParam = ThisForm.test();
```
## Compliant Solution
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
ThisObject.myParam = ThisObject.test();
```
## See

View File

@ -0,0 +1,34 @@
# Excessive named self reference in manager module
Excessive usage of named self reference in manager module (when referencing method, property or attribute).
## Noncompliant Code Example
Inside Catalog manager module named "MyCatalog":
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
Catalog.MyCatalog.myParam = Catalog.MyCatalog.test();
```
## Compliant Solution
Inside Catalog manager module named "MyCatalog":
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
myParam = test();
```
## See

View File

@ -0,0 +1,33 @@
# Self reference is excessive
Excessive usage of self reference with use of `ThisObject` (when referencing method, property or attribute)
For form modules only check self reference for methods and existing properties
(if `Check only existing form properties` parameter is set, otherwise, check for all cases)
## Noncompliant Code Example
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
ThisObject.myParam = ThisObject.test();
```
## Compliant Solution
```bsl
Var myParam;
Function test() Export
// code here
EndFunction
myParam = test();
```
## See

View File

@ -0,0 +1,46 @@
# Избыточное обращение по собственному имени внутри общего модуля
Избыточное обращение по собственному имени внутри общего модуля (к методу, свойству или реквизиту)
Для модулей с повторным использованием возвращаемых значений обращение по собственному имени разрешено
## Неправильно
Внутри модуля с именем "МойМодуль":
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
МойМодуль.мояПеременная = МойМодуль.тест();
```
## Правильно
Внутри модуля с именем "МойМодуль":
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
мояПеременная = тест();
```
Внутри модуля с именем "МойМодульПовтИсп":
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
мояПеременная = МойМодульПовтИсп.тест();
```
## См.

View File

@ -0,0 +1,29 @@
# Использование устаревшего псевдонима
Следует использовать псевдоним "ЭтотОбъект" вместо устаревшего "ЭтаФорма" в модуле формы
## Неправильно
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
ЭтаФорма.мояПеременная = ЭтаФорма.тест();
```
## Правильно
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
ЭтотОбъект.мояПеременная = ЭтотОбъект.тест();
```
## См.

View File

@ -0,0 +1,32 @@
# Избыточное обращение по собственному имени внутри модуля менеджера
Избыточное обращение по собственному имени внутри модуля менеджера (к методу, свойству или реквизиту)
## Неправильно
Внутри модуля модуля менеджера типа Справочники с именем "МойСправочник":
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
Справочники.МойСправочник.мояПеременная = Справочники.МойСправочник.тест();
```
## Правильно
Внутри модуля модуля менеджера типа Справочники с именем "МойСправочник":
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
мояПеременная = тест();
```
## См.

View File

@ -0,0 +1,32 @@
# Избыточное использование псевдонима "ЭтотОбъект"
Избыточное обращение внутри модуля через псевдоним "ЭтотОбъект" (к методу, свойству или реквизиту)
Для модулей форм проверяется только обращение к методам и существующим свойствам
(в случае если установлен параметр `Проверять только существовующие свойства в форме`, инчае проверяются все случаи)
## Неправильно
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
ЭтотОбъект.мояПеременная = ЭтотОбъект.тест();
```
## Правильно
```bsl
Парам мояПеременная;
Функция тест() Экспорт
// код
КонецФункции
мояПеременная = тест();
```
## См.

View File

@ -239,6 +239,22 @@
category="com.e1c.v8codestyle.bsl"
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.check.LockOutOfTryCheck">
</check>
<check
category="com.e1c.v8codestyle.bsl"
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.check.SelfReferenceCheck">
</check>
<check
category="com.e1c.v8codestyle.bsl"
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.check.FormSelfReferenceOutdatedCheck">
</check>
<check
category="com.e1c.v8codestyle.bsl"
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.check.CommonModuleNamedSelfReferenceCheck">
</check>
<check
category="com.e1c.v8codestyle.bsl"
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.check.ManagerModuleNamedSelfReferenceCheck">
</check>
</extension>
<extension

View File

@ -0,0 +1,96 @@
/*******************************************************************************
* Copyright (C) 2022, 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.DYNAMIC_FEATURE_ACCESS;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.xtext.EcoreUtil2;
import com._1c.g5.v8.dt.bsl.model.DynamicFeatureAccess;
import com._1c.g5.v8.dt.bsl.model.Expression;
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.StaticFeatureAccess;
import com._1c.g5.v8.dt.common.StringUtils;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
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;
import com.e1c.g5.v8.dt.check.settings.IssueSeverity;
import com.e1c.g5.v8.dt.check.settings.IssueType;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
/**
* Check self references by name in common modules.
* Modules with "ПовтИсп/Cached" in name can be self referenced.
*
* @author Maxim Galios
*
*/
public class CommonModuleNamedSelfReferenceCheck
extends BasicCheck
{
private static final String CHECK_ID = "common-module-named-self-reference"; //$NON-NLS-1$
@Override
public String getCheckId()
{
return CHECK_ID;
}
@Override
protected void configureCheck(CheckConfigurer builder)
{
builder.title(Messages.CommonModuleNamedSelfReferenceCheck_title)
.description(Messages.CommonModuleNamedSelfReferenceCheck_description)
.complexity(CheckComplexity.NORMAL)
.severity(IssueSeverity.MINOR)
.issueType(IssueType.CODE_STYLE)
.extension(new StandardCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
.module()
.checkedObjectType(DYNAMIC_FEATURE_ACCESS);
}
@Override
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
IProgressMonitor monitor)
{
Expression featureAccessSource = ((DynamicFeatureAccess)object).getSource();
if (monitor.isCanceled() || !(featureAccessSource instanceof StaticFeatureAccess))
{
return;
}
StaticFeatureAccess source = (StaticFeatureAccess)featureAccessSource;
if (isReferenceExcessive(source))
{
resultAceptor.addIssue(Messages.CommonModuleNamedSelfReferenceCheck_issue, source);
}
}
private boolean isReferenceExcessive(StaticFeatureAccess source)
{
Module module = EcoreUtil2.getContainerOfType(source, Module.class);
if (module.getModuleType() != ModuleType.COMMON_MODULE)
{
return false;
}
CommonModule commonModule = (CommonModule)module.getOwner();
return (commonModule.getReturnValuesReuse() == ReturnValuesReuse.DONT_USE)
&& StringUtils.equals(commonModule.getName(), source.getName());
}
}

View File

@ -0,0 +1,91 @@
/*******************************************************************************
* Copyright (C) 2022, 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.DYNAMIC_FEATURE_ACCESS;
import java.util.Collection;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.xtext.EcoreUtil2;
import com._1c.g5.v8.dt.bsl.model.DynamicFeatureAccess;
import com._1c.g5.v8.dt.bsl.model.Expression;
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.StaticFeatureAccess;
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;
import com.e1c.g5.v8.dt.check.settings.IssueSeverity;
import com.e1c.g5.v8.dt.check.settings.IssueType;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
/**
* Check oudated self references in from modules. Outdated are references with "ЭтаФорма/ThisForm".
*
* @author Maxim Galios
*
*/
public class FormSelfReferenceOutdatedCheck
extends BasicCheck
{
private static final String CHECK_ID = "form-self-reference"; //$NON-NLS-1$
private static final Collection<String> OUTDATED_ALIASES = Set.of("ЭтаФорма", "ThisForm"); //$NON-NLS-1$ //$NON-NLS-2$
@Override
public String getCheckId()
{
return CHECK_ID;
}
@Override
protected void configureCheck(CheckConfigurer builder)
{
builder.title(Messages.FormSelfReferenceOutdatedCheck_Title)
.description(Messages.FormSelfReferenceOutdatedCheck_Description)
.complexity(CheckComplexity.NORMAL)
.severity(IssueSeverity.MINOR)
.issueType(IssueType.CODE_STYLE)
.extension(new StandardCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
.module()
.checkedObjectType(DYNAMIC_FEATURE_ACCESS);
}
@Override
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
IProgressMonitor monitor)
{
Expression featureAccessSource = ((DynamicFeatureAccess)object).getSource();
if (monitor.isCanceled() || !(featureAccessSource instanceof StaticFeatureAccess))
{
return;
}
StaticFeatureAccess source = (StaticFeatureAccess)featureAccessSource;
if (isAliasOutdated(source))
{
resultAceptor.addIssue(Messages.FormSelfReferenceOutdatedCheck_Issue, source);
}
}
private boolean isAliasOutdated(StaticFeatureAccess source)
{
Module module = EcoreUtil2.getContainerOfType(source, Module.class);
return module.getModuleType() == ModuleType.FORM_MODULE && OUTDATED_ALIASES.contains(source.getName());
}
}

View File

@ -0,0 +1,120 @@
/*******************************************************************************
* Copyright (C) 2022, 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.DYNAMIC_FEATURE_ACCESS;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.resource.IResourceServiceProvider;
import com._1c.g5.v8.dt.bsl.documentation.comment.LinkPart;
import com._1c.g5.v8.dt.bsl.model.DynamicFeatureAccess;
import com._1c.g5.v8.dt.bsl.model.Expression;
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.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;
import com.e1c.g5.v8.dt.check.settings.IssueSeverity;
import com.e1c.g5.v8.dt.check.settings.IssueType;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
/**
* CHeck self reference by name in manager modules.
*
* @author Maxim Galios
*
*/
public class ManagerModuleNamedSelfReferenceCheck
extends BasicCheck
{
private static final String CHECK_ID = "manager-module-named-self-reference"; //$NON-NLS-1$
private final IQualifiedNameProvider bslQualifiedNameProvider;
public ManagerModuleNamedSelfReferenceCheck()
{
super();
IResourceServiceProvider resourceServiceProvider =
IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(URI.createURI("*.bsl")); //$NON-NLS-1$
this.bslQualifiedNameProvider = resourceServiceProvider.get(IQualifiedNameProvider.class);
}
@Override
public String getCheckId()
{
return CHECK_ID;
}
@Override
protected void configureCheck(CheckConfigurer builder)
{
builder.title(Messages.ManagerModuleNamedSelfReferenceCheck_title)
.description(Messages.ManagerModuleNamedSelfReferenceCheck_description)
.complexity(CheckComplexity.NORMAL)
.severity(IssueSeverity.MINOR)
.issueType(IssueType.CODE_STYLE)
.extension(new StandardCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
.module()
.checkedObjectType(DYNAMIC_FEATURE_ACCESS);
}
@Override
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
IProgressMonitor monitor)
{
Expression featureAccessSource = ((DynamicFeatureAccess)object).getSource();
Module module = EcoreUtil2.getContainerOfType(featureAccessSource, Module.class);
if (monitor.isCanceled() || !(featureAccessSource instanceof DynamicFeatureAccess)
|| module.getModuleType() != ModuleType.MANAGER_MODULE)
{
return;
}
DynamicFeatureAccess source = (DynamicFeatureAccess)featureAccessSource;
Expression managerTypeExpression = source.getSource();
if (monitor.isCanceled() || !(managerTypeExpression instanceof StaticFeatureAccess))
{
return;
}
StaticFeatureAccess managerType = (StaticFeatureAccess)managerTypeExpression;
if (isManagerTypeValid(managerType) && isReferenceExcessive(source, module))
{
resultAceptor.addIssue(Messages.ManagerModuleNamedSelfReferenceCheck_issue, source);
}
}
private boolean isManagerTypeValid(StaticFeatureAccess managerType)
{
CaseInsensitiveString managerTypeName = new CaseInsensitiveString(managerType.getName());
return LinkPart.MD_OBJECT_MANAGERS.containsKey(managerTypeName)
|| LinkPart.MD_OBJECT_MANAGERS_RU.containsKey(managerTypeName);
}
private boolean isReferenceExcessive(DynamicFeatureAccess source, Module module)
{
return StringUtils.equals(bslQualifiedNameProvider.getFullyQualifiedName(module).getSegment(1),
source.getName());
}
}

View File

@ -46,6 +46,12 @@ final class Messages
public static String ChangeAndValidateInsteadOfAroundCheck_Use_ChangeAndValidate_instead_of_Around;
public static String ChangeAndValidateInsteadOfAroundCheck_title;
public static String CommonModuleNamedSelfReferenceCheck_description;
public static String CommonModuleNamedSelfReferenceCheck_issue;
public static String CommonModuleNamedSelfReferenceCheck_title;
public static String EmptyExceptStatementCheck_description;
public static String EmptyExceptStatementCheck_title;
@ -84,6 +90,12 @@ final class Messages
public static String ExportMethodInCommandModule_Do_not_use_export_method_in_commands_module;
public static String ManagerModuleNamedSelfReferenceCheck_description;
public static String ManagerModuleNamedSelfReferenceCheck_issue;
public static String ManagerModuleNamedSelfReferenceCheck_title;
public static String ModuleStructureTopRegionCheck_description;
public static String ModuleStructureTopRegionCheck_error_message;
@ -112,6 +124,14 @@ final class Messages
public static String QueryInLoop_Loop_has_query;
public static String QueryInLoop_title;
public static String SelfReferenceCheck_check_only_existing_form_properties;
public static String SelfReferenceCheck_Description;
public static String SelfReferenceCheck_Title;
public static String SelfReferenceCheck_Issue;
public static String StructureCtorTooManyKeysCheck_description;
public static String StructureCtorTooManyKeysCheck_Maximum_structure_constructor_keys;
public static String StructureCtorTooManyKeysCheck_Structure_constructor_has_more_than__0__keys;
@ -187,6 +207,12 @@ final class Messages
public static String FormModuleMissingPragmaCheck_title;
public static String FormSelfReferenceOutdatedCheck_Description;
public static String FormSelfReferenceOutdatedCheck_Issue;
public static String FormSelfReferenceOutdatedCheck_Title;
public static String InvocationFormEventHandlerCheck_Program_invocation_of_form_event_handler_description;
public static String InvocationFormEventHandlerCheck_Program_invocation_of_form_event_handler_result;

View File

@ -0,0 +1,131 @@
/*******************************************************************************
* Copyright (C) 2022, 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.DYNAMIC_FEATURE_ACCESS;
import java.util.Collection;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.xtext.EcoreUtil2;
import com._1c.g5.v8.dt.bsl.model.DynamicFeatureAccess;
import com._1c.g5.v8.dt.bsl.model.Expression;
import com._1c.g5.v8.dt.bsl.model.Invocation;
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.StaticFeatureAccess;
import com._1c.g5.v8.dt.bsl.resource.DynamicFeatureAccessComputer;
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;
import com.e1c.g5.v8.dt.check.settings.IssueSeverity;
import com.e1c.g5.v8.dt.check.settings.IssueType;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
import com.google.inject.Inject;
/**
* Check excessive self references in modules.
* For form modules only check self reference for methods and existing properties
* (if PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES is set, otherwise, check for all cases)
*
* @author Maxim Galios
*
*/
public class SelfReferenceCheck
extends BasicCheck
{
private static final String CHECK_ID = "module-self-reference"; //$NON-NLS-1$
private static final Collection<String> EXCESSIVE_NAMES = Set.of("ЭтотОбъект", "ThisObject"); //$NON-NLS-1$ //$NON-NLS-2$
public static final String PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES = "checkOnlyExistingFormProperties"; //$NON-NLS-1$
private DynamicFeatureAccessComputer dynamicFeatureAccessComputer;
/**
* Instantiates a new self reference check.
*
* @param dynamicFeatureAccessComputer dynamic feature computer, cannot be {@code null}.
*/
@Inject
public SelfReferenceCheck(DynamicFeatureAccessComputer dynamicFeatureAccessComputer)
{
super();
this.dynamicFeatureAccessComputer = dynamicFeatureAccessComputer;
}
@Override
public String getCheckId()
{
return CHECK_ID;
}
@Override
protected void configureCheck(CheckConfigurer builder)
{
builder.title(Messages.SelfReferenceCheck_Title)
.description(Messages.SelfReferenceCheck_Description)
.complexity(CheckComplexity.NORMAL)
.severity(IssueSeverity.MINOR)
.issueType(IssueType.CODE_STYLE)
.extension(new StandardCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
.module()
.checkedObjectType(DYNAMIC_FEATURE_ACCESS)
.parameter(PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES, Boolean.class, Boolean.TRUE.toString(),
Messages.SelfReferenceCheck_check_only_existing_form_properties);
}
@Override
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
IProgressMonitor monitor)
{
DynamicFeatureAccess dynamicFeatureAccess = (DynamicFeatureAccess)object;
Expression featureAccessSource = dynamicFeatureAccess.getSource();
if (monitor.isCanceled() || !(featureAccessSource instanceof StaticFeatureAccess))
{
return;
}
StaticFeatureAccess source = (StaticFeatureAccess)featureAccessSource;
if (isReferenceExcessive(dynamicFeatureAccess, source,
parameters.getBoolean(PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES)))
{
resultAceptor.addIssue(Messages.SelfReferenceCheck_Issue,
source);
}
}
private boolean isReferenceExcessive(DynamicFeatureAccess dynamicFeatureAccess, StaticFeatureAccess source,
boolean checkOnlyExistingFormProperties)
{
if (!EXCESSIVE_NAMES.contains(source.getName()))
{
return false;
}
if (!checkOnlyExistingFormProperties || (dynamicFeatureAccess.eContainer() instanceof Invocation))
{
return true;
}
Module module = EcoreUtil2.getContainerOfType(dynamicFeatureAccess, Module.class);
return !(module.getModuleType() == ModuleType.FORM_MODULE
&& dynamicFeatureAccessComputer.resolveObject(dynamicFeatureAccess, module.environments()).isEmpty());
}
}

View File

@ -40,6 +40,12 @@ ChangeAndValidateInsteadOfAroundCheck_description = Checks that pragma &ChangeAn
ChangeAndValidateInsteadOfAroundCheck_title = Use pragma &ChangeAndValidate instead of &Around
CommonModuleNamedSelfReferenceCheck_description=Excessive named self reference
CommonModuleNamedSelfReferenceCheck_issue=Excessive named self reference
CommonModuleNamedSelfReferenceCheck_title=Excessive named self reference in common module
EmptyExceptStatementCheck_description = Empty except statement
EmptyExceptStatementCheck_title = Empty except statement
@ -93,6 +99,12 @@ FormModulePragmaCheck_description = Use form module compilation pragma
FormModulePragmaCheck_title = Use form module compilation pragma
FormSelfReferenceOutdatedCheck_Description="ThisObject" should be used instead of outdated "ThisForm"
FormSelfReferenceOutdatedCheck_Issue="ThisObject" should be used instead of outdated "ThisForm"
FormSelfReferenceOutdatedCheck_Title=Outdated alias used
InvocationFormEventHandlerCheck_Program_invocation_of_form_event_handler_description=Program invocation of form event handler
InvocationFormEventHandlerCheck_Program_invocation_of_form_event_handler_result=Program invocation of form event handler
@ -113,6 +125,12 @@ LockOutOfTry_Lock_out_of_try=Lock out of Try
LockOutOfTry_Method_lock_out_of_try=Method Lock() out of try block
ManagerModuleNamedSelfReferenceCheck_description=Excessive named self reference
ManagerModuleNamedSelfReferenceCheck_issue=Excessive named self reference
ManagerModuleNamedSelfReferenceCheck_title=Excessive named self reference in manager module
MethodTooManyPramsCheck_Max_parameters = Max parameters
MethodTooManyPramsCheck_Max_parameters_with_default_value = Max parameters with default value
@ -205,6 +223,14 @@ RegionEmptyCheck_description = Check that module region is empty
RegionEmptyCheck_title = Region is empty
SelfReferenceCheck_check_only_existing_form_properties=Check only existing form properties
SelfReferenceCheck_Description=Excessive usage of self reference (when referencing method, property or attribute)
SelfReferenceCheck_Title=Excessive self reference
SelfReferenceCheck_Issue=Excessive usage of self reference (when referencing method, property or attribute)
StructureCtorTooManyKeysCheck_Maximum_structure_constructor_keys = Maximum structure constructor keys
StructureCtorTooManyKeysCheck_Structure_constructor_has_more_than__0__keys = Structure constructor has more than {0} keys

View File

@ -40,6 +40,12 @@ ChangeAndValidateInsteadOfAroundCheck_description = Проверяет, что
ChangeAndValidateInsteadOfAroundCheck_title = Используется аннотация &ИзменениеИКонтроль вместо &Вместо
CommonModuleNamedSelfReferenceCheck_description=Избыточное обращение по собственному имени
CommonModuleNamedSelfReferenceCheck_issue=Избыточное обращение по собственному имени
CommonModuleNamedSelfReferenceCheck_title=Избыточное обращение по собственному имени в общем модуле
EmptyExceptStatementCheck_description = "Попытка...Исключение" не содержит кода в исключении
EmptyExceptStatementCheck_title = "Попытка...Исключение" не содержит кода в исключении
@ -96,6 +102,12 @@ FormModulePragmaCheck_description = Использование директив
FormModulePragmaCheck_title = Использование директив компиляции модуля формы
FormSelfReferenceOutdatedCheck_Description=Следует использовать псевдоним "ЭтотОбъект" вместо устаревшего "ЭтаФорма"
FormSelfReferenceOutdatedCheck_Issue=Следует использовать псевдоним "ЭтотОбъект" вместо устаревшего "ЭтаФорма"
FormSelfReferenceOutdatedCheck_Title=Использование устаревшего псевдонима
InvocationFormEventHandlerCheck_Program_invocation_of_form_event_handler_description=Программный вызов обработчика события формы
InvocationFormEventHandlerCheck_Program_invocation_of_form_event_handler_result=Программный вызов обработчика события формы
@ -116,6 +128,12 @@ LockOutOfTry_Lock_out_of_try=Метод Заблокировать() вне бл
LockOutOfTry_Method_lock_out_of_try=Метод Заблокировать() вне блока Попытка-Исключение
ManagerModuleNamedSelfReferenceCheck_description=Избыточное обращение по собственному имени
ManagerModuleNamedSelfReferenceCheck_issue=Избыточное обращение по собственному имени
ManagerModuleNamedSelfReferenceCheck_title=Избыточное обращение по собственному имени в модуле менеджера
MethodTooManyPramsCheck_Max_parameters = Максимум параметров
MethodTooManyPramsCheck_Max_parameters_with_default_value = Максимум параметров со значением по умолчанию
@ -208,6 +226,14 @@ RegionEmptyCheck_description = Проверяет что область моду
RegionEmptyCheck_title = Область пустая
SelfReferenceCheck_check_only_existing_form_properties=Проверять только существовующие свойства в форме
SelfReferenceCheck_Description=Избыточное обращение внутри модуля через псевдоним "ЭтотОбъект" (к методу, свойству или реквизиту)
SelfReferenceCheck_Title=Избыточное использование псевдонима "ЭтотОбъект"
SelfReferenceCheck_Issue=Избыточное обращение внутри модуля через псевдоним "ЭтотОбъект" (к методу, свойству или реквизиту)
StructureCtorTooManyKeysCheck_Maximum_structure_constructor_keys = Максимальное количество ключей структуры в конструкторе
StructureCtorTooManyKeysCheck_Structure_constructor_has_more_than__0__keys = Конструктор структуры содержит более чем {0} ключей

View File

@ -0,0 +1,94 @@
/*******************************************************************************
* Copyright (C) 2022, 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.itests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.core.runtime.Path;
import org.junit.Test;
import com._1c.g5.v8.dt.validation.marker.IExtraInfoKeys;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.v8codestyle.bsl.check.CommonModuleNamedSelfReferenceCheck;
/**
* Test for the class {@link CommonModuleNamedSelfReferenceCheck}
*
* @author Maxim Galios
*
*/
public class CommonModuleNamedSelfReferenceCheckTest
extends AbstractSingleModuleTestBase
{
private static final String PROJECT_NAME = "CommonModuleNamedSelfReferenceCheck";
private static final String COMMON_MODULE_FILE_NAME = "/src/CommonModules/MyCommonModule/Module.bsl";
private static final String CACHED_COMMON_MODULE_FILE_NAME = "/src/CommonModules/MyCommonModuleCached/Module.bsl";
public CommonModuleNamedSelfReferenceCheckTest()
{
super(CommonModuleNamedSelfReferenceCheck.class);
}
@Override
protected String getTestConfigurationName()
{
return PROJECT_NAME;
}
/**
* Check self references by name in common module
*
* @throws Exception
*/
@Test
public void testCommonModule() throws Exception
{
List<Marker> markers = getMarkers(COMMON_MODULE_FILE_NAME);
assertEquals(2, markers.size());
assertEquals("6", markers.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("6", markers.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
/**
* Check self references by name in cached common moudle
*
* @throws Exception
*/
@Test
public void testCachedCommonModule() throws Exception
{
List<Marker> markers = getMarkers(CACHED_COMMON_MODULE_FILE_NAME);
assertEquals(0, markers.size());
}
private List<Marker> getMarkers(String moduleFileName)
{
String moduleId = Path.ROOT.append(getTestConfigurationName()).append(moduleFileName).toString();
List<Marker> markers = List.of(markerManager.getMarkers(getProject().getWorkspaceProject(), moduleId));
String chekcId = getCheckId();
assertNotNull(chekcId);
return markers.stream()
.filter(marker -> chekcId.equals(getCheckIdFromMarker(marker, getProject())))
.collect(Collectors.toList());
}
}

View File

@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (C) 2022, 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.itests;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.eclipse.core.runtime.Path;
import org.junit.Test;
import com._1c.g5.v8.dt.validation.marker.IExtraInfoKeys;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.v8codestyle.bsl.check.FormSelfReferenceOutdatedCheck;
/**
* The test for class {@link FormSelfReferenceOutdatedCheck}
* @author Maxim Galios
*
*/
public class FormSelfReferenceOutdatedCheckTest
extends AbstractSingleModuleTestBase
{
private static final String PROJECT_NAME = "FormSelfReferenceOutdatedCheck";
private static final String FORM_MODULE_FILE_NAME = "/src/CommonForms/MyForm/Module.bsl";
public FormSelfReferenceOutdatedCheckTest()
{
super(FormSelfReferenceOutdatedCheck.class);
}
@Override
protected String getTestConfigurationName()
{
return PROJECT_NAME;
}
@Override
protected String getModuleId()
{
return Path.ROOT.append(getTestConfigurationName()).append(FORM_MODULE_FILE_NAME).toString();
}
/**
* Test ЭтаФорма/ThisForm references presence in form module
*
* @throws Exception
*/
@Test
public void testFormModule() throws Exception
{
List<Marker> markers = getModuleMarkers();
assertEquals(2, markers.size());
assertEquals("11", markers.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("12", markers.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
}

View File

@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (C) 2022, 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.itests;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.eclipse.core.runtime.Path;
import org.junit.Test;
import com._1c.g5.v8.dt.validation.marker.IExtraInfoKeys;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.v8codestyle.bsl.check.ManagerModuleNamedSelfReferenceCheck;
/**
* Test for the class {@link ManagerModuleNamedSelfReferenceCheck}
*
* @author Maxim Galios
*
*/
public class ManagerModuleNamedSelfReferenceCheckTest
extends AbstractSingleModuleTestBase
{
private static final String PROJECT_NAME = "ManagerModuleNamedSelfReferenceCheck";
private static final String MANAGER_MODULE_FILE_NAME = "/src/Catalogs/Catalog/ManagerModule.bsl";
public ManagerModuleNamedSelfReferenceCheckTest()
{
super(ManagerModuleNamedSelfReferenceCheck.class);
}
@Override
protected String getTestConfigurationName()
{
return PROJECT_NAME;
}
@Override
protected String getModuleId()
{
return Path.ROOT.append(getTestConfigurationName()).append(MANAGER_MODULE_FILE_NAME).toString();
}
/**
* Check self reference in manager module
*
* @throws Exception
*/
@Test
public void testManagerModule() throws Exception
{
List<Marker> markers = getModuleMarkers();
assertEquals(4, markers.size());
assertEquals("6", markers.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("6", markers.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("7", markers.get(2).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("7", markers.get(3).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
}

View File

@ -0,0 +1,149 @@
/*******************************************************************************
* Copyright (C) 2022, 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.itests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;
import org.junit.Test;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.validation.marker.IExtraInfoKeys;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.g5.v8.dt.check.settings.CheckUid;
import com.e1c.g5.v8.dt.check.settings.ICheckSettings;
import com.e1c.v8codestyle.bsl.check.SelfReferenceCheck;
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
/**
* The test for class {@link SelfReferenceCheck}.
*
* @author Maxim Galios
*
*/
public class SelfReferenceCheckTest
extends AbstractSingleModuleTestBase
{
private static final String PROJECT_NAME = "SelfReferenceCheck";
private static final String COMMON_MODULE_FILE_NAME = "/src/CommonModules/MyCommonModule/Module.bsl";
private static final String FORM_MODULE_FILE_NAME = "/src/CommonForms/MyForm/Module.bsl";
private static final String OBJECT_MODULE_FILE_NAME = "/src/Catalogs/Products/ObjectModule.bsl";
public SelfReferenceCheckTest()
{
super(SelfReferenceCheck.class);
}
@Override
protected String getTestConfigurationName()
{
return PROJECT_NAME;
}
/**
* Test ThisPbject/ЭтотОбъект references presence in common module
*
* @throws Exception
*/
@Test
public void testCommonModule() throws Exception
{
List<Marker> markers = getMarkers(COMMON_MODULE_FILE_NAME);
assertEquals(4, markers.size());
assertEquals("6", markers.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("6", markers.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("10", markers.get(2).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("10", markers.get(3).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
/**
* Test ThisPbject/ЭтотОбъект references presence in form module
*
* @throws Exception
*/
@Test
public void testFormModule() throws Exception
{
List<Marker> markers = getMarkers(FORM_MODULE_FILE_NAME);
assertEquals(3, markers.size());
assertEquals("11", markers.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("12", markers.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("13", markers.get(2).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
IDtProject dtProject = getProject();
IProject project = dtProject.getWorkspaceProject();
ICheckSettings settings = checkRepository.getSettings(new CheckUid(getCheckId(), BslPlugin.PLUGIN_ID), project);
settings.getParameters()
.get(SelfReferenceCheck.PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES)
.setValue(Boolean.toString(false));
checkRepository.applyChanges(Collections.singleton(settings), project);
waitForDD(dtProject);
List<Marker> markersAfterSettingsChange = getMarkers(FORM_MODULE_FILE_NAME);
assertEquals(5, markersAfterSettingsChange.size());
assertEquals("11",
markersAfterSettingsChange.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("11",
markersAfterSettingsChange.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("12",
markersAfterSettingsChange.get(2).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("12",
markersAfterSettingsChange.get(3).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("13",
markersAfterSettingsChange.get(4).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
/**
* Test ThisPbject/ЭтотОбъект references presence in object module
*
* @throws Exception
*/
@Test
public void testObjectModule() throws Exception
{
List<Marker> markers = getMarkers(OBJECT_MODULE_FILE_NAME);
assertEquals(4, markers.size());
assertEquals("8", markers.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("8", markers.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("9", markers.get(2).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
assertEquals("9", markers.get(3).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
}
private List<Marker> getMarkers(String moduleFileName)
{
String moduleId = Path.ROOT.append(getTestConfigurationName()).append(moduleFileName).toString();
List<Marker> markers = List.of(markerManager.getMarkers(getProject().getWorkspaceProject(), moduleId));
String chekcId = getCheckId();
assertNotNull(chekcId);
return markers.stream()
.filter(marker -> chekcId.equals(getCheckIdFromMarker(marker, getProject())))
.collect(Collectors.toList());
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CommonModuleNamedSelfReferenceCheck</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>com._1c.g5.v8.dt.core.V8ConfigurationNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
topObjects=true

View File

@ -0,0 +1,3 @@
addModuleStrictTypesAnnotation=false
createModuleStructure=false
eclipse.preferences.version=1

View File

@ -0,0 +1,3 @@
commonChecks=true
eclipse.preferences.version=1
standardChecks=true

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Runtime-Version: 8.3.21

View File

@ -0,0 +1,7 @@
Функция МояФункция() экспорт
Возврат 1;
КонецФункции
Процедура Тест1()
MyCommonModule.МойРеквизит = MyCommonModule.МояФункция();
КонецПроцедуры

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="5271826d-0127-4d6e-b1fe-e40ad5159a30">
<name>MyCommonModule</name>
<synonym>
<key>en</key>
<value>My common module</value>
</synonym>
<server>true</server>
<externalConnection>true</externalConnection>
<clientOrdinaryApplication>true</clientOrdinaryApplication>
</mdclass:CommonModule>

View File

@ -0,0 +1,7 @@
Функция МояФункция() экспорт
Возврат 1;
КонецФункции
Процедура Тест1()
MyCommonModuleCached.МойРеквизит = MyCommonModuleCached.МояФункция();
КонецПроцедуры

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="31478f4e-9361-40bd-ac0c-c26c20f07536">
<name>MyCommonModuleCached</name>
<synonym>
<key>en</key>
<value>My common module cached</value>
</synonym>
<server>true</server>
<externalConnection>true</externalConnection>
<clientOrdinaryApplication>true</clientOrdinaryApplication>
<returnValuesReuse>DuringSession</returnValuesReuse>
</mdclass:CommonModule>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="b22d543e-3b57-4be7-8142-2fb0a95f351c">
<name>CommonModuleNamedSelfReferenceCheck</name>
<synonym>
<key>en</key>
<value>Common module named self reference check</value>
</synonym>
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="02df510a-1aaf-4238-b764-3d2fe73c4019"/>
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="7374f4e4-6140-4c72-967e-f24a63ca4d35"/>
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="08b238e2-ae9e-45fb-bdf1-145d7819e849"/>
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="b18dec52-774f-4207-9e86-27a5d00e5302"/>
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="4978d152-51ea-43c6-a55c-d36771108705"/>
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="95fe14e0-b0ca-41f5-900a-183ed5e7e785"/>
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="a2c6d816-8c15-4db2-8994-9b272e76add6"/>
<configurationExtensionCompatibilityMode>8.3.21</configurationExtensionCompatibilityMode>
<defaultRunMode>ManagedApplication</defaultRunMode>
<usePurposes>PersonalComputer</usePurposes>
<usedMobileApplicationFunctionalities>
<functionality>
<use>true</use>
</functionality>
<functionality>
<functionality>OSBackup</functionality>
<use>true</use>
</functionality>
</usedMobileApplicationFunctionalities>
<defaultLanguage>Language.English</defaultLanguage>
<dataLockControlMode>Managed</dataLockControlMode>
<objectAutonumerationMode>NotAutoFree</objectAutonumerationMode>
<modalityUseMode>DontUse</modalityUseMode>
<synchronousPlatformExtensionAndAddInCallUseMode>DontUse</synchronousPlatformExtensionAndAddInCallUseMode>
<compatibilityMode>8.3.21</compatibilityMode>
<languages uuid="7690cd5a-38fb-432a-8165-15cf2124b9bb">
<name>English</name>
<synonym>
<key>en</key>
<value>English</value>
</synonym>
<languageCode>en</languageCode>
</languages>
<commonModules>CommonModule.MyCommonModule</commonModules>
<commonModules>CommonModule.MyCommonModuleCached</commonModules>
</mdclass:Configuration>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FormSelfReferenceOutdatedCheck</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>com._1c.g5.v8.dt.core.V8ConfigurationNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
topObjects=true

View File

@ -0,0 +1,3 @@
addModuleStrictTypesAnnotation=false
createModuleStructure=false
eclipse.preferences.version=1

View File

@ -0,0 +1,3 @@
commonChecks=true
eclipse.preferences.version=1
standardChecks=true

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Runtime-Version: 8.3.21

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<form:Form xmlns:form="http://g5.1c.ru/v8/dt/form">
<autoCommandBar>
<name>FormCommandBar</name>
<id>-1</id>
<visible>true</visible>
<enabled>true</enabled>
<userVisible>
<common>true</common>
</userVisible>
<horizontalAlign>Left</horizontalAlign>
<autoFill>true</autoFill>
</autoCommandBar>
<autoTitle>true</autoTitle>
<autoUrl>true</autoUrl>
<group>Vertical</group>
<autoFillCheck>true</autoFillCheck>
<allowFormCustomize>true</allowFormCustomize>
<enabled>true</enabled>
<showTitle>true</showTitle>
<showCloseButton>true</showCloseButton>
<commandInterface>
<navigationPanel/>
<commandBar/>
</commandInterface>
</form:Form>

View File

@ -0,0 +1,13 @@
&НаКлиенте
Перем МойРеквизит экспорт;
&НаКлиенте
Функция МояФункция() экспорт
Возврат 1;
КонецФункции
&НаКлиенте
Процедура Тест()
ЭтаФорма.МойРеквизит = ЭтотОбъект.МояФункция();
ThisForm.МойРеквизит = ThisObject.МояФункция();
КонецПроцедуры

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonForm xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="52cfc7c5-cef1-4876-ae65-b0fadc3b457e">
<name>MyForm</name>
<synonym>
<key>en</key>
<value>My form</value>
</synonym>
<usePurposes>PersonalComputer</usePurposes>
<usePurposes>MobileDevice</usePurposes>
</mdclass:CommonForm>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="3832fb42-5617-450c-8be5-c963f07c948f">
<name>FormSelfReferenceOutdatedCheck</name>
<synonym>
<key>en</key>
<value>Form self reference outdated check</value>
</synonym>
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="aa557d22-e1fc-425e-b64a-5c364da6548a"/>
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="18b8c6ef-2a63-407f-bb80-c4ddc1dac887"/>
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="d849813b-7fd5-4d44-8524-c2928934ce51"/>
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="11d0d305-cc13-413a-9cf5-efa49cec8d21"/>
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="980c74b1-f900-4a48-9923-1e0ed46ec517"/>
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="604c9079-8486-4540-9f71-84d0e8193c23"/>
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="f02642d4-c01d-4e99-94f1-cef125a022ad"/>
<configurationExtensionCompatibilityMode>8.3.21</configurationExtensionCompatibilityMode>
<defaultRunMode>ManagedApplication</defaultRunMode>
<usePurposes>PersonalComputer</usePurposes>
<usedMobileApplicationFunctionalities>
<functionality>
<use>true</use>
</functionality>
<functionality>
<functionality>OSBackup</functionality>
<use>true</use>
</functionality>
</usedMobileApplicationFunctionalities>
<defaultLanguage>Language.English</defaultLanguage>
<dataLockControlMode>Managed</dataLockControlMode>
<objectAutonumerationMode>NotAutoFree</objectAutonumerationMode>
<modalityUseMode>DontUse</modalityUseMode>
<synchronousPlatformExtensionAndAddInCallUseMode>DontUse</synchronousPlatformExtensionAndAddInCallUseMode>
<compatibilityMode>8.3.21</compatibilityMode>
<languages uuid="3ffda2c6-c1de-4d69-b1e5-609a2e9ca6b7">
<name>English</name>
<synonym>
<key>en</key>
<value>English</value>
</synonym>
<languageCode>en</languageCode>
</languages>
<commonForms>CommonForm.MyForm</commonForms>
</mdclass:Configuration>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ManagerModuleNamedSelfReferenceCheck</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>com._1c.g5.v8.dt.core.V8ConfigurationNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
topObjects=true

View File

@ -0,0 +1,3 @@
addModuleStrictTypesAnnotation=false
createModuleStructure=false
eclipse.preferences.version=1

View File

@ -0,0 +1,3 @@
commonChecks=true
eclipse.preferences.version=1
standardChecks=true

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Runtime-Version: 8.3.21

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Catalog xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="9f5e5c49-0c63-42e9-afb5-d994bf19ddce">
<producedTypes>
<objectType typeId="5a6a6b01-2c43-4c4d-bdcb-ccbb1dfd04e3" valueTypeId="e2f12439-637f-4a27-81fe-cfe631e01107"/>
<refType typeId="801479f2-5a84-45f7-8aa2-278b206cefa4" valueTypeId="cbc30cf9-ed18-40a6-b473-b5a2c408f602"/>
<selectionType typeId="4f08fadc-1c67-4769-8e5b-05b7d0b43e1f" valueTypeId="f07b8974-a5e5-4e8b-9dec-200e48f95835"/>
<listType typeId="8720b617-2689-4d03-bb9a-ba7bf139c16e" valueTypeId="1feedc4e-0dc9-4b58-bd01-c3faab1d5529"/>
<managerType typeId="2544c98a-3054-4404-ae06-aa637b707cc5" valueTypeId="62031592-69bd-4694-87cb-0c9edebb5026"/>
</producedTypes>
<name>Catalog</name>
<synonym>
<key>en</key>
<value>Catalog</value>
</synonym>
<useStandardCommands>true</useStandardCommands>
<inputByString>Catalog.Catalog.StandardAttribute.Code</inputByString>
<inputByString>Catalog.Catalog.StandardAttribute.Description</inputByString>
<fullTextSearchOnInputByString>DontUse</fullTextSearchOnInputByString>
<createOnInput>Use</createOnInput>
<dataLockControlMode>Managed</dataLockControlMode>
<fullTextSearch>Use</fullTextSearch>
<levelCount>2</levelCount>
<foldersOnTop>true</foldersOnTop>
<codeLength>9</codeLength>
<descriptionLength>25</descriptionLength>
<codeType>String</codeType>
<codeAllowedLength>Variable</codeAllowedLength>
<checkUnique>true</checkUnique>
<autonumbering>true</autonumbering>
<defaultPresentation>AsDescription</defaultPresentation>
<editType>InDialog</editType>
<choiceMode>BothWays</choiceMode>
</mdclass:Catalog>

View File

@ -0,0 +1,8 @@
Функция МояФункция() экспорт
Возврат 1;
КонецФункции
Процедура Тест()
Catalogs.Catalog.МойРеквизит = Catalogs.Catalog.МояФункция();
Справочники.Catalog.МойРеквизит = Справочники.Catalog.МояФункция();
КонецПроцедуры

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="5aa8bf26-196b-4ac3-ad68-923d2b544ac3">
<name>ManagerModuleNamedSelfReferenceCheck</name>
<synonym>
<key>en</key>
<value>Manager module named self reference check</value>
</synonym>
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="090a6b3c-c00a-40bc-be57-6d174a6fb691"/>
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="9b589fd4-070d-40ba-804f-4ebde30760c9"/>
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="37d74b95-108d-4864-8739-23488fe7bc68"/>
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="6f127730-cfe8-41a4-8af8-ed98a6703b01"/>
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="168f6f0e-0456-4776-9040-f52bd2ae6c56"/>
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="0a7c8214-7906-4928-8650-1a1796cebed6"/>
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="9935b673-ffa5-4226-b6ed-ea0ab9f01b71"/>
<configurationExtensionCompatibilityMode>8.3.21</configurationExtensionCompatibilityMode>
<defaultRunMode>ManagedApplication</defaultRunMode>
<usePurposes>PersonalComputer</usePurposes>
<usedMobileApplicationFunctionalities>
<functionality>
<use>true</use>
</functionality>
<functionality>
<functionality>OSBackup</functionality>
<use>true</use>
</functionality>
</usedMobileApplicationFunctionalities>
<defaultLanguage>Language.English</defaultLanguage>
<dataLockControlMode>Managed</dataLockControlMode>
<objectAutonumerationMode>NotAutoFree</objectAutonumerationMode>
<modalityUseMode>DontUse</modalityUseMode>
<synchronousPlatformExtensionAndAddInCallUseMode>DontUse</synchronousPlatformExtensionAndAddInCallUseMode>
<compatibilityMode>8.3.21</compatibilityMode>
<languages uuid="cfd0ee03-fa6d-44bd-8552-f0b955f11cf1">
<name>English</name>
<synonym>
<key>en</key>
<value>English</value>
</synonym>
<languageCode>en</languageCode>
</languages>
<catalogs>Catalog.Catalog</catalogs>
</mdclass:Configuration>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SelfReferenceCheck</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>com._1c.g5.v8.dt.core.V8ConfigurationNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,4 @@
{
"version": 1,
"settings": {}
}

View File

@ -0,0 +1,4 @@
defaultValuesInitialized=true
eclipse.preferences.version=1
projectSpecificSettingsInited=true
showWhitespaceCharacters=false

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
topObjects=true

View File

@ -0,0 +1,3 @@
addModuleStrictTypesAnnotation=false
createModuleStructure=false
eclipse.preferences.version=1

View File

@ -0,0 +1,3 @@
commonChecks=true
eclipse.preferences.version=1
standardChecks=true

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Runtime-Version: 8.3.21

View File

@ -0,0 +1,10 @@
Перем МойРеквизит экспорт;
Функция МояФункция(Реквизит) экспорт
Возврат Реквизит + 1;
КонецФункции
Процедура Тест()
ЭтотОбъект.МойРеквизит = ЭтотОбъект.МояФункция(МойРеквизит);
ThisObject.МойРеквизит = ThisObject.МояФункция(МойРеквизит);
КонецПроцедуры

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Catalog xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="aadfa90f-2260-4100-9cc4-a4afa319b717">
<producedTypes>
<objectType typeId="e0130f06-4ecd-4ede-b89b-fd061e903d38" valueTypeId="423b5408-6b7e-4618-81e4-9bf752845fcc"/>
<refType typeId="ae80994e-83a4-4630-b9af-3d026a137854" valueTypeId="3eac1c41-d4e0-4b5c-bb5d-63e22f29199c"/>
<selectionType typeId="a975a3a8-badf-4337-b6f6-8c7ca866bb01" valueTypeId="6f16cd78-a195-4c7f-bb30-789612f7ecbe"/>
<listType typeId="0d1c11dd-0f4e-4269-b4d6-3ba8c3bc3b90" valueTypeId="5eba3973-abd0-4594-846b-f6ade1fc3d47"/>
<managerType typeId="5952c419-a8fa-4ef0-8a1f-e18db8b9d9b6" valueTypeId="48d82148-d85c-4747-a2fe-97be70c5dfd2"/>
</producedTypes>
<name>Products</name>
<synonym>
<key>en</key>
<value>Products</value>
</synonym>
<useStandardCommands>true</useStandardCommands>
<inputByString>Catalog.Products.StandardAttribute.Code</inputByString>
<inputByString>Catalog.Products.StandardAttribute.Description</inputByString>
<fullTextSearchOnInputByString>DontUse</fullTextSearchOnInputByString>
<createOnInput>Use</createOnInput>
<dataLockControlMode>Managed</dataLockControlMode>
<fullTextSearch>Use</fullTextSearch>
<levelCount>2</levelCount>
<foldersOnTop>true</foldersOnTop>
<codeLength>9</codeLength>
<descriptionLength>25</descriptionLength>
<codeType>String</codeType>
<codeAllowedLength>Variable</codeAllowedLength>
<checkUnique>true</checkUnique>
<autonumbering>true</autonumbering>
<defaultPresentation>AsDescription</defaultPresentation>
<editType>InDialog</editType>
<choiceMode>BothWays</choiceMode>
</mdclass:Catalog>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<form:Form xmlns:form="http://g5.1c.ru/v8/dt/form">
<autoCommandBar>
<name>FormCommandBar</name>
<id>-1</id>
<visible>true</visible>
<enabled>true</enabled>
<userVisible>
<common>true</common>
</userVisible>
<horizontalAlign>Left</horizontalAlign>
<autoFill>true</autoFill>
</autoCommandBar>
<autoTitle>true</autoTitle>
<autoUrl>true</autoUrl>
<group>Vertical</group>
<autoFillCheck>true</autoFillCheck>
<allowFormCustomize>true</allowFormCustomize>
<enabled>true</enabled>
<showTitle>true</showTitle>
<showCloseButton>true</showCloseButton>
<attributes>
<name>MyAttrubute</name>
<title>
<key>en</key>
<value>My attrubute</value>
</title>
<id>1</id>
<valueType>
<types>String</types>
<stringQualifiers/>
</valueType>
<view>
<common>true</common>
</view>
<edit>
<common>true</common>
</edit>
</attributes>
<commandInterface>
<navigationPanel/>
<commandBar/>
</commandInterface>
</form:Form>

View File

@ -0,0 +1,14 @@
&НаКлиенте
Перем МойРеквизит экспорт;
&НаКлиенте
Функция МояФункция() экспорт
Возврат 1;
КонецФункции
&НаКлиенте
Процедура Тест()
ЭтотОбъект.МойРеквизит = ЭтотОбъект.МояФункция();
ThisObject.МойРеквизит = ThisObject.МояФункция();
ThisObject.MyAttrubute = "Value";
КонецПроцедуры

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonForm xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="9134b708-8ac3-4a05-a4ce-89aca0536121">
<name>MyForm</name>
<synonym>
<key>en</key>
<value>My form</value>
</synonym>
<usePurposes>PersonalComputer</usePurposes>
<usePurposes>MobileDevice</usePurposes>
</mdclass:CommonForm>

View File

@ -0,0 +1,11 @@
Функция МояФункция() экспорт
Возврат 1;
КонецФункции
Процедура Тест1()
ЭтотОбъект.МойРеквизит = ЭтотОбъект.МояФункция();
КонецПроцедуры
Процедура Тест2()
ThisObject.МойРеквизит = ThisObject.МояФункция();
КонецПроцедуры

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="ef30c2af-55aa-483d-a444-25c6801a2554">
<name>MyCommonModule</name>
<synonym>
<key>en</key>
<value>My common module</value>
</synonym>
<server>true</server>
<externalConnection>true</externalConnection>
<clientOrdinaryApplication>true</clientOrdinaryApplication>
</mdclass:CommonModule>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="b782c0d1-4f91-45b5-a72f-87d6f9838291">
<name>SelfReferenceCheck</name>
<synonym>
<key>en</key>
<value>Self reference check</value>
</synonym>
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="15a9af06-faaf-4646-bb48-479c18949864"/>
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="bf1d9e29-94a7-473e-9972-e2a885f278b9"/>
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="c15c6023-8763-4462-90c4-bb25bbe2bbdb"/>
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="c078e1c5-a996-4c23-9e8b-cb1d047ba4be"/>
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="792b186f-1e0c-4378-9a94-1dff5f7014a5"/>
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="2104fef5-41c6-4396-ac09-3d6bbfa310c3"/>
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="c750ae79-4505-4be4-9c67-866fa974527c"/>
<configurationExtensionCompatibilityMode>8.3.21</configurationExtensionCompatibilityMode>
<defaultRunMode>ManagedApplication</defaultRunMode>
<usePurposes>PersonalComputer</usePurposes>
<usedMobileApplicationFunctionalities>
<functionality>
<use>true</use>
</functionality>
<functionality>
<functionality>OSBackup</functionality>
<use>true</use>
</functionality>
</usedMobileApplicationFunctionalities>
<defaultLanguage>Language.English</defaultLanguage>
<dataLockControlMode>Managed</dataLockControlMode>
<objectAutonumerationMode>NotAutoFree</objectAutonumerationMode>
<modalityUseMode>DontUse</modalityUseMode>
<synchronousPlatformExtensionAndAddInCallUseMode>DontUse</synchronousPlatformExtensionAndAddInCallUseMode>
<compatibilityMode>8.3.21</compatibilityMode>
<languages uuid="e83312e1-b530-4382-a431-3b8c6d87d2c4">
<name>English</name>
<synonym>
<key>en</key>
<value>English</value>
</synonym>
<languageCode>en</languageCode>
</languages>
<commonModules>CommonModule.MyCommonModule</commonModules>
<commonForms>CommonForm.MyForm</commonForms>
<catalogs>Catalog.Products</catalogs>
</mdclass:Configuration>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>