Skip to content

Commit

Permalink
Refactor the QuteProcessor#validateNestedExpressions() method
Browse files Browse the repository at this point in the history
- resolves quarkusio#32299
  • Loading branch information
mkouba authored and maxandersen committed Apr 14, 2023
1 parent d7c827f commit 86e391e
Show file tree
Hide file tree
Showing 3 changed files with 507 additions and 329 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
import io.quarkus.qute.LoopSectionHelper;
import io.quarkus.qute.Namespaces;
import io.quarkus.qute.Resolver;
import io.quarkus.qute.deployment.QuteProcessor.LookupConfig;
import io.quarkus.qute.deployment.QuteProcessor.Match;
import io.quarkus.qute.deployment.QuteProcessor.JavaMemberLookupConfig;
import io.quarkus.qute.deployment.QuteProcessor.MatchResult;
import io.quarkus.qute.deployment.TemplatesAnalysisBuildItem.TemplateAnalysis;
import io.quarkus.qute.deployment.Types.AssignableInfo;
import io.quarkus.qute.deployment.Types.HierarchyIndexer;
Expand Down Expand Up @@ -453,7 +453,8 @@ public String apply(String id) {
List<TemplateExtensionMethodBuildItem> regularExtensionMethods = templateExtensionMethods.stream()
.filter(Predicate.not(TemplateExtensionMethodBuildItem::hasNamespace)).collect(Collectors.toUnmodifiableList());

LookupConfig lookupConfig = new QuteProcessor.FixedLookupConfig(index, QuteProcessor.initDefaultMembersFilter(), false);
JavaMemberLookupConfig lookupConfig = new QuteProcessor.FixedJavaMemberLookupConfig(index,
QuteProcessor.initDefaultMembersFilter(), false);
Map<DotName, AssignableInfo> assignableCache = new HashMap<>();
HierarchyIndexer hierarchyIndexer = new HierarchyIndexer(index);

Expand Down Expand Up @@ -507,7 +508,7 @@ public String apply(String id) {
}
}

Map<Integer, Match> generatedIdsToMatches = Collections.emptyMap();
Map<Integer, MatchResult> generatedIdsToMatches = Collections.emptyMap();
for (TemplateExpressionMatchesBuildItem templateExpressionMatchesBuildItem : expressionMatches) {
if (templateExpressionMatchesBuildItem.templateGeneratedId.equals(templateAnalysis.generatedId)) {
generatedIdsToMatches = templateExpressionMatchesBuildItem.getGeneratedIdsToMatches();
Expand Down Expand Up @@ -558,7 +559,7 @@ public String apply(String id) {
int idx = 0;
for (Expression param : params) {
if (param.hasTypeInfo()) {
Map<String, Match> results = new HashMap<>();
Map<String, MatchResult> results = new HashMap<>();

final List<Predicate<TypeCheckExcludeBuildItem.TypeCheck>> excludes = new ArrayList<>();
// subset of excludes specific for extension methods
Expand All @@ -576,7 +577,7 @@ public String apply(String id) {
extensionMethodExcludes, checkedTemplate, lookupConfig, namedBeans,
namespaceTemplateData, regularExtensionMethods, namespaceExtensionMethods,
assignableCache, hierarchyIndexer);
Match match = results.get(param.toOriginalString());
MatchResult match = results.get(param.toOriginalString());
if (match != null && !match.isEmpty() && !Types.isAssignableFrom(match.type(),
methodParams.get(idx), index, assignableCache)) {
incorrectExpressions
Expand Down
Loading

0 comments on commit 86e391e

Please sign in to comment.