Merge branch 'master' into removeWildcards
This commit is contained in:
commit
21aa7e0e9c
@ -1,6 +1,7 @@
|
||||
package com.sun.tools.javac.api;
|
||||
|
||||
import com.sun.source.tree.CompilationUnitTree;
|
||||
import com.sun.source.tree.MemberSelectTree;
|
||||
import com.sun.source.tree.MethodInvocationTree;
|
||||
import com.sun.source.util.*;
|
||||
|
||||
@ -62,6 +63,36 @@ public class WildcardFinderPlugin extends TreeScanner<Void, Void> implements Plu
|
||||
return count;
|
||||
}
|
||||
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
|
||||
public Void visitMethodInvocation(MethodInvocationTree node, Void unused) {
|
||||
var args = node.getArguments();
|
||||
@ -86,6 +117,8 @@ public class WildcardFinderPlugin extends TreeScanner<Void, Void> implements Plu
|
||||
int methodPos = pos_field.getInt(node);
|
||||
if(typeText.contains("capture#") && methString.startsWith("<")){ //we found a capture conversion
|
||||
//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);
|
||||
}else{
|
||||
logger.accept(preText + "normal Method call");
|
||||
|
Loading…
Reference in New Issue
Block a user