Skip to content

Commit

Permalink
ignore checks when type is from macro
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Feb 15, 2024
1 parent 12529ba commit 2ffa3bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 2ffa3bc

Please sign in to comment.