private void ensureDir(File dir) { if (dir.exists()) { if (!dir.isDirectory()) { throw new DocGenException("File " + dir.getAbsolutePath() + " is not a dir"); } } else if (!dir.mkdirs()) { throw new DocGenException("could not create dir " + dir.getAbsolutePath()); } }
private void visitLink(PackageElement pkgElt, String label, String signature, DocGenerator generator, DocWriter writer) { ElementResolution res = resolutions.get(signature); if (res == null) { res = new ElementResolution(signature); resolutions.put(signature, res); } LinkProcessing fut = new LinkProcessing(generator, label); res.add(fut); writer.write(() -> { DocWriter ww = fut.writer; if (ww == null) { throw new DocGenException(pkgElt, "Could not resolve " + signature); } return ww; }); }
/** * Read the source code of the provided element, this returns the source of the entire related compilation unit. * * @param elt the element to load * @return the source */ String readSource(Element elt) { CompilationUnitTree unit = docTrees.getPath(elt).getCompilationUnit(); StringBuilder source = new StringBuilder(); try(Reader reader = unit.getSourceFile().openReader(true)) { char[] buffer = new char[256]; while (true) { int len = reader.read(buffer); if (len == -1) { break; } source.append(buffer, 0, len); } return source.toString(); } catch (IOException e) { throw new DocGenException(elt, "Could not read source code of element " + elt); } }
for (PackageElement stackElt : stack) { if (pkgElt.getQualifiedName().equals(stackElt.getQualifiedName())) { throw new DocGenException(stack.peekLast(), "Circular include"); throw new DocGenException(e.getMessage());