mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2024-11-28 17:41:06 +02:00
#398 Merge remote-tracking branch 'upstream/master' into feature/398-use-goto
This commit is contained in:
commit
7b5b2be944
@ -14,23 +14,31 @@
|
||||
- Реквизит "Комментарий" имеет корректный тип
|
||||
- В документе, предполагающем проведение, не установлен флаг "Привилегированный режим при проведении / отмене проведения"
|
||||
- Проверка наличия буквы "ё" в имени, синониме или комментарии объекта метаданных
|
||||
- В функциональной опции не установлен флаг "Привилегированный режим при получении"
|
||||
|
||||
#### Формы
|
||||
|
||||
- Использована ролевая настройка видимости, редактирования, использования для элемента формы
|
||||
|
||||
#### Код модулей
|
||||
|
||||
- Проверка отсутствия кода после асинхронного вызова
|
||||
- Проверка использования метода ДанныеФормыВЗначение вместо РеквизитФормыВЗначение
|
||||
- В проверку использования нерекомендуемых методов (use-non-recommended-method) добавлен метод ПолучитьФорму(GetForm)
|
||||
- Использование устаревшего метода Найти
|
||||
- Отсутствует комментарий к экспортной процедуре (функции)
|
||||
- Документирующий комментарий не содержит секцию "Описание" для экспортной процедуры (функции)
|
||||
- В проверку "module-self-reference" добавлен параметр, позволяющий пропускать проверку для модулей объектов, наборов записей и менеджеров значений
|
||||
- Проверка корректного наименования переменных
|
||||
- Обращение к несуществующему параметру формы
|
||||
- Необязательный параметр процедуры/функции стоит перед обязательным
|
||||
- Обращение к опциональному параметру формы
|
||||
- Функция "РольДоступна" ссылается на несуществующие роли
|
||||
- Проверка на использование оператора Перейти (Goto) в коде модулей
|
||||
|
||||
#### Запросы
|
||||
|
||||
- Доработана проверка ql-temp-table-index: параметр MAX_TOP (Макс. кол-во строк в выборке) теперь настраиваемый.
|
||||
|
||||
#### Права ролей
|
||||
|
||||
@ -75,7 +83,6 @@
|
||||
- Устаревшая процедура (функция) расположена вне области "УстаревшиеПроцедурыИФункции"
|
||||
- Использован обработчик событий, подключаемый из кода и не содержащий префикса "Подключаемый_"
|
||||
|
||||
|
||||
### Новые быстрые исправления (Quick-fix)
|
||||
|
||||
- Исправление превышения максимального количества допустимых пустых строк
|
||||
|
@ -20,6 +20,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Automatic-Module-Name: com.e1c.v8codestyle.bsl
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Import-Package: com._1c.g5.v8.bm.core;version="[7.0.0,8.0.0)",
|
||||
com._1c.g5.v8.dt.bm.xtext;version="[14.1.100,15.0.0)",
|
||||
com._1c.g5.v8.dt.bsl;version="[5.0.0,6.0.0)",
|
||||
com._1c.g5.v8.dt.bsl.comment;version="[3.0.0,4.0.0)",
|
||||
com._1c.g5.v8.dt.bsl.common;version="[6.0.0,7.0.0)",
|
||||
@ -38,6 +39,7 @@ Import-Package: com._1c.g5.v8.bm.core;version="[7.0.0,8.0.0)",
|
||||
com._1c.g5.v8.dt.bsl.util;version="[7.0.0,8.0.0)",
|
||||
com._1c.g5.v8.dt.bsl.validation;version="[16.0.0,17.0.0)",
|
||||
com._1c.g5.v8.dt.common;version="[6.0.0,7.0.0)",
|
||||
com._1c.g5.v8.dt.core.naming;version="[6.0.0,7.0.0)",
|
||||
com._1c.g5.v8.dt.core.platform;version="[10.0.0,11.0.0)",
|
||||
com._1c.g5.v8.dt.form.model;version="[11.0.0,12.0.0)",
|
||||
com._1c.g5.v8.dt.lcore.ui.editor;version="[2.3.0,3.0.0)",
|
||||
|
@ -0,0 +1,24 @@
|
||||
# The asynchronous method is not followed by lines of code
|
||||
|
||||
In the asynchronous approach the method is called as usual, but control returns to the caller before the asynchronous
|
||||
method is completed. After that, execution of the caller continues.
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
```bsl
|
||||
Text = "Warning text";
|
||||
ShowMessageBox( , Text);
|
||||
Message("Warning is closed");
|
||||
```
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
```bsl
|
||||
Text = "Warning text";
|
||||
Await DoMessageBoxAsync(Text);
|
||||
Message("Warning is closed");
|
||||
```
|
||||
|
||||
## See
|
||||
|
||||
- [Synchronous and asynchronous operations](https://kb.1ci.com/1C_Enterprise_Platform/Guides/Developer_Guides/1C_Enterprise_8.3.19_Developer_Guide/Chapter_4._1C_Enterprise_language/4.7._Queries/4.7.9._Synchronous_and_asynchronous_operations/)
|
@ -0,0 +1,11 @@
|
||||
# Referring to a non-existent role
|
||||
|
||||
In the parameter of the function "IsInRole" must existing role to be specified.
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
|
||||
## See
|
@ -0,0 +1,19 @@
|
||||
# Method optional parameters before required
|
||||
|
||||
Optional parameters (with default values) must follow required parameters (without default values).
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
```bsl
|
||||
Function ExchangeRateOnDate(Date = Undefined, Currency) Export
|
||||
```
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
```bsl
|
||||
Function ExchangeRateOnDate(Currency, Date = Undefined) Export
|
||||
```
|
||||
|
||||
## See
|
||||
|
||||
- [Procedure and function parameters](https://kb.1ci.com/1C_Enterprise_Platform/Guides/Developer_Guides/1C_Enterprise_Development_Standards/Code_conventions/Module_formatting/Procedure_and_function_parameters/)
|
@ -1,9 +1,13 @@
|
||||
# Self reference is excessive
|
||||
|
||||
Excessive usage of self reference with use of `ThisObject` (when referencing method, property or attribute)
|
||||
Excessive usage of self reference with use of `ThisObject` (when referencing method, property or attribute).
|
||||
|
||||
Check common module, object module, recordset module, value manager module, form module.
|
||||
Check of onject module, recordset module and value manager module can be disable, if
|
||||
`Check object (recordset, value manager) module` isn't set.
|
||||
|
||||
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)
|
||||
(if `Check only existing form properties` parameter is set, otherwise, check for all cases).
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
# Optional form parameter access
|
||||
|
||||
Form parameters must be declared explicitly on the Parameters tab of the form editor.
|
||||
In this case, the OnCreateOnServer handler code does not need to check for the existence of properties
|
||||
at the Parameters structure, and the composition of the form parameters itself is explicitly declared
|
||||
(therefore, they are not requiredrecover by examining the entire code of the OnCreateOnServer handler).
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
```bsl
|
||||
&AtServer
|
||||
Procedure OnCreateAtServer(Cancel, StandardProcessing)
|
||||
FirstNameLastName = Undefined;
|
||||
If Parameters.Property("FirstNameLastName", FirstNameLastName) Then
|
||||
Object.Name = FirstNameLastName;
|
||||
EndIf;
|
||||
EndProcedure
|
||||
```
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
```bsl
|
||||
&AtServer
|
||||
Procedure OnCreateAtServer(Cancel, StandardProcessing)
|
||||
Object.Name = Parameters.FirstNameLastName;
|
||||
EndProcedure
|
||||
```
|
||||
|
||||
## See
|
||||
|
||||
- [Opening parameterized forms](https://kb.1ci.com/1C_Enterprise_Platform/Guides/Developer_Guides/1C_Enterprise_Development_Standards/Designing_user_interfaces/Implementation_of_form/Opening_parameterized_forms/)
|
@ -0,0 +1,54 @@
|
||||
# Код расположен после асинхронного вызова
|
||||
|
||||
При асинхронном подходе вызов метода выполняется как обычно, но управление возвращается вызывающему коду до того,
|
||||
как асинхронный метод завершит свою работу. После этого вызывающий код продолжает свое выполнение.
|
||||
Особенность асинхронного выполнения: исполнение на стороне вызывающего кода продолжится до того,
|
||||
как полностью закончилось исполнение вызванного метода.
|
||||
|
||||
Для правильного решения нужно вынести весь код, который должен быть выполнен после выполнения асинхронного действия,
|
||||
в экспортный метод и указать его имя в обработке оповещения, которая будет вызвана после завершения асинхронного действия.
|
||||
Или использовать асинхронность через обещания, например, Ждать ПредупреждениеАсинх(Текст).
|
||||
|
||||
## Неправильно
|
||||
|
||||
```bsl
|
||||
Текст = "Текст предупреждения";
|
||||
ПоказатьПредупреждение( , Текст);
|
||||
Сообщить("Закрыли предупреждение");
|
||||
```
|
||||
|
||||
```bsl
|
||||
ПоказатьПредупреждение(,ТекстПредупреждения);
|
||||
Отказ = Истина;
|
||||
```
|
||||
|
||||
## Правильно
|
||||
|
||||
```bsl
|
||||
Текст = "Текст предупреждения";
|
||||
Ждать ПредупреждениеАсинх(Текст);
|
||||
Сообщить("Закрыли предупреждение");
|
||||
```
|
||||
|
||||
```bsl
|
||||
&НаКлиенте
|
||||
Процедура Команда1(Команда)
|
||||
Оповещение = Новый ОписаниеОповещения("ПредупреждениеЗавершение", ЭтотОбъект);
|
||||
Текст = "Текст предупреждения";
|
||||
ПоказатьПредупреждение(Оповещение, Текст);
|
||||
КонецПроцедуры
|
||||
|
||||
&НаКлиенте
|
||||
Процедура ПредупреждениеЗавершение(ДополнительныеПараметры) Экспорт
|
||||
Сообщить("Закрыли предупреждение");
|
||||
КонецПроцедуры;
|
||||
```
|
||||
|
||||
```bsl
|
||||
Отказ = Истина;
|
||||
ПоказатьПредупреждение(,ТекстПредупреждения);
|
||||
```
|
||||
|
||||
## См.
|
||||
|
||||
- [Синхронные и асинхронные методы работы](https://its.1c.ru/db/v8319doc#bookmark:dev:TI000001505)
|
@ -0,0 +1,11 @@
|
||||
# Обращение к несуществующей роли
|
||||
|
||||
В параметре функции "РольДоступна" должна быть указана существующая роль.
|
||||
|
||||
## Неправильно
|
||||
|
||||
|
||||
## Правильно
|
||||
|
||||
|
||||
## См.
|
@ -0,0 +1,20 @@
|
||||
# Необязательные параметры процедуры/функции расположены перед обязательными
|
||||
|
||||
Необязательные параметры (параметры со значениями по умолчанию)
|
||||
должны располагаться после параметров без значений по умолчанию.
|
||||
|
||||
## Неправильно
|
||||
|
||||
```bsl
|
||||
Функция КурсВалютыНаДату(Дата = Неопределено, Валюта) Экспорт
|
||||
```
|
||||
|
||||
## Правильно
|
||||
|
||||
```bsl
|
||||
Функция КурсВалютыНаДату(Валюта, Дата = Неопределено) Экспорт
|
||||
```
|
||||
|
||||
## См.
|
||||
|
||||
- [Параметры процедур и функций](https://its.1c.ru/db/v8std#content:640:hdoc:4)
|
@ -1,9 +1,13 @@
|
||||
# Избыточное использование псевдонима "ЭтотОбъект"
|
||||
|
||||
Избыточное обращение внутри модуля через псевдоним "ЭтотОбъект" (к методу, свойству или реквизиту)
|
||||
Избыточное обращение внутри модуля через псевдоним "ЭтотОбъект" (к методу, свойству или реквизиту).
|
||||
|
||||
Проверяются общие модули, модули объектов, наборов записей, модули менеджеров значений и модули форм.
|
||||
Проверку модулей объектов, наборов записей и менеджеров значений можно отключить
|
||||
через параметр `Проверять модули объектов (наборов записей, менеджеров значений)`.
|
||||
|
||||
Для модулей форм проверяется только обращение к методам и существующим свойствам
|
||||
(в случае если установлен параметр `Проверять только существовующие свойства в форме`, инчае проверяются все случаи)
|
||||
(в случае если установлен параметр `Проверять только существовующие свойства в форме`, иначе проверяются все случаи).
|
||||
|
||||
## Неправильно
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
# Обращение к опциональному параметру формы
|
||||
|
||||
Параметры формы следует объявлять явно на закладке Параметры редактора формы.
|
||||
В таком случае в коде обработчика ПриСозданииНаСервере не требуется проверять наличие свойств
|
||||
у структуры Параметры, а сам состав параметров формы явно задекларирован (поэтому их не требуется
|
||||
восстанавливать, изучая весь код обработчика ПриСозданииНаСервере).
|
||||
|
||||
## Неправильно
|
||||
|
||||
```bsl
|
||||
&НаСервере
|
||||
Процедура ПриСозданииНаСервере(Отказ, СтандартнаяОбработка)
|
||||
ФамилияИмяОтчество = Неопределено;
|
||||
Если Параметры.Свойство("ФамилияИмяОтчество", ФамилияИмяОтчество) Тогда
|
||||
Объект.Наименование = ФамилияИмяОтчество;
|
||||
КонецЕсли;
|
||||
КонецПроцедуры
|
||||
```
|
||||
|
||||
## Правильно
|
||||
|
||||
```bsl
|
||||
&НаСервере
|
||||
Процедура ПриСозданииНаСервере(Отказ, СтандартнаяОбработка)
|
||||
Объект.Наименование = Параметры.ФамилияИмяОтчество;
|
||||
КонецПроцедуры
|
||||
```
|
||||
|
||||
## См.
|
||||
|
||||
- [Открытие параметризированных форм](https://its.1c.ru/db/v8std#content:741:hdoc)
|
@ -351,6 +351,18 @@
|
||||
category="com.e1c.v8codestyle.bsl"
|
||||
class="com.e1c.v8codestyle.bsl.check.UseGotoOperatorCheck">
|
||||
</check>
|
||||
<check
|
||||
category="com.e1c.v8codestyle.bsl"
|
||||
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.check.IsInRoleMethodRoleExistCheck">
|
||||
</check>
|
||||
<check
|
||||
category="com.e1c.v8codestyle.bsl"
|
||||
class="com.e1c.v8codestyle.bsl.check.MethodOptionalParameterBeforeRequiredCheck">
|
||||
</check>
|
||||
<check
|
||||
category="com.e1c.v8codestyle.bsl"
|
||||
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.check.CodeAfterAsyncCallCheck">
|
||||
</check>
|
||||
<check
|
||||
category="com.e1c.v8codestyle.bsl"
|
||||
class="com.e1c.v8codestyle.internal.bsl.ExecutableExtensionFactory:com.e1c.v8codestyle.bsl.check.UnknownFormParameterAccessCheck">
|
||||
@ -371,6 +383,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.OptionalFormParameterAccessCheck">
|
||||
</check>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.preferences">
|
||||
|
@ -0,0 +1,44 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com._1c.g5.v8.dt.platform.version.Version;
|
||||
|
||||
/**
|
||||
* Platform context asynchronous methods provider
|
||||
*
|
||||
* @author Artem Iliukhin
|
||||
*/
|
||||
public interface IAsyncInvocationProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Global context methods.
|
||||
*
|
||||
* @param version the version of platform, cannot be {@code null}
|
||||
* @return the asynchronous invocation names
|
||||
*/
|
||||
Collection<String> getAsyncInvocationNames(Version version);
|
||||
|
||||
/**
|
||||
* Methods with a list of types in which they are used.
|
||||
*
|
||||
* @param version the version of platform, cannot be {@code null}
|
||||
* @return the asynchronous type method names
|
||||
*/
|
||||
Map<String, Collection<String>> getAsyncTypeMethodNames(Version version);
|
||||
|
||||
}
|
@ -0,0 +1,261 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.INVOCATION;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.xtext.EcoreUtil2;
|
||||
|
||||
import com._1c.g5.v8.dt.bsl.model.AwaitStatement;
|
||||
import com._1c.g5.v8.dt.bsl.model.BslPackage;
|
||||
import com._1c.g5.v8.dt.bsl.model.Conditional;
|
||||
import com._1c.g5.v8.dt.bsl.model.DynamicFeatureAccess;
|
||||
import com._1c.g5.v8.dt.bsl.model.EmptyStatement;
|
||||
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.LoopStatement;
|
||||
import com._1c.g5.v8.dt.bsl.model.PreprocessorConditional;
|
||||
import com._1c.g5.v8.dt.bsl.model.PreprocessorItemStatements;
|
||||
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.bsl.model.TryExceptStatement;
|
||||
import com._1c.g5.v8.dt.bsl.resource.TypesComputer;
|
||||
import com._1c.g5.v8.dt.mcore.Environmental;
|
||||
import com._1c.g5.v8.dt.mcore.TypeItem;
|
||||
import com._1c.g5.v8.dt.mcore.util.McoreUtil;
|
||||
import com._1c.g5.v8.dt.platform.version.IRuntimeVersionSupport;
|
||||
import com._1c.g5.v8.dt.platform.version.Version;
|
||||
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.bsl.IAsyncInvocationProvider;
|
||||
import com.e1c.v8codestyle.check.CommonSenseCheckExtension;
|
||||
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Checks that the asynchronous method is not followed by lines of code,
|
||||
* since in this case the specified lines of code are executed immediately,
|
||||
* without waiting for the asynchronous method to execute.
|
||||
*
|
||||
* @author Artem Iliukhin
|
||||
*/
|
||||
public final class CodeAfterAsyncCallCheck
|
||||
extends BasicCheck
|
||||
{
|
||||
|
||||
private static final String CHECK_ID = "code-after-async-call"; //$NON-NLS-1$
|
||||
private static final String DEFAULT_CHECK = Boolean.toString(Boolean.TRUE);
|
||||
private static final String PARAMETER_NAME = "notifyDescriptionIsDefined"; //$NON-NLS-1$
|
||||
private static final String TYPE_NAME = "NotifyDescription"; //$NON-NLS-1$
|
||||
private final IAsyncInvocationProvider asyncInvocationProvider;
|
||||
private final IRuntimeVersionSupport runtimeVersionSupport;
|
||||
private final TypesComputer typesComputer;
|
||||
|
||||
@Inject
|
||||
public CodeAfterAsyncCallCheck(IRuntimeVersionSupport runtimeVersionSupport,
|
||||
IAsyncInvocationProvider asyncInvocationProvider, TypesComputer typesComputer)
|
||||
{
|
||||
super();
|
||||
this.asyncInvocationProvider = asyncInvocationProvider;
|
||||
this.runtimeVersionSupport = runtimeVersionSupport;
|
||||
this.typesComputer = typesComputer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
{
|
||||
return CHECK_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCheck(CheckConfigurer builder)
|
||||
{
|
||||
builder.title(Messages.CodeAfterAsyncCallCheck_Title)
|
||||
.description(Messages.CodeAfterAsyncCallCheck_Description)
|
||||
.complexity(CheckComplexity.NORMAL)
|
||||
.severity(IssueSeverity.MAJOR)
|
||||
.issueType(IssueType.WARNING)
|
||||
.extension(new CommonSenseCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
|
||||
.module()
|
||||
.checkedObjectType(INVOCATION)
|
||||
.parameter(PARAMETER_NAME, Boolean.class, DEFAULT_CHECK,
|
||||
Messages.CodeAfterAsyncCallCheck_Parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
|
||||
IProgressMonitor monitor)
|
||||
{
|
||||
Version version = runtimeVersionSupport.getRuntimeVersionOrDefault((EObject)object, Version.LATEST);
|
||||
|
||||
Invocation inv = (Invocation)object;
|
||||
FeatureAccess featureAccess = inv.getMethodAccess();
|
||||
if (featureAccess instanceof StaticFeatureAccess)
|
||||
{
|
||||
Collection<String> asyncMethodsNames = asyncInvocationProvider.getAsyncInvocationNames(version);
|
||||
if (asyncMethodsNames.contains(featureAccess.getName())
|
||||
&& (isNotifyDescriptionDefined(inv) || !parameters.getBoolean(PARAMETER_NAME)))
|
||||
{
|
||||
checkNeighboringStatement(resultAceptor, inv);
|
||||
}
|
||||
}
|
||||
else if (featureAccess instanceof DynamicFeatureAccess)
|
||||
{
|
||||
Map<String, Collection<String>> names = asyncInvocationProvider.getAsyncTypeMethodNames(version);
|
||||
if (names.containsKey(featureAccess.getName())
|
||||
&& (isNotifyDescriptionDefined(inv) || !parameters.getBoolean(PARAMETER_NAME)))
|
||||
{
|
||||
Expression source = ((DynamicFeatureAccess)featureAccess).getSource();
|
||||
List<TypeItem> sourceTypes = computeTypes(source);
|
||||
Collection<String> collection = names.get(featureAccess.getName());
|
||||
if (collection.retainAll(sourceTypes.stream().map(McoreUtil::getTypeName).collect(Collectors.toSet())))
|
||||
{
|
||||
checkNeighboringStatement(resultAceptor, inv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNotifyDescriptionDefined(Invocation inv)
|
||||
{
|
||||
for (Expression param : inv.getParams())
|
||||
{
|
||||
List<TypeItem> sourceTypes = computeTypes(param);
|
||||
for (TypeItem typeItem : sourceTypes)
|
||||
{
|
||||
if (TYPE_NAME.equals(McoreUtil.getTypeName(typeItem)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<TypeItem> computeTypes(Expression expression)
|
||||
{
|
||||
Environmental environmental = EcoreUtil2.getContainerOfType(expression, Environmental.class);
|
||||
if (environmental != null)
|
||||
{
|
||||
return typesComputer.computeTypes(expression, environmental.environments());
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
|
||||
private void checkNeighboringStatement(ResultAcceptor resultAceptor, Invocation inv)
|
||||
{
|
||||
Statement statement = getStatementFromInvoc(inv);
|
||||
if (statement != null && !(statement instanceof AwaitStatement))
|
||||
{
|
||||
statement = getNextStatement(statement);
|
||||
if (statement != null && !(statement instanceof ReturnStatement)
|
||||
&& !(statement instanceof EmptyStatement) && !(statement instanceof AwaitStatement))
|
||||
{
|
||||
resultAceptor.addIssue(Messages.CodeAfterAsyncCallCheck_Issue, statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Statement getStatementFromInvoc(Invocation invocation)
|
||||
{
|
||||
EObject container = invocation.eContainer();
|
||||
while (!(container instanceof Statement))
|
||||
{
|
||||
container = container.eContainer();
|
||||
}
|
||||
return container instanceof Statement ? (Statement)container : null;
|
||||
}
|
||||
|
||||
private Statement getNextStatement(Statement statement)
|
||||
{
|
||||
Iterator<EObject> it = EcoreUtil2.getAllContainers(statement).iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
EObject container = it.next();
|
||||
if (container instanceof PreprocessorConditional)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<Statement> st = getContainer(container);
|
||||
if (st != null)
|
||||
{
|
||||
int index = st.indexOf(statement);
|
||||
if (index != -1 && index + 1 < st.size())
|
||||
{
|
||||
return st.get(index + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Statement> getContainer(EObject container)
|
||||
{
|
||||
List<Statement> statements = null;
|
||||
if (container instanceof LoopStatement)
|
||||
{
|
||||
statements = ((LoopStatement)container).getStatements();
|
||||
}
|
||||
else if (container instanceof Conditional)
|
||||
{
|
||||
statements = ((Conditional)container).getStatements();
|
||||
}
|
||||
else if (container instanceof IfStatement)
|
||||
{
|
||||
statements = ((IfStatement)container).getElseStatements();
|
||||
}
|
||||
else if (container instanceof TryExceptStatement)
|
||||
{
|
||||
statements = getStatementsFromContainer((TryExceptStatement)container);
|
||||
}
|
||||
else if (container instanceof PreprocessorItemStatements)
|
||||
{
|
||||
statements = ((PreprocessorItemStatements)container).getStatements();
|
||||
}
|
||||
else
|
||||
{
|
||||
statements = getStatementsFromContainer(container);
|
||||
}
|
||||
return statements;
|
||||
}
|
||||
|
||||
private List<Statement> getStatementsFromContainer(TryExceptStatement container)
|
||||
{
|
||||
List<Statement> res = Lists.newArrayList();
|
||||
res.addAll(container.getTryStatements());
|
||||
res.addAll(container.getExceptStatements());
|
||||
return res;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Statement> getStatementsFromContainer(EObject container)
|
||||
{
|
||||
Object obj = container.eGet(BslPackage.Literals.BLOCK__STATEMENTS);
|
||||
return obj instanceof List ? (List<Statement>)obj : null;
|
||||
}
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.INVOCATION;
|
||||
import static com._1c.g5.v8.dt.bsl.model.BslPackage.Literals.STRING_LITERAL__LINES;
|
||||
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION__ROLES;
|
||||
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.ROLE;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.xtext.naming.IQualifiedNameConverter;
|
||||
import org.eclipse.xtext.resource.IEObjectDescription;
|
||||
import org.eclipse.xtext.scoping.IScope;
|
||||
import org.eclipse.xtext.scoping.IScopeProvider;
|
||||
|
||||
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.StaticFeatureAccess;
|
||||
import com._1c.g5.v8.dt.bsl.model.StringLiteral;
|
||||
import com._1c.g5.v8.dt.common.StringUtils;
|
||||
import com._1c.g5.v8.dt.core.naming.ITopObjectFqnGenerator;
|
||||
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.CommonSenseCheckExtension;
|
||||
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Check the method IsInRole, that first param contains exists roles.
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class IsInRoleMethodRoleExistCheck
|
||||
extends BasicCheck
|
||||
{
|
||||
|
||||
private static final String CHECK_ID = "method-isinrole-role-exist"; //$NON-NLS-1$
|
||||
|
||||
private static final String METHOD_ISINROLE_NAME = "IsInRole"; //$NON-NLS-1$
|
||||
|
||||
private static final String METHOD_ISINROLE_NAME_RU = "РольДоступна"; //$NON-NLS-1$
|
||||
|
||||
private final IScopeProvider scopeProvider;
|
||||
|
||||
private final IQualifiedNameConverter qualifiedNameConverter;
|
||||
|
||||
private final ITopObjectFqnGenerator topObjectFqnGenerator;
|
||||
|
||||
/**
|
||||
* Instantiates a new invocation role check access exist role check.
|
||||
*
|
||||
* @param scopeProvider the scope provider
|
||||
* @param qualifiedNameConverter the qualified name converter
|
||||
* @param topObjectFqnGenerator the top object fqn generator
|
||||
*/
|
||||
@Inject
|
||||
public IsInRoleMethodRoleExistCheck(IScopeProvider scopeProvider, IQualifiedNameConverter qualifiedNameConverter,
|
||||
ITopObjectFqnGenerator topObjectFqnGenerator)
|
||||
{
|
||||
super();
|
||||
this.scopeProvider = scopeProvider;
|
||||
this.qualifiedNameConverter = qualifiedNameConverter;
|
||||
this.topObjectFqnGenerator = topObjectFqnGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
{
|
||||
return CHECK_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCheck(CheckConfigurer builder)
|
||||
{
|
||||
builder.title(Messages.IsInRoleMethodRoleExistCheck_title)
|
||||
.description(Messages.IsInRoleMethodRoleExistCheck_description)
|
||||
.complexity(CheckComplexity.NORMAL)
|
||||
.severity(IssueSeverity.MAJOR)
|
||||
.issueType(IssueType.WARNING)
|
||||
.extension(new CommonSenseCheckExtension(getCheckId(), BslPlugin.PLUGIN_ID))
|
||||
.module()
|
||||
.checkedObjectType(INVOCATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void check(Object object, ResultAcceptor resultAcceptor, ICheckParameters parameters,
|
||||
IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
Invocation inv = (Invocation)object;
|
||||
if (monitor.isCanceled() || !isValidInvocation(inv))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EList<Expression> params = inv.getParams();
|
||||
if (monitor.isCanceled() || params.isEmpty() || !(params.get(0) instanceof StringLiteral))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StringLiteral literal = (StringLiteral)params.get(0);
|
||||
String roleName = literal.lines(true).get(0);
|
||||
|
||||
if (StringUtils.isEmpty(roleName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IEObjectDescription roleDesc = getRoleDescFromScope(inv, roleName);
|
||||
if (!monitor.isCanceled() && roleDesc == null)
|
||||
{
|
||||
String message = MessageFormat
|
||||
.format(Messages.IsInRoleMethodRoleExistCheck_Role_named_not_exists_in_configuration, roleName);
|
||||
resultAcceptor.addIssue(message, literal, STRING_LITERAL__LINES);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isValidInvocation(Invocation invocation)
|
||||
{
|
||||
|
||||
if (invocation.getMethodAccess() instanceof StaticFeatureAccess)
|
||||
{
|
||||
StaticFeatureAccess sfa = (StaticFeatureAccess)invocation.getMethodAccess();
|
||||
if (sfa.getName().equalsIgnoreCase(METHOD_ISINROLE_NAME)
|
||||
|| sfa.getName().equalsIgnoreCase(METHOD_ISINROLE_NAME_RU))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private IEObjectDescription getRoleDescFromScope(Invocation inv, String roleName)
|
||||
{
|
||||
IScope scope = scopeProvider.getScope(inv, CONFIGURATION__ROLES);
|
||||
String fqn = topObjectFqnGenerator.generateStandaloneObjectFqn(ROLE, roleName);
|
||||
return scope.getSingleElement(qualifiedNameConverter.toQualifiedName(fqn));
|
||||
}
|
||||
|
||||
}
|
@ -61,6 +61,14 @@ final class Messages
|
||||
public static String ChangeAndValidateInsteadOfAroundCheck_Use_ChangeAndValidate_instead_of_Around;
|
||||
public static String ChangeAndValidateInsteadOfAroundCheck_title;
|
||||
|
||||
public static String CodeAfterAsyncCallCheck_Description;
|
||||
|
||||
public static String CodeAfterAsyncCallCheck_Issue;
|
||||
|
||||
public static String CodeAfterAsyncCallCheck_Parameter;
|
||||
|
||||
public static String CodeAfterAsyncCallCheck_Title;
|
||||
|
||||
public static String CommitTransactionCheck_Commit_transaction_must_be_in_try_catch;
|
||||
|
||||
public static String CommitTransactionCheck_No_begin_transaction_for_commit_transaction;
|
||||
@ -281,6 +289,8 @@ final class Messages
|
||||
public static String QueryInLoop_Loop_has_query;
|
||||
public static String QueryInLoop_title;
|
||||
|
||||
public static String SelfReferenceCheck_check_object_module;
|
||||
|
||||
public static String SelfReferenceCheck_check_only_existing_form_properties;
|
||||
|
||||
public static String SelfReferenceCheck_Description;
|
||||
@ -366,6 +376,12 @@ final class Messages
|
||||
|
||||
public static String UseNonRecommendedMethods_title;
|
||||
|
||||
public static String MethodOptionalParameterBeforeRequiredCheck_description;
|
||||
|
||||
public static String MethodOptionalParameterBeforeRequiredCheck_Optional_parameter_before_required;
|
||||
|
||||
public static String MethodOptionalParameterBeforeRequiredCheck_title;
|
||||
|
||||
public static String MethodTooManyPramsCheck_description;
|
||||
|
||||
public static String MethodTooManyPramsCheck_Max_parameters;
|
||||
@ -432,6 +448,12 @@ final class Messages
|
||||
|
||||
public static String IsInRoleCheck_Using_IsInRole;
|
||||
|
||||
public static String IsInRoleMethodRoleExistCheck_description;
|
||||
|
||||
public static String IsInRoleMethodRoleExistCheck_Role_named_not_exists_in_configuration;
|
||||
|
||||
public static String IsInRoleMethodRoleExistCheck_title;
|
||||
|
||||
public static String ModuleUndefinedVariableCheck_Title;
|
||||
public static String ModuleUndefinedVariableCheck_Description;
|
||||
public static String ModuleUndefinedVariable_msg;
|
||||
@ -448,6 +470,12 @@ final class Messages
|
||||
|
||||
public static String LockOutOfTry_Method_lock_out_of_try;
|
||||
|
||||
public static String OptionalFormParameterAccessCheck_description;
|
||||
|
||||
public static String OptionalFormParameterAccessCheck_Optional_form_parameter_access;
|
||||
|
||||
public static String OptionalFormParameterAccessCheck_title;
|
||||
|
||||
public static String VariableNameInvalidCheck_description;
|
||||
public static String VariableNameInvalidCheck_message_variable_length_is_less_than;
|
||||
public static String VariableNameInvalidCheck_param_MIN_NAME_LENGTH_PARAM_title;
|
||||
@ -466,4 +494,4 @@ final class Messages
|
||||
{
|
||||
// N/A
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,112 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.METHOD;
|
||||
import static com._1c.g5.v8.dt.mcore.McorePackage.Literals.NAMED_ELEMENT__NAME;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
|
||||
import com._1c.g5.v8.dt.bsl.model.FormalParam;
|
||||
import com._1c.g5.v8.dt.bsl.model.Method;
|
||||
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 methods formal params, that optional parameter before required.
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class MethodOptionalParameterBeforeRequiredCheck
|
||||
extends BasicCheck
|
||||
{
|
||||
|
||||
private static final String CHECK_ID = "method-optional-parameter-before-required"; //$NON-NLS-1$
|
||||
|
||||
public MethodOptionalParameterBeforeRequiredCheck()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
{
|
||||
return CHECK_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCheck(CheckConfigurer builder)
|
||||
{
|
||||
builder.title(Messages.MethodOptionalParameterBeforeRequiredCheck_title)
|
||||
.description(Messages.MethodOptionalParameterBeforeRequiredCheck_description)
|
||||
.complexity(CheckComplexity.NORMAL)
|
||||
.severity(IssueSeverity.TRIVIAL)
|
||||
.issueType(IssueType.CODE_STYLE)
|
||||
.extension(new StandardCheckExtension(640, getCheckId(), BslPlugin.PLUGIN_ID))
|
||||
.module()
|
||||
.checkedObjectType(METHOD);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void check(Object object, ResultAcceptor resultAcceptor, ICheckParameters parameters,
|
||||
IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
Method method = (Method)object;
|
||||
EList<FormalParam> params = method.getFormalParams();
|
||||
if (monitor.isCanceled() || params.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int indexOfOptionalParam = -1;
|
||||
int indexOfRequiredParam = -1;
|
||||
|
||||
for (int i = 0; i < params.size(); i++)
|
||||
{
|
||||
|
||||
if (monitor.isCanceled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.get(i).getDefaultValue() == null)
|
||||
{
|
||||
indexOfRequiredParam = i;
|
||||
}
|
||||
|
||||
if (params.get(i).getDefaultValue() != null && indexOfOptionalParam == -1)
|
||||
{
|
||||
indexOfOptionalParam = i;
|
||||
}
|
||||
|
||||
if (indexOfOptionalParam != -1 && indexOfRequiredParam != -1 && indexOfOptionalParam < indexOfRequiredParam)
|
||||
{
|
||||
resultAcceptor.addIssue(
|
||||
Messages.MethodOptionalParameterBeforeRequiredCheck_Optional_parameter_before_required,
|
||||
params.get(indexOfOptionalParam), NAMED_ELEMENT__NAME);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.INVOCATION;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
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.FeatureAccess;
|
||||
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.model.StringLiteral;
|
||||
import com._1c.g5.v8.dt.common.StringUtils;
|
||||
import com._1c.g5.v8.dt.form.model.Form;
|
||||
import com._1c.g5.v8.dt.form.model.FormParameter;
|
||||
import com._1c.g5.v8.dt.mcore.DuallyNamedElement;
|
||||
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 the Parameter.Property() access to exist parameter of form.
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class OptionalFormParameterAccessCheck
|
||||
extends BasicCheck
|
||||
{
|
||||
|
||||
private static final String CHECK_ID = "optional-form-parameter-access"; //$NON-NLS-1$
|
||||
|
||||
private static final String PROPERTY_NAME_RU = "Свойство"; //$NON-NLS-1$
|
||||
|
||||
private static final String PROPERTY_NAME = "Property"; //$NON-NLS-1$
|
||||
|
||||
private static final String PARAMETERS_KEYWORD_RU = "Параметры"; //$NON-NLS-1$
|
||||
|
||||
private static final String PARAMETERS_KEYWORD = "Parameters"; //$NON-NLS-1$
|
||||
|
||||
public OptionalFormParameterAccessCheck()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
{
|
||||
return CHECK_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCheck(CheckConfigurer builder)
|
||||
{
|
||||
builder.title(Messages.OptionalFormParameterAccessCheck_title)
|
||||
.description(Messages.OptionalFormParameterAccessCheck_description)
|
||||
.complexity(CheckComplexity.NORMAL)
|
||||
.severity(IssueSeverity.MINOR)
|
||||
.issueType(IssueType.CODE_STYLE)
|
||||
.extension(new StandardCheckExtension(741, getCheckId(), BslPlugin.PLUGIN_ID))
|
||||
.extension(ModuleTypeFilter.onlyTypes(ModuleType.FORM_MODULE))
|
||||
.module()
|
||||
.checkedObjectType(INVOCATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void check(Object object, ResultAcceptor resultAcceptor, ICheckParameters parameters,
|
||||
IProgressMonitor monitor)
|
||||
{
|
||||
Invocation inv = (Invocation)object;
|
||||
if (monitor.isCanceled() || !isValidInvocation(inv))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String paramName = getParamName(inv);
|
||||
if (monitor.isCanceled() || StringUtils.isEmpty(paramName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Module module = EcoreUtil2.getContainerOfType(inv, Module.class);
|
||||
EObject moduleOwner = module.getOwner();
|
||||
if (monitor.isCanceled() || !(moduleOwner instanceof Form))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Form form = (Form)moduleOwner;
|
||||
if (!monitor.isCanceled() && findParameter(form, paramName))
|
||||
{
|
||||
String msg = MessageFormat.format(Messages.OptionalFormParameterAccessCheck_Optional_form_parameter_access,
|
||||
paramName);
|
||||
resultAcceptor.addIssue(msg, inv);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidInvocation(Invocation inv)
|
||||
{
|
||||
|
||||
FeatureAccess access = inv.getMethodAccess();
|
||||
if ((access instanceof DynamicFeatureAccess) && !(((DynamicFeatureAccess)access).getFeatureEntries().isEmpty()))
|
||||
{
|
||||
|
||||
DynamicFeatureAccess dfa = (DynamicFeatureAccess)access;
|
||||
EObject featureEntry = dfa.getFeatureEntries().get(0).getFeature();
|
||||
if (featureEntry instanceof DuallyNamedElement)
|
||||
{
|
||||
|
||||
DuallyNamedElement namedElement = (DuallyNamedElement)featureEntry;
|
||||
Expression source = dfa.getSource();
|
||||
if ((namedElement.getName().equalsIgnoreCase(PROPERTY_NAME)
|
||||
|| namedElement.getNameRu().equalsIgnoreCase(PROPERTY_NAME_RU))
|
||||
&& source instanceof StaticFeatureAccess
|
||||
&& !(((StaticFeatureAccess)source).getFeatureEntries().isEmpty()))
|
||||
{
|
||||
featureEntry = ((StaticFeatureAccess)source).getFeatureEntries().get(0).getFeature();
|
||||
if (featureEntry instanceof DuallyNamedElement)
|
||||
{
|
||||
namedElement = (DuallyNamedElement)featureEntry;
|
||||
return (namedElement.getName().equalsIgnoreCase(PARAMETERS_KEYWORD)
|
||||
|| namedElement.getNameRu().equalsIgnoreCase(PARAMETERS_KEYWORD_RU)) && isValidParam(inv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isValidParam(Invocation inv)
|
||||
{
|
||||
return !(inv.getParams().isEmpty() || !(inv.getParams().get(0) instanceof StringLiteral));
|
||||
}
|
||||
|
||||
private String getParamName(Invocation inv)
|
||||
{
|
||||
StringLiteral literal = (StringLiteral)inv.getParams().get(0);
|
||||
return String.join("", literal.lines(true)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private boolean findParameter(Form form, String paramName)
|
||||
{
|
||||
for (FormParameter param : form.getParameters())
|
||||
{
|
||||
if (param.getName().equalsIgnoreCase(paramName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2022, 1C-Soft LLC and others.
|
||||
* Copyright (C) 2023, 1C-Soft LLC and others.
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@ -47,6 +47,7 @@ import com.google.inject.Inject;
|
||||
* (if PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES is set, otherwise, check for all cases)
|
||||
*
|
||||
* @author Maxim Galios
|
||||
* @author Vadim Goncharov
|
||||
*
|
||||
*/
|
||||
public class SelfReferenceCheck
|
||||
@ -57,8 +58,13 @@ public class SelfReferenceCheck
|
||||
|
||||
private static final Collection<String> EXCESSIVE_NAMES = Set.of("ЭтотОбъект", "ThisObject"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final Set<ModuleType> OBJECT_MODULE_TYPE_LIST =
|
||||
Set.of(ModuleType.OBJECT_MODULE, ModuleType.RECORDSET_MODULE, ModuleType.VALUE_MANAGER_MODULE);
|
||||
|
||||
public static final String PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES = "checkOnlyExistingFormProperties"; //$NON-NLS-1$
|
||||
|
||||
public static final String PARAMETER_CHEKC_OBJECT_MODULE = "checkObjectModule"; //$NON-NLS-1$
|
||||
|
||||
private DynamicFeatureAccessComputer dynamicFeatureAccessComputer;
|
||||
|
||||
/**
|
||||
@ -88,10 +94,16 @@ public class SelfReferenceCheck
|
||||
.severity(IssueSeverity.MINOR)
|
||||
.issueType(IssueType.CODE_STYLE)
|
||||
.extension(new StandardCheckExtension(467, getCheckId(), BslPlugin.PLUGIN_ID))
|
||||
.extension(ModuleTypeFilter.excludeTypes(ModuleType.ORDINARY_APP_MODULE, ModuleType.MANAGED_APP_MODULE,
|
||||
ModuleType.EXTERNAL_CONN_MODULE, ModuleType.SESSION_MODULE, ModuleType.MANAGER_MODULE,
|
||||
ModuleType.WEB_SERVICE_MODULE, ModuleType.HTTP_SERVICE_MODULE, ModuleType.INTEGRATION_SERVICE_MODULE,
|
||||
ModuleType.BOT_MODULE))
|
||||
.module()
|
||||
.checkedObjectType(DYNAMIC_FEATURE_ACCESS)
|
||||
.parameter(PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES, Boolean.class, Boolean.TRUE.toString(),
|
||||
Messages.SelfReferenceCheck_check_only_existing_form_properties);
|
||||
Messages.SelfReferenceCheck_check_only_existing_form_properties)
|
||||
.parameter(PARAMETER_CHEKC_OBJECT_MODULE, Boolean.class, Boolean.TRUE.toString(),
|
||||
Messages.SelfReferenceCheck_check_object_module);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,28 +120,35 @@ public class SelfReferenceCheck
|
||||
|
||||
StaticFeatureAccess source = (StaticFeatureAccess)featureAccessSource;
|
||||
|
||||
if (isReferenceExcessive(dynamicFeatureAccess, source,
|
||||
parameters.getBoolean(PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES)))
|
||||
if (isReferenceExcessive(dynamicFeatureAccess, source, parameters))
|
||||
{
|
||||
resultAceptor.addIssue(Messages.SelfReferenceCheck_Issue,
|
||||
source);
|
||||
resultAceptor.addIssue(Messages.SelfReferenceCheck_Issue, source);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isReferenceExcessive(DynamicFeatureAccess dynamicFeatureAccess, StaticFeatureAccess source,
|
||||
boolean checkOnlyExistingFormProperties)
|
||||
ICheckParameters parameters)
|
||||
{
|
||||
|
||||
boolean checkOnlyExistingFormProperties = parameters.getBoolean(PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES);
|
||||
boolean checkObjectModule = parameters.getBoolean(PARAMETER_CHEKC_OBJECT_MODULE);
|
||||
|
||||
if (!EXCESSIVE_NAMES.contains(source.getName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Module module = EcoreUtil2.getContainerOfType(dynamicFeatureAccess, Module.class);
|
||||
if (!checkObjectModule && OBJECT_MODULE_TYPE_LIST.contains(module.getModuleType()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkOnlyExistingFormProperties || (dynamicFeatureAccess.eContainer() instanceof Invocation))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Module module = EcoreUtil2.getContainerOfType(dynamicFeatureAccess, Module.class);
|
||||
|
||||
|
||||
return !(module.getModuleType() == ModuleType.FORM_MODULE
|
||||
&& isEmptySource(dynamicFeatureAccessComputer.resolveObject(dynamicFeatureAccess, module.environments())));
|
||||
}
|
||||
|
@ -62,6 +62,14 @@ ChangeAndValidateInsteadOfAroundCheck_description = Checks that pragma &ChangeAn
|
||||
|
||||
ChangeAndValidateInsteadOfAroundCheck_title = Use pragma &ChangeAndValidate instead of &Around
|
||||
|
||||
CodeAfterAsyncCallCheck_Description = Checks that the asynchronous method is not followed by lines of code, since in this case the specified lines of code are executed immediately, without waiting for the asynchronous method to execute
|
||||
|
||||
CodeAfterAsyncCallCheck_Issue = The asynchronous method is followed by lines of code
|
||||
|
||||
CodeAfterAsyncCallCheck_Parameter = Only with the defined parameter NotifyDescription, if applicable
|
||||
|
||||
CodeAfterAsyncCallCheck_Title = The code should not follow an asynchronous call
|
||||
|
||||
CommitTransactionCheck_Commit_transaction_must_be_in_try_catch = Commit transaction must be in a try-catch
|
||||
|
||||
CommitTransactionCheck_No_begin_transaction_for_commit_transaction = There is no begin transaction for commit transaction
|
||||
@ -146,6 +154,12 @@ ExportMethodInCommandModule_Do_not_emded_export_method_in_modules_of_command_res
|
||||
|
||||
ExportMethodInCommandModule_Do_not_use_export_method_in_commands_module = Restrictions on the use of export procedures and functions
|
||||
|
||||
ExportProcedureMissingCommentCheck_Export_procedure_missing_comment = Export procedure (function) "{0}" should be described by adding comment
|
||||
|
||||
ExportProcedureMissingCommentCheck_description = Export procedure (function) should be described by adding comment
|
||||
|
||||
ExportProcedureMissingCommentCheck_title = Export procedure (function) should be described by adding comment
|
||||
|
||||
ExportVariableInObjectModuleCheck_Description = Use of an export variable is not recommended
|
||||
|
||||
ExportVariableInObjectModuleCheck_Issue = It's not recommended to use the export variable in the object module
|
||||
@ -156,12 +170,6 @@ ExtensionMethodPrefixCheck_Description = The procedure (function) in the module
|
||||
|
||||
ExtensionMethodPrefixCheck_Ext_method__0__should_have__1__prefix = The method "{0}" should have "{1}" prefix
|
||||
|
||||
ExportProcedureMissingCommentCheck_description=Export procedure (function) should be described by adding comment
|
||||
|
||||
ExportProcedureMissingCommentCheck_Export_procedure_missing_comment=Export procedure (function) "{0}" should be described by adding comment
|
||||
|
||||
ExportProcedureMissingCommentCheck_title=Export procedure (function) should be described by adding comment
|
||||
|
||||
ExtensionMethodPrefixCheck_Title = Extension method does not have extension prefix
|
||||
|
||||
ExtensionVariablePrefixCheck_Description = The variable in the module of the extension object does not have a prefix corresponding to the prefix of the extension itself
|
||||
@ -208,6 +216,12 @@ IsInRoleCheck_Use_AccessRight_instead_IsInRole = Use the AccessRight() function
|
||||
|
||||
IsInRoleCheck_Using_IsInRole = Using "IsInRole" method
|
||||
|
||||
IsInRoleMethodRoleExistCheck_Role_named_not_exists_in_configuration=Role named {0} not exists in configuration
|
||||
|
||||
IsInRoleMethodRoleExistCheck_description=Referring to a non-existent role
|
||||
|
||||
IsInRoleMethodRoleExistCheck_title=Referring to a non-existent role
|
||||
|
||||
LockOutOfTry_Checks_for_init_of_the_data_lock = Checks for initialization of the data lock. If the creation of a lock is found, the call of the Lock() method is checked, and the call must be in a try.
|
||||
|
||||
LockOutOfTry_Lock_out_of_try = Lock out of Try
|
||||
@ -220,6 +234,12 @@ ManagerModuleNamedSelfReferenceCheck_issue = Excessive named self reference
|
||||
|
||||
ManagerModuleNamedSelfReferenceCheck_title = Excessive named self reference in manager module
|
||||
|
||||
MethodOptionalParameterBeforeRequiredCheck_description=Optional parameter before required
|
||||
|
||||
MethodOptionalParameterBeforeRequiredCheck_Optional_parameter_before_required=Optional parameter before required
|
||||
|
||||
MethodOptionalParameterBeforeRequiredCheck_title=Optional parameter before required
|
||||
|
||||
MethodTooManyPramsCheck_Max_parameters = Max parameters
|
||||
|
||||
MethodTooManyPramsCheck_Max_parameters_with_default_value = Max parameters with default value
|
||||
@ -382,6 +402,12 @@ NstrStringLiteralFormatCheck_description = NStr string literal format
|
||||
|
||||
NstrStringLiteralFormatCheck_title = NStr string literal format
|
||||
|
||||
OptionalFormParameterAccessCheck_description = Optional form parameter access
|
||||
|
||||
OptionalFormParameterAccessCheck_Optional_form_parameter_access = Optional form parameter {0} access
|
||||
|
||||
OptionalFormParameterAccessCheck_title = Optional form parameter access
|
||||
|
||||
QueryInLoop_Loop_has_method_with_query__0 = Loop has method with query "{0}"
|
||||
|
||||
QueryInLoop_Loop_has_query = Loop has query
|
||||
@ -432,6 +458,8 @@ SelfReferenceCheck_Issue = Excessive usage of self reference (when referencing m
|
||||
|
||||
SelfReferenceCheck_Title = Excessive self reference
|
||||
|
||||
SelfReferenceCheck_check_object_module = Check object (recordset, value manager) module
|
||||
|
||||
SelfReferenceCheck_check_only_existing_form_properties = Check only existing form properties
|
||||
|
||||
ServerExecutionSafeModeCheck_description = Safe mode is not enabled when calling "Execute" or "Eval'
|
||||
@ -472,16 +500,16 @@ UseNonRecommendedMethods_parameter = List of non-recommended methods
|
||||
|
||||
UseNonRecommendedMethods_title = Using non-recommended methods
|
||||
|
||||
VariableNameInvalidCheck_description=Variable name is invalid
|
||||
VariableNameInvalidCheck_description = Variable name is invalid
|
||||
|
||||
VariableNameInvalidCheck_message_variable_length_is_less_than=variable length is less than {0}
|
||||
VariableNameInvalidCheck_message_variable_length_is_less_than = variable length is less than {0}
|
||||
|
||||
VariableNameInvalidCheck_param_MIN_NAME_LENGTH_PARAM_title=Min. lenght of variable name
|
||||
VariableNameInvalidCheck_param_MIN_NAME_LENGTH_PARAM_title = Min. lenght of variable name
|
||||
|
||||
VariableNameInvalidCheck_title=Variable name is invalid
|
||||
VariableNameInvalidCheck_title = Variable name is invalid
|
||||
|
||||
VariableNameInvalidCheck_variable_name_is_invalid=Variable name {0} is invalid: {1}
|
||||
VariableNameInvalidCheck_variable_name_is_invalid = Variable name {0} is invalid: {1}
|
||||
|
||||
VariableNameInvalidCheck_variable_name_must_start_with_a_capital_letter=variable name must start with a capital letter
|
||||
VariableNameInvalidCheck_variable_name_must_start_with_a_capital_letter = variable name must start with a capital letter
|
||||
|
||||
VariableNameInvalidCheck_variable_name_starts_with_an_underline=variable name starts with an underline
|
||||
VariableNameInvalidCheck_variable_name_starts_with_an_underline = variable name starts with an underline
|
||||
|
@ -62,6 +62,14 @@ ChangeAndValidateInsteadOfAroundCheck_description = Проверяет, что
|
||||
|
||||
ChangeAndValidateInsteadOfAroundCheck_title = Используется аннотация &ИзменениеИКонтроль вместо &Вместо
|
||||
|
||||
CodeAfterAsyncCallCheck_Description = Проверяет, что за асинхронным методом не следуют строки кода, поскольку в этом случае указанные строки кода выполняются немедленно, не дожидаясь выполнения асинхронного метода
|
||||
|
||||
CodeAfterAsyncCallCheck_Issue = За асинхронным методом следуют строки кода
|
||||
|
||||
CodeAfterAsyncCallCheck_Parameter = Tолько с заданным параметром ОписаниеОповещения, если применимо
|
||||
|
||||
CodeAfterAsyncCallCheck_Title = Код не должен следовать за асинхронным вызовом
|
||||
|
||||
CommitTransactionCheck_Commit_transaction_must_be_in_try_catch = Вызов "ЗафиксироватьТранзакцию()" находится вне конструкции "Попытка... Исключение"
|
||||
|
||||
CommitTransactionCheck_No_begin_transaction_for_commit_transaction = Отсутствует вызов "НачатьТранзакцию()", хотя вызываются "ЗафиксироватьТранзакцию()"
|
||||
@ -146,6 +154,12 @@ ExportMethodInCommandModule_Do_not_emded_export_method_in_modules_of_command_res
|
||||
|
||||
ExportMethodInCommandModule_Do_not_use_export_method_in_commands_module = Ограничения на использование экспортных процедур и функций
|
||||
|
||||
ExportProcedureMissingCommentCheck_Export_procedure_missing_comment = Отсутствует комментарий к экспортной процедуре (функции) "{0}"
|
||||
|
||||
ExportProcedureMissingCommentCheck_description = Отсутствует комментарий к экспортной процедуре (функции)
|
||||
|
||||
ExportProcedureMissingCommentCheck_title = Отсутствует комментарий к экспортной процедуре (функции)
|
||||
|
||||
ExportVariableInObjectModuleCheck_Description = Использование экспортной переменной не рекомендовано
|
||||
|
||||
ExportVariableInObjectModuleCheck_Issue = Не рекомендуется использовать экспортную переменную в модуле объекта
|
||||
@ -162,12 +176,6 @@ ExtensionVariablePrefixCheck_Description = Переменная модуля р
|
||||
|
||||
ExtensionVariablePrefixCheck_Title = Переменная расширения должна содержать в имени префикс расширения
|
||||
|
||||
ExportProcedureMissingCommentCheck_description=Отсутствует комментарий к экспортной процедуре (функции)
|
||||
|
||||
ExportProcedureMissingCommentCheck_Export_procedure_missing_comment=Отсутствует комментарий к экспортной процедуре (функции) "{0}"
|
||||
|
||||
ExportProcedureMissingCommentCheck_title=Отсутствует комментарий к экспортной процедуре (функции)
|
||||
|
||||
ExtensionVariablePrefixCheck_Variable_0_should_have_1_prefix = Переменная "{0}" должна иметь префикс "{1}"
|
||||
|
||||
FormDataToValueCheck_Description = Использование ДанныеФормыВЗначение вместо РеквизитФормыВЗначение
|
||||
@ -208,6 +216,12 @@ IsInRoleCheck_Use_AccessRight_instead_IsInRole = Используйте функ
|
||||
|
||||
IsInRoleCheck_Using_IsInRole = Использован не рекомендованный метод "РольДоступна"
|
||||
|
||||
IsInRoleMethodRoleExistCheck_Role_named_not_exists_in_configuration = Роль {0} не существует в конфигурации
|
||||
|
||||
IsInRoleMethodRoleExistCheck_description = Обращение к несуществующей роли
|
||||
|
||||
IsInRoleMethodRoleExistCheck_title = Обращение к несуществующей роли
|
||||
|
||||
LockOutOfTry_Checks_for_init_of_the_data_lock = Правило проверяет наличие инициализации блокировки данных. В случае если найдено создание блокировки, проверяется вызов метода "Заблокировать()", при этом вызов должен быть в попытке.
|
||||
|
||||
LockOutOfTry_Lock_out_of_try = Метод Заблокировать() вне блока Попытка-Исключение
|
||||
@ -220,6 +234,12 @@ ManagerModuleNamedSelfReferenceCheck_issue = Избыточное обращен
|
||||
|
||||
ManagerModuleNamedSelfReferenceCheck_title = Избыточное обращение по собственному имени в модуле менеджера
|
||||
|
||||
MethodOptionalParameterBeforeRequiredCheck_Optional_parameter_before_required = Обязательный параметр расположен перед обязательным
|
||||
|
||||
MethodOptionalParameterBeforeRequiredCheck_description = Обязательный параметр расположен перед обязательным
|
||||
|
||||
MethodOptionalParameterBeforeRequiredCheck_title = Обязательный параметр расположен перед обязательным
|
||||
|
||||
MethodTooManyPramsCheck_Max_parameters = Максимум параметров
|
||||
|
||||
MethodTooManyPramsCheck_Max_parameters_with_default_value = Максимум параметров со значением по умолчанию
|
||||
@ -382,6 +402,12 @@ NstrStringLiteralFormatCheck_description = НСтр формат строков
|
||||
|
||||
NstrStringLiteralFormatCheck_title = НСтр формат строкового литерала
|
||||
|
||||
OptionalFormParameterAccessCheck_Optional_form_parameter_access = Обращение к опциональному параметру формы {0}
|
||||
|
||||
OptionalFormParameterAccessCheck_description = Обращение к опциональному параметру формы
|
||||
|
||||
OptionalFormParameterAccessCheck_title = Обращение к опциональному параметру формы
|
||||
|
||||
QueryInLoop_Loop_has_method_with_query__0 = Цикл содержит вызов метода с запросом "{0}"
|
||||
|
||||
QueryInLoop_Loop_has_query = Цикл содержит выполнение запроса
|
||||
@ -432,6 +458,8 @@ SelfReferenceCheck_Issue = Избыточное обращение внутри
|
||||
|
||||
SelfReferenceCheck_Title = Избыточное использование псевдонима "ЭтотОбъект"
|
||||
|
||||
SelfReferenceCheck_check_object_module = Проверять модули объектов (наборов записей, менеджеров значений)
|
||||
|
||||
SelfReferenceCheck_check_only_existing_form_properties = Проверять только существующие свойства в форме
|
||||
|
||||
ServerExecutionSafeModeCheck_description = Отсутствует включение безопасного режима перед вызовом метода "Выполнить" или "Вычислить"
|
||||
@ -484,4 +512,4 @@ VariableNameInvalidCheck_variable_name_is_invalid = Имя переменной
|
||||
|
||||
VariableNameInvalidCheck_variable_name_must_start_with_a_capital_letter = имя переменной должно начинаться с заглавной буквы
|
||||
|
||||
VariableNameInvalidCheck_variable_name_starts_with_an_underline = имя переменной начинается с символа подчеркивания
|
||||
VariableNameInvalidCheck_variable_name_starts_with_an_underline = имя переменной начинается с символа подчеркивания
|
||||
|
@ -36,9 +36,9 @@ FunctionCtorReturnSectionCheck_Declared_property__N__with_type__T__missing_retur
|
||||
|
||||
FunctionCtorReturnSectionCheck_Declared_property__N__with_type__T__not_returning = Декларируемое свойство "{0}" с типом: "{1}" не возвращается
|
||||
|
||||
FunctionCtorReturnSectionCheck_Return_non_declared_propertes__N = Возвращается не декларируемое свойство: "{0}"
|
||||
FunctionCtorReturnSectionCheck_Return_non_declared_propertes__N = Возвращается недекларируемое свойство: "{0}"
|
||||
|
||||
FunctionCtorReturnSectionCheck_Return_non_declared_type__T = Возвращается не декларированный тип: {0}
|
||||
FunctionCtorReturnSectionCheck_Return_non_declared_type__T = Возвращается недекларированный тип: {0}
|
||||
|
||||
FunctionCtorReturnSectionCheck_User_extandable_Data_type_list_comma_separated = Список типов данных расширяемых пользователем, через запятую
|
||||
|
||||
@ -84,9 +84,9 @@ StructureCtorValueTypeCheck_description = Проверяет строковый
|
||||
|
||||
StructureCtorValueTypeCheck_title = Типизация значений в конструкторе структуры
|
||||
|
||||
TypedValueAddingToUntypedCollectionCheck_description = Добавление типизированного значения в не типизированную коллекцию
|
||||
TypedValueAddingToUntypedCollectionCheck_description = Добавление типизированного значения в нетипизированную коллекцию
|
||||
|
||||
TypedValueAddingToUntypedCollectionCheck_title = Добавление типизированного значения в не типизированную коллекцию
|
||||
TypedValueAddingToUntypedCollectionCheck_title = Добавление типизированного значения в нетипизированную коллекцию
|
||||
|
||||
VariableTypeCheck_Variable_M_has_no_value_type = Переменная "{0}" не имеет типа
|
||||
|
||||
|
@ -0,0 +1,242 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.internal.bsl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.xtext.resource.IEObjectDescription;
|
||||
|
||||
import com._1c.g5.v8.dt.bm.xtext.BmAwareResourceSetProvider;
|
||||
import com._1c.g5.v8.dt.core.platform.IV8Project;
|
||||
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
|
||||
import com._1c.g5.v8.dt.mcore.ContextDef;
|
||||
import com._1c.g5.v8.dt.mcore.McorePackage;
|
||||
import com._1c.g5.v8.dt.mcore.Method;
|
||||
import com._1c.g5.v8.dt.mcore.ParamSet;
|
||||
import com._1c.g5.v8.dt.mcore.Parameter;
|
||||
import com._1c.g5.v8.dt.mcore.Type;
|
||||
import com._1c.g5.v8.dt.mcore.TypeItem;
|
||||
import com._1c.g5.v8.dt.mcore.TypeSet;
|
||||
import com._1c.g5.v8.dt.mcore.util.Environment;
|
||||
import com._1c.g5.v8.dt.mcore.util.McoreUtil;
|
||||
import com._1c.g5.v8.dt.platform.IEObjectProvider;
|
||||
import com._1c.g5.v8.dt.platform.version.Version;
|
||||
import com.e1c.v8codestyle.bsl.IAsyncInvocationProvider;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Implementing service to provide asynchronous methods
|
||||
*
|
||||
* @author Artem Iliukhin
|
||||
*/
|
||||
public class AsyncInvocationProvider
|
||||
implements IAsyncInvocationProvider
|
||||
{
|
||||
|
||||
private static final String RET_TYPE_NAME = "Promise"; //$NON-NLS-1$
|
||||
private static final String EXEPTION_NAME = "RunCallback"; //$NON-NLS-1$
|
||||
private static final String TYPE_NAME = "NotifyDescription"; //$NON-NLS-1$
|
||||
private final Map<Version, Collection<String>> cashNames;
|
||||
private final Map<Version, Map<String, Collection<String>>> cashTypesMethodNames;
|
||||
private final IV8ProjectManager v8ProjectManager;
|
||||
private final BmAwareResourceSetProvider resourceSetProvider;
|
||||
private final Set<Environment> clientEnv;
|
||||
|
||||
@Inject
|
||||
public AsyncInvocationProvider(IV8ProjectManager v8ProjectManager, BmAwareResourceSetProvider resourceSetProvider)
|
||||
{
|
||||
super();
|
||||
this.v8ProjectManager = v8ProjectManager;
|
||||
this.resourceSetProvider = resourceSetProvider;
|
||||
this.cashNames = new ConcurrentHashMap<>();
|
||||
this.cashTypesMethodNames = new ConcurrentHashMap<>();
|
||||
this.clientEnv = Set.of(Environment.CLIENT, Environment.MNG_CLIENT, Environment.MOBILE_CLIENT,
|
||||
Environment.MOBILE_THIN_CLIENT, Environment.THIN_CLIENT, Environment.WEB_CLIENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getAsyncInvocationNames(Version version)
|
||||
{
|
||||
return cashNames.computeIfAbsent(version, this::collectGlobalAsyncMethods);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Collection<String>> getAsyncTypeMethodNames(Version version)
|
||||
{
|
||||
return cashTypesMethodNames.computeIfAbsent(version, this::collectAsyncMethods);
|
||||
}
|
||||
|
||||
private Collection<String> collectGlobalAsyncMethods(Version version)
|
||||
{
|
||||
Collection<String> asyncMethodsNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
||||
Iterator<IV8Project> iterator = v8ProjectManager.getProjects().iterator();
|
||||
if (iterator.hasNext())
|
||||
{
|
||||
ResourceSet context = resourceSetProvider.get(iterator.next().getProject());
|
||||
IEObjectProvider provider = IEObjectProvider.Registry.INSTANCE.get(McorePackage.Literals.METHOD, version);
|
||||
Iterable<IEObjectDescription> items = provider.getEObjectDescriptions(null);
|
||||
for (IEObjectDescription item : items)
|
||||
{
|
||||
EObject object = EcoreUtil.resolve(item.getEObjectOrProxy(), context);
|
||||
if (object instanceof Method)
|
||||
{
|
||||
collectMethod(asyncMethodsNames, (Method)object);
|
||||
}
|
||||
}
|
||||
}
|
||||
return asyncMethodsNames;
|
||||
}
|
||||
|
||||
private Map<String, Collection<String>> collectAsyncMethods(Version version)
|
||||
{
|
||||
Map<String, Collection<String>> asyncMethodsNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
Iterator<IV8Project> iterator = v8ProjectManager.getProjects().iterator();
|
||||
if (iterator.hasNext())
|
||||
{
|
||||
ResourceSet context = resourceSetProvider.get(iterator.next().getProject());
|
||||
IEObjectProvider provider =
|
||||
IEObjectProvider.Registry.INSTANCE.get(McorePackage.Literals.TYPE_ITEM, version);
|
||||
Iterable<IEObjectDescription> items = provider.getEObjectDescriptions(null);
|
||||
|
||||
for (IEObjectDescription item : items)
|
||||
{
|
||||
EObject object = EcoreUtil.resolve(item.getEObjectOrProxy(), context);
|
||||
if (object instanceof Type)
|
||||
{
|
||||
Type type = (Type)object;
|
||||
process(asyncMethodsNames, type);
|
||||
}
|
||||
else if (object instanceof TypeSet)
|
||||
{
|
||||
TypeSet typeSet = (TypeSet)object;
|
||||
for (Type type : typeSet.getTypes())
|
||||
{
|
||||
process(asyncMethodsNames, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return asyncMethodsNames;
|
||||
}
|
||||
|
||||
private void process(Map<String, Collection<String>> asyncMethodsNames, Type type)
|
||||
{
|
||||
if (type == null || type.eIsProxy())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ContextDef contextDef = type.getContextDef();
|
||||
if (contextDef == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Method method : contextDef.allMethods())
|
||||
{
|
||||
if (isClient(method) && isRetTypePromise(method))
|
||||
{
|
||||
if (asyncMethodsNames.get(method.getName()) == null)
|
||||
{
|
||||
asyncMethodsNames.putIfAbsent(method.getName(), new TreeSet<>());
|
||||
asyncMethodsNames.putIfAbsent(method.getNameRu(), new TreeSet<>());
|
||||
}
|
||||
asyncMethodsNames.get(method.getName()).add(type.getName());
|
||||
asyncMethodsNames.get(method.getName()).add(type.getNameRu());
|
||||
asyncMethodsNames.get(method.getNameRu()).add(type.getName());
|
||||
asyncMethodsNames.get(method.getNameRu()).add(type.getNameRu());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void collectMethod(Collection<String> asyncMethodsNames, Method method)
|
||||
{
|
||||
if (EXEPTION_NAME.equals(method.getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isMethodAsync(method))
|
||||
{
|
||||
asyncMethodsNames.add(method.getName());
|
||||
asyncMethodsNames.add(method.getNameRu());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMethodAsync(Method method)
|
||||
{
|
||||
if (isClient(method) && isRetTypePromise(method))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (ParamSet paramSet : method.getParamSet())
|
||||
{
|
||||
for (Parameter param : paramSet.getParams())
|
||||
{
|
||||
if (isCallbackDescription(param))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isClient(Method method)
|
||||
{
|
||||
for (Environment env : method.environments().toArray())
|
||||
{
|
||||
if (!clientEnv.contains(env))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isRetTypePromise(Method method)
|
||||
{
|
||||
for (TypeItem type : method.getRetValType())
|
||||
{
|
||||
if (RET_TYPE_NAME.equals(McoreUtil.getTypeName(type)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isCallbackDescription(Parameter param)
|
||||
{
|
||||
for (TypeItem type : param.getType())
|
||||
{
|
||||
if (TYPE_NAME.equals(McoreUtil.getTypeName(type)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -20,6 +20,7 @@ import org.osgi.framework.BundleContext;
|
||||
import com._1c.g5.v8.dt.bsl.model.BslPackage;
|
||||
import com._1c.g5.wiring.InjectorAwareServiceRegistrator;
|
||||
import com._1c.g5.wiring.ServiceInitialization;
|
||||
import com.e1c.v8codestyle.bsl.IAsyncInvocationProvider;
|
||||
import com.e1c.v8codestyle.bsl.IModuleStructureProvider;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
@ -131,6 +132,7 @@ public class BslPlugin
|
||||
ServiceInitialization.schedule(() -> {
|
||||
// register services from injector
|
||||
registrator.service(IModuleStructureProvider.class).registerInjected();
|
||||
registrator.service(IAsyncInvocationProvider.class).registerInjected();
|
||||
registrator.managedService(MultiCheckFixRegistrator.class).activateBeforeRegistration().registerInjected();
|
||||
});
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
|
||||
import org.eclipse.xtext.scoping.IScopeProvider;
|
||||
|
||||
import com._1c.g5.v8.dt.bm.xtext.BmAwareResourceSetProvider;
|
||||
import com._1c.g5.v8.dt.bsl.common.IBslPreferences;
|
||||
import com._1c.g5.v8.dt.bsl.contextdef.IBslModuleContextDefService;
|
||||
import com._1c.g5.v8.dt.bsl.documentation.comment.BslMultiLineCommentDocumentationProvider;
|
||||
@ -42,6 +43,7 @@ import com._1c.g5.v8.dt.platform.version.IRuntimeVersionSupport;
|
||||
import com._1c.g5.wiring.AbstractServiceAwareModule;
|
||||
import com.e1c.g5.v8.dt.check.qfix.IFixRepository;
|
||||
import com.e1c.g5.v8.dt.check.settings.ICheckRepository;
|
||||
import com._1c.g5.v8.dt.core.naming.ITopObjectFqnGenerator;
|
||||
|
||||
/**
|
||||
* The external dependencies for plugin
|
||||
@ -66,6 +68,7 @@ class ExternalDependenciesModule
|
||||
bind(IBslPreferences.class).toService();
|
||||
bind(IQualifiedNameConverter.class).toService();
|
||||
bind(IBslModuleContextDefService.class).toService();
|
||||
bind(ITopObjectFqnGenerator.class).toService();
|
||||
|
||||
bind(ICheckRepository.class).toService();
|
||||
bind(IFixRepository.class).toService();
|
||||
@ -91,5 +94,6 @@ class ExternalDependenciesModule
|
||||
bind(ResourceDescriptionsProvider.class).toService();
|
||||
bind(IConfigurationProvider.class).toService();
|
||||
bind(BslGrammarAccess.class).toProvider(() -> rsp.get(BslGrammarAccess.class));
|
||||
bind(BmAwareResourceSetProvider.class).toProvider(() -> rsp.get(BmAwareResourceSetProvider.class));
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
*******************************************************************************/
|
||||
package com.e1c.v8codestyle.internal.bsl;
|
||||
|
||||
import com.e1c.v8codestyle.bsl.IAsyncInvocationProvider;
|
||||
import com.e1c.v8codestyle.bsl.IModuleStructureProvider;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Singleton;
|
||||
@ -29,6 +30,7 @@ public class ServiceModule
|
||||
protected void configure()
|
||||
{
|
||||
bind(IModuleStructureProvider.class).to(ModuleStructureProvider.class).in(Singleton.class);
|
||||
bind(IAsyncInvocationProvider.class).to(AsyncInvocationProvider.class).in(Singleton.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
# Role-based setting of visibility (editing, use) for the form element is used
|
||||
|
||||
In case of a large number of roles in the configuration (from several
|
||||
tens) it is not recommended to use the role-based visibility setting in
|
||||
form elements (viewing and editing details by roles,
|
||||
user visibility of form fields by roles, use of commands by
|
||||
roles).
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
## See
|
||||
|
||||
[Checking permissions](https://its.1c.ru/db/v8std#content:737:hdoc:1)
|
@ -0,0 +1,15 @@
|
||||
# Использована ролевая настройка видимости (редактирования, использования) для элемента формы
|
||||
|
||||
В случае большого количества ролей в конфигурации (от нескольких
|
||||
десятков) не рекомендуется использовать ролевую настройку видимости в
|
||||
элементах форм (просмотр и редактирование реквизитов по ролям,
|
||||
пользовательскую видимость полей формы по ролям, использование команд по
|
||||
ролям).
|
||||
|
||||
## Неправильно
|
||||
|
||||
## Правильно
|
||||
|
||||
## См.
|
||||
|
||||
[Checking permissions](https://its.1c.ru/db/v8std#content:737:hdoc:1)
|
@ -50,6 +50,10 @@
|
||||
category="com.e1c.v8codestyle.form"
|
||||
class="com.e1c.v8codestyle.internal.form.ExecutableExtensionFactory:com.e1c.v8codestyle.form.check.FormCommandsSingleEventHandlerCheck">
|
||||
</check>
|
||||
<check
|
||||
category="com.e1c.v8codestyle.form"
|
||||
class="com.e1c.v8codestyle.form.check.FormItemVisibleSettingsByRolesCheck">
|
||||
</check>
|
||||
</extension>
|
||||
<extension
|
||||
point="com.e1c.g5.v8.dt.check.fixes">
|
||||
|
@ -0,0 +1,171 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.form.check;
|
||||
|
||||
import static com._1c.g5.v8.dt.form.model.FormPackage.Literals.ABSTRACT_FORM_ATTRIBUTE__EDIT;
|
||||
import static com._1c.g5.v8.dt.form.model.FormPackage.Literals.ABSTRACT_FORM_ATTRIBUTE__VIEW;
|
||||
import static com._1c.g5.v8.dt.form.model.FormPackage.Literals.FORM;
|
||||
import static com._1c.g5.v8.dt.form.model.FormPackage.Literals.FORM_COMMAND__USE;
|
||||
import static com._1c.g5.v8.dt.form.model.FormPackage.Literals.VISIBLE__USER_VISIBLE;
|
||||
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.ADJUSTABLE_BOOLEAN;
|
||||
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.ADJUSTABLE_BOOLEAN__COMMON;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.EStructuralFeature;
|
||||
|
||||
import com._1c.g5.v8.dt.form.model.FormAttribute;
|
||||
import com._1c.g5.v8.dt.form.model.FormCommand;
|
||||
import com._1c.g5.v8.dt.form.model.Visible;
|
||||
import com._1c.g5.v8.dt.mcore.NamedElement;
|
||||
import com._1c.g5.v8.dt.metadata.mdclass.AdjustableBoolean;
|
||||
import com._1c.g5.v8.dt.metadata.mdclass.ForRoleType;
|
||||
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.form.CorePlugin;
|
||||
|
||||
/**
|
||||
* Check if Form Item (attribute, command, visible item) use role-based settings for visible, use edit.
|
||||
*
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class FormItemVisibleSettingsByRolesCheck
|
||||
extends BasicCheck
|
||||
{
|
||||
|
||||
private static final String CHECK_ID = "form-item-visible-settings-by-roles"; //$NON-NLS-1$
|
||||
|
||||
private static final Set<EStructuralFeature> FEATURE_LIST =
|
||||
Set.of(VISIBLE__USER_VISIBLE, FORM_COMMAND__USE, ABSTRACT_FORM_ATTRIBUTE__EDIT, ABSTRACT_FORM_ATTRIBUTE__VIEW);
|
||||
|
||||
public FormItemVisibleSettingsByRolesCheck()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
{
|
||||
return CHECK_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCheck(CheckConfigurer builder)
|
||||
{
|
||||
builder.title(Messages.FormItemVisibleSettingsByRoles_title)
|
||||
.description(Messages.FormItemVisibleSettingsByRoles_description)
|
||||
.complexity(CheckComplexity.NORMAL)
|
||||
.severity(IssueSeverity.MINOR)
|
||||
.issueType(IssueType.WARNING)
|
||||
.extension(new StandardCheckExtension(737, getCheckId(), CorePlugin.PLUGIN_ID))
|
||||
.topObject(FORM)
|
||||
.containment(ADJUSTABLE_BOOLEAN)
|
||||
.features(ADJUSTABLE_BOOLEAN__COMMON);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
|
||||
IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
AdjustableBoolean adjBoolean = (AdjustableBoolean)object;
|
||||
EObject eContainer = adjBoolean.eContainer();
|
||||
EStructuralFeature eContainingFeature = adjBoolean.eContainingFeature();
|
||||
|
||||
if (monitor.isCanceled() || !(adjBoolean.isCommon() && isCorrectContainer(eContainer)
|
||||
&& isCorrectContainmentFeature(eContainingFeature)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EList<ForRoleType> forRoleList = adjBoolean.getFor();
|
||||
if (monitor.isCanceled() || forRoleList == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!forRoleList.isEmpty())
|
||||
{
|
||||
|
||||
String itemName = getItemName(eContainer);
|
||||
String propertyName = getPropertyName(eContainer, eContainingFeature);
|
||||
|
||||
resultAceptor.addIssue(
|
||||
MessageFormat.format(Messages.FormItemVisibleSettingsByRoles_Message_template, propertyName, itemName),
|
||||
adjBoolean,
|
||||
ADJUSTABLE_BOOLEAN__COMMON);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isCorrectContainer(EObject eContainer)
|
||||
{
|
||||
return eContainer instanceof Visible || eContainer instanceof FormCommand
|
||||
|| eContainer instanceof FormAttribute;
|
||||
}
|
||||
|
||||
private boolean isCorrectContainmentFeature(EStructuralFeature feature)
|
||||
{
|
||||
return FEATURE_LIST.contains(feature);
|
||||
}
|
||||
|
||||
private String getItemName(EObject eContainer)
|
||||
{
|
||||
String itemName = null;
|
||||
|
||||
if (eContainer instanceof Visible && eContainer instanceof NamedElement)
|
||||
{
|
||||
itemName = ((NamedElement)eContainer).getName();
|
||||
}
|
||||
else if (eContainer instanceof FormCommand)
|
||||
{
|
||||
|
||||
itemName = ((FormCommand)eContainer).getName();
|
||||
}
|
||||
else if (eContainer instanceof FormAttribute)
|
||||
{
|
||||
itemName = ((FormAttribute)eContainer).getName();
|
||||
}
|
||||
|
||||
return itemName;
|
||||
}
|
||||
|
||||
private String getPropertyName(EObject eContainer, EStructuralFeature eContainingFeature)
|
||||
{
|
||||
String propertyName = null;
|
||||
if (eContainer instanceof Visible
|
||||
|| eContainer instanceof FormAttribute && eContainingFeature.equals(ABSTRACT_FORM_ATTRIBUTE__VIEW))
|
||||
{
|
||||
propertyName = Messages.FormItemVisibleSettingsByRoles_Property_name_visible;
|
||||
}
|
||||
else if (eContainer instanceof FormAttribute && eContainingFeature.equals(ABSTRACT_FORM_ATTRIBUTE__EDIT))
|
||||
{
|
||||
propertyName = Messages.FormItemVisibleSettingsByRoles_Property_name_edit;
|
||||
}
|
||||
else if (eContainer instanceof FormCommand)
|
||||
{
|
||||
propertyName = Messages.FormItemVisibleSettingsByRoles_Property_name_use;
|
||||
}
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
}
|
@ -33,6 +33,12 @@ final class Messages
|
||||
public static String FormItemsSingleEventHandlerCheck_itemName_dot_eventName;
|
||||
public static String FormItemsSingleEventHandlerCheck_the_handler_is_already_assigned_to_event;
|
||||
public static String FormItemsSingleEventHandlerCheck_title;
|
||||
public static String FormItemVisibleSettingsByRoles_description;
|
||||
public static String FormItemVisibleSettingsByRoles_Message_template;
|
||||
public static String FormItemVisibleSettingsByRoles_Property_name_edit;
|
||||
public static String FormItemVisibleSettingsByRoles_Property_name_use;
|
||||
public static String FormItemVisibleSettingsByRoles_Property_name_visible;
|
||||
public static String FormItemVisibleSettingsByRoles_title;
|
||||
public static String FormListFieldRefNotAddedCheck_description;
|
||||
public static String FormListFieldRefNotAddedCheck_The_Ref_field_is_not_added_to_dynamic_list;
|
||||
public static String FormListFieldRefNotAddedCheck_title;
|
||||
|
@ -25,6 +25,18 @@ FormCommandsSingleEventHandlerCheck_Handler__0__command__1__assigned_to_command_
|
||||
|
||||
FormCommandsSingleEventHandlerCheck_Title = One handler assigned to multiple commands
|
||||
|
||||
FormItemVisibleSettingsByRoles_Message_template = Use role-based setting "{0}" for form item "{1}"
|
||||
|
||||
FormItemVisibleSettingsByRoles_Property_name_edit = Edit
|
||||
|
||||
FormItemVisibleSettingsByRoles_Property_name_use = Use
|
||||
|
||||
FormItemVisibleSettingsByRoles_Property_name_visible = Visible
|
||||
|
||||
FormItemVisibleSettingsByRoles_description = Use role-based settings for form item
|
||||
|
||||
FormItemVisibleSettingsByRoles_title = Use role-based settings for form item
|
||||
|
||||
FormItemsSingleEventHandlerCheck_description = Each event in the form items should have a unique handler
|
||||
|
||||
FormItemsSingleEventHandlerCheck_itemName_dot_eventName = {0}.{1}
|
||||
|
@ -25,6 +25,18 @@ FormCommandsSingleEventHandlerCheck_Handler__0__command__1__assigned_to_command_
|
||||
|
||||
FormCommandsSingleEventHandlerCheck_Title = Один обработчик назначен нескольким командам
|
||||
|
||||
FormItemVisibleSettingsByRoles_Message_template = Использована ролевая настройка "{0}" для элемента формы "{1}"
|
||||
|
||||
FormItemVisibleSettingsByRoles_Property_name_edit = Редактирование
|
||||
|
||||
FormItemVisibleSettingsByRoles_Property_name_use = Использование
|
||||
|
||||
FormItemVisibleSettingsByRoles_Property_name_visible = Видимость
|
||||
|
||||
FormItemVisibleSettingsByRoles_description = Использована ролевая настройка для элемента формы
|
||||
|
||||
FormItemVisibleSettingsByRoles_title = Использована ролевая настройка для элемента формы
|
||||
|
||||
FormItemsSingleEventHandlerCheck_description = У каждого события должна быть назначена своя процедура-обработчик
|
||||
|
||||
FormItemsSingleEventHandlerCheck_itemName_dot_eventName = {0}.{1}
|
||||
|
@ -0,0 +1,19 @@
|
||||
# Functional option don't set flag "Privileged get mode"
|
||||
|
||||
1.8. All functional options must have the "Privileged mode upon receiving"
|
||||
check boxes selected.
|
||||
|
||||
Exception: a configuration can include parameterized functional options, for which developers
|
||||
provide for differences in values obtained by users with different rights.
|
||||
Example: There is a parameterized functional option UseCurrencyUponSettlementsWithPersonnel,
|
||||
which is parameterized by the company. If a user receives its value in the context of their rights,
|
||||
they will not see the Currency field in the document if they do not have a company where currency
|
||||
accounting is applied.
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
## Compliant Solution
|
||||
|
||||
## See
|
||||
|
||||
[Configuring roles and access rights](https://kb.1ci.com/1C_Enterprise_Platform/Guides/Developer_Guides/1C_Enterprise_Development_Standards/Setting_data_access_rights/Configuring_roles_and_access_rights/)
|
@ -0,0 +1,21 @@
|
||||
# В функциональной опции не установлен флаг "Привилегированный режим при получении"
|
||||
|
||||
Во всех функциональных опциях должны быть выставлены флаги
|
||||
«Привилегированный режим при получении».
|
||||
|
||||
Исключение: в конфигурации могут быть предусмотрены параметризированные
|
||||
ФО, для которых разработчик специально предусматривает различия в
|
||||
получаемых значениях пользователями с разными правами.
|
||||
Пример: Есть параметризованная ФО
|
||||
ИспользватьВалютуПриРасчетеСПерсоналом, которая параметризуется
|
||||
организацией. Если пользователь будет получать ее значение в контексте
|
||||
своих прав, то он не увидит поле «валюта» в документе, если у него нет
|
||||
ни одной организации, где применяется валютный учет.
|
||||
|
||||
## Неправильно
|
||||
|
||||
## Правильно
|
||||
|
||||
## См.
|
||||
|
||||
[Настройка ролей и прав доступа](https://its.1c.ru/db/v8std#content:689:hdoc:1.8)
|
@ -126,6 +126,10 @@
|
||||
category="com.e1c.v8codestyle.md"
|
||||
class="com.e1c.v8codestyle.md.check.MdObjectAttributeCommentNotExistCheck">
|
||||
</check>
|
||||
<check
|
||||
category="com.e1c.v8codestyle.md"
|
||||
class="com.e1c.v8codestyle.md.check.FunctionalOptionPrivilegedGetModeCheck">
|
||||
</check>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
</plugin>
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.md.check;
|
||||
|
||||
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.FUNCTIONAL_OPTION;
|
||||
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.FUNCTIONAL_OPTION__PRIVILEGED_GET_MODE;
|
||||
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.FUNCTIONAL_OPTION__LOCATION;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import com._1c.g5.v8.dt.metadata.mdclass.FunctionalOption;
|
||||
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.md.CorePlugin;
|
||||
|
||||
/**
|
||||
* Check functional option use privileged get mode.
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class FunctionalOptionPrivilegedGetModeCheck
|
||||
extends BasicCheck
|
||||
{
|
||||
|
||||
private static final String CHECK_ID = "functional-option-privileged-get-mode"; //$NON-NLS-1$
|
||||
|
||||
public FunctionalOptionPrivilegedGetModeCheck()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
{
|
||||
return CHECK_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureCheck(CheckConfigurer builder)
|
||||
{
|
||||
builder.title(Messages.FunctionalOptionPrivilegedGetModeCheck_title)
|
||||
.description(Messages.FunctionalOptionPrivilegedGetModeCheck_description)
|
||||
.complexity(CheckComplexity.NORMAL)
|
||||
.severity(IssueSeverity.MAJOR)
|
||||
.issueType(IssueType.WARNING)
|
||||
.extension(new StandardCheckExtension(689, getCheckId(), CorePlugin.PLUGIN_ID))
|
||||
.extension(new SkipAdoptedInExtensionMdObjectExtension())
|
||||
.topObject(FUNCTIONAL_OPTION)
|
||||
.checkTop()
|
||||
.features(FUNCTIONAL_OPTION__PRIVILEGED_GET_MODE, FUNCTIONAL_OPTION__LOCATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void check(Object object, ResultAcceptor resultAcceptor, ICheckParameters parameters,
|
||||
IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
FunctionalOption fo = (FunctionalOption)object;
|
||||
if (!monitor.isCanceled() && fo.getLocation() != null && !fo.isPrivilegedGetMode())
|
||||
{
|
||||
resultAcceptor.addIssue(Messages.FunctionalOptionPrivilegedGetModeCheck_message, fo,
|
||||
FUNCTIONAL_OPTION__PRIVILEGED_GET_MODE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -72,6 +72,9 @@ final class Messages
|
||||
public static String ExtensionMdObjectNamePrefixCheck_Description;
|
||||
public static String ExtensionMdObjectNamePrefixCheck_Object_0_should_have_1_prefix;
|
||||
public static String ExtensionMdObjectNamePrefixCheck_Title;
|
||||
public static String FunctionalOptionPrivilegedGetModeCheck_description;
|
||||
public static String FunctionalOptionPrivilegedGetModeCheck_message;
|
||||
public static String FunctionalOptionPrivilegedGetModeCheck_title;
|
||||
public static String MdObjectNameLength_description;
|
||||
public static String MdObjectNameLength_Maximum_name_length_description;
|
||||
public static String MdObjectNameLength_message;
|
||||
|
@ -73,6 +73,12 @@ ExtensionMdObjectNamePrefixCheck_Object_0_should_have_1_prefix = The object "{0}
|
||||
|
||||
ExtensionMdObjectNamePrefixCheck_Title = Extension object name does not have extension prefix
|
||||
|
||||
FunctionalOptionPrivilegedGetModeCheck_message = Functional option don't use privileged get mode
|
||||
|
||||
FunctionalOptionPrivilegedGetModeCheck_description = Functional option don't use privileged get mode
|
||||
|
||||
FunctionalOptionPrivilegedGetModeCheck_title = Functional option don't use privileged get mode
|
||||
|
||||
MdListObjectPresentationCheck_Neither_Object_presentation_nor_List_presentation_is_not_filled = Neither Object presentation nor List presentation is not filled
|
||||
|
||||
MdListObjectPresentationCheck_decription = Neither Object presentation nor List presentation is not filled
|
||||
|
@ -60,20 +60,26 @@ DbObjectRefNonRefTypesCheck_Ref_and_other = Реквизиты составно
|
||||
|
||||
DbObjectRefNonRefTypesCheck_Title = Использование составного типа, содержащего ссылочные и не ссылочный тип вместе.
|
||||
|
||||
DocumentPostInPrivilegedModeCheck_title = В документе, предполагающем проведение, не стоит флаг "Прив. режим при проведении/отмене проведения"
|
||||
|
||||
DocumentPostInPrivilegedModeCheck_description = В документе, предполагающем проведение, не стоит флаг "Прив. режим при проведении/отмене проведения"
|
||||
|
||||
DocumentPostInPrivilegedModeCheck_message_Post_in_privileged_mode = В документе, предполагающем проведение, не стоит флаг "Прив. режим при проведении"
|
||||
|
||||
DocumentPostInPrivilegedModeCheck_message_Unpost_in_privileged_mode = В документе, предполагающем проведение, не стоит флаг "Прив. режим при отмене проведения"
|
||||
|
||||
DocumentPostInPrivilegedModeCheck_title = В документе, предполагающем проведение, не стоит флаг "Прив. режим при проведении/отмене проведения"
|
||||
|
||||
ExtensionMdObjectNamePrefixCheck_Description = Имя объекта в расширении не содержит префикс расширения
|
||||
|
||||
ExtensionMdObjectNamePrefixCheck_Object_0_should_have_1_prefix = Имя объекта "{0}" должно содержать префикс "{1}"
|
||||
|
||||
ExtensionMdObjectNamePrefixCheck_Title = Имя объекта в расширении должно содержать префикс расширения
|
||||
|
||||
FunctionalOptionPrivilegedGetModeCheck_message = В функциональной опции не установлен флаг "Привилегированный режим при получении"
|
||||
|
||||
FunctionalOptionPrivilegedGetModeCheck_description = В функциональной опции не установлен флаг "Привилегированный режим при получении"
|
||||
|
||||
FunctionalOptionPrivilegedGetModeCheck_title = В функциональной опции не установлен флаг "Привилегированный режим при получении"
|
||||
|
||||
MdListObjectPresentationCheck_Neither_Object_presentation_nor_List_presentation_is_not_filled = Не заполнено ни представление объекта, ни представление списка
|
||||
|
||||
MdListObjectPresentationCheck_decription = Не заполнено ни представление объекта, ни представление списка
|
||||
|
@ -1,6 +1,12 @@
|
||||
# Temporary table should have indexes
|
||||
|
||||
|
||||
1. Indexing is reasonable if:
|
||||
1.1 A large temporary table is involved in a join (regardless of on which side).
|
||||
Add fields involved in the BY condition to the index.
|
||||
1.2 A temporary table is called in a subquery of the construct of the logical IN (...) operator.
|
||||
To the index, add fields of the temporary table from a selection list that match fields listed
|
||||
on the left side of the logical IN(...) operator.
|
||||
2. You do not need to index small temporary tables consisting of less than 1,000 records.
|
||||
|
||||
## Noncompliant Code Example
|
||||
|
||||
@ -8,3 +14,4 @@
|
||||
|
||||
## See
|
||||
|
||||
- [Using temporary tables](https://kb.1ci.com/1C_Enterprise_Platform/Guides/Developer_Guides/1C_Enterprise_Development_Standards/Data_processing/Optimizing_queries/Using_temporary_tables/)
|
@ -1,10 +1,104 @@
|
||||
# Временная таблица должна содержать индексы
|
||||
|
||||
|
||||
1. Индекс следует строить если:
|
||||
1.1 Большая временная таблица участвует в соединении (не важно, с какой стороны).
|
||||
В индекс следует добавлять поля, участвующие в условии ПО.
|
||||
1.2 Обращение к временной таблице выполняется в подзапросе конструкции логического оператора В (...).
|
||||
В индекс следует добавлять поля временной таблицы из списка выбора, соответствующие перечисленным
|
||||
с левой стороны логического оператора В (...).
|
||||
2. Маленькие временные таблицы индексировать не нужно (менее 1000 записей).
|
||||
|
||||
## Неправильно
|
||||
|
||||
```bsl
|
||||
|
||||
// Пример 1. Создаем врем. таблицу и делаем из нее выборку по полю "Контрагент". Т.к. врем. таблица не ограничена
|
||||
// количеством записей (их может быть больше 1000), необходимо создать индекс.
|
||||
ВЫБРАТЬ
|
||||
СФПолученная.Контрагент КАК Контрагент,
|
||||
СФПолученная.Сумма КАК Сумма
|
||||
ПОМЕСТИТЬ ВТ
|
||||
ИЗ
|
||||
Документ.СФПолученная КАК СФПолученная
|
||||
ГДЕ
|
||||
СФПолученная.Дата МЕЖДУ &НачалоПериода И &КонецПериода
|
||||
СФПолученная.Контрагент В(&Контрагенты);
|
||||
|
||||
ВЫБРАТЬ
|
||||
ВТ.Сумма КАК Сумма
|
||||
ИЗ
|
||||
ВТ КАК ВТ
|
||||
ГДЕ
|
||||
ВТ.Контрагент = &Контрагент_ТД;
|
||||
|
||||
|
||||
// Пример 2. Врем. таблица ВТ содержит не более 500 записей, поэтому ее индексирование будет излишним.
|
||||
ВЫБРАТЬ ПЕРВЫЕ 500
|
||||
Сотрудники.Ссылка КАК Сотрудник,
|
||||
Сотрудники.Организация КАК Организация
|
||||
ПОМЕСТИТЬ ВТ
|
||||
ИЗ
|
||||
Справочник.Сотрудники КАК Сотрудники
|
||||
ГДЕ
|
||||
Сотрудники.ВАрхиве
|
||||
|
||||
ИНДЕКСИРОВАТЬ ПО
|
||||
Сотрудник;
|
||||
|
||||
ВЫБРАТЬ
|
||||
ВТ.Сотрудник КАК Сотрудник
|
||||
ИЗ
|
||||
ВТ КАК ВТ
|
||||
ГДЕ
|
||||
ВТ.Организация = &Организация;
|
||||
```
|
||||
|
||||
## Правильно
|
||||
|
||||
```bsl
|
||||
|
||||
// Пример 1. Создаем временную таблицу и выбираем из нее данные. Врем. таблица не ограничена кол-вом записей
|
||||
// и может быть большого размера, поэтому индексируем по полю Контагент, т.к. выборка из ВТ с отбором по этому полю.
|
||||
ВЫБРАТЬ
|
||||
СФПолученная.Контрагент КАК Контрагент,
|
||||
СФПолученная.Сумма КАК Сумма
|
||||
ПОМЕСТИТЬ ВТ
|
||||
ИЗ
|
||||
Документ.СФПолученная КАК СФПолученная
|
||||
ГДЕ
|
||||
СФПолученная.Контрагент В(&Контрагенты)
|
||||
|
||||
ИНДЕКСИРОВАТЬ ПО
|
||||
Контрагент;
|
||||
|
||||
ВЫБРАТЬ
|
||||
ВТ.Сумма КАК Сумма
|
||||
ИЗ
|
||||
ВТ КАК ВТ
|
||||
ГДЕ
|
||||
ВТ.Контрагент = &Контрагент_Астория;
|
||||
|
||||
// Пример 2. Врем. таблица может иметь до 10000 строк, поэтому индексирование необходимо.
|
||||
ВЫБРАТЬ ПЕРВЫЕ 10000
|
||||
Сотрудники.Ссылка КАК Сотрудник,
|
||||
Сотрудники.Организация КАК Организация
|
||||
ПОМЕСТИТЬ ВТ
|
||||
ИЗ
|
||||
Справочник.Сотрудники КАК Сотрудники
|
||||
ГДЕ
|
||||
Сотрудники.ВАрхиве
|
||||
|
||||
ИНДЕКСИРОВАТЬ ПО
|
||||
Сотрудник;
|
||||
|
||||
ВЫБРАТЬ
|
||||
ВТ.Сотрудник КАК Сотрудник
|
||||
ИЗ
|
||||
ВТ КАК ВТ
|
||||
ГДЕ
|
||||
ВТ.Организация = &Организация;
|
||||
```
|
||||
|
||||
## См.
|
||||
|
||||
- [Использование временных таблиц](https://its.1c.ru/db/v8std/content/777/hdoc)
|
@ -44,6 +44,7 @@ final class Messages
|
||||
public static String TempTableHasIndex_description;
|
||||
public static String TempTableHasIndex_Exclude_table_name_pattern;
|
||||
public static String TempTableHasIndex_New_temporary_table_should_have_indexes;
|
||||
public static String TempTableHasIndex_Parameter_max_top;
|
||||
public static String TempTableHasIndex_title;
|
||||
public static String UsingForUpdateCheck_description;
|
||||
public static String UsingForUpdateCheck_title;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021, 1C-Soft LLC and others.
|
||||
* Copyright (C) 2023, 1C-Soft LLC and others.
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@ -34,6 +34,7 @@ import com.e1c.v8codestyle.internal.ql.CorePlugin;
|
||||
* This check may be enhanced in the future.
|
||||
*
|
||||
* @author Dmitriy Marmyshev
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class TempTableHasIndex
|
||||
extends QlBasicDelegateCheck
|
||||
@ -43,7 +44,9 @@ public class TempTableHasIndex
|
||||
|
||||
private static final String PARAMETER_EXCLUDE_TABLE_NAME_PATTERN = "excludeObjectNamePattern"; //$NON-NLS-1$
|
||||
|
||||
private static final int MAX_TOP = 1000;
|
||||
private static final String PARAMETER_MAX_TOP = "maxTop"; //$NON-NLS-1$
|
||||
|
||||
private static final int MAX_TOP_DEFAULT = 1000;
|
||||
|
||||
@Override
|
||||
public String getCheckId()
|
||||
@ -61,8 +64,11 @@ public class TempTableHasIndex
|
||||
.issueType(IssueType.PERFORMANCE)
|
||||
.extension(new StandardCheckExtension(777, getCheckId(), CorePlugin.PLUGIN_ID))
|
||||
.delegate(QuerySchemaSelectQuery.class);
|
||||
builder.parameter(PARAMETER_EXCLUDE_TABLE_NAME_PATTERN, String.class, StringUtils.EMPTY,
|
||||
Messages.TempTableHasIndex_Exclude_table_name_pattern);
|
||||
builder
|
||||
.parameter(PARAMETER_EXCLUDE_TABLE_NAME_PATTERN, String.class, StringUtils.EMPTY,
|
||||
Messages.TempTableHasIndex_Exclude_table_name_pattern)
|
||||
.parameter(PARAMETER_MAX_TOP, Integer.class, Integer.toString(MAX_TOP_DEFAULT),
|
||||
Messages.TempTableHasIndex_Parameter_max_top);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,7 +76,8 @@ public class TempTableHasIndex
|
||||
ICheckParameters parameters, IProgressMonitor monitor)
|
||||
{
|
||||
QuerySchemaSelectQuery selectQuery = (QuerySchemaSelectQuery)object;
|
||||
if (selectQuery.getPlacementTable() == null || isTopLessThenThousand(selectQuery))
|
||||
int maxTop = parameters.getInt(PARAMETER_MAX_TOP);
|
||||
if (selectQuery.getPlacementTable() == null || isTopLessThenMaxTop(selectQuery, maxTop))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -89,7 +96,7 @@ public class TempTableHasIndex
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTopLessThenThousand(QuerySchemaSelectQuery selectQuery)
|
||||
private boolean isTopLessThenMaxTop(QuerySchemaSelectQuery selectQuery, int maxTop)
|
||||
{
|
||||
if (!selectQuery.getOperators().isEmpty() && selectQuery.getOperators().get(0).getGetRecordsCount() != null)
|
||||
{
|
||||
@ -97,7 +104,7 @@ public class TempTableHasIndex
|
||||
try
|
||||
{
|
||||
int top = Integer.parseInt(count);
|
||||
return top < MAX_TOP;
|
||||
return top < maxTop;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
|
@ -56,6 +56,8 @@ TempTableHasIndex_New_temporary_table_should_have_indexes = New temporary table
|
||||
|
||||
TempTableHasIndex_description = Temporary table should have indexes
|
||||
|
||||
TempTableHasIndex_Parameter_max_top = Max rows in query
|
||||
|
||||
TempTableHasIndex_title = Temporary table should have indexes
|
||||
|
||||
UsingForUpdateCheck_description = Check if query contains "FOR UPDATE"
|
||||
|
@ -57,6 +57,8 @@ TempTableHasIndex_New_temporary_table_should_have_indexes = Новая врем
|
||||
|
||||
TempTableHasIndex_description = Временная таблица должна содержать индексы
|
||||
|
||||
TempTableHasIndex_Parameter_max_top = Макс. количество строк в запросе
|
||||
|
||||
TempTableHasIndex_title = Временная таблица должна содержать индексы
|
||||
|
||||
UsingForUpdateCheck_description = Проверка наличия конструкции "ДЛЯ ИЗМЕНЕНИЯ" в запросе
|
||||
|
@ -0,0 +1,16 @@
|
||||
|
||||
&НаКлиенте
|
||||
Процедура Тест()
|
||||
|
||||
Оповещение = Новый ОписаниеОповещения("ПредупреждениеЗавершение", ЭтотОбъект);
|
||||
Текст = "Текст предупреждения";
|
||||
ПоказатьПредупреждение(Оповещение, Текст);
|
||||
|
||||
КонецПроцедуры
|
||||
|
||||
&НаКлиенте
|
||||
Процедура ПредупреждениеЗавершение(ДополнительныеПараметры) Экспорт
|
||||
|
||||
Сообщить("Закрыли предупреждение");
|
||||
|
||||
КонецПроцедуры;
|
@ -0,0 +1,7 @@
|
||||
|
||||
Асинх Процедура Тест1(Параметры)
|
||||
|
||||
Ждать ВопросАсинх(Параметры,);
|
||||
Сообщить("Закрыли предупреждение");
|
||||
|
||||
КонецПроцедуры
|
@ -0,0 +1,8 @@
|
||||
|
||||
Асинх Процедура Тест2(Параметры)
|
||||
|
||||
Обещание = ПредупреждениеАсинх(Параметры);
|
||||
Ждать Обещание;
|
||||
Сообщить("Закрыли предупреждение");
|
||||
|
||||
КонецПроцедуры
|
@ -0,0 +1,6 @@
|
||||
|
||||
Асинх Функция Тест3(Параметры)
|
||||
|
||||
Возврат Ждать ПредупреждениеАсинх(Параметры);
|
||||
|
||||
КонецФункции
|
@ -0,0 +1,7 @@
|
||||
|
||||
Асинх Функция Тест4(Параметры)
|
||||
|
||||
Обещание = ПредупреждениеАсинх(Параметры);
|
||||
Возврат Ждать Обещание;
|
||||
|
||||
КонецФункции
|
@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
Процедура Тест()
|
||||
|
||||
ТабДок = Новый ТабличныйДокумент;
|
||||
ТабДок.ЗаписатьАсинх();
|
||||
|
||||
Сообщить("кто быстрее?");
|
||||
|
||||
КонецПроцедуры
|
@ -0,0 +1,9 @@
|
||||
|
||||
&НаКлиенте
|
||||
Процедура Тест()
|
||||
|
||||
Текст = "Текст предупреждения";
|
||||
ПоказатьПредупреждение(, Текст);
|
||||
Сообщить("Закрыли предупреждение");
|
||||
|
||||
КонецПроцедуры
|
@ -0,0 +1,17 @@
|
||||
Процедура ПолучитьЗадолженностьКонтрагента(Дата = Неопределено, Контрагент)
|
||||
КонецПроцедуры
|
||||
|
||||
Процедура ПолучитьЗадолженностьКонтрагента2(Контрагент, Дата = Неопределено)
|
||||
КонецПроцедуры
|
||||
|
||||
Процедура ПолучитьЗадолженностьКонтрагента3(Контрагент, Дата)
|
||||
КонецПроцедуры
|
||||
|
||||
Процедура РассчитатьКурсовыеРазницы(Организация, Подразделение = Неопределено, Дата)
|
||||
КонецПроцедуры
|
||||
|
||||
Процедура РассчитатьКурсовыеРазницы2(Организация, Подразделение = Неопределено, Дата = Неопределено)
|
||||
КонецПроцедуры
|
||||
|
||||
Процедура ОтправитьСообщениеПользователю()
|
||||
КонецПроцедуры
|
@ -0,0 +1,135 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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 static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
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.CodeAfterAsyncCallCheck;
|
||||
import com.e1c.v8codestyle.internal.bsl.BslPlugin;
|
||||
|
||||
/**
|
||||
* Tests for {@link CodeAfterAsyncCallCheck} check.
|
||||
*
|
||||
* @author Artem Iliukhin
|
||||
*/
|
||||
public class CodeAfterAsyncCallCheckTest
|
||||
extends AbstractSingleModuleTestBase
|
||||
{
|
||||
private static final String CHECK_ID = "code-after-async-call"; //$NON-NLS-1$
|
||||
private static final String PARAMETER_NAME = "notifyDescriptionIsDefined"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Instantiates a new code after async call check test.
|
||||
*/
|
||||
public CodeAfterAsyncCallCheckTest()
|
||||
{
|
||||
super(CodeAfterAsyncCallCheck.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCodeAfterExistence() throws Exception
|
||||
{
|
||||
setParameterValue(Boolean.FALSE);
|
||||
|
||||
updateModule(FOLDER_RESOURCE + "code-after-async-call-existence.bsl");
|
||||
|
||||
Marker marker = getFirstMarker(CHECK_ID, getModuleId(), getProject());
|
||||
assertNotNull(marker);
|
||||
assertEquals("7", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCallBackDescriptionCompliant() throws Exception
|
||||
{
|
||||
updateModule(FOLDER_RESOURCE + "async-call-back-descr.bsl");
|
||||
|
||||
Marker marker = getFirstMarker(CHECK_ID, getModuleId(), getProject());
|
||||
assertNull(marker);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPromiseCompliant() throws Exception
|
||||
{
|
||||
setParameterValue(Boolean.FALSE);
|
||||
|
||||
updateModule(FOLDER_RESOURCE + "async-call-promise.bsl");
|
||||
|
||||
Marker marker = getFirstMarker(CHECK_ID, getModuleId(), getProject());
|
||||
assertNull(marker);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPromiseCompliant2() throws Exception
|
||||
{
|
||||
setParameterValue(Boolean.FALSE);
|
||||
|
||||
updateModule(FOLDER_RESOURCE + "async-call-promise2.bsl");
|
||||
|
||||
Marker marker = getFirstMarker(CHECK_ID, getModuleId(), getProject());
|
||||
assertNull(marker);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPromiseCompliant3() throws Exception
|
||||
{
|
||||
setParameterValue(Boolean.FALSE);
|
||||
|
||||
updateModule(FOLDER_RESOURCE + "async-call-promise3.bsl");
|
||||
|
||||
Marker marker = getFirstMarker(CHECK_ID, getModuleId(), getProject());
|
||||
assertNull(marker);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPromiseComplian4() throws Exception
|
||||
{
|
||||
setParameterValue(Boolean.FALSE);
|
||||
|
||||
updateModule(FOLDER_RESOURCE + "async-call-promise4.bsl");
|
||||
|
||||
Marker marker = getFirstMarker(CHECK_ID, getModuleId(), getProject());
|
||||
assertNull(marker);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpreadsheetDocumentNonCompliant() throws Exception
|
||||
{
|
||||
updateModule(FOLDER_RESOURCE + "async-call-spread-sh-doc.bsl");
|
||||
|
||||
Marker marker = getFirstMarker(CHECK_ID, getModuleId(), getProject());
|
||||
assertNotNull(marker);
|
||||
assertEquals("8", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
|
||||
}
|
||||
|
||||
private void setParameterValue(Boolean value)
|
||||
{
|
||||
IDtProject dtProject = getProject();
|
||||
IProject project = dtProject.getWorkspaceProject();
|
||||
ICheckSettings settings = checkRepository.getSettings(new CheckUid(CHECK_ID, BslPlugin.PLUGIN_ID), project);
|
||||
settings.getParameters().get(PARAMETER_NAME).setValue(Boolean.toString(value));
|
||||
checkRepository.applyChanges(Collections.singleton(settings), project);
|
||||
waitForDD(dtProject);
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.IsInRoleMethodRoleExistCheck;
|
||||
|
||||
/**
|
||||
* The test for {@link IsInRoleMethodRoleExistCheck} class.
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class IsInRoleMethodRoleExistCheckTest
|
||||
extends AbstractSingleModuleTestBase
|
||||
{
|
||||
|
||||
private static final String PROJECT_NAME = "IsInRoleMethodRoleExist"; //$NON-NLS-1$
|
||||
|
||||
private static final String COMMON_MODULE_FILE_NAME = "/src/CommonModules/RolesCommonModule/Module.bsl"; //$NON-NLS-1$
|
||||
|
||||
public IsInRoleMethodRoleExistCheckTest()
|
||||
{
|
||||
super(IsInRoleMethodRoleExistCheck.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestConfigurationName()
|
||||
{
|
||||
return PROJECT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleFileName()
|
||||
{
|
||||
return COMMON_MODULE_FILE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test invocation role check access exist role check.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void testIsInRoleMethodRoleExistCheck() throws Exception
|
||||
{
|
||||
|
||||
List<Marker> markers = getModuleMarkers();
|
||||
assertEquals(2, markers.size());
|
||||
|
||||
assertEquals("2", markers.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
|
||||
assertEquals("9", markers.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.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.MethodOptionalParameterBeforeRequiredCheck;
|
||||
|
||||
/**
|
||||
* Test for the class {@link MethodOptionalParameterBeforeRequiredCheck}.
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class MethodOptionalParameterBeforeRequiredCheckTest
|
||||
extends AbstractSingleModuleTestBase
|
||||
{
|
||||
|
||||
public MethodOptionalParameterBeforeRequiredCheckTest()
|
||||
{
|
||||
super(MethodOptionalParameterBeforeRequiredCheck.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test optional param before require.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void testOptionalParamBeforeRequire() throws Exception
|
||||
{
|
||||
updateModule(FOLDER_RESOURCE + "method-optional-parameter-before-required.bsl");
|
||||
|
||||
List<Marker> markers = getModuleMarkers();
|
||||
assertEquals(2, markers.size());
|
||||
|
||||
assertEquals("1", markers.get(0).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
|
||||
assertEquals("10", markers.get(1).getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.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.OptionalFormParameterAccessCheck;
|
||||
|
||||
/**
|
||||
* Test class for {@link OptionalFormParameterAccessCheck}
|
||||
*/
|
||||
public class OptionalFormParameterAccessCheckTest
|
||||
extends AbstractSingleModuleTestBase
|
||||
{
|
||||
|
||||
private static final String PROJECT_NAME = "OptionalFormParameterAccess";
|
||||
|
||||
private static final String COMMON_FORM_FILE_NAME = "/src/CommonForms/TestForm/Module.bsl";
|
||||
|
||||
public OptionalFormParameterAccessCheckTest()
|
||||
{
|
||||
super(OptionalFormParameterAccessCheck.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestConfigurationName()
|
||||
{
|
||||
return PROJECT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleFileName()
|
||||
{
|
||||
return COMMON_FORM_FILE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Parameters.Property("") access to exist form parameter.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void testOptionalFormParameterAccess() throws Exception
|
||||
{
|
||||
List<Marker> markers = getModuleMarkers();
|
||||
assertEquals(1, markers.size());
|
||||
|
||||
Marker marker = markers.get(0);
|
||||
assertEquals("5", marker.getExtraInfo().get(IExtraInfoKeys.TEXT_EXTRA_INFO_LINE_KEY));
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2022, 1C-Soft LLC and others.
|
||||
* Copyright (C) 2023, 1C-Soft LLC and others.
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@ -35,6 +35,7 @@ import com.e1c.v8codestyle.internal.bsl.BslPlugin;
|
||||
* The test for class {@link SelfReferenceCheck}.
|
||||
*
|
||||
* @author Maxim Galios
|
||||
* @author Vadim Goncharov
|
||||
*
|
||||
*/
|
||||
public class SelfReferenceCheckTest
|
||||
@ -94,12 +95,8 @@ public class SelfReferenceCheckTest
|
||||
|
||||
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);
|
||||
changeProjectSetting(project, SelfReferenceCheck.PARAMETER_CHECK_ONLY_EXISTING_FORM_PROPERTIES,
|
||||
Boolean.toString(false));
|
||||
waitForDD(dtProject);
|
||||
|
||||
List<Marker> markersAfterSettingsChange = getMarkers(FORM_MODULE_FILE_NAME);
|
||||
@ -132,6 +129,15 @@ public class SelfReferenceCheckTest
|
||||
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));
|
||||
|
||||
IDtProject dtProject = getProject();
|
||||
IProject project = dtProject.getWorkspaceProject();
|
||||
changeProjectSetting(project, SelfReferenceCheck.PARAMETER_CHEKC_OBJECT_MODULE, Boolean.toString(false));
|
||||
waitForDD(dtProject);
|
||||
|
||||
List<Marker> markersAfterSettingsChange = getMarkers(OBJECT_MODULE_FILE_NAME);
|
||||
assertEquals(0, markersAfterSettingsChange.size());
|
||||
|
||||
}
|
||||
|
||||
private List<Marker> getMarkers(String moduleFileName)
|
||||
@ -146,4 +152,12 @@ public class SelfReferenceCheckTest
|
||||
.filter(marker -> chekcId.equals(getCheckIdFromMarker(marker, getProject())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void changeProjectSetting(IProject project, String parameter, String value)
|
||||
{
|
||||
ICheckSettings settings = checkRepository.getSettings(new CheckUid(getCheckId(), BslPlugin.PLUGIN_ID), project);
|
||||
settings.getParameters().get(parameter).setValue(value);
|
||||
checkRepository.applyChanges(Collections.singleton(settings), project);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>IsInRoleMethodRoleExist</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>
|
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
Runtime-Version: 8.3.19
|
@ -0,0 +1,19 @@
|
||||
Procedure TestIsInRole()
|
||||
If IsInRole("TestRole3") Then
|
||||
EndIf;
|
||||
If IsInRole("TestRole1") Then
|
||||
EndIf;
|
||||
EndProcedure
|
||||
|
||||
Процедура ТестРольДоступна()
|
||||
Если РольДоступна("TestRole3") Тогда
|
||||
КонецЕсли;
|
||||
Если РольДоступна("TestRole1") Тогда
|
||||
КонецЕсли;
|
||||
КонецПроцедуры
|
||||
|
||||
Procedure TestStaff()
|
||||
If Users.RolesAvailable("TestRole1,TestRole2,TestRole3") Then
|
||||
Message("Test message");
|
||||
EndIf;
|
||||
EndProcedure
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="6f749273-bdc4-4395-bcf0-a26399389210">
|
||||
<name>RolesCommonModule</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Roles common module</value>
|
||||
</synonym>
|
||||
<server>true</server>
|
||||
</mdclass:CommonModule>
|
@ -0,0 +1,8 @@
|
||||
Function RolesAvailable(RolesNames, User = Undefined, ForPrivilegedMode = True) Export
|
||||
//Some checks
|
||||
Return True;
|
||||
EndFunction
|
||||
|
||||
Function IsFullUser(User = Undefined) Export
|
||||
Return True;
|
||||
EndFunction
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:CommonModule xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="72701a84-135e-494e-b68f-f287fb81c335">
|
||||
<name>Users</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Users</value>
|
||||
</synonym>
|
||||
<server>true</server>
|
||||
</mdclass:CommonModule>
|
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="94ce6be4-4189-4a62-85af-1d9e391d338a">
|
||||
<name>IsInRoleMethodRoleExist</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>IsInRoleMethodRoleExistCheck</value>
|
||||
</synonym>
|
||||
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="cfa3e992-f719-4203-af07-9f7c4f155fb0"/>
|
||||
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="1976c333-6fbe-408d-99b8-3bdabac4d2ed"/>
|
||||
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="c2f98eea-d716-482c-8b7d-b3fc30f88f53"/>
|
||||
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="011b4269-fe6f-4876-b48f-6894315ec46b"/>
|
||||
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="f87a21ff-82a5-40f3-8c45-0b72448175de"/>
|
||||
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="4206d029-9520-4b4e-a4ce-24b61c5f219b"/>
|
||||
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="305fd434-af42-4e89-ad3d-c2c8d426eeba"/>
|
||||
<configurationExtensionCompatibilityMode>8.3.19</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.19</compatibilityMode>
|
||||
<languages uuid="e486c146-37cf-4259-b763-c572f1a9343f">
|
||||
<name>English</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>English</value>
|
||||
</synonym>
|
||||
<languageCode>en</languageCode>
|
||||
</languages>
|
||||
<roles>Role.TestRole1</roles>
|
||||
<commonModules>CommonModule.RolesCommonModule</commonModules>
|
||||
<commonModules>CommonModule.Users</commonModules>
|
||||
</mdclass:Configuration>
|
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Rights xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://v8.1c.ru/8.2/roles" xsi:type="Rights">
|
||||
<setForNewObjects>false</setForNewObjects>
|
||||
<setForAttributesByDefault>true</setForAttributesByDefault>
|
||||
<independentRightsOfChildObjects>false</independentRightsOfChildObjects>
|
||||
<object>
|
||||
<name>Configuration.IsInRoleMethodRoleExist</name>
|
||||
<right>
|
||||
<name>SaveUserData</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>ThinClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>WebClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeEmbeddedWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeKiosk</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeNormal</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeFullscreenWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>AnalyticsSystemClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
</object>
|
||||
</Rights>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:Role xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="f34da7cf-73e2-4936-a972-c6f281dcf791">
|
||||
<name>TestRole1</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Test role1</value>
|
||||
</synonym>
|
||||
</mdclass:Role>
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OptionalFormParameterAccess</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>
|
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
Runtime-Version: 8.3.19
|
@ -0,0 +1,37 @@
|
||||
<?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>
|
||||
<handlers>
|
||||
<event>OnCreateAtServer</event>
|
||||
<name>OnCreateAtServer</name>
|
||||
</handlers>
|
||||
<autoTitle>true</autoTitle>
|
||||
<autoUrl>true</autoUrl>
|
||||
<group>Vertical</group>
|
||||
<autoFillCheck>true</autoFillCheck>
|
||||
<allowFormCustomize>true</allowFormCustomize>
|
||||
<enabled>true</enabled>
|
||||
<showTitle>true</showTitle>
|
||||
<showCloseButton>true</showCloseButton>
|
||||
<parameters>
|
||||
<name>Organisation</name>
|
||||
<valueType>
|
||||
<types>String</types>
|
||||
<stringQualifiers/>
|
||||
</valueType>
|
||||
</parameters>
|
||||
<commandInterface>
|
||||
<navigationPanel/>
|
||||
<commandBar/>
|
||||
</commandInterface>
|
||||
</form:Form>
|
@ -0,0 +1,13 @@
|
||||
|
||||
&AtServer
|
||||
Procedure OnCreateAtServer(Cancel, StandardProcessing)
|
||||
|
||||
If Parameters.Property("Organisation") Then
|
||||
//
|
||||
EndIf;
|
||||
|
||||
If Parameters.Property("Warehouse") Then
|
||||
//
|
||||
EndIf;
|
||||
|
||||
EndProcedure
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:CommonForm xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="d6a9c018-6b69-46fa-a1d1-9821ee7ea5d5">
|
||||
<name>TestForm</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Test form</value>
|
||||
</synonym>
|
||||
<usePurposes>PersonalComputer</usePurposes>
|
||||
<usePurposes>MobileDevice</usePurposes>
|
||||
</mdclass:CommonForm>
|
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>
|
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="dc17eb25-9fec-4997-8e59-ca736dfd6b63">
|
||||
<name>OptionalFormParameterAccess</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Optional form parameter access</value>
|
||||
</synonym>
|
||||
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="fc968cb6-f902-4387-8720-1b3ce80f10b5"/>
|
||||
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="3d691eba-f860-4571-937d-7a0369604445"/>
|
||||
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="69f3ec31-6fa7-454d-b160-55d8ab50f3ee"/>
|
||||
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="3853c1ad-5fbe-4353-98e4-7dc9ead46330"/>
|
||||
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="61d8c266-eeee-4eea-949b-f5beb3258d28"/>
|
||||
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="bdf4936e-20eb-4f56-a739-eff4bde83c57"/>
|
||||
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="9a63718a-77ba-487c-9b5d-b258c2f1034a"/>
|
||||
<configurationExtensionCompatibilityMode>8.3.19</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.19</compatibilityMode>
|
||||
<languages uuid="c0b86a18-4d45-4bfa-bd85-3677df68c5e4">
|
||||
<name>English</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>English</value>
|
||||
</synonym>
|
||||
<languageCode>en</languageCode>
|
||||
</languages>
|
||||
<commonForms>CommonForm.TestForm</commonForms>
|
||||
</mdclass:Configuration>
|
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>
|
@ -0,0 +1,87 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2023, 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.form.check.itests;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com._1c.g5.v8.dt.core.platform.IDtProject;
|
||||
import com._1c.g5.v8.dt.validation.marker.Marker;
|
||||
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;
|
||||
import com.e1c.v8codestyle.form.check.FormItemVisibleSettingsByRolesCheck;
|
||||
|
||||
/**
|
||||
* Tests for {@link FormItemVisibleSettingsByRolesCheck} check.
|
||||
* @author Vadim Goncharov
|
||||
*/
|
||||
public class FormItemVisibleSettingsByRolesCheckTest
|
||||
extends CheckTestBase
|
||||
{
|
||||
|
||||
private static final String CHECK_ID = "form-item-visible-settings-by-roles";
|
||||
|
||||
private static final String PROJECT_NAME = "FormItemVisibleSettingsByRoles";
|
||||
|
||||
/**
|
||||
* Test form item use role based settings.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void testFormItemUseRoleBasedSettings() throws Exception
|
||||
{
|
||||
IDtProject project = openProjectAndWaitForValidationFinish(PROJECT_NAME);
|
||||
assertNotNull(project);
|
||||
|
||||
// Form attribute edit setting by roles
|
||||
long id = getTopObjectIdByFqn("CommonForm.TestForm1.Form", project);
|
||||
Marker marker = getFirstNestedMarker(CHECK_ID, id, project);
|
||||
assertNotNull(marker);
|
||||
|
||||
// Form attribute view setting by roles
|
||||
id = getTopObjectIdByFqn("CommonForm.TestForm2.Form", project);
|
||||
marker = getFirstNestedMarker(CHECK_ID, id, project);
|
||||
assertNotNull(marker);
|
||||
|
||||
// Form visible item view setting by roles
|
||||
id = getTopObjectIdByFqn("CommonForm.TestForm3.Form", project);
|
||||
marker = getFirstNestedMarker(CHECK_ID, id, project);
|
||||
assertNotNull(marker);
|
||||
|
||||
// Form command use setting by roles
|
||||
id = getTopObjectIdByFqn("CommonForm.TestForm4.Form", project);
|
||||
marker = getFirstNestedMarker(CHECK_ID, id, project);
|
||||
assertNotNull(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test form item not use role based settings.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void testFormItemNotUseRoleBasedSettings() throws Exception
|
||||
{
|
||||
IDtProject project = openProjectAndWaitForValidationFinish(PROJECT_NAME);
|
||||
assertNotNull(project);
|
||||
|
||||
// Form attribute, visible item and command
|
||||
long id = getTopObjectIdByFqn("CommonForm.TestForm5.Form", project);
|
||||
Marker marker = getFirstNestedMarker(CHECK_ID, id, project);
|
||||
assertNull(marker);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>FormItemVisibleSettingsByRoles</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>
|
@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
Runtime-Version: 8.3.19
|
@ -0,0 +1,48 @@
|
||||
<?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>TestAttributeEditByRoles</name>
|
||||
<title>
|
||||
<key>en</key>
|
||||
<value>Test attribute edit by roles</value>
|
||||
</title>
|
||||
<id>1</id>
|
||||
<valueType>
|
||||
<types>String</types>
|
||||
<stringQualifiers/>
|
||||
</valueType>
|
||||
<view>
|
||||
<common>true</common>
|
||||
</view>
|
||||
<edit>
|
||||
<common>true</common>
|
||||
<for>
|
||||
<value>true</value>
|
||||
<role>Role.TestRole1</role>
|
||||
</for>
|
||||
</edit>
|
||||
</attributes>
|
||||
<commandInterface>
|
||||
<navigationPanel/>
|
||||
<commandBar/>
|
||||
</commandInterface>
|
||||
</form:Form>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:CommonForm xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="420e0b97-3465-4d75-b55b-c383c7ef9341">
|
||||
<name>TestForm1</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Test form1</value>
|
||||
</synonym>
|
||||
<usePurposes>PersonalComputer</usePurposes>
|
||||
<usePurposes>MobileDevice</usePurposes>
|
||||
</mdclass:CommonForm>
|
@ -0,0 +1,48 @@
|
||||
<?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>TestAttributeViewByRoles</name>
|
||||
<title>
|
||||
<key>en</key>
|
||||
<value>Test attribute view by roles</value>
|
||||
</title>
|
||||
<id>1</id>
|
||||
<valueType>
|
||||
<types>String</types>
|
||||
<stringQualifiers/>
|
||||
</valueType>
|
||||
<view>
|
||||
<common>true</common>
|
||||
<for>
|
||||
<value>true</value>
|
||||
<role>Role.TestRole1</role>
|
||||
</for>
|
||||
</view>
|
||||
<edit>
|
||||
<common>true</common>
|
||||
</edit>
|
||||
</attributes>
|
||||
<commandInterface>
|
||||
<navigationPanel/>
|
||||
<commandBar/>
|
||||
</commandInterface>
|
||||
</form:Form>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:CommonForm xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="87a0eb6a-8818-41ec-a5e8-f112703bbf3a">
|
||||
<name>TestForm2</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Test form2</value>
|
||||
</synonym>
|
||||
<usePurposes>PersonalComputer</usePurposes>
|
||||
<usePurposes>MobileDevice</usePurposes>
|
||||
</mdclass:CommonForm>
|
@ -0,0 +1,45 @@
|
||||
<?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>
|
||||
<formCommands>
|
||||
<name>TestCommandUseByRoles</name>
|
||||
<title>
|
||||
<key>en</key>
|
||||
<value>Test command use by roles</value>
|
||||
</title>
|
||||
<id>1</id>
|
||||
<use>
|
||||
<common>true</common>
|
||||
<for>
|
||||
<value>true</value>
|
||||
<role>Role.TestRole1</role>
|
||||
</for>
|
||||
<for>
|
||||
<role>Role.TestRole2</role>
|
||||
</for>
|
||||
</use>
|
||||
<currentRowUse>Auto</currentRowUse>
|
||||
</formCommands>
|
||||
<commandInterface>
|
||||
<navigationPanel/>
|
||||
<commandBar/>
|
||||
</commandInterface>
|
||||
</form:Form>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:CommonForm xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="251a878c-0393-42c4-9ac8-5ac5ba982171">
|
||||
<name>TestForm3</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Test form3</value>
|
||||
</synonym>
|
||||
<usePurposes>PersonalComputer</usePurposes>
|
||||
<usePurposes>MobileDevice</usePurposes>
|
||||
</mdclass:CommonForm>
|
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form:Form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:form="http://g5.1c.ru/v8/dt/form">
|
||||
<items xsi:type="form:FormField">
|
||||
<name>TestAttribute</name>
|
||||
<id>1</id>
|
||||
<visible>true</visible>
|
||||
<enabled>true</enabled>
|
||||
<userVisible>
|
||||
<common>true</common>
|
||||
<for>
|
||||
<value>true</value>
|
||||
<role>Role.TestRole1</role>
|
||||
</for>
|
||||
</userVisible>
|
||||
<dataPath xsi:type="form:DataPath">
|
||||
<segments>TestAttribute</segments>
|
||||
</dataPath>
|
||||
<extendedTooltip>
|
||||
<name>TestAttributeExtendedTooltip</name>
|
||||
<id>3</id>
|
||||
<visible>true</visible>
|
||||
<enabled>true</enabled>
|
||||
<userVisible>
|
||||
<common>true</common>
|
||||
</userVisible>
|
||||
<type>Label</type>
|
||||
<autoMaxWidth>true</autoMaxWidth>
|
||||
<autoMaxHeight>true</autoMaxHeight>
|
||||
<extInfo xsi:type="form:LabelDecorationExtInfo">
|
||||
<horizontalAlign>Left</horizontalAlign>
|
||||
</extInfo>
|
||||
</extendedTooltip>
|
||||
<contextMenu>
|
||||
<name>TestAttributeContextMenu</name>
|
||||
<id>2</id>
|
||||
<visible>true</visible>
|
||||
<enabled>true</enabled>
|
||||
<userVisible>
|
||||
<common>true</common>
|
||||
</userVisible>
|
||||
<autoFill>true</autoFill>
|
||||
</contextMenu>
|
||||
<type>InputField</type>
|
||||
<editMode>Enter</editMode>
|
||||
<showInHeader>true</showInHeader>
|
||||
<headerHorizontalAlign>Left</headerHorizontalAlign>
|
||||
<showInFooter>true</showInFooter>
|
||||
<extInfo xsi:type="form:InputFieldExtInfo">
|
||||
<autoMaxWidth>true</autoMaxWidth>
|
||||
<autoMaxHeight>true</autoMaxHeight>
|
||||
<wrap>true</wrap>
|
||||
<chooseType>true</chooseType>
|
||||
<typeDomainEnabled>true</typeDomainEnabled>
|
||||
<textEdit>true</textEdit>
|
||||
</extInfo>
|
||||
</items>
|
||||
<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>TestAttribute</name>
|
||||
<title>
|
||||
<key>en</key>
|
||||
<value>Test attribute</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>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:CommonForm xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="7730a94f-eacf-4d47-bf4d-fb224ffb5734">
|
||||
<name>TestForm4</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Test form4</value>
|
||||
</synonym>
|
||||
<usePurposes>PersonalComputer</usePurposes>
|
||||
<usePurposes>MobileDevice</usePurposes>
|
||||
</mdclass:CommonForm>
|
@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form:Form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:form="http://g5.1c.ru/v8/dt/form">
|
||||
<items xsi:type="form:FormField">
|
||||
<name>TestAttribute</name>
|
||||
<id>1</id>
|
||||
<visible>true</visible>
|
||||
<enabled>true</enabled>
|
||||
<userVisible>
|
||||
<common>true</common>
|
||||
</userVisible>
|
||||
<dataPath xsi:type="form:DataPath">
|
||||
<segments>TestAttribute</segments>
|
||||
</dataPath>
|
||||
<extendedTooltip>
|
||||
<name>TestAttributeExtendedTooltip</name>
|
||||
<id>3</id>
|
||||
<visible>true</visible>
|
||||
<enabled>true</enabled>
|
||||
<userVisible>
|
||||
<common>true</common>
|
||||
</userVisible>
|
||||
<type>Label</type>
|
||||
<autoMaxWidth>true</autoMaxWidth>
|
||||
<autoMaxHeight>true</autoMaxHeight>
|
||||
<extInfo xsi:type="form:LabelDecorationExtInfo">
|
||||
<horizontalAlign>Left</horizontalAlign>
|
||||
</extInfo>
|
||||
</extendedTooltip>
|
||||
<contextMenu>
|
||||
<name>TestAttributeContextMenu</name>
|
||||
<id>2</id>
|
||||
<visible>true</visible>
|
||||
<enabled>true</enabled>
|
||||
<userVisible>
|
||||
<common>true</common>
|
||||
</userVisible>
|
||||
<autoFill>true</autoFill>
|
||||
</contextMenu>
|
||||
<type>InputField</type>
|
||||
<editMode>Enter</editMode>
|
||||
<showInHeader>true</showInHeader>
|
||||
<headerHorizontalAlign>Left</headerHorizontalAlign>
|
||||
<showInFooter>true</showInFooter>
|
||||
<extInfo xsi:type="form:InputFieldExtInfo">
|
||||
<autoMaxWidth>true</autoMaxWidth>
|
||||
<autoMaxHeight>true</autoMaxHeight>
|
||||
<wrap>true</wrap>
|
||||
<chooseType>true</chooseType>
|
||||
<typeDomainEnabled>true</typeDomainEnabled>
|
||||
<textEdit>true</textEdit>
|
||||
</extInfo>
|
||||
</items>
|
||||
<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>TestAttribute</name>
|
||||
<title>
|
||||
<key>en</key>
|
||||
<value>Test attribute</value>
|
||||
</title>
|
||||
<id>1</id>
|
||||
<valueType>
|
||||
<types>String</types>
|
||||
<stringQualifiers/>
|
||||
</valueType>
|
||||
<view>
|
||||
<common>true</common>
|
||||
</view>
|
||||
<edit>
|
||||
<common>true</common>
|
||||
</edit>
|
||||
</attributes>
|
||||
<formCommands>
|
||||
<name>TestCommand</name>
|
||||
<title>
|
||||
<key>en</key>
|
||||
<value>Test command</value>
|
||||
</title>
|
||||
<id>1</id>
|
||||
<use>
|
||||
<common>true</common>
|
||||
</use>
|
||||
<currentRowUse>Auto</currentRowUse>
|
||||
</formCommands>
|
||||
<commandInterface>
|
||||
<navigationPanel/>
|
||||
<commandBar/>
|
||||
</commandInterface>
|
||||
</form:Form>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:CommonForm xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="813fe8ef-b5b1-4d65-b24b-8829dc74f337">
|
||||
<name>TestForm5</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Test form5</value>
|
||||
</synonym>
|
||||
<usePurposes>PersonalComputer</usePurposes>
|
||||
<usePurposes>MobileDevice</usePurposes>
|
||||
</mdclass:CommonForm>
|
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>
|
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:Configuration xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="26f4970b-c897-4aa2-866d-ad17153eafb2">
|
||||
<name>FormItemVisibleSettingsByRoles</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Form item visible settings by roles</value>
|
||||
</synonym>
|
||||
<containedObjects classId="9cd510cd-abfc-11d4-9434-004095e12fc7" objectId="196a845a-13dd-4713-99d0-217a5022aabc"/>
|
||||
<containedObjects classId="9fcd25a0-4822-11d4-9414-008048da11f9" objectId="14efdbc2-c91a-4592-8894-eaece1e78015"/>
|
||||
<containedObjects classId="e3687481-0a87-462c-a166-9f34594f9bba" objectId="d8f46aa6-ef9b-4824-af95-24cda3b203fc"/>
|
||||
<containedObjects classId="9de14907-ec23-4a07-96f0-85521cb6b53b" objectId="a63d8cf6-8d73-48ab-a95d-c439ef46d0d9"/>
|
||||
<containedObjects classId="51f2d5d8-ea4d-4064-8892-82951750031e" objectId="44fa1756-5d92-4466-b9a3-58482e2b466e"/>
|
||||
<containedObjects classId="e68182ea-4237-4383-967f-90c1e3370bc7" objectId="97c6744f-e578-49e1-9616-6f8dd26045bc"/>
|
||||
<containedObjects classId="fb282519-d103-4dd3-bc12-cb271d631dfc" objectId="1f4a3b62-d948-46d7-8a84-7c4e318ad383"/>
|
||||
<configurationExtensionCompatibilityMode>8.3.19</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.19</compatibilityMode>
|
||||
<languages uuid="8b1f0920-6533-48d6-8daa-726a6c5cfbb9">
|
||||
<name>English</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>English</value>
|
||||
</synonym>
|
||||
<languageCode>en</languageCode>
|
||||
</languages>
|
||||
<roles>Role.TestRole1</roles>
|
||||
<roles>Role.TestRole2</roles>
|
||||
<commonForms>CommonForm.TestForm1</commonForms>
|
||||
<commonForms>CommonForm.TestForm2</commonForms>
|
||||
<commonForms>CommonForm.TestForm3</commonForms>
|
||||
<commonForms>CommonForm.TestForm4</commonForms>
|
||||
<commonForms>CommonForm.TestForm5</commonForms>
|
||||
</mdclass:Configuration>
|
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<cmi:CommandInterface xmlns:cmi="http://g5.1c.ru/v8/dt/cmi"/>
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Rights xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://v8.1c.ru/8.2/roles" xsi:type="Rights">
|
||||
<setForNewObjects>false</setForNewObjects>
|
||||
<setForAttributesByDefault>true</setForAttributesByDefault>
|
||||
<independentRightsOfChildObjects>false</independentRightsOfChildObjects>
|
||||
<object>
|
||||
<name>Configuration.FormItemVisibleSettingsByRoles</name>
|
||||
<right>
|
||||
<name>SaveUserData</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>ThinClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>WebClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeEmbeddedWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeKiosk</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeNormal</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeFullscreenWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>AnalyticsSystemClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
</object>
|
||||
</Rights>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mdclass:Role xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass" uuid="60eac3fb-13fa-4915-ba23-dedf42d6ed46">
|
||||
<name>TestRole1</name>
|
||||
<synonym>
|
||||
<key>en</key>
|
||||
<value>Test role1</value>
|
||||
</synonym>
|
||||
</mdclass:Role>
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Rights xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://v8.1c.ru/8.2/roles" xsi:type="Rights">
|
||||
<setForNewObjects>false</setForNewObjects>
|
||||
<setForAttributesByDefault>true</setForAttributesByDefault>
|
||||
<independentRightsOfChildObjects>false</independentRightsOfChildObjects>
|
||||
<object>
|
||||
<name>Configuration.FormItemVisibleSettingsByRoles</name>
|
||||
<right>
|
||||
<name>SaveUserData</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>ThinClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>WebClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeEmbeddedWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeKiosk</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeNormal</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeFullscreenWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>MainWindowModeWorkplace</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
<right>
|
||||
<name>AnalyticsSystemClient</name>
|
||||
<value>true</value>
|
||||
</right>
|
||||
</object>
|
||||
</Rights>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user