本文整理汇总了Java中com.sun.tools.javac.code.Symbol.MethodSymbol方法的典型用法代码示例。如果您正苦于以下问题:Java Symbol.MethodSymbol方法的具体用法?Java Symbol.MethodSymbol怎么用?Java Symbol.MethodSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.code.Symbol
的用法示例。
在下文中一共展示了Symbol.MethodSymbol方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchLambdaExpression
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
@Override
public Description matchLambdaExpression(LambdaExpressionTree tree, VisitorState state) {
Symbol.MethodSymbol methodSymbol =
NullabilityUtil.getFunctionalInterfaceMethod(tree, state.getTypes());
handler.onMatchLambdaExpression(this, tree, state, methodSymbol);
Description description = checkParamOverriding(tree, tree.getParameters(), methodSymbol, true);
if (description != Description.NO_MATCH) {
return description;
}
if (tree.getBodyKind() == LambdaExpressionTree.BodyKind.EXPRESSION
&& methodSymbol.getReturnType().getKind() != TypeKind.VOID) {
ExpressionTree resExpr = (ExpressionTree) tree.getBody();
return checkReturnExpression(tree, resExpr, methodSymbol, state);
}
return Description.NO_MATCH;
}
示例2: isInitializerMethod
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
private boolean isInitializerMethod(VisitorState state, Symbol.MethodSymbol symbol) {
if (ASTHelpers.hasDirectAnnotationWithSimpleName(symbol, "Initializer")
|| config.isKnownInitializerMethod(symbol)) {
return true;
}
for (AnnotationMirror anno : symbol.getAnnotationMirrors()) {
String annoTypeStr = anno.getAnnotationType().toString();
if (config.isInitializerMethodAnnotation(annoTypeStr)) {
return true;
}
}
Symbol.MethodSymbol closestOverriddenMethod =
getClosestOverriddenMethod(symbol, state.getTypes());
if (closestOverriddenMethod == null) {
return false;
}
return isInitializerMethod(state, closestOverriddenMethod);
}
示例3: replaceExtCall
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
private void replaceExtCall( JCTree.JCMethodInvocation tree, Symbol.MethodSymbol method )
{
JCExpression methodSelect = tree.getMethodSelect();
if( methodSelect instanceof JCTree.JCFieldAccess )
{
JCTree.JCFieldAccess m = (JCTree.JCFieldAccess)methodSelect;
boolean isStatic = m.sym.getModifiers().contains( javax.lang.model.element.Modifier.STATIC );
TreeMaker make = _tp.getTreeMaker();
JavacElements javacElems = _tp.getElementUtil();
JCExpression thisArg = m.selected;
String extensionFqn = method.getEnclosingElement().asType().tsym.toString();
m.selected = memberAccess( make, javacElems, extensionFqn );
BasicJavacTask javacTask = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getJavacTask();
Symbol.ClassSymbol extensionClassSym = ClassSymbols.instance( _sp.getTypeLoader().getModule() ).getClassSymbol( javacTask, extensionFqn ).getFirst();
assignTypes( m.selected, extensionClassSym );
m.sym = method;
m.type = method.type;
if( !isStatic )
{
ArrayList<JCExpression> newArgs = new ArrayList<>( tree.args );
newArgs.add( 0, thisArg );
tree.args = List.from( newArgs );
}
}
}
示例4: MapperMethod
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
public MapperMethod(DaoEnv daoEnv, Symbol.MethodSymbol methodSymbol) {
this.daoEnv = daoEnv;
if (!methodSymbol.getTypeParameters().isEmpty()){
throw new RuntimeException("不支持有类型参数的方法生成");
}
this.returnType = getRealType(methodSymbol.getReturnType());
this.methodName = DaoGenHelper.getMethodName(methodSymbol);
this.params = methodSymbol.getParameters();
}
示例5: findAfterMethodAnnotation
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
@Nullable
public static Attribute.Compound findAfterMethodAnnotation(@NonNull final Symbol.MethodSymbol ms) throws Exception {
if (ms.hasAnnotations()) {
for (final Attribute.Compound am : ms.getAnnotationMirrors()) {
if (extractClass(am) == AutoProxy.AfterCall.class) return am;
}
}
return null;
}
示例6: mimicThrows
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
/** Compose exceptions throwing signature. */
public static void mimicThrows(@NonNull final MethodSpec.Builder builder,
@NonNull final Symbol.MethodSymbol ms) {
for (final Type typeThrown : ms.getThrownTypes()) {
builder.addException(TypeName.get(typeThrown));
}
}
示例7: onMatchMethodInvocation
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
@Override
public void onMatchMethodInvocation(
NullAway analysis,
MethodInvocationTree tree,
VisitorState state,
Symbol.MethodSymbol methodSymbol) {
// NoOp
}
示例8: setUnconditionalArgumentNullness
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
private void setUnconditionalArgumentNullness(
AccessPathNullnessPropagation.Updates bothUpdates,
List<Node> arguments,
Symbol.MethodSymbol callee) {
Set<Integer> requiredNonNullParameters =
libraryModels.failIfNullParameters().get(LibraryModels.MethodRef.fromSymbol(callee));
for (AccessPath accessPath : accessPathsAtIndexes(requiredNonNullParameters, arguments)) {
bothUpdates.set(accessPath, NONNULL);
}
}
示例9: checkParamOverriding
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
private Description checkParamOverriding(
Tree tree,
List<? extends VariableTree> methodParams,
Symbol.MethodSymbol closestOverriddenMethod,
boolean isLambda) {
com.sun.tools.javac.util.List<VarSymbol> superParamSymbols =
closestOverriddenMethod.getParameters();
for (int i = 0; i < superParamSymbols.size(); i++) {
VarSymbol superParam = superParamSymbols.get(i);
if (Nullness.hasNullableAnnotation(superParam)) {
VariableTree param = methodParams.get(i);
VarSymbol paramSymbol = ASTHelpers.getSymbol(param);
// in the case where we have a parameter of a lambda expression, we do
// *not* force the parameter to be annotated with @Nullable; instead we "inherit"
// nullability from the corresponding functional interface method
if (!Nullness.hasNullableAnnotation(paramSymbol)
&& !(isLambda && !NullabilityUtil.lambdaParamIsExplicitlyTyped(param))) {
String message =
"parameter "
+ param.getName()
+ " is @NonNull, but parameter in "
+ (isLambda ? "functional interface " : "superclass ")
+ "method "
+ ASTHelpers.enclosingClass(closestOverriddenMethod)
+ "."
+ closestOverriddenMethod.toString()
+ " is @Nullable";
return createErrorDescription(MessageTypes.WRONG_OVERRIDE_PARAM, param, message, param);
}
}
}
return Description.NO_MATCH;
}
示例10: onMatchMethod
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
@Override
public void onMatchMethod(
NullAway analysis, MethodTree tree, VisitorState state, Symbol.MethodSymbol methodSymbol) {
for (Handler h : handlers) {
h.onMatchMethod(analysis, tree, state, methodSymbol);
}
}
示例11: isMapPut
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
public static boolean isMapPut(Symbol.MethodSymbol symbol, Types types) {
return isMapMethod(symbol, types, "put");
}
示例12: toMapperMethod
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
public static MapperMethod toMapperMethod(DaoEnv daoEnv, Symbol.MethodSymbol methodSymbol) {
return new MapperMethod(daoEnv, methodSymbol);
}
示例13: getMethodName
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
public static String getMethodName(Symbol.MethodSymbol methodSymbol) {
return methodSymbol.getSimpleName().toString();
}
示例14: validate
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
public void validate(CblEntityHolder holder, Logger logger) throws ClassNotFoundException {
if (holder.getSourceElement().getModifiers().contains(Modifier.PRIVATE)) {
logger.error(CblEntity.class.getSimpleName() + " can not be private", holder.getSourceElement());
}
if (holder.getSourceElement().getModifiers().contains(Modifier.FINAL)) {
logger.error(CblEntity.class.getSimpleName() + " can not be final", holder.getSourceElement());
}
for (Element member : holder.getSourceElement().getEnclosedElements()) {
if (member.getKind() == ElementKind.FIELD) {
CblField fieldAnnotation = member.getAnnotation(CblField.class);
CblConstant constantAnnotation = member.getAnnotation(CblConstant.class);
if (fieldAnnotation != null) {
if(constantAnnotation != null){
logger.error("Element can´t be "+ CblField.class.getName() + " and "+ CblConstant.class.getName() + " at the same time", member);
}
if (!member.getModifiers().contains(Modifier.PRIVATE)) {
logger.error(CblField.class.getSimpleName() + " must be private", member);
}
if (!fieldAnnotation.attachmentType().equals("")) {
Class<?> classTypeOfField = Class.forName(member.asType().toString());
if (!InputStream.class.isAssignableFrom(classTypeOfField) && !URL.class.isAssignableFrom(classTypeOfField)) {
logger.error(CblField.class.getSimpleName() + " attachments must be Inputstream or URL", member);
}
}
}else if(constantAnnotation != null){
if(fieldAnnotation != null){
logger.error("Element can´t be "+ CblField.class.getName() + " and "+ CblConstant.class.getName() + " at the same time", member);
}
if (!member.getModifiers().contains(Modifier.PRIVATE)) {
logger.error(CblConstant.class.getSimpleName() + " must be private", member);
}
}
} else if (member.getKind() == ElementKind.CONSTRUCTOR) {
Symbol.MethodSymbol constructor = (Symbol.MethodSymbol)member;
if (constructor.getParameters().size() != 0) {
logger.error(CblEntity.class.getSimpleName() + " should not have a contructor", member);
}
}
}
}
示例15: resolveMethod
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
private Symbol.MethodSymbol resolveMethod( JCDiagnostic.DiagnosticPosition pos, Name name, Type qual, List<Type> args )
{
return resolveMethod( pos, _tp.getContext(), (JCTree.JCCompilationUnit)_tp.getCompilationUnit(), name, qual, args );
}