Add Additional output. For Fields using CC and more verbose for method calls
This commit is contained in:
parent
fa1d70f954
commit
3fe35f6476
@ -1,6 +1,7 @@
|
|||||||
package com.sun.tools.javac.api;
|
package com.sun.tools.javac.api;
|
||||||
|
|
||||||
import com.sun.source.tree.CompilationUnitTree;
|
import com.sun.source.tree.CompilationUnitTree;
|
||||||
|
import com.sun.source.tree.MemberSelectTree;
|
||||||
import com.sun.source.tree.MethodInvocationTree;
|
import com.sun.source.tree.MethodInvocationTree;
|
||||||
import com.sun.source.util.*;
|
import com.sun.source.util.*;
|
||||||
|
|
||||||
@ -62,6 +63,36 @@ public class WildcardFinderPlugin extends TreeScanner<Void, Void> implements Plu
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
public static final String preText = "[ANDI] ";
|
public static final String preText = "[ANDI] ";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitMemberSelect(MemberSelectTree node, Void unused) {
|
||||||
|
try {
|
||||||
|
var type_field = node.getClass().getField("type");
|
||||||
|
var pos_field = node.getClass().getField("pos");
|
||||||
|
type_field.setAccessible(true);
|
||||||
|
pos_field.setAccessible(true);
|
||||||
|
String typeText = type_field.get(node).toString();
|
||||||
|
int methodPos = pos_field.getInt(node);
|
||||||
|
if(typeText.contains("capture#")){ //we found a capture conversion
|
||||||
|
//System.out.println(node.getClass().getMethod("getStartPosition").invoke(node));
|
||||||
|
logger.accept(preText + "Field-CC: " + typeText + " in " + currentSource + " " + lineOfPosition(currentClassContent,methodPos));
|
||||||
|
var expr = node.getExpression();
|
||||||
|
var expr_type_field = node.getClass().getField("type");
|
||||||
|
expr_type_field.setAccessible(true);
|
||||||
|
String exprTypeText = expr_type_field.get(expr).toString();
|
||||||
|
if(exprTypeText.contains("capture") || exprTypeText.contains("?")){
|
||||||
|
logger.accept(preText + "Field-CC!: " + typeText + " in " + currentSource + " " + lineOfPosition(currentClassContent,methodPos));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.accept(preText + "normal field access");
|
||||||
|
}
|
||||||
|
} catch (Throwable e){
|
||||||
|
//System.out.println("Error in method invocation: " + e.getMessage()+
|
||||||
|
// " in "+currentSource);i
|
||||||
|
}
|
||||||
|
return super.visitMemberSelect(node, unused);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitMethodInvocation(MethodInvocationTree node, Void unused) {
|
public Void visitMethodInvocation(MethodInvocationTree node, Void unused) {
|
||||||
var args = node.getArguments();
|
var args = node.getArguments();
|
||||||
@ -86,6 +117,8 @@ public class WildcardFinderPlugin extends TreeScanner<Void, Void> implements Plu
|
|||||||
int methodPos = pos_field.getInt(node);
|
int methodPos = pos_field.getInt(node);
|
||||||
if(typeText.contains("capture#") && methString.startsWith("<")){ //we found a capture conversion
|
if(typeText.contains("capture#") && methString.startsWith("<")){ //we found a capture conversion
|
||||||
//System.out.println(node.getClass().getMethod("getStartPosition").invoke(node));
|
//System.out.println(node.getClass().getMethod("getStartPosition").invoke(node));
|
||||||
|
logger.accept(preText + "CC!: "+ "Arg#"+argumentNumber + ": " + typeText + " in " + currentSource + " " + lineOfPosition(currentClassContent,methodPos) + " of method " + methString);
|
||||||
|
}else if(typeText.contains("capture#")) {
|
||||||
logger.accept(preText + "CC: "+ "Arg#"+argumentNumber + ": " + typeText + " in " + currentSource + " " + lineOfPosition(currentClassContent,methodPos) + " of method " + methString);
|
logger.accept(preText + "CC: "+ "Arg#"+argumentNumber + ": " + typeText + " in " + currentSource + " " + lineOfPosition(currentClassContent,methodPos) + " of method " + methString);
|
||||||
}else{
|
}else{
|
||||||
logger.accept(preText + "normal Method call");
|
logger.accept(preText + "normal Method call");
|
||||||
|
Loading…
Reference in New Issue
Block a user