本文整理汇总了Java中com.sun.tools.javac.parser.Tokens.Comment类的典型用法代码示例。如果您正苦于以下问题:Java Comment类的具体用法?Java Comment怎么用?Java Comment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Comment类属于com.sun.tools.javac.parser.Tokens包,在下文中一共展示了Comment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DocCommentParser
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) {
this.fac = fac;
this.diagSource = diagSource;
this.comment = comment;
names = fac.names;
m = fac.docTreeMaker;
Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale;
Options options = fac.options;
boolean useBreakIterator = options.isSet("breakIterator");
if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage()))
sentenceBreaker = BreakIterator.getSentenceInstance(locale);
initTagParsers();
}
示例2: documentifyBase
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
private void documentifyBase(JCClassDecl base, boolean isTopLevel, boolean isFxStyle) {
// add doc comment to class itself
Comment comm = comment(docGen.getBaseComment(base, isTopLevel));
curDocComments.putComment(base, comm);
// add doc comments to members
for (JCTree member : base.getMembers()) {
switch (member.getTag()) {
case VARDEF:
documentifyField(base, (JCVariableDecl)member, isFxStyle);
break;
case METHODDEF:
documentifyMethod(base, (JCMethodDecl)member, isFxStyle);
break;
case CLASSDEF:
documentifyBase((JCClassDecl)member, false, isFxStyle);
break;
}
}
}
示例3: attach
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
static void attach(final JCTree node, String docCommentContent, Object map_) {
final String docCommentContent_ = docCommentContent;
((DocCommentTable) map_).putComment(node, new Comment() {
@Override public String getText() {
return docCommentContent_;
}
@Override public int getSourcePos(int index) {
return -1;
}
@Override public CommentStyle getStyle() {
return CommentStyle.JAVADOC;
}
@Override public boolean isDeprecated() {
return JavacHandlerUtil.nodeHasDeprecatedFlag(node);
}
});
}
示例4: createJavadocComment
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
private static Comment createJavadocComment(final String text, final JavacNode field) {
return new Comment() {
@Override public String getText() {
return text;
}
@Override public int getSourcePos(int index) {
return -1;
}
@Override public CommentStyle getStyle() {
return CommentStyle.JAVADOC;
}
@Override public boolean isDeprecated() {
return text.contains("@deprecated") && field.getKind() == Kind.FIELD && isFieldDeprecated(field);
}
};
}
示例5: isApproximateMatchingComment
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
private static boolean isApproximateMatchingComment(Comment comment, String formal) {
switch (comment.getStyle()) {
case BLOCK:
case LINE:
// sometimes people use comments around arguments for higher level structuring - such as
// dividing two separate blocks of arguments. In these cases we want to avoid concluding
// that its a match. Therefore we also check to make sure that the comment is not really
// long and that it doesn't contain acsii-art style markup.
String commentText = Comments.getTextFromComment(comment);
boolean textMatches =
Arrays.asList(commentText.split("[^a-zA-Z0-9_]+", -1)).contains(formal);
boolean tooLong = commentText.length() > formal.length() + 5 && commentText.length() > 50;
boolean tooMuchMarkup = CharMatcher.anyOf("-*[email protected]<>").countIn(commentText) > 5;
return textMatches && !tooLong && !tooMuchMarkup;
default:
return false;
}
}
示例6: classDeclaration
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
@Override
protected JCClassDecl classDeclaration(JCModifiers mods, Comment dc) {
if (cancelService != null) {
cancelService.abortIfCanceled();
}
return super.classDeclaration(mods, dc);
}
示例7: interfaceDeclaration
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
@Override
protected JCClassDecl interfaceDeclaration(JCModifiers mods, Comment dc) {
if (cancelService != null) {
cancelService.abortIfCanceled();
}
return super.interfaceDeclaration(mods, dc);
}
示例8: enumDeclaration
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
@Override
protected JCClassDecl enumDeclaration(JCModifiers mods, Comment dc) {
if (cancelService != null) {
cancelService.abortIfCanceled();
}
return super.enumDeclaration(mods, dc);
}
示例9: methodDeclaratorRest
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
@Override
protected JCTree methodDeclaratorRest(int pos, JCModifiers mods, JCExpression type, Name name, List<JCTypeParameter> typarams, boolean isInterface, boolean isVoid, Comment dc) {
if (cancelService != null) {
cancelService.abortIfCanceled();
}
return super.methodDeclaratorRest(pos, mods, type, name, typarams, isInterface, isVoid, dc);
}
示例10: DCDocComment
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
public DCDocComment(Comment comment,
List<DCTree> firstSentence, List<DCTree> body, List<DCTree> tags) {
this.comment = comment;
this.firstSentence = firstSentence;
this.body = body;
this.tags = tags;
}
示例11: DocCommentParser
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
public DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) {
this.fac = fac;
this.diagSource = diagSource;
this.comment = comment;
names = fac.names;
m = fac.docTreeMaker;
initTagParsers();
}
示例12: DCDocComment
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
public DCDocComment(Comment comment,
List<DCTree> fullBody,
List<DCTree> firstSentence,
List<DCTree> body,
List<DCTree> tags) {
this.comment = comment;
this.firstSentence = firstSentence;
this.fullBody = fullBody;
this.body = body;
this.tags = tags;
}
示例13: newDocCommentTree
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的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;
}
示例14: documentifyField
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的package包/类
private void documentifyField(JCClassDecl base, JCVariableDecl field, boolean isFxStyle) {
Kind baseKind = base.getKind();
Set<Modifier> fieldMods = field.getModifiers().getFlags();
String doc = (baseKind == Kind.ENUM
&& fieldMods.contains(Modifier.PUBLIC)
&& fieldMods.contains(Modifier.STATIC)
&& fieldMods.contains(Modifier.FINAL)) ?
docGen.getConstComment() :
docGen.getFieldComment(base, field, isFxStyle);
Comment comm = comment(doc);
curDocComments.putComment(field, comm);
}
示例15: comment
import com.sun.tools.javac.parser.Tokens.Comment; //导入依赖的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);
}