better enricher
This commit is contained in:
@@ -45,6 +45,17 @@ public class TransitionLinkerEnricher implements AnalysisEnricher {
|
||||
boolean isWildcard = triggerEvent.equals("event") || triggerEvent.equals("e") ||
|
||||
triggerEvent.equals("msg") || triggerEvent.equals("message") ||
|
||||
triggerEvent.equals("payload") || triggerEvent.matches(".*\\.get[A-Z].*\\(\\)");
|
||||
|
||||
if (isWildcard) {
|
||||
String targetVar = chain.getContextMachineId();
|
||||
if (targetVar == null && chain.getTriggerPoint() != null) {
|
||||
targetVar = chain.getTriggerPoint().getStateMachineId();
|
||||
}
|
||||
if (targetVar == null || targetVar.isEmpty()) {
|
||||
// Wildcard without specific routing context is too broad, do not link
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (isWildcard || smEvent.equals(triggerEvent) || triggerEvent.toLowerCase().contains(smEvent.toLowerCase()) || smEvent.toLowerCase().contains(triggerEvent.toLowerCase())) {
|
||||
// Event matches or is a wildcard
|
||||
@@ -52,17 +63,27 @@ public class TransitionLinkerEnricher implements AnalysisEnricher {
|
||||
String smSourceRaw = smSourceState.fullIdentifier() != null ? smSourceState.fullIdentifier() : smSourceState.rawName();
|
||||
String smSource = simplify(smSourceRaw);
|
||||
if (triggerSource == null || triggerSource.equals(smSource)) {
|
||||
for (State smTargetState : t.getTargetStates()) {
|
||||
String sourceRaw = smSourceState.fullIdentifier() != null ? smSourceState.fullIdentifier() : smSourceState.rawName();
|
||||
String targetRaw = smTargetState.fullIdentifier() != null ? smTargetState.fullIdentifier() : smTargetState.rawName();
|
||||
if (t.getTargetStates() == null || t.getTargetStates().isEmpty()) {
|
||||
MatchedTransition mt = MatchedTransition.builder()
|
||||
.sourceState(sourceRaw)
|
||||
.targetState(targetRaw)
|
||||
.sourceState(smSourceRaw)
|
||||
.targetState(smSourceRaw)
|
||||
.event(smEventRaw)
|
||||
.build();
|
||||
if (isRoutedToCorrectMachine(chain, result.getName())) {
|
||||
matched.add(mt);
|
||||
}
|
||||
} else {
|
||||
for (State smTargetState : t.getTargetStates()) {
|
||||
String targetRaw = smTargetState.fullIdentifier() != null ? smTargetState.fullIdentifier() : smTargetState.rawName();
|
||||
MatchedTransition mt = MatchedTransition.builder()
|
||||
.sourceState(smSourceRaw)
|
||||
.targetState(targetRaw)
|
||||
.event(smEventRaw)
|
||||
.build();
|
||||
if (isRoutedToCorrectMachine(chain, result.getName())) {
|
||||
matched.add(mt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,6 +136,9 @@ public class TransitionLinkerEnricher implements AnalysisEnricher {
|
||||
if (name == null) return null;
|
||||
// Strip common suffixes
|
||||
String simplified = name.replaceAll("(?i)(.*)(Event|Action|Transition|Command)(s)?$", "$1");
|
||||
if (simplified.isEmpty()) {
|
||||
simplified = name;
|
||||
}
|
||||
// Simplify full identifiers to just the last part (enum name)
|
||||
simplified = simplified.replaceAll("^.*\\.([A-Z0-9_]+)$", "$1");
|
||||
// For remaining full caps with underscores (like EVENT_X), keep as is or try to simplify
|
||||
|
||||
@@ -302,7 +302,8 @@ public class GenericEventDetector {
|
||||
} else if (current.arguments().isEmpty() && current.getExpression() instanceof SimpleName sn) {
|
||||
// If the event is obtained by calling a method on a provider/supplier parameter,
|
||||
// return the provider's name so CallGraphBuilder can trace the lambda argument
|
||||
return sn.getIdentifier();
|
||||
String traced = extractEventFromMessageBuilder(sn);
|
||||
return traced != null ? traced : sn.getIdentifier();
|
||||
}
|
||||
|
||||
Expression receiver = current.getExpression();
|
||||
|
||||
Reference in New Issue
Block a user