当前位置: 首页>>代码示例>>Java>>正文


Java JavaContext.findSurroundingClass方法代码示例

本文整理汇总了Java中com.android.tools.lint.detector.api.JavaContext.findSurroundingClass方法的典型用法代码示例。如果您正苦于以下问题:Java JavaContext.findSurroundingClass方法的具体用法?Java JavaContext.findSurroundingClass怎么用?Java JavaContext.findSurroundingClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.tools.lint.detector.api.JavaContext的用法示例。


在下文中一共展示了JavaContext.findSurroundingClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAppBarActivityCall

import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
private static boolean isAppBarActivityCall(@NonNull JavaContext context,
        @NonNull MethodInvocation node) {
    ResolvedNode resolved = context.resolve(node);
    if (resolved instanceof ResolvedMethod) {
        ResolvedMethod method = (ResolvedMethod) resolved;
        ResolvedClass containingClass = method.getContainingClass();
        if (containingClass.isSubclassOf(CLASS_ACTIVITY, false)) {
            // Make sure that the calling context is a subclass of ActionBarActivity;
            // we don't want to flag these calls if they are in non-appcompat activities
            // such as PreferenceActivity (see b.android.com/58512)
            ClassDeclaration surroundingClass = JavaContext.findSurroundingClass(node);
            if (surroundingClass != null) {
                ResolvedNode clz = context.resolve(surroundingClass);
                return clz instanceof ResolvedClass &&
                        ((ResolvedClass)clz).isSubclassOf(
                                "android.support.v7.app.ActionBarActivity",
                                false);
            }
        }
    }
    return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AppCompatCallDetector.java

示例2: parseContainingClass

import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
public static JavaParser.ResolvedClass parseContainingClass(
        @NonNull JavaContext context, @NonNull Node node) {
    if (null == context || null == node) {
        return null;
    }

    JavaParser.ResolvedNode resolvedNode = null;
    try {
        resolvedNode = context.resolve(node);
    } catch (Exception e) {
        // TODO
    }

    if (resolvedNode instanceof JavaParser.ResolvedMethod) {
        return ((JavaParser.ResolvedMethod)resolvedNode).getContainingClass();
    } else if (resolvedNode instanceof JavaParser.ResolvedField) {
        return ((JavaParser.ResolvedField)resolvedNode).getContainingClass();
    } else if (resolvedNode instanceof JavaParser.ResolvedClass) {
        return ((JavaParser.ResolvedClass)resolvedNode).getContainingClass();
    } else {
        ClassDeclaration classDeclaration = JavaContext.findSurroundingClass(node);
        if (null == classDeclaration) {
            return null;
        }
        resolvedNode = context.resolve(classDeclaration);
        return (resolvedNode instanceof JavaParser.ResolvedClass) ?
                (JavaParser.ResolvedClass)resolvedNode : null;
    }
}
 
开发者ID:squirrel-explorer,项目名称:eagleeye-android,代码行数:30,代码来源:NodeUtils.java

示例3: getTargetApi

import com.android.tools.lint.detector.api.JavaContext; //导入方法依赖的package包/类
private static int getTargetApi(ClassDeclaration node) {
    while (node != null) {
        int targetApi = ApiDetector.getTargetApi(node.astModifiers());
        if (targetApi != -1) {
            return targetApi;
        }

        node = JavaContext.findSurroundingClass(node.getParent());
    }

    return -1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:OverrideConcreteDetector.java


注:本文中的com.android.tools.lint.detector.api.JavaContext.findSurroundingClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。