Loading tools/lint/common/src/main/java/com/google/android/lint/aidl/EnforcePermissionUtils.kt +19 −8 Original line number Diff line number Diff line Loading @@ -24,20 +24,31 @@ import com.intellij.psi.PsiReferenceList import org.jetbrains.uast.UMethod /** * Given a UMethod, determine if this method is the entrypoint to an interface * generated by AIDL, returning the interface name if so, otherwise returning * null * Given a UMethod, determine if this method is the entrypoint to an interface generated by AIDL, * returning the interface name if so, otherwise returning null. */ fun getContainingAidlInterface(context: JavaContext, node: UMethod): String? { return containingAidlInterfacePsiClass(context, node)?.name } /** * Given a UMethod, determine if this method is the entrypoint to an interface generated by AIDL, * returning the fully qualified interface name if so, otherwise returning null. */ fun getContainingAidlInterfaceQualified(context: JavaContext, node: UMethod): String? { return containingAidlInterfacePsiClass(context, node)?.qualifiedName } private fun containingAidlInterfacePsiClass(context: JavaContext, node: UMethod): PsiClass? { val containingStub = containingStub(context, node) ?: return null val superMethod = node.findSuperMethods(containingStub) if (superMethod.isEmpty()) return null return containingStub.containingClass?.name return containingStub.containingClass } /* Returns the containing Stub class if any. This is not sufficient to infer * that the method itself extends an AIDL generated method. See * getContainingAidlInterface for that purpose. /** * Returns the containing Stub class if any. This is not sufficient to infer that the method itself * extends an AIDL generated method. See getContainingAidlInterface for that purpose. */ fun containingStub(context: JavaContext, node: UMethod?): PsiClass? { var superClass = node?.containingClass?.superClass Loading @@ -48,7 +59,7 @@ fun containingStub(context: JavaContext, node: UMethod?): PsiClass? { return null } private fun isStub(context: JavaContext, psiClass: PsiClass?): Boolean { fun isStub(context: JavaContext, psiClass: PsiClass?): Boolean { if (psiClass == null) return false if (psiClass.name != "Stub") return false if (!context.evaluator.isStatic(psiClass)) return false Loading Loading
tools/lint/common/src/main/java/com/google/android/lint/aidl/EnforcePermissionUtils.kt +19 −8 Original line number Diff line number Diff line Loading @@ -24,20 +24,31 @@ import com.intellij.psi.PsiReferenceList import org.jetbrains.uast.UMethod /** * Given a UMethod, determine if this method is the entrypoint to an interface * generated by AIDL, returning the interface name if so, otherwise returning * null * Given a UMethod, determine if this method is the entrypoint to an interface generated by AIDL, * returning the interface name if so, otherwise returning null. */ fun getContainingAidlInterface(context: JavaContext, node: UMethod): String? { return containingAidlInterfacePsiClass(context, node)?.name } /** * Given a UMethod, determine if this method is the entrypoint to an interface generated by AIDL, * returning the fully qualified interface name if so, otherwise returning null. */ fun getContainingAidlInterfaceQualified(context: JavaContext, node: UMethod): String? { return containingAidlInterfacePsiClass(context, node)?.qualifiedName } private fun containingAidlInterfacePsiClass(context: JavaContext, node: UMethod): PsiClass? { val containingStub = containingStub(context, node) ?: return null val superMethod = node.findSuperMethods(containingStub) if (superMethod.isEmpty()) return null return containingStub.containingClass?.name return containingStub.containingClass } /* Returns the containing Stub class if any. This is not sufficient to infer * that the method itself extends an AIDL generated method. See * getContainingAidlInterface for that purpose. /** * Returns the containing Stub class if any. This is not sufficient to infer that the method itself * extends an AIDL generated method. See getContainingAidlInterface for that purpose. */ fun containingStub(context: JavaContext, node: UMethod?): PsiClass? { var superClass = node?.containingClass?.superClass Loading @@ -48,7 +59,7 @@ fun containingStub(context: JavaContext, node: UMethod?): PsiClass? { return null } private fun isStub(context: JavaContext, psiClass: PsiClass?): Boolean { fun isStub(context: JavaContext, psiClass: PsiClass?): Boolean { if (psiClass == null) return false if (psiClass.name != "Stub") return false if (!context.evaluator.isStatic(psiClass)) return false Loading