Hi Tor and all, now I need the same thing but in other context. Previously, it was AST context, this time it's class context (ASM).
I used context.getDriver().isSubclassOf(classNode, FRAGMENT_ACTIVITY_V4) (full code here: https://github.com/adorilson/android-lint-checks/blob/master/src/br/ufrn/UsesFragmentTransaction.java#L71 ) and/or successive calls to context.getClient().getSuperClass(context.getProject(), className) (full code here: https://github.com/adorilson/android-lint-checks/blob/master/src/br/ufrn/LintUtils.java#L23 ) show the all parents. It's works fine with two applications[1][2] but fails with Google I/O[3]. So, what problem with this last one? How exactly this works in Lint? [1] https://github.com/adorilson/MMUnB/tree/UsesFragmentManager [2] https://github.com/AntennaPod/AntennaPod [3] https://github.com/google/iosched.git 2015-05-08 21:10 GMT-03:00 Adorilson Bezerra de Araújo < [email protected]>: > > 2015-04-07 16:53 GMT-03:00 'Tor Norbye' via adt-dev < > [email protected]>: > >> Use JavaContext.resolve(node) to look up the type-resolved class, and >> from the resulting ResolvedClass you can do hierarchy checks (look at the >> methods on ResolvedClass). >> > > > Txs, Tor. > It works with just some fix. > > public boolean visitClassDeclaration(ClassDeclaration node) { > > ResolvedNode rNode = mContext.resolve(node); > ResolvedClass rClass = (ResolvedClass) rNode; > > boolean isFragmentActivity = > rClass.isSubclassOf("android.support.v4.app.FragmentActivity", false); > // some code mode... > } > > > >> >> On Mon, Mar 30, 2015 at 8:18 AM, Adorilson Bezerra de Araújo < >> [email protected]> wrote: >> >>> Hi, >>> >>> how can I check if a class is subclasse another in Lint? >>> >>> For a direct extends, I use node.astExtending() in visitClassDeclaration >>> method. >>> But is doesn't works for indirect subclass. Then, I tried >>> LintClient.isSubclassOf[0], but >>> is doesn't works too. It's always returns "null". >>> >>> There a any LintClient subclass that override this method? >>> >>> Someone help me? Thanks. >>> >>> [0] >>> https://android.googlesource.com/platform/tools/base/+/master/lint/libs/lint-api/src/main/java/com/android/tools/lint/client/api/LintClient.java >>> >>> >>> -- >>> Adorilson Bezerra >>> Mestrando em Engenharia de Software >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "adt-dev" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "adt-dev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > -- > Adorilson Bezerra > Mestrando em Engenharia de Software > -- -- Adorilson Bezerra Mestrando em Engenharia de Software -- You received this message because you are subscribed to the Google Groups "adt-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
