public SourcePosition getSourcePosition() { return new SourcePosition() { @Override public File file() { return sourceFilePath.toFile(); } @Override public int line() { return 0; } @Override public int column() { return 0; } @Override public String toString() { return file().toString(); } }; }
private String expand(Tag tag) { // create the URL SourcePosition file = tag.position(); String pathAndFile = file.file().toString(); pathAndFile = pathAndFile.substring(pathAndFile.indexOf("src/main")); pathAndFile = correctSlashes(pathAndFile); Matcher matcher = pathPattern.matcher(pathAndFile); if (matcher.matches()) { String url = "https://github.com/cdk/cdk/tree/" + BRANCH + "/" + matcher.group(1); return "<a href=\"" + url + "\" target=\"_blank\">" + BRANCH + "</a>"; } else { System.out.println("Could not resolve class name from: " + pathAndFile); } return ""; }
@Override public boolean showMessage(SourcePosition pos, String key) { if (root instanceof RootDocImpl) { return pos == null || ((RootDocImpl) root).showTagMessages(); } return true; }
/** * Reporter alias method for {@link #info(String, Object...)} with position info. * * @param msg The message (without parameters). * @see #info(String, Object...) */ @Override public void printNotice(SourcePosition pos, String msg) { try (GlobalPosition gp = new GlobalPosition(pos)) { info(msg); } }
/** * Reporter alias method for {@link #warn(String, Object...)} with position info. * * @param msg The message (without parameters). * @see #warn(String, Object...) */ @Override public void printWarning(SourcePosition pos, String msg) { try (GlobalPosition gp = new GlobalPosition(pos)) { warn(msg); } }
/** * Reporter alias method for {@link #error(String, Object...)} with position info. * * @param msg The message (without parameters). * @see #error(String, Object...) */ @Override public void printError(SourcePosition pos, String msg) { try (GlobalPosition gp = new GlobalPosition(pos)) { error(msg); } }
void error(Doc d, String s) { SourcePosition sp = d != null ? d.position() : null; if (sp != null) { root.printError(sp, s); } else { root.printError(s); } okSoFar = false; }
void info(Doc d, String s) { if (verbose) { SourcePosition sp = d != null ? d.position() : null; if (log != null) { log.println((sp != null ? sp.toString() + " : " : "") + s); log.flush(); } if (sp != null) { root.printNotice(sp, s); } else { root.printNotice(s); } } }
void notice(Doc d, String s) { SourcePosition sp = d != null ? d.position() : null; if (log != null) { log.println((sp != null ? sp.toString() + " : " : "") + s); log.flush(); } if (sp != null) { root.printNotice(sp, s); } else { root.printNotice(s); } }
/** * Extract the full class name from the tag source position. * * @param tag the tag on a given source file * @return the class name */ private static String getClassName(Tag tag){ SourcePosition position = tag.position(); File file = position.file(); String path = file.getPath().replaceAll(File.separator, "."); return path.substring(path.indexOf("org.openscience.cdk"), path.lastIndexOf(".java")); }
/** * Default processing of any documentation node. * * @param doc The documentation. * @param fixLeadingSpaces `true` if leading spaces should be fixed. * * @see Options#toHtml(String, boolean) */ protected void defaultProcess(Doc doc, boolean fixLeadingSpaces) { try { StringBuilder buf = new StringBuilder(); buf.append(getOptions().toHtml(doc.commentText(), fixLeadingSpaces)); buf.append('\n'); for ( Tag tag : doc.tags() ) { processTag(tag, buf); buf.append('\n'); } doc.setRawCommentText(buf.toString()); } catch ( final ParserRuntimeException e ) { if ( doc instanceof RootDoc ) { printError(new SourcePosition() { @Override public File file() { return options.getOverviewFile(); } @Override public int line() { return 0; } @Override public int column() { return 0; } }, e.getMessage()); } else { printError(doc.position(), e.getMessage()); } } }
public static SourcePosition make(FileObject file, int pos, Position.LineMap lineMap) { if (file == null) return null; return new SourcePositionImpl(file, pos, lineMap); }
private File resolve(String file, SourcePosition source) { return new File(source.file().getParentFile(), file); }
public static SourcePosition make(String file, int pos, Position.LineMap lineMap) { if (file == null) return null; return new SourcePositionImpl(file, pos, lineMap); }
@Override public void printError(SourcePosition pos, String msg) { error(); rootDoc.printError(pos, msg); }
@Override public void printWarning(SourcePosition pos, String msg) { rootDoc.printWarning(pos, msg); }
@Override public void printNotice(SourcePosition pos, String msg) { rootDoc.printNotice(pos, msg); }
@Override public SourcePosition position() { return delegate.position(); }
@Override public void printError(SourcePosition pos, String msg) { delegate.printError(pos, msg); }
@Override public void printWarning(SourcePosition pos, String msg) { delegate.printWarning(pos, msg); }
@Override public void printNotice(SourcePosition pos, String msg) { delegate.printNotice(pos, msg); }
/** * Only sets a new global position if the source position is non-null. * * @param pos The new 'current' global position (<code>null</code> will be ignored). */ public GlobalPosition(SourcePosition pos) { this.pos = pos; if (pos != null) setPos(this); }
public SourcePosition position() { return null; }