From 974a7fce679fae278814e6112608c157a8c483c7 Mon Sep 17 00:00:00 2001 From: azerr Date: Wed, 28 Aug 2024 20:45:03 +0200 Subject: [PATCH] fix: prevent from duplicate Qute parameter key Signed-off-by: azerr --- .../internal/template/datamodel/CheckedTemplateSupport.java | 2 +- .../internal/template/datamodel/TemplateRecordsSupport.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/qute/psi/internal/template/datamodel/CheckedTemplateSupport.java b/src/main/java/com/redhat/devtools/intellij/qute/psi/internal/template/datamodel/CheckedTemplateSupport.java index f9159231f..fa2a1a4c1 100644 --- a/src/main/java/com/redhat/devtools/intellij/qute/psi/internal/template/datamodel/CheckedTemplateSupport.java +++ b/src/main/java/com/redhat/devtools/intellij/qute/psi/internal/template/datamodel/CheckedTemplateSupport.java @@ -291,7 +291,7 @@ public static void collectParameters(PsiMethod method, ITypeResolver typeResolve if (templateOrFragment.getParameter(parameter.getKey()) == null) { // Add parameter if it doesn't exist // to avoid parameters duplication - templateOrFragment.getParameters().add(parameter); + templateOrFragment.addParameter(parameter); } } } diff --git a/src/main/java/com/redhat/devtools/intellij/qute/psi/internal/template/datamodel/TemplateRecordsSupport.java b/src/main/java/com/redhat/devtools/intellij/qute/psi/internal/template/datamodel/TemplateRecordsSupport.java index 75fdd3c46..9e87ba28e 100644 --- a/src/main/java/com/redhat/devtools/intellij/qute/psi/internal/template/datamodel/TemplateRecordsSupport.java +++ b/src/main/java/com/redhat/devtools/intellij/qute/psi/internal/template/datamodel/TemplateRecordsSupport.java @@ -98,7 +98,11 @@ private static DataModelTemplate createTemplateDataModel(Psi DataModelParameter parameter = new DataModelParameter(); parameter.setKey(field.getName()); parameter.setSourceType(PsiTypeUtils.resolveSignature(field.getType(), field.isVarArgs())); - template.getParameters().add(parameter); + if (template.getParameter(parameter.getKey()) == null) { + // Add parameter if it doesn't exist + // to avoid parameters duplication + template.addParameter(parameter); + } } // Collect data parameters for the given template