Skip to content

Commit

Permalink
fix(#7): Исправления кода проверок идентификаторов форм по результатам
Browse files Browse the repository at this point in the history
ревью

- Исправлены опечатки в javadoc
- Конфигурирование через поля заменено на конфигурирование через
конструктор
  • Loading branch information
nikolay-martynov committed Aug 8, 2022
1 parent e54c741 commit eecdb82
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 16 deletions.
Expand Up @@ -57,7 +57,7 @@
* child content. To make sure we do not try to walk the whole form when validating every form item,
* the check specifies the form itself as an object to be validated.
* When user changes identifier of an item or removes an item, we need to trigger form re-validation
* because duplicates might have gone away. For example, first opject with the same id (which did not have markers)
* because duplicates might have gone away. For example, first object with the same id (which did not have markers)
* might have been deleted and we need to cleanup markers on a second object that has those markers.
* For this purpose implementation uses {@link AdditionalRevalidationRules} extension to specify extra rules.
* <p/>
Expand All @@ -73,8 +73,18 @@ public class InvalidItemIdCheck
/**
* Service to delegate checking to.
*/
private final IInvalidItemIdService invalidItemIdservice;

/**
* Creates new instance.
* @param invalidItemIdService Service that will be used to delegate checks to. Must not be {@code null}.
*/
@Inject
private IInvalidItemIdService service;
public InvalidItemIdCheck(IInvalidItemIdService invalidItemIdService)
{
Objects.requireNonNull(invalidItemIdService, "invalidItemIdService"); //$NON-NLS-1$
this.invalidItemIdservice = invalidItemIdService;
}

@Override
public String getCheckId()
Expand Down Expand Up @@ -115,7 +125,7 @@ protected void check(Object object, ResultAcceptor resultAcceptor, ICheckParamet
return;
}
Form form = (Form)object;
service.validate(form)
invalidItemIdservice.validate(form)
.entrySet()
.stream()
.forEach(itemAndMesage -> resultAcceptor.addIssue(itemAndMesage.getValue(), itemAndMesage.getKey(),
Expand Down
Expand Up @@ -186,7 +186,7 @@ public boolean isDebugging()
*
* @param traceOption Name of the option that is to be checked if message should be traced.
* This corresponds to an individual component of function. The value should have
* the following format: /debug/componentName. It should be toggled eother via .options file
* the following format: /debug/componentName. It should be toggled either via .options file
* or through Window  → Preferences  → General → Tracing. Note the importance of {@code /} in the beginning.
* If value is {@code null} then option for an individual component will not be checked.
* However, {@link #DEBUG_OPTION} will still be checked.
Expand Down
Expand Up @@ -53,7 +53,7 @@
* When there are multiple form items with the same identifier then one of
* them is considered to be valid while others are deemed to be problematic duplicates.
* This is to reduce number of errors shown to user.
* Identifiers that are arelady invalid (as described previously) do not paticipate into
* Identifiers that are already invalid (as described previously) do not paticipate into
* duplicates check and are just reported as incorrect. This means that if there are two from items
* with {@code 0} identifiers then both of them will be reported as having incorrect rather than duplicate
* identifiers.
Expand Down
Expand Up @@ -15,6 +15,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Spliterators;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -61,26 +62,49 @@ public class InvalidItemIdCleanup
/**
* Service used to obtain project model.
*/
@Inject
private IBmModelManager bmModelManager;
private final IBmModelManager bmModelManager;

/**
* Service used to check if editing is allowed.
*/
@Inject
private IModelEditingSupport editingSupport;
private final IModelEditingSupport editingSupport;

/**
* Service used to obtain project configuration.
*/
@Inject
private IConfigurationProvider configurationProvider;
private final IConfigurationProvider configurationProvider;

/**
* Service to delegate checking and fixing to.
*/
private final IInvalidItemIdService invalidItemIdService;

/**
* Creates new instance.
*
* @param invalidItemIdService Service to which delegate actual checking and fixing of form item identifiers.
* Must not be {@code null}.
* @param configurationProvider Service instance that is to be used to obtain configuration.
* Must not be {@code null}.
* @param bmModelManager Service instance that is to be used to obtain project model.
* Must not be {@code null}.
* @param editingSupport Service instance that is to be used to check if we're allowed to change configuration.
* Must not be {@code null}.
*/
@Inject
private IInvalidItemIdService service;
public InvalidItemIdCleanup(IInvalidItemIdService invalidItemIdService,
IConfigurationProvider configurationProvider, IBmModelManager bmModelManager,
IModelEditingSupport editingSupport)
{
Objects.requireNonNull(bmModelManager, "bmModelManager"); //$NON-NLS-1$
Objects.requireNonNull(editingSupport, "editingSupport"); //$NON-NLS-1$
Objects.requireNonNull(configurationProvider, "configurationProvider"); //$NON-NLS-1$
Objects.requireNonNull(invalidItemIdService, "invalidItemIdService"); //$NON-NLS-1$
this.bmModelManager = bmModelManager;
this.editingSupport = editingSupport;
this.configurationProvider = configurationProvider;
this.invalidItemIdService = invalidItemIdService;
}

@Override
public List<ICleanUpBmObjectTask> getCleanUpProjectTasks(IDtProject project)
Expand Down Expand Up @@ -148,7 +172,7 @@ public List<ICleanUpBmObjectTask> execute(IBmTransaction transaction, IProgressM
*/
private Stream<FormItem> validateForm(Form form)
{
return service.validate(form).keySet().stream();
return invalidItemIdService.validate(form).keySet().stream();
}

}
Expand Down Expand Up @@ -181,7 +205,7 @@ private class InvalidItemIdCleanupTask
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor progressMonitor)
{
service.fix(itemToFix);
invalidItemIdService.fix(itemToFix);
return null;
}

Expand Down
Expand Up @@ -12,6 +12,8 @@
*******************************************************************************/
package com.e1c.dt.check.internal.form.fix;

import java.util.Objects;

import org.eclipse.emf.ecore.EStructuralFeature;

import com._1c.g5.v8.dt.form.model.FormItem;
Expand Down Expand Up @@ -43,8 +45,19 @@ public class InvalidItemIdFix
/**
* Service to delegate fixing to.
*/
private final IInvalidItemIdService invalidItemIdService;

/**
* Creates new instnce.
*
* @param invalidItemIdService Service to which actual fixing should be delegated to. Must not be {@code null}.
*/
@Inject
private IInvalidItemIdService service;
public InvalidItemIdFix(IInvalidItemIdService invalidItemIdService)
{
Objects.requireNonNull(invalidItemIdService, "invalidItemIdService"); //$NON-NLS-1$
this.invalidItemIdService = invalidItemIdService;
}

@Override
protected void configureFix(FixConfigurer configurer)
Expand All @@ -57,7 +70,7 @@ protected void configureFix(FixConfigurer configurer)
protected void applyChanges(FormItem modelObject, EStructuralFeature targetFeature, BasicModelFixContext context,
IFixSession session)
{
service.fix(modelObject);
invalidItemIdService.fix(modelObject);
}

}

0 comments on commit eecdb82

Please sign in to comment.