Skip to content

Commit

Permalink
Refactor the QuteProcessor#validateNestedExpressions() method
Browse files Browse the repository at this point in the history
- resolves quarkusio#32299
mkouba committed Apr 3, 2023
1 parent 4fca0d7 commit 1b2afda
Showing 3 changed files with 507 additions and 329 deletions.
Original file line number Diff line number Diff line change
@@ -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;
@@ -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);

@@ -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();
@@ -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
@@ -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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -3,24 +3,24 @@
import java.util.Map;

import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.qute.deployment.QuteProcessor.Match;
import io.quarkus.qute.deployment.QuteProcessor.MatchResult;

final class TemplateExpressionMatchesBuildItem extends MultiBuildItem {

final String templateGeneratedId;

private final Map<Integer, Match> generatedIdsToMatches;
private final Map<Integer, MatchResult> generatedIdsToMatches;

public TemplateExpressionMatchesBuildItem(String templateGeneratedId, Map<Integer, Match> generatedIdsToMatches) {
public TemplateExpressionMatchesBuildItem(String templateGeneratedId, Map<Integer, MatchResult> generatedIdsToMatches) {
this.templateGeneratedId = templateGeneratedId;
this.generatedIdsToMatches = generatedIdsToMatches;
}

Match getMatch(Integer generatedId) {
MatchResult getMatch(Integer generatedId) {
return generatedIdsToMatches.get(generatedId);
}

Map<Integer, Match> getGeneratedIdsToMatches() {
Map<Integer, MatchResult> getGeneratedIdsToMatches() {
return generatedIdsToMatches;
}

0 comments on commit 1b2afda

Please sign in to comment.