Regexp to match members declaration of Java source files

£可爱£侵袭症+ 提交于 2019-12-11 09:48:36

问题


In a Javalike language where parsers and other advanced methods do not exist I want to parse and evaluate source files. It's the language Apex from the proprietary cloud platform Salesforce.com. I know its based on Antrl/Java but there is no way to parse it from inside the platform as I want to parse Apex code with Apex code and the only means is Regexp.

When reading in a source file I want (by using a regexp) to match and extract all parts that are interesting to draw an UML class diagram:

  • class declaration
  • method declaration
  • inner class declaration

I want to find them and by using Regexp groups I would love to be able to directly access parts of the matched string. Those parts are:

  • Is is public or private?
  • Is it static, abstract or default?
  • Is it a class or an interface?
  • What's the methodname?
  • What's the Returntype?
  • What's the param list?

来源:https://stackoverflow.com/questions/14870742/regexp-to-match-members-declaration-of-java-source-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!