added utility method

This commit is contained in:
Renaud Pawlak 2020-02-09 12:59:37 +01:00
parent 6668b64895
commit f00c09a413
2 changed files with 16 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package org.jsweet.transpiler.model;
import java.util.List;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
/**
@ -12,6 +13,11 @@ import javax.lang.model.type.TypeMirror;
*/
public interface Util {
/**
* Returns true if the given type is an interface.
*/
boolean isInterface(TypeElement type);
/**
* Gets the qualified name for the given type.
*/

View File

@ -29,6 +29,7 @@ import javax.lang.model.type.TypeMirror;
import org.jsweet.transpiler.JSweetContext;
import org.jsweet.transpiler.model.Util;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Type.CapturedType;
import com.sun.tools.javac.tree.JCTree;
@ -181,7 +182,7 @@ public class UtilSupport implements Util {
public String getRelativePath(String fromPath, String toPath) {
return org.jsweet.transpiler.util.Util.getRelativePath(fromPath, toPath);
}
@Override
public String getTypeInitialValue(TypeMirror type) {
if (type == null) {
@ -197,6 +198,13 @@ public class UtilSupport implements Util {
return "null";
}
}
@Override
public boolean isInterface(TypeElement type) {
if (type instanceof TypeSymbol) {
return context.isInterface((TypeSymbol) type);
}
return false;
}
}