{"action":"created","issue":{"url":"https://api.github.com/repos/javaparser/javaparser/issues/259","labels_url":"https://api.github.com/repos/javaparser/javaparser/issues/259/labels{/name}","comments_url":"https://api.github.com/repos/javaparser/javaparser/issues/259/comments","events_url":"https://api.github.com/repos/javaparser/javaparser/issues/259/events","html_url":"https://github.com/javaparser/javaparser/issues/259","id":126439718,"number":259,"title":"About the class inheritance relation","user":{"login":"ZSShen","id":7473953,"avatar_url":"https://avatars.githubusercontent.com/u/7473953?v=3","gravatar_id":"","url":"https://api.github.com/users/ZSShen","html_url":"https://github.com/ZSShen","followers_url":"https://api.github.com/users/ZSShen/followers","following_url":"https://api.github.com/users/ZSShen/following{/other_user}","gists_url":"https://api.github.com/users/ZSShen/gists{/gist_id}","starred_url":"https://api.github.com/users/ZSShen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZSShen/subscriptions","organizations_url":"https://api.github.com/users/ZSShen/orgs","repos_url":"https://api.github.com/users/ZSShen/repos","events_url":"https://api.github.com/users/ZSShen/events{/privacy}","received_events_url":"https://api.github.com/users/ZSShen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-13T15:12:25Z","updated_at":"2016-01-13T15:42:08Z","closed_at":null,"body":"Hi there, I am new to this amazing project!\r\n\r\nWell, my question is, is it possible to blueprint the `class inheritance relation` via some \r\njavaparser APIs?\r\n\r\nFor example, \r\n```java\r\nList<TypeDeclaration> list_type = cu.getTypes();\r\nfor (TypeDeclaration type : list_type) {\r\n    List<BodyDeclaration> list_member = type.getMembers();\r\n    // type.getBaseType(); Some APIs to trace the inherited ancestors.\r\n}\r\n```\r\nIt seems that TypeDeclaration does not offer the similar functionality.\r\n"},"comment":{"url":"https://api.github.com/repos/javaparser/javaparser/issues/comments/171334900","html_url":"https://github.com/javaparser/javaparser/issues/259#issuecomment-171334900","issue_url":"https://api.github.com/repos/javaparser/javaparser/issues/259","id":171334900,"user":{"login":"ftomassetti","id":439078,"avatar_url":"https://avatars.githubusercontent.com/u/439078?v=3","gravatar_id":"","url":"https://api.github.com/users/ftomassetti","html_url":"https://github.com/ftomassetti","followers_url":"https://api.github.com/users/ftomassetti/followers","following_url":"https://api.github.com/users/ftomassetti/following{/other_user}","gists_url":"https://api.github.com/users/ftomassetti/gists{/gist_id}","starred_url":"https://api.github.com/users/ftomassetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ftomassetti/subscriptions","organizations_url":"https://api.github.com/users/ftomassetti/orgs","repos_url":"https://api.github.com/users/ftomassetti/repos","events_url":"https://api.github.com/users/ftomassetti/events{/privacy}","received_events_url":"https://api.github.com/users/ftomassetti/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T15:42:08Z","updated_at":"2016-01-13T15:42:08Z","body":"No, it is not possible to print the inherited ancestors. JavaParser is a parser and built the AST: it basically organizes in a tree the information which is present in the source file. However to find the inherited ancestor you should be able to find the declarations corresponding to the names. For example:\r\n\r\n\r\n```\r\nimport a.Foo;\r\n\r\nclass A extends Foo {\r\n}\r\n```\r\n\r\nIn this case the AST tells me that A extends \"Foo\" but it does not have the logic to understand that \"Foo\" is actually \"a.Foo\" and it does not know how to locale a.Foo, extract information from it and finding the ancestors. Note that a.Foo could be a class in a Jar, in the JDK or another source file."}}