• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DocPretty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Constraints类代码示例发布时间:2022-05-22
下一篇:
Java KeyspaceDefinition类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap