1
0
mirror of https://github.com/1C-Company/v8-code-style.git synced 2024-11-28 17:41:06 +02:00

Merge pull request #1317 from 1C-Company/G5V8DT-23259

G5V8DT-23259 Падение NPE в коде расчета типов
This commit is contained in:
Dmitriy Marmyshev 2023-04-16 13:48:01 -07:00 committed by GitHub
commit 0144eb6211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 10 deletions

View File

@ -138,7 +138,7 @@ public class ReadingAttributesFromDataBaseCheck
}
String typeName = McoreUtil.getTypeName(type);
if (McoreUtil.getTypeName(type) == null)
if (typeName == null)
{
return;
}

View File

@ -283,7 +283,10 @@ public class FunctionCtorReturnSectionCheck
.collect(Collectors.toList());
List<TypeItem> types2 = types.stream()
.filter(t -> McoreUtil.getTypeName(t) != null && !declaredType.contains(McoreUtil.getTypeName(t)))
.filter(t -> {
String typeName = McoreUtil.getTypeName(t);
return typeName != null && !declaredType.contains(typeName);
})
.collect(Collectors.toList());
if (types.isEmpty())
{
@ -353,6 +356,7 @@ public class FunctionCtorReturnSectionCheck
property.getTypes()
.stream()
.map(useRussianScript ? McoreUtil::getTypeNameRu : McoreUtil::getTypeName)
.filter(Objects::nonNull)
.collect(Collectors.toList())));
resultAceptor.addIssue(message, statment, Literals.RETURN_STATEMENT__EXPRESSION);
@ -367,10 +371,12 @@ public class FunctionCtorReturnSectionCheck
property.getTypes()
.stream()
.map(useRussianScript ? McoreUtil::getTypeNameRu : McoreUtil::getTypeName)
.filter(Objects::nonNull)
.collect(Collectors.toList())),
String.join(", ", //$NON-NLS-1$
missingTypes.stream()
.map(useRussianScript ? McoreUtil::getTypeNameRu : McoreUtil::getTypeName)
.filter(Objects::nonNull)
.collect(Collectors.toList())));
resultAceptor.addIssue(message, statment, Literals.RETURN_STATEMENT__EXPRESSION);

View File

@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
@ -491,7 +492,8 @@ public class InvocationParamIntersectionCheck
ScriptVariant variant = project.getScriptVariant();
Function<TypeItem, String> nameFunc =
variant == ScriptVariant.RUSSIAN ? McoreUtil::getTypeNameRu : McoreUtil::getTypeName;
List<String> typeNames = targetTypes.stream().map(nameFunc).collect(Collectors.toList());
List<String> typeNames =
targetTypes.stream().map(nameFunc).filter(Objects::nonNull).collect(Collectors.toList());
String name = parameter == null ? String.valueOf(index + 1) : parameter.getName();
if (parameter instanceof DuallyNamedElement && variant == ScriptVariant.RUSSIAN)

View File

@ -17,7 +17,9 @@ import static com._1c.g5.v8.dt.bsl.model.BslPackage.Literals.SIMPLE_STATEMENT;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
@ -35,7 +37,6 @@ import com._1c.g5.v8.dt.bsl.model.Invocation;
import com._1c.g5.v8.dt.bsl.model.SimpleStatement;
import com._1c.g5.v8.dt.bsl.model.StaticFeatureAccess;
import com._1c.g5.v8.dt.bsl.model.Variable;
import com._1c.g5.v8.dt.bsl.util.BslUtil;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
@ -50,7 +51,6 @@ import com.e1c.g5.v8.dt.check.ICheckParameters;
import com.e1c.g5.v8.dt.check.components.ModuleTopObjectNameFilterExtension;
import com.e1c.g5.v8.dt.check.settings.IssueSeverity;
import com.e1c.g5.v8.dt.check.settings.IssueType;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
/**
@ -204,12 +204,15 @@ public class SimpleStatementTypeCheck
return false;
}
Set<String> targetNames = Sets.newLinkedHashSet(BslUtil.transform(target, BslUtil.TYPE_NAME));
if (canResetToUndefined && targetNames.contains(IEObjectTypeNames.UNDEFINED) && targetNames.size() == 1)
if (canResetToUndefined)
{
Set<String> targetNames =
target.stream().map(McoreUtil::getTypeName).filter(Objects::nonNull).collect(Collectors.toSet());
if (targetNames.contains(IEObjectTypeNames.UNDEFINED) && targetNames.size() == 1)
{
return true;
}
}
return intersectTypeItem(source, target, context);
}

View File

@ -216,7 +216,7 @@ public class TypedValueAddingToUntypedCollectionCheck
private boolean isActualCollectionItemTypeEmpty(Collection<TypeItem> actualTypes)
{
actualTypes.removeIf(p -> McoreUtil.getTypeName(p).equals(IEObjectTypeNames.ARBITRARY));
actualTypes.removeIf(p -> IEObjectTypeNames.ARBITRARY.equals(McoreUtil.getTypeName(p)));
return actualTypes.isEmpty();
}