Skip to content

Commit

Permalink
Merge pull request #1152 from 1C-Company/bugfix/1138-parent-type-inte…
Browse files Browse the repository at this point in the history
…rsect

Исправление пересечения родительских типов ОМД #1138
  • Loading branch information
marmyshev authored Sep 16, 2022
2 parents 4595de4 + 4f39560 commit dc66530
Show file tree
Hide file tree
Showing 15 changed files with 501 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
- Не понятно в какой бинарной операции ошибка ql-constants-in-binary-operation #1143
- Возникает NPE при работе проверки form-list-ref-user-visibility-enabled #1146
- Проверка: doc-comment-parameter-section не находит ошибку #1087
- Исправление пересечения родительских типов ОМД #1138

## 0.2.0

Expand Down
3 changes: 2 additions & 1 deletion bundles/com.e1c.v8codestyle.bsl/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.13.0,4.0.0)",
org.eclipse.xtext.builder;bundle-version="[2.18.0,3.0.0)",
org.eclipse.xtext.ui;bundle-version="[2.24.0,3.0.0)",
org.eclipse.handly;bundle-version="[1.5.0,2.0.0)",
org.eclipse.xtext.ui.shared;bundle-version="[2.19.0,3.0.0)"
org.eclipse.xtext.ui.shared;bundle-version="[2.19.0,3.0.0)",
org.eclipse.jdt.annotation;bundle-version="[2.2.0,3.0.0)";resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: com.e1c.v8codestyle.bsl
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
import com._1c.g5.v8.dt.mcore.TypeSet;
import com._1c.g5.v8.dt.mcore.util.Environments;
import com._1c.g5.v8.dt.mcore.util.McoreUtil;
import com._1c.g5.v8.dt.platform.IEObjectDynamicTypeNames;
import com._1c.g5.v8.dt.platform.IEObjectTypeNames;
import com.e1c.g5.v8.dt.check.components.BasicCheck;
import com.e1c.v8codestyle.internal.bsl.BslPlugin;

/**
* Abstract check of types in module objects. Allows to compute types respecting system enums,
Expand All @@ -68,14 +68,6 @@
public abstract class AbstractTypeCheck
extends BasicCheck
{

private static final Collection<String> ALL_REF_TYPE_SET_PARENT_TYPE_NAMES =
Set.of(IEObjectDynamicTypeNames.CATALOG_REF_TYPE_NAME, IEObjectDynamicTypeNames.DOCUMENT_REF_TYPE_NAME,
IEObjectDynamicTypeNames.ENUM_REF_TYPE_NAME, IEObjectDynamicTypeNames.COC_REF_TYPE_NAME,
IEObjectDynamicTypeNames.COA_REF_TYPE_NAME, IEObjectDynamicTypeNames.CALCULATION_TYPE_REF_TYPE_NAME,
IEObjectDynamicTypeNames.BP_REF_TYPE_NAME, IEObjectDynamicTypeNames.BP_ROUTEPOINT_TYPE_NAME,
IEObjectDynamicTypeNames.TASK_REF_TYPE_NAME, IEObjectDynamicTypeNames.EXCHANGE_PLAN_REF_TYPE_NAME);

private static final String COMMON_MODULE = "CommonModule"; //$NON-NLS-1$

private static final QualifiedName QN_COMMON_MODULE = QualifiedName.create(COMMON_MODULE);
Expand All @@ -101,6 +93,8 @@ public abstract class AbstractTypeCheck
/** The comment provider service. */
protected final BslMultiLineCommentDocumentationProvider commentProvider;

private final InternalTypeNameRegistry internalTypeNameRegistry;

/**
* Instantiates a new abstract type check.
*
Expand All @@ -121,6 +115,9 @@ protected AbstractTypeCheck(IResourceLookup resourceLookup, IBslPreferences bslP
this.scopeProvider = rsp.get(IScopeProvider.class);
this.commentProvider = rsp.get(BslMultiLineCommentDocumentationProvider.class);
this.qualifiedNameConverter = qualifiedNameConverter;
this.internalTypeNameRegistry =
BslPlugin.getDefault().getInjector().getInstance(InternalTypeNameRegistry.class);

}

/**
Expand Down Expand Up @@ -316,7 +313,7 @@ else if (type instanceof Type && COMMON_MODULE.equals(McoreUtil.getTypeCategory(
return parentTypes;
}

private static Collection<String> getTypeNames(Collection<TypeItem> parentTypes, EObject context)
private Collection<String> getTypeNames(Collection<TypeItem> parentTypes, EObject context)
{
Set<String> typeNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (TypeItem type : parentTypes)
Expand All @@ -326,6 +323,11 @@ private static Collection<String> getTypeNames(Collection<TypeItem> parentTypes,
if (typeName != null)
{
typeNames.add(typeName);
String parentTypeName = getTypeSetItemParentTypeName(typeName);
if (parentTypeName != null)
{
typeNames.add(parentTypeName);
}
}
if (type instanceof TypeSet && typeName != null)
{
Expand All @@ -337,48 +339,16 @@ private static Collection<String> getTypeNames(Collection<TypeItem> parentTypes,

if (IEObjectTypeNames.ANY_REF.equals(typeName))
{
typeNames.addAll(ALL_REF_TYPE_SET_PARENT_TYPE_NAMES);
}
else
{
String parentTypeName = getTypeSetItemParentTypeName(typeName);
if (parentTypeName != null)
{
typeNames.add(parentTypeName);
}
typeNames.addAll(internalTypeNameRegistry.allRefTypeSetParentTypeNames());
}
}
}
return typeNames;
}

private static String getTypeSetItemParentTypeName(String typeName)
private String getTypeSetItemParentTypeName(String typeName)
{
switch (typeName)
{
case IEObjectTypeNames.CATALOG_REF:
return IEObjectDynamicTypeNames.CATALOG_REF_TYPE_NAME;
case IEObjectTypeNames.DOCUMENT_REF:
return IEObjectDynamicTypeNames.DOCUMENT_REF_TYPE_NAME;
case IEObjectTypeNames.ENUM_REF:
return IEObjectDynamicTypeNames.ENUM_REF_TYPE_NAME;
case IEObjectTypeNames.CHART_OF_CHARACTERISTIC_TYPES_REF:
return IEObjectDynamicTypeNames.COC_REF_TYPE_NAME;
case IEObjectTypeNames.CHART_OF_ACCOUNTS_REF:
return IEObjectDynamicTypeNames.COA_REF_TYPE_NAME;
case IEObjectTypeNames.CHART_OF_CALCULATION_TYPES_REF:
return IEObjectDynamicTypeNames.CALCULATION_TYPE_REF_TYPE_NAME;
case IEObjectTypeNames.BUSINESS_PROCESS_REF:
return IEObjectDynamicTypeNames.BP_REF_TYPE_NAME;
case IEObjectTypeNames.BUSINESS_PROCESS_ROUTE_POINT_REF:
return IEObjectDynamicTypeNames.BP_ROUTEPOINT_TYPE_NAME;
case IEObjectTypeNames.TASK_REF:
return IEObjectDynamicTypeNames.TASK_REF_TYPE_NAME;
case IEObjectTypeNames.EXCHANGE_PLAN_REF:
return IEObjectDynamicTypeNames.EXCHANGE_PLAN_REF_TYPE_NAME;
default:
return null;
}
return internalTypeNameRegistry.getInternalTypeName(typeName);
}

}
Loading

0 comments on commit dc66530

Please sign in to comment.