From 2ffa3bc558c0d6d09b3ed4b395c05e11a63e377a Mon Sep 17 00:00:00 2001 From: m0rkeulv Date: Thu, 15 Feb 2024 16:03:16 +0100 Subject: [PATCH] ignore checks when type is from macro --- .../haxe/ide/annotator/semantics/HaxeSemanticsUtil.java | 9 +++++++++ .../haxe/ide/annotator/semantics/HaxeTypeAnnotator.java | 1 + 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeSemanticsUtil.java b/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeSemanticsUtil.java index 9e47b4f67..a009c270d 100644 --- a/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeSemanticsUtil.java +++ b/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeSemanticsUtil.java @@ -29,6 +29,8 @@ public static void check( boolean requireConstant, final AnnotationHolder holder ) { + if (isTypeFromMacroVar(tag))return; // ignore if macro variable name + final ResultHolder varType = HaxeTypeResolver.getTypeFromTypeTag(tag, erroredElement); final ResultHolder initType = getTypeFromVarInit(initExpression, varType); if (initType.isInvalid()) return; @@ -56,6 +58,13 @@ else if (requireConstant && !isConstant(initType, initExpression)) { } } + private static boolean isTypeFromMacroVar(HaxeTypeTag tag) { + if (tag.getTypeOrAnonymous() != null) { + return tag.getTypeOrAnonymous().getText().startsWith("$"); + } + return false; + } + private static boolean isConstant(ResultHolder initType, HaxeVarInit initExpression) { SpecificTypeReference specificTypeReference = initType.getType(); diff --git a/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeTypeAnnotator.java b/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeTypeAnnotator.java index 9f6d5edb5..c84eee52f 100644 --- a/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeTypeAnnotator.java +++ b/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeTypeAnnotator.java @@ -86,6 +86,7 @@ private static void checkTypeParametersForType(HaxeType type, AnnotationHolder h if (typeParameterCount != classParameterCount) { String typeName = getTypeName(type.getReferenceExpression().getIdentifier()); + if (typeName.startsWith("$"))return; // ignore when type is from macro variable holder.newAnnotation(HighlightSeverity.ERROR, HaxeBundle.message("haxe.inspections.parameter.count.mismatch.description", typeName, classParameterCount, typeParameterCount))