Skip to content

Commit

Permalink
Исправление возможных NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
marmyshev committed Mar 30, 2022
1 parent e246d4d commit 0826c0a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Collection;
import java.util.Deque;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -192,8 +193,9 @@ else if (object instanceof StaticFeatureAccess && ((StaticFeatureAccess)object).
String typeName = fa.getName();
String propertyName = dfa.getName();
TypeItem type = sourceTypes.get(0);
if ((typeName.equalsIgnoreCase(McoreUtil.getTypeNameRu(type))
|| typeName.equalsIgnoreCase(McoreUtil.getTypeName(type)))
if (typeName != null
&& (typeName.equalsIgnoreCase(McoreUtil.getTypeNameRu(type))
|| typeName.equalsIgnoreCase(McoreUtil.getTypeName(type)))
&& dynamicFeatureAccessComputer.getAllProperties(sourceTypes, object.eResource())
.stream()
.flatMap(e -> e.getFirst().stream())
Expand Down Expand Up @@ -308,11 +310,17 @@ private static Collection<String> getTypeNames(Collection<TypeItem> parentTypes,
{
type = (TypeItem)EcoreUtil.resolve(type, context);
String typeName = McoreUtil.getTypeName(type);
typeNames.add(typeName);
if (type instanceof TypeSet)
if (typeName != null)
{
typeNames.add(typeName);
}
if (type instanceof TypeSet && typeName != null)
{
typeNames.addAll(
((TypeSet)type).getTypes().stream().map(McoreUtil::getTypeName).collect(Collectors.toList()));
typeNames.addAll(((TypeSet)type).getTypes()
.stream()
.map(McoreUtil::getTypeName)
.filter(Objects::nonNull)
.collect(Collectors.toList()));

if (IEObjectTypeNames.ANY_REF.equals(typeName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
Expand Down Expand Up @@ -176,8 +177,10 @@ protected void checkDocumentationCommentObject(IDescriptionPart object, BslDocum

Set<String> checkTypes = getCheckTypes(parameters);

List<String> computedReturnTypeNames =
computedReturnTypes.stream().map(McoreUtil::getTypeName).collect(Collectors.toList());
List<String> computedReturnTypeNames = computedReturnTypes.stream()
.map(McoreUtil::getTypeName)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (isUserDataTypes(computedReturnTypeNames, checkTypes))
{

Expand Down Expand Up @@ -256,8 +259,11 @@ private void checkTypeProperties(Function function, ReturnStatement statment, bo
{
String propertyName = useRussianScript ? declaredProperty.getNameRu() : declaredProperty.getName();
declaredProertyNames.add(propertyName);
List<String> declaredType =
declaredProperty.getTypes().stream().map(McoreUtil::getTypeName).collect(Collectors.toList());
List<String> declaredType = declaredProperty.getTypes()
.stream()
.map(McoreUtil::getTypeName)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (declaredType.isEmpty())
{
continue;
Expand All @@ -271,7 +277,7 @@ private void checkTypeProperties(Function function, ReturnStatement statment, bo
.collect(Collectors.toList());

List<TypeItem> types2 = types.stream()
.filter(t -> !declaredType.contains(McoreUtil.getTypeName(t)))
.filter(t -> McoreUtil.getTypeName(t) != null && !declaredType.contains(McoreUtil.getTypeName(t)))
.collect(Collectors.toList());
if (types.isEmpty())
{
Expand Down

0 comments on commit 0826c0a

Please sign in to comment.