Compare commits

..

No commits in common. "f63a8bcd4efa021450ced9879f4c5a62aba00c81" and "3fe35f647606da89faa5d558e5f575251a9f4592" have entirely different histories.

5 changed files with 4 additions and 55 deletions

View File

@ -71,15 +71,6 @@ public interface VariableTree extends StatementTree {
*/ */
Tree getType(); Tree getType();
/**
* 0 - no generic
* 1 - is a generic
* 2 - contains a generic
* 3 - contains a generic like List<List<X>>
* @return
*/
int deepestGeneric();
/** /**
* Returns the initializer for the variable, or {@code null} if none. * Returns the initializer for the variable, or {@code null} if none.
* @return the initializer * @return the initializer

View File

@ -201,7 +201,7 @@ public class BasicJavacTask extends JavacTask {
PlatformDescription platformProvider = context.get(PlatformDescription.class); PlatformDescription platformProvider = context.get(PlatformDescription.class);
//ANDI: Init our own plugin to count CC's //ANDI: Init our own plugin to count CC's
initPlugin(new WildcardFinderPlugin((s -> Log.instance(context).printRawLines(Log.WriterKind.NOTICE,s)))); initPlugin(new WildcardFinderPlugin((s -> Log.instance(context).printRawLines(s))));
if (platformProvider != null) { if (platformProvider != null) {
for (PluginInfo<Plugin> pluginDesc : platformProvider.getPlugins()) { for (PluginInfo<Plugin> pluginDesc : platformProvider.getPlugins()) {
java.util.List<String> options = java.util.List<String> options =

View File

@ -1,9 +1,10 @@
package com.sun.tools.javac.api; package com.sun.tools.javac.api;
import com.sun.source.tree.*; import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.MemberSelectTree;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.util.*; import com.sun.source.util.*;
import javax.tools.JavaFileObject;
import java.io.IOException; import java.io.IOException;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -12,7 +13,6 @@ public class WildcardFinderPlugin extends TreeScanner<Void, Void> implements Plu
private final Consumer<String> logger; private final Consumer<String> logger;
public WildcardFinderPlugin(Consumer<String> logger){ public WildcardFinderPlugin(Consumer<String> logger){
this.logger = logger; this.logger = logger;
} }
@Override @Override
@ -39,21 +39,6 @@ public class WildcardFinderPlugin extends TreeScanner<Void, Void> implements Plu
javacTask.addTaskListener(this); javacTask.addTaskListener(this);
} }
@Override
public Void visitClass(ClassTree node, Void unused) {
node.getMembers().forEach(typeDecl -> {
if (typeDecl instanceof VariableTree) {
logger.accept(preText + "Field Type: " + ((VariableTree) typeDecl).getType().toString());
logger.accept(preText + "deepestGeneric: " + ((VariableTree) typeDecl).deepestGeneric());
if( ((VariableTree) typeDecl).deepestGeneric() >= 3){
logger.accept(preText + "Field not Wildcard compatible");
}
//logger.accept("deepestGeneric: " + ((VariableTree)((VariableTree) typeDecl).getType()).deepestGeneric());
}
});
return super.visitClass(node, unused);
}
String currentSource = ""; String currentSource = "";
String currentClassContent = ""; String currentClassContent = "";
@Override @Override

View File

@ -82,9 +82,6 @@ import static com.sun.tools.javac.code.TypeTag.*;
*/ */
public abstract class Type extends AnnoConstruct implements TypeMirror, PoolConstant { public abstract class Type extends AnnoConstruct implements TypeMirror, PoolConstant {
public int deepestGeneric(){
return 0;
}
/** /**
* Type metadata, Should be {@code null} for the default value. * Type metadata, Should be {@code null} for the default value.
* *
@ -901,11 +898,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror, PoolCons
}; };
} }
@Override
public int deepestGeneric() {
return 0;
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return WILDCARD; return WILDCARD;
@ -1039,12 +1031,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror, PoolCons
this.interfaces_field = null; this.interfaces_field = null;
} }
@Override
public int deepestGeneric() {
int deepest = typarams_field.stream().mapToInt(t -> t.deepestGeneric()).max().orElse(0);
return deepest>0?1 + deepest:0;
}
public int poolTag() { public int poolTag() {
return ClassFile.CONSTANT_Class; return ClassFile.CONSTANT_Class;
} }
@ -1368,11 +1354,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror, PoolCons
this(that.elemtype, that.tsym, that.getMetadata()); this(that.elemtype, that.tsym, that.getMetadata());
} }
@Override
public int deepestGeneric() {
return elemtype.deepestGeneric();
}
public int poolTag() { public int poolTag() {
return ClassFile.CONSTANT_Class; return ClassFile.CONSTANT_Class;
} }
@ -1718,11 +1699,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror, PoolCons
}; };
} }
@Override
public int deepestGeneric() {
return 1;
}
@Override @Override
public TypeTag getTag() { public TypeTag getTag() {
return TYPEVAR; return TYPEVAR;

View File

@ -1076,9 +1076,6 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
public JCExpression getNameExpression() { return nameexpr; } public JCExpression getNameExpression() { return nameexpr; }
@DefinedBy(Api.COMPILER_TREE) @DefinedBy(Api.COMPILER_TREE)
public JCTree getType() { return vartype; } public JCTree getType() { return vartype; }
public int deepestGeneric(){
return type.deepestGeneric();
}
@DefinedBy(Api.COMPILER_TREE) @DefinedBy(Api.COMPILER_TREE)
public JCExpression getInitializer() { public JCExpression getInitializer() {
return init; return init;