com.thoughtworks.qdox.JavaDocBuilder Java Examples

The following examples show how to use com.thoughtworks.qdox.JavaDocBuilder. 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: TestClass.java    From code with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws FileNotFoundException {
    String fileFullPath = "D:\\code\\GitRepository\\Code\\java-basic\\jdk5\\src\\main\\java\\cn\\lastwhisper\\jdk5\\feature\\reflect\\TestClass.java";
    JavaDocBuilder builder = new JavaDocBuilder();
    builder.addSource(new FileReader(fileFullPath));

    JavaSource src = builder.getSources()[0];
    String[] imports = src.getImports();

    for (String imp : imports) {
        System.out.println(imp);
    }
}
 
Example #2
Source File: FlowContext.java    From nomulus with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the set of exceptions imported in this test file.  First extracts the set of
 * all names imported by the test file, and then uses these to filter a global list of possible
 * exceptions, so that the additional exception information available via the global list objects
 * (which are ErrorCases wrapping exception names) can be preserved.
 */
private Set<ErrorCase> getImportExceptionsFromFile(String filename) throws IOException {
  JavaDocBuilder builder = new JavaDocBuilder();
  JavaSource src = builder.addSource(new File(filename));
  final Set<String> importedNames = Sets.newHashSet(src.getImports());
  return possibleExceptions
      .stream()
      .filter(errorCase -> importedNames.contains(errorCase.getClassName()))
      .collect(toImmutableSet());
}
 
Example #3
Source File: TestParser.java    From yatspec with Apache License 2.0 5 votes vote down vote up
private static Callable1<URL, JavaClass> asAJavaClass(final Class aClass) {
    return new Callable1<URL, JavaClass>() {
        @Override
        public JavaClass call(URL url) throws Exception {
            JavaDocBuilder builder = new JavaDocBuilder();
            builder.addSource(url);
            return builder.getClassByName(aClass.getName());
        }
    };
}
 
Example #4
Source File: Util.java    From uima-uimafit with Apache License 2.0 4 votes vote down vote up
public static JavaSource parseSource(String aSourceFile, String aEncoding) throws IOException {
  JavaDocBuilder builder = new JavaDocBuilder();
  builder.setEncoding(aEncoding);
  builder.addSource(new FileReader(aSourceFile));
  return builder.getSources()[0];
}