remove tons of logs
This commit is contained in:
@@ -364,6 +364,7 @@ public class HeuristicBeanResolutionEngine implements BeanResolutionEngine {
|
||||
if (type1 == null || type2 == null) return false;
|
||||
type1 = eraseGenerics(type1);
|
||||
type2 = eraseGenerics(type2);
|
||||
if (type1.length() == 1 || type2.length() == 1) return false;
|
||||
if (type1.equals("java.lang.String") || type1.equals("String") || type1.equals("java.lang.Object") || type1.equals("Object")) return false;
|
||||
if (type2.equals("java.lang.String") || type2.equals("String") || type2.equals("java.lang.Object") || type2.equals("Object")) return false;
|
||||
return !type1.equals(type2);
|
||||
|
||||
@@ -18,14 +18,28 @@ public class SiblingDependencyResolver {
|
||||
private static final Pattern MAVEN_DEPENDENCY = Pattern.compile("<dependency>\\s*<groupId>(.*?)</groupId>\\s*<artifactId>(.*?)</artifactId>\\s*<version>(.*?)</version>", Pattern.DOTALL);
|
||||
|
||||
public Set<Path> resolveSiblings(Path projectDir) {
|
||||
Set<Path> siblings = new HashSet<>();
|
||||
try {
|
||||
siblings.addAll(resolveGradleSiblings(projectDir));
|
||||
siblings.addAll(resolveMavenSiblings(projectDir));
|
||||
} catch (Exception e) {
|
||||
log.warn("Error resolving sibling dependencies for {}", projectDir, e);
|
||||
Set<Path> allSiblings = new HashSet<>();
|
||||
Queue<Path> queue = new LinkedList<>();
|
||||
queue.add(projectDir);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
Path current = queue.poll();
|
||||
Set<Path> currentSiblings = new HashSet<>();
|
||||
try {
|
||||
currentSiblings.addAll(resolveGradleSiblings(current));
|
||||
currentSiblings.addAll(resolveMavenSiblings(current));
|
||||
} catch (Exception e) {
|
||||
log.warn("Error resolving sibling dependencies for {}", current, e);
|
||||
}
|
||||
|
||||
for (Path sibling : currentSiblings) {
|
||||
if (!allSiblings.contains(sibling) && !sibling.equals(projectDir)) {
|
||||
allSiblings.add(sibling);
|
||||
queue.add(sibling);
|
||||
}
|
||||
}
|
||||
}
|
||||
return siblings;
|
||||
return allSiblings;
|
||||
}
|
||||
|
||||
private Set<Path> resolveGradleSiblings(Path projectDir) throws IOException {
|
||||
|
||||
@@ -524,9 +524,7 @@ public class GenericEventDetector {
|
||||
}
|
||||
|
||||
private String[] resolveStateMachineTypeArguments(MethodInvocation node) {
|
||||
System.out.println("resolveStateMachineTypeArguments CALLED for node: " + node);
|
||||
Expression receiver = node.getExpression();
|
||||
System.out.println("initial receiver: " + receiver);
|
||||
|
||||
// Trace back the receiver if it's a builder chain
|
||||
while (receiver instanceof MethodInvocation mi) {
|
||||
@@ -557,22 +555,63 @@ public class GenericEventDetector {
|
||||
|
||||
// Fallback: search enclosing class/method for variable declaration
|
||||
Type declType = findReceiverTypeManually(receiver, node);
|
||||
System.out.println("findReceiverTypeManually returned: " + declType);
|
||||
if (declType instanceof ParameterizedType pt) {
|
||||
List<?> typeArgs = pt.typeArguments();
|
||||
System.out.println("typeArgs size: " + typeArgs.size());
|
||||
if (typeArgs.size() >= 2) {
|
||||
CompilationUnit cu = (CompilationUnit) node.getRoot();
|
||||
String stateType = resolveTypeToFqn((Type) typeArgs.get(0), cu);
|
||||
String eventType = resolveTypeToFqn((Type) typeArgs.get(1), cu);
|
||||
System.out.println("Resolved types: state=" + stateType + " event=" + eventType);
|
||||
|
||||
if (stateType != null && stateType.length() == 1) {
|
||||
stateType = resolveGenericTypeVariable(stateType, node, cu);
|
||||
}
|
||||
if (eventType != null && eventType.length() == 1) {
|
||||
eventType = resolveGenericTypeVariable(eventType, node, cu);
|
||||
}
|
||||
|
||||
return new String[]{stateType, eventType};
|
||||
}
|
||||
}
|
||||
System.out.println("Returning null, null");
|
||||
return new String[]{null, null};
|
||||
}
|
||||
|
||||
private String resolveGenericTypeVariable(String typeVarName, ASTNode node, CompilationUnit cu) {
|
||||
TypeDeclaration enclosingClass = findEnclosingType(node);
|
||||
if (enclosingClass == null) return typeVarName;
|
||||
String className = context.getFqn(enclosingClass);
|
||||
if (className == null) return typeVarName;
|
||||
|
||||
List<String> impls = context.getImplementations(className);
|
||||
if (impls == null || impls.isEmpty()) return typeVarName;
|
||||
|
||||
for (String implFqn : impls) {
|
||||
org.eclipse.jdt.core.dom.AbstractTypeDeclaration implNode = context.getAbstractTypeDeclaration(implFqn);
|
||||
if (implNode instanceof TypeDeclaration td) {
|
||||
Type superclassType = td.getSuperclassType();
|
||||
if (superclassType instanceof ParameterizedType pt) {
|
||||
Type baseType = pt.getType();
|
||||
String baseName = resolveTypeToFqn(baseType, (CompilationUnit) implNode.getRoot());
|
||||
if (className.equals(baseName) || className.endsWith("." + baseName)) {
|
||||
int typeIndex = -1;
|
||||
List<?> typeParams = enclosingClass.typeParameters();
|
||||
for (int i = 0; i < typeParams.size(); i++) {
|
||||
TypeParameter tp = (TypeParameter) typeParams.get(i);
|
||||
if (tp.getName().getIdentifier().equals(typeVarName)) {
|
||||
typeIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (typeIndex >= 0 && typeIndex < pt.typeArguments().size()) {
|
||||
Type concreteType = (Type) pt.typeArguments().get(typeIndex);
|
||||
return resolveTypeToFqn(concreteType, (CompilationUnit) implNode.getRoot());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return typeVarName;
|
||||
}
|
||||
|
||||
private ITypeBinding findStateMachineSupertype(ITypeBinding binding, java.util.Set<String> visited) {
|
||||
ITypeBinding current = binding;
|
||||
while (current != null) {
|
||||
|
||||
Reference in New Issue
Block a user