当前位置: 首页>>代码示例>>Java>>正文


Java DocPretty类代码示例

本文整理汇总了Java中com.sun.tools.javac.tree.DocPretty的典型用法代码示例。如果您正苦于以下问题:Java DocPretty类的具体用法?Java DocPretty怎么用?Java DocPretty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DocPretty类属于com.sun.tools.javac.tree包,在下文中一共展示了DocPretty类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check

import com.sun.tools.javac.tree.DocPretty; //导入依赖的package包/类
@Override
    void check(TreePath path, Name name) throws Exception {
        String raw = trees.getDocComment(path);
        String normRaw = normalize(raw);

        StringWriter out = new StringWriter();
        DocPretty dp = new DocPretty(out);
        dp.print(trees.getDocCommentTree(path));
        String pretty = out.toString();

        if (!pretty.equals(normRaw)) {
            error("mismatch");
            System.err.println("*** expected:");
            System.err.println(normRaw.replace(" ", "_"));
            System.err.println("*** found:");
            System.err.println(pretty.replace(" ", "_"));
//            throw new Error();
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:DocCommentTester.java

示例2: getAttrValue

import com.sun.tools.javac.tree.DocPretty; //导入依赖的package包/类
private String getAttrValue(AttributeTree tree) {
    if (tree.getValue() == null)
        return null;

    StringWriter sw = new StringWriter();
    try {
        new DocPretty(sw).print(tree.getValue());
    } catch (IOException e) {
        // cannot happen
    }
    // ignore potential use of entities for now
    return sw.toString();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:Checker.java

示例3: runElementAndBreakIteratorTests

import com.sun.tools.javac.tree.DocPretty; //导入依赖的package包/类
/**
 * Tests getting a DocCommentTree from an element, as well
 * as test if break iterator setter/getter works correctly.
 *
 * @param javaFileName a test file to be processed
 * @param expected the expected output
 * @throws java.io.IOException
 */
public void runElementAndBreakIteratorTests(String javaFileName, String expected) throws IOException {
    List<File> javaFiles = new ArrayList<>();
    javaFiles.add(new File(testSrc, javaFileName));

    List<File> dirs = new ArrayList<>();
    dirs.add(new File(testSrc));

    try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
        fm.setLocation(javax.tools.StandardLocation.SOURCE_PATH, dirs);
        Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(javaFiles);

        final JavacTask t = javac.getTask(null, fm, null, null, null, fos);
        final DocTrees trees = DocTrees.instance(t);

        Iterable<? extends Element> elements = t.analyze();

        Element klass = elements.iterator().next();
        DocCommentTree dcTree = trees.getDocCommentTree(klass);

        List<? extends DocTree> firstSentence = dcTree.getFirstSentence();
        StringWriter sw = new StringWriter();
        DocPretty pretty = new DocPretty(sw);
        pretty.print(firstSentence);
        check("getDocCommentTree(Element)", expected, sw.toString());

        BreakIterator bi = BreakIterator.getSentenceInstance(Locale.FRENCH);
        trees.setBreakIterator(bi);
        BreakIterator nbi = trees.getBreakIterator();
        if (bi.equals(nbi)) {
            pass++;
            check("getDocCommentTree(Element) with BreakIterator", expected, sw.toString());
        } else {
            fail++;
            System.err.println("BreakIterators don't match");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:DocCommentTreeApiTester.java

示例4: getExpectText

import com.sun.tools.javac.tree.DocPretty; //导入依赖的package包/类
String getExpectText(DocTree t) {
    StringWriter sw = new StringWriter();
    DocPretty p = new DocPretty(sw);
    try { p.print(t); } catch (IOException never) { }
    String s = sw.toString();
    if (s.length() <= 1)
        return s;
    int ws = s.replaceAll("\\s+", " ").indexOf(" ");
    if (ws != -1) s = s.substring(0, ws);
    return (s.length() < 5) ? s : s.substring(0, 5);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:DocCommentTester.java


注:本文中的com.sun.tools.javac.tree.DocPretty类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。