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

Java CommentStyle类代码示例

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

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



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

示例1: processComment

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
/**
 * Called when a complete comment has been scanned. pos and endPos
 * will mark the comment boundary.
 */
protected Tokens.Comment processComment(int pos, int endPos, CommentStyle style) {
    if (scannerDebug)
        System.out.println("processComment(" + pos
                           + "," + endPos + "," + style + ")=|"
                           + new String(reader.getRawCharacters(pos, endPos))
                           + "|");
    char[] buf = reader.getRawCharacters(pos, endPos);
    return new BasicComment<UnicodeReader>(new UnicodeReader(fac, buf, buf.length), style);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:JavaTokenizer.java


示例2: getText

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
@Override
public String getText() {
    if (!scanned && cs == CommentStyle.JAVADOC) {
        scanDocComment();
    }
    return docComment;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:JavadocTokenizer.java


示例3: processComment

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
/**
 * Called when a complete comment has been scanned. pos and endPos
 * will mark the comment boundary.
 */
protected Tokens.Comment processComment(int pos, int endPos, CommentStyle style) {
    if (scannerDebug)
        System.out.println("processComment(" + pos
                           + "," + endPos + "," + style + ")=|"
                           + new String(reader.getRawCharacters(pos, endPos))
                           + "|");
    char[] buf = reader.getRawCharacters(pos, endPos);
    return new BasicComment<>(new UnicodeReader(fac, buf, buf.length), style);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:JavaTokenizer.java


示例4: newDocCommentTree

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCDocComment newDocCommentTree(List<? extends DocTree> fullBody, List<? extends DocTree> tags) {
    ListBuffer<DCTree> lb = new ListBuffer<>();
    lb.addAll(cast(fullBody));
    List<DCTree> fBody = lb.toList();

    // A dummy comment to keep the diagnostics logic happy.
    Comment c = new Comment() {
        @Override
        public String getText() {
            return null;
        }

        @Override
        public int getSourcePos(int index) {
            return Position.NOPOS;
        }

        @Override
        public CommentStyle getStyle() {
            return CommentStyle.JAVADOC;
        }

        @Override
        public boolean isDeprecated() {
            return false;
        }
    };
    Pair<List<DCTree>, List<DCTree>> pair = splitBody(fullBody);
    DCDocComment tree = new DCDocComment(c, fBody, pair.fst, pair.snd, cast(tags));
    return tree;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:DocTreeMaker.java


示例5: comment

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
private Comment comment(String docString) {
    StringBuilder docComment = new StringBuilder()
                               .append("/**")
                               .append(docString)
                               .append("*/");
    Scanner scanner = scanners.newScanner(docComment, true);
    scanner.nextToken();
    Token token = scanner.token();
    return token.comment(CommentStyle.JAVADOC);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Documentifier.java


示例6: newDocCommentTree

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCDocComment newDocCommentTree(List<? extends DocTree> firstSentence, List<? extends DocTree> body, List<? extends DocTree> tags) {
    ListBuffer<DCTree> lb = new ListBuffer<>();
    lb.addAll(cast(firstSentence));
    lb.addAll(cast(body));
    List<DCTree> fullBody = lb.toList();

    // A dummy comment to keep the diagnostics logic happy.
    Comment c = new Comment() {
        @Override
        public String getText() {
            return null;
        }

        @Override
        public int getSourcePos(int index) {
            return Position.NOPOS;
        }

        @Override
        public CommentStyle getStyle() {
            return CommentStyle.JAVADOC;
        }

        @Override
        public boolean isDeprecated() {
            return false;
        }
    };

    DCDocComment tree = new DCDocComment(c, fullBody, cast(firstSentence), cast(body), cast(tags));
    return tree;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:34,代码来源:DocTreeMaker.java


示例7: processComment

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
@Override
protected Comment processComment(int pos, int endPos, CommentStyle style) {
	int prevEndPos = Math.max(prevEndPosition, endComment);
	endComment = endPos;
	String content = new String(reader.getRawCharacters(pos, endPos));
	StartConnection start = determineStartConnection(prevEndPos, pos);
	EndConnection end = determineEndConnection(endPos); 

	CommentInfo comment = new CommentInfo(prevEndPos, pos, endPos, content, start, end);
	comments.append(comment);

	return super.processComment(pos, endPos, style);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:CommentCollectingTokenizer.java


示例8: CommentWithTextAndPosition

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
public CommentWithTextAndPosition(
    int pos, int endPos, AccessibleReader reader, CommentStyle style) {
  this.pos = pos;
  this.endPos = endPos;
  this.reader = reader;
  this.style = style;
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:ErrorProneTokens.java


示例9: notAnnotated

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
static MatchedComment notAnnotated() {
  return new AutoValue_NamedParameterComment_MatchedComment(
      new Comment() {
        @Override
        public String getText() {
          throw new IllegalArgumentException(
              "Attempt to call getText on comment when in NOT_ANNOTATED state");
        }

        @Override
        public int getSourcePos(int i) {
          throw new IllegalArgumentException(
              "Attempt to call getText on comment when in NOT_ANNOTATED state");
        }

        @Override
        public CommentStyle getStyle() {
          throw new IllegalArgumentException(
              "Attempt to call getText on comment when in NOT_ANNOTATED state");
        }

        @Override
        public boolean isDeprecated() {
          throw new IllegalArgumentException(
              "Attempt to call getText on comment when in NOT_ANNOTATED state");
        }
      },
      MatchType.NOT_ANNOTATED);
}
 
开发者ID:google,项目名称:error-prone,代码行数:30,代码来源:NamedParameterComment.java


示例10: match

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
/**
 * Determine the kind of match we have between the comments on this argument and the formal
 * parameter name.
 */
static MatchedComment match(Commented<ExpressionTree> actual, String formal) {
  Optional<Comment> lastBlockComment =
      Streams.findLast(
          actual.beforeComments().stream().filter(c -> c.getStyle() == CommentStyle.BLOCK));

  if (lastBlockComment.isPresent()) {
    Matcher m =
        PARAMETER_COMMENT_PATTERN.matcher(Comments.getTextFromComment(lastBlockComment.get()));
    if (m.matches()) {
      return MatchedComment.create(
          lastBlockComment.get(),
          m.group(1).equals(formal) ? MatchType.EXACT_MATCH : MatchType.BAD_MATCH);
    }
  }

  Optional<Comment> approximateMatchComment =
      Stream.concat(actual.beforeComments().stream(), actual.afterComments().stream())
          .filter(comment -> isApproximateMatchingComment(comment, formal))
          .findFirst();

  if (approximateMatchComment.isPresent()) {
    // Report EXACT_MATCH for comments that don't use the recommended style (e.g. `/*foo*/`
    // instead of `/* foo= */`), but which match the formal parameter name exactly, since it's
    // a style nit rather than a possible correctness issue.
    // TODO(cushon): revisit this if we standardize on the recommended comment style.
    String text =
        CharMatcher.anyOf("=:")
            .trimTrailingFrom(Comments.getTextFromComment(approximateMatchComment.get()).trim());
    return MatchedComment.create(
        approximateMatchComment.get(),
        text.equals(formal) ? MatchType.EXACT_MATCH : MatchType.APPROXIMATE_MATCH);
  }

  return MatchedComment.notAnnotated();
}
 
开发者ID:google,项目名称:error-prone,代码行数:40,代码来源:NamedParameterComment.java


示例11: parseCompilationUnit

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
/** CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}
 */
public JCTree.JCCompilationUnit parseCompilationUnit() {
    Token firstToken = token;
    JCExpression pid = null;
    JCModifiers mods = null;
    boolean consumedToplevelDoc = false;
    boolean seenImport = false;
    boolean seenPackage = false;
    List<JCAnnotation> packageAnnotations = List.nil();
    if (token.kind == MONKEYS_AT)
        mods = modifiersOpt();

    if (token.kind == PACKAGE) {
        seenPackage = true;
        if (mods != null) {
            checkNoMods(mods.flags);
            packageAnnotations = mods.annotations;
            mods = null;
        }
        nextToken();
        pid = qualident(false);
        accept(SEMI);
    }
    ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
    boolean checkForImports = true;
    boolean firstTypeDecl = true;
    while (token.kind != EOF) {
        if (token.pos > 0 && token.pos <= endPosTable.errorEndPos) {
            // error recovery
            skip(checkForImports, false, false, false);
            if (token.kind == EOF)
                break;
        }
        if (checkForImports && mods == null && token.kind == IMPORT) {
            seenImport = true;
            defs.append(importDeclaration());
        } else {
            Comment docComment = token.comment(CommentStyle.JAVADOC);
            if (firstTypeDecl && !seenImport && !seenPackage) {
                docComment = firstToken.comment(CommentStyle.JAVADOC);
                consumedToplevelDoc = true;
            }
            JCTree def = typeDeclaration(mods, docComment);
            if (def instanceof JCExpressionStatement)
                def = ((JCExpressionStatement)def).expr;
            defs.append(def);
            if (def instanceof JCClassDecl)
                checkForImports = false;
            mods = null;
            firstTypeDecl = false;
        }
    }
    JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(packageAnnotations, pid, defs.toList());
    if (!consumedToplevelDoc)
        attach(toplevel, firstToken.comment(CommentStyle.JAVADOC));
    if (defs.isEmpty())
        storeEnd(toplevel, S.prevToken().endPos);
    if (keepDocComments)
        toplevel.docComments = docComments;
    if (keepLineMap)
        toplevel.lineMap = S.getLineMap();
    this.endPosTable.setParser(null); // remove reference to parser
    toplevel.endPositions = this.endPosTable;
    return toplevel;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:67,代码来源:JavacParser.java


示例12: BasicComment

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
protected BasicComment(U comment_reader, CommentStyle cs) {
    this.comment_reader = comment_reader;
    this.cs = cs;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:JavaTokenizer.java


示例13: getStyle

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
public CommentStyle getStyle() {
    return cs;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:JavaTokenizer.java


示例14: isDeprecated

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
public boolean isDeprecated() {
    if (!scanned && cs == CommentStyle.JAVADOC) {
        scanDocComment();
    }
    return deprecatedFlag;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:JavaTokenizer.java


示例15: processComment

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
@Override
protected Comment processComment(int pos, int endPos, CommentStyle style) {
    char[] buf = reader.getRawCharacters(pos, endPos);
    return new JavadocComment(new DocReader(fac, buf, buf.length, pos), style);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:JavadocTokenizer.java


示例16: JavadocComment

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
JavadocComment(DocReader reader, CommentStyle cs) {
    super(reader, cs);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:JavadocTokenizer.java


示例17: getDocCommentTree

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DocCommentTree getDocCommentTree(FileObject fileObject) {
    JavaFileObject jfo = asJavaFileObject(fileObject);
    DiagnosticSource diagSource = new DiagnosticSource(jfo, log);

    final Comment comment = new Comment() {
        int offset = 0;
        @Override
        public String getText() {
            try {
                CharSequence rawDoc = fileObject.getCharContent(true);
                Pattern bodyPat =
                        Pattern.compile("(?is).*?<body\\b[^>]*>(.*)</body\\b.*");
                Matcher m = bodyPat.matcher(rawDoc);
                if (m.matches()) {
                    offset = m.end(1);
                    return m.group(1);
                } else {
                    // Assume doclint will do the right thing.
                    return "";
                }
            } catch (IOException ignore) {
                // do nothing
            }
            return "";
        }

        @Override
        public int getSourcePos(int index) {
            return offset + index;
        }

        @Override
        public CommentStyle getStyle() {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean isDeprecated() {
            throw new UnsupportedOperationException();
        }
    };

    return new DocCommentParser(parser, diagSource, comment).parse();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:JavacTrees.java


示例18: parseCompilationUnit

import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; //导入依赖的package包/类
/** CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}
 */
public JCTree.JCCompilationUnit parseCompilationUnit() {
    Token firstToken = token;
    JCModifiers mods = null;
    boolean consumedToplevelDoc = false;
    ListBuffer<JCTree> defs = new ListBuffer<>();

    if (token.kind == IDENTIFIER && token.name() == names.module) {
        defs.append(moduleDecl(token.comment(CommentStyle.JAVADOC)));
        consumedToplevelDoc = true;
    } else {
        boolean seenImport = false;
        boolean seenPackage = false;
        if (token.kind == MONKEYS_AT)
            mods = modifiersOpt();

        if (token.kind == PACKAGE) {
            int packagePos = token.pos;
            List<JCAnnotation> annotations = List.nil();
            seenPackage = true;
            if (mods != null) {
                checkNoMods(mods.flags);
                annotations = mods.annotations;
                mods = null;
            }
            nextToken();
            JCExpression pid = qualident(false);
            accept(SEMI);
            JCPackageDecl pd = F.at(packagePos).PackageDecl(annotations, pid);
            attach(pd, firstToken.comment(CommentStyle.JAVADOC));
            consumedToplevelDoc = true;
            storeEnd(pd, token.pos);
            defs.append(pd);
        }
        boolean checkForImports = true;
        boolean firstTypeDecl = true;
        while (token.kind != EOF) {
            if (token.pos <= endPosTable.errorEndPos) {
                // error recovery
                skip(checkForImports, false, false, false);
                if (token.kind == EOF)
                    break;
            }
            if (checkForImports && mods == null && token.kind == IMPORT) {
                seenImport = true;
                defs.append(importDeclaration());
            } else {
                Comment docComment = token.comment(CommentStyle.JAVADOC);
                if (firstTypeDecl && !seenImport && !seenPackage) {
                    docComment = firstToken.comment(CommentStyle.JAVADOC);
                    consumedToplevelDoc = true;
                }
                JCTree def = typeDeclaration(mods, docComment);
                if (def instanceof JCExpressionStatement)
                    def = ((JCExpressionStatement)def).expr;
                defs.append(def);
                if (def instanceof JCClassDecl)
                    checkForImports = false;
                mods = null;
                firstTypeDecl = false;
            }
        }
    }

    JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(defs.toList());
    if (!consumedToplevelDoc)
        attach(toplevel, firstToken.comment(CommentStyle.JAVADOC));
    if (defs.isEmpty())
        storeEnd(toplevel, S.prevToken().endPos);
    if (keepDocComments)
        toplevel.docComments = docComments;
    if (keepLineMap)
        toplevel.lineMap = S.getLineMap();
    this.endPosTable.setParser(null); // remove reference to parser
    toplevel.endPositions = this.endPosTable;
    return toplevel;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:79,代码来源:JavacParser.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SessionIdGenerator类代码示例发布时间:2022-05-22
下一篇:
Java XdmAtomicValue类代码示例发布时间: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