Java Code Examples for com.android.tools.lint.detector.api.JavaContext#findSurroundingClass()
The following examples show how to use
com.android.tools.lint.detector.api.JavaContext#findSurroundingClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppCompatCallDetector.java From javaide with GNU General Public License v3.0 | 6 votes |
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; }
Example 2
Source File: OverrideConcreteDetector.java From javaide with GNU General Public License v3.0 | 5 votes |
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; }