diff --git a/magik-squid/src/main/java/nl/ramsolutions/sw/magik/analysis/typing/types/TypeString.java b/magik-squid/src/main/java/nl/ramsolutions/sw/magik/analysis/typing/types/TypeString.java index a988c4af..f0dca2b8 100644 --- a/magik-squid/src/main/java/nl/ramsolutions/sw/magik/analysis/typing/types/TypeString.java +++ b/magik-squid/src/main/java/nl/ramsolutions/sw/magik/analysis/typing/types/TypeString.java @@ -177,11 +177,28 @@ public String getFullString() { return this.currentPackage + ":" + this.string; } + /** + * Test if this type is undefined. + * @return {@code true} if this type is undefined. + */ public boolean isUndefined() { return !this.isCombined() && this.getString().equalsIgnoreCase(UndefinedType.SERIALIZED_NAME); } + /** + * Test if this type contains an undefined type. + * @return {@code true} if this type contains an undefined type. + */ + public boolean containsUndefined() { + if (this.isCombined()) { + return this.combinedTypes.stream() + .anyMatch(TypeString::containsUndefined); + } + + return this.isUndefined(); + } + public boolean isSelf() { return !this.isCombined() && this.getString().equalsIgnoreCase(SelfType.SERIALIZED_NAME); diff --git a/magik-typed-checks/src/main/java/nl/ramsolutions/sw/magik/typedchecks/fixers/TypeDocReturnTypeFixer.java b/magik-typed-checks/src/main/java/nl/ramsolutions/sw/magik/typedchecks/fixers/TypeDocReturnTypeFixer.java index 48c4fa95..6a0c9df5 100644 --- a/magik-typed-checks/src/main/java/nl/ramsolutions/sw/magik/typedchecks/fixers/TypeDocReturnTypeFixer.java +++ b/magik-typed-checks/src/main/java/nl/ramsolutions/sw/magik/typedchecks/fixers/TypeDocReturnTypeFixer.java @@ -63,27 +63,26 @@ private List extractReturnTypeCodeActions( return StreamUtils.zip(methodResultString.stream(), typeDocNodes.entrySet().stream()) .map(entry -> { final TypeString methodTypeString = entry.getKey(); - if (methodTypeString == TypeString.UNDEFINED) { + if (methodTypeString != null && methodTypeString.containsUndefined()) { // Don't propose code actions for undefined types. return null; } final Map.Entry typeDocEntry = entry.getValue(); if (methodTypeString != null && typeDocEntry == null) { - // Code action: Add type-doc line. return this.createAddReturnCodeAction(methodDefinition, methodTypeString); } - final TypeString typeDocTypeString = typeDocEntry.getValue(); final AstNode typeDocNode = typeDocEntry.getKey(); final AstNode typeValueNode = typeDocNode.getFirstChild(TypeDocGrammar.TYPE_VALUE); if (methodTypeString == null && typeDocEntry != null) { - // Code action: Remove type-doc line. return this.createRemoveReturnCodeAction(typeValueNode); - } else if (methodTypeString != null // && typeDocTypeString != null - && methodTypeString != TypeString.UNDEFINED + } + + final TypeString typeDocTypeString = typeDocEntry.getValue(); + if (methodTypeString != null // && typeDocTypeString != null + && !methodTypeString.containsUndefined() && !methodTypeString.equals(typeDocTypeString)) { - // Code action: Update type-doc line. return this.createUpdateReturnCodeAction(methodTypeString, typeValueNode); }