more fixes
This commit is contained in:
@@ -40,6 +40,21 @@ public class HeuristicBeanResolutionEngine implements BeanResolutionEngine {
|
||||
boolean hasPositiveMatch = false;
|
||||
boolean hasStrongMismatch = false;
|
||||
|
||||
if (chain.getTriggerPoint() != null && chain.getTriggerPoint().getClassName() != null) {
|
||||
String chainClass = chain.getTriggerPoint().getClassName();
|
||||
String chainPackage = getPackageName(chainClass);
|
||||
String chainSimple = getSimpleClassName(chainClass);
|
||||
String chainPrefix = getFirstCamelCaseWord(chainSimple);
|
||||
|
||||
if (smPrefix != null && chainPrefix != null && smPrefix.equals(chainPrefix)) {
|
||||
hasPositiveMatch = true;
|
||||
}
|
||||
|
||||
if (isDomainMatch(smPackage, chainPackage, smPrefix, chainPrefix)) {
|
||||
hasPositiveMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (String method : chain.getMethodChain()) {
|
||||
String chainClass = getClassNameOnly(method);
|
||||
String chainPackage = getPackageName(chainClass);
|
||||
|
||||
@@ -551,6 +551,17 @@ import java.util.*;
|
||||
polymorphicEvents.removeIf(e -> {
|
||||
if (e.contains(".")) return false; // If it's a fully qualified enum/constant, keep it
|
||||
String val = e;
|
||||
boolean isKnownEnumVal = false;
|
||||
for (java.util.List<String> vals : context.getEnumValuesMap().values()) {
|
||||
for (String v : vals) {
|
||||
if (v.endsWith("." + val)) {
|
||||
isKnownEnumVal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isKnownEnumVal) break;
|
||||
}
|
||||
if (isKnownEnumVal) return false;
|
||||
return !val.equals(val.toUpperCase()) || val.length() <= 1;
|
||||
});
|
||||
|
||||
@@ -963,6 +974,18 @@ import java.util.*;
|
||||
}
|
||||
|
||||
protected List<String> resolveClassConstantReturns(String className, click.kamil.springstatemachineexporter.ast.common.CodebaseContext context, CompilationUnit contextCu) {
|
||||
if (className != null && className.contains(".")) {
|
||||
String prefix = className.substring(0, className.lastIndexOf('.'));
|
||||
String suffix = className.substring(className.lastIndexOf('.') + 1);
|
||||
TypeDeclaration prefixTd = contextCu != null ? context.getTypeDeclaration(prefix, contextCu) : context.getTypeDeclaration(prefix);
|
||||
if (prefixTd == null) prefixTd = context.getTypeDeclaration(prefix);
|
||||
boolean isKnownType = prefixTd != null || context.getEnumValues(prefix) != null;
|
||||
if (isKnownType) {
|
||||
String simplePrefix = prefix.contains(".") ? prefix.substring(prefix.lastIndexOf('.') + 1) : prefix;
|
||||
return java.util.Collections.singletonList(simplePrefix + "." + suffix);
|
||||
}
|
||||
}
|
||||
|
||||
TypeDeclaration td = contextCu != null ? context.getTypeDeclaration(className, contextCu) : context.getTypeDeclaration(className);
|
||||
if (td == null) td = context.getTypeDeclaration(className);
|
||||
if (td == null) return null;
|
||||
@@ -1126,7 +1149,16 @@ import java.util.*;
|
||||
// then evaluates the getter body (handles switch-based enum transformations).
|
||||
java.util.List<String> narrowed = resolveInlineInstantiationGetterResult(
|
||||
cic, methodName, context, new java.util.HashSet<>());
|
||||
if (!narrowed.isEmpty()) {
|
||||
if (narrowed.isEmpty()) {
|
||||
String typeName = click.kamil.springstatemachineexporter.ast.common.AstUtils.extractSimpleTypeName(cic.getType());
|
||||
CompilationUnit contextCu = expr.getRoot() instanceof CompilationUnit ? (CompilationUnit) expr.getRoot() : null;
|
||||
TypeDeclaration typeDecl = contextCu != null ? context.getTypeDeclaration(typeName, contextCu) : context.getTypeDeclaration(typeName);
|
||||
if (typeDecl == null) typeDecl = context.getTypeDeclaration(typeName);
|
||||
if (typeDecl != null) {
|
||||
narrowed = resolveMethodReturnConstant(context.getFqn(typeDecl), methodName, 0, new java.util.HashSet<>(), contextCu);
|
||||
}
|
||||
}
|
||||
if (narrowed != null && !narrowed.isEmpty()) {
|
||||
constants.addAll(narrowed);
|
||||
handledByLombok = true; // reuse flag to skip fallback below
|
||||
}
|
||||
@@ -1480,7 +1512,9 @@ import java.util.*;
|
||||
|
||||
String typeName = click.kamil.springstatemachineexporter.ast.common.AstUtils
|
||||
.extractSimpleTypeName(cic.getType());
|
||||
org.eclipse.jdt.core.dom.TypeDeclaration td = context.getTypeDeclaration(typeName);
|
||||
org.eclipse.jdt.core.dom.CompilationUnit contextCu = cic.getRoot() instanceof org.eclipse.jdt.core.dom.CompilationUnit ? (org.eclipse.jdt.core.dom.CompilationUnit) cic.getRoot() : null;
|
||||
org.eclipse.jdt.core.dom.TypeDeclaration td = contextCu != null ? context.getTypeDeclaration(typeName, contextCu) : context.getTypeDeclaration(typeName);
|
||||
if (td == null) td = context.getTypeDeclaration(typeName);
|
||||
if (td == null) return java.util.Collections.emptyList();
|
||||
|
||||
org.eclipse.jdt.core.dom.MethodDeclaration getter =
|
||||
@@ -2258,6 +2292,12 @@ import java.util.*;
|
||||
String calledName = mi.getName().getIdentifier();
|
||||
String targetClass = context.getFqn(td);
|
||||
CompilationUnit cu = td.getRoot() instanceof CompilationUnit ? (CompilationUnit) td.getRoot() : null;
|
||||
if (mi.getExpression() == null) {
|
||||
TypeDeclaration targetTd = context.resolveStaticImport(calledName, cu);
|
||||
if (targetTd != null) {
|
||||
targetClass = context.getFqn(targetTd);
|
||||
}
|
||||
}
|
||||
results.addAll(resolveMethodReturnConstant(targetClass, calledName, 0, visited, cu));
|
||||
} else {
|
||||
String val = constantResolver.resolve(tracedRight, context);
|
||||
@@ -2291,6 +2331,12 @@ import java.util.*;
|
||||
if (targetTd != null) {
|
||||
targetClass = context.getFqn(targetTd);
|
||||
}
|
||||
} else if (mi.getExpression() == null) {
|
||||
CompilationUnit cu = td.getRoot() instanceof CompilationUnit ? (CompilationUnit) td.getRoot() : null;
|
||||
TypeDeclaration targetTd = context.resolveStaticImport(calledName, cu);
|
||||
if (targetTd != null) {
|
||||
targetClass = context.getFqn(targetTd);
|
||||
}
|
||||
}
|
||||
|
||||
CompilationUnit cu = td.getRoot() instanceof CompilationUnit ? (CompilationUnit) td.getRoot() : null;
|
||||
|
||||
@@ -328,6 +328,10 @@ public class CodebaseContext {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getEnumValuesMap() {
|
||||
return enumValues;
|
||||
}
|
||||
|
||||
public List<String> getEnumValues(String fqnOrSimpleName) {
|
||||
if (fqnOrSimpleName == null) return null;
|
||||
List<String> values = enumValues.get(fqnOrSimpleName);
|
||||
|
||||
Reference in New Issue
Block a user