本文整理汇总了Java中org.eclipse.jdt.internal.corext.dom.TokenScanner.isComment方法的典型用法代码示例。如果您正苦于以下问题:Java TokenScanner.isComment方法的具体用法?Java TokenScanner.isComment怎么用?Java TokenScanner.isComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.dom.TokenScanner
的用法示例。
在下文中一共展示了TokenScanner.isComment方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSurroundingComment
import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private int getSurroundingComment(IScanner scanner) {
try {
int start = fLocation.getOffset();
int end = start + fLocation.getLength();
int token = scanner.getNextToken();
while (token != ITerminalSymbols.TokenNameEOF) {
if (TokenScanner.isComment(token)) {
int currStart = scanner.getCurrentTokenStartPosition();
int currEnd = scanner.getCurrentTokenEndPosition() + 1;
if (currStart <= start && end <= currEnd) {
return token;
}
}
token = scanner.getNextToken();
}
} catch (InvalidInputException e) {
// ignore
}
return ITerminalSymbols.TokenNameEOF;
}
示例2: getSurroundingComment
import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private int getSurroundingComment(IScanner scanner) {
try {
int start= fLocation.getOffset();
int end= start + fLocation.getLength();
int token= scanner.getNextToken();
while (token != ITerminalSymbols.TokenNameEOF) {
if (TokenScanner.isComment(token)) {
int currStart= scanner.getCurrentTokenStartPosition();
int currEnd= scanner.getCurrentTokenEndPosition() + 1;
if (currStart <= start && end <= currEnd) {
return token;
}
}
token= scanner.getNextToken();
}
} catch (InvalidInputException e) {
// ignore
}
return ITerminalSymbols.TokenNameEOF;
}
示例3: isValidComment
import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private boolean isValidComment(String template) {
IScanner scanner = ToolFactory.createScanner(true, false, false, false);
scanner.setSource(template.toCharArray());
try {
int next = scanner.getNextToken();
while (TokenScanner.isComment(next)) {
next = scanner.getNextToken();
}
return next == ITerminalSymbols.TokenNameEOF;
} catch (InvalidInputException e) {
}
return false;
}
示例4: isValidComment
import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private boolean isValidComment(String template) {
IScanner scanner = ToolFactory.createScanner(true, false, false, false);
scanner.setSource(template.toCharArray());
try {
int next = scanner.getNextToken();
while (TokenScanner.isComment(next)) {
next = scanner.getNextToken();
}
return next == ITerminalSymbols.TokenNameEOF;
} catch (InvalidInputException e) {
}
return false;
}
示例5: isValidComment
import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private boolean isValidComment(String template) {
IScanner scanner = ToolFactory.createScanner(true, false, false, false);
scanner.setSource(template.toCharArray());
try {
int next = scanner.getNextToken();
while (TokenScanner.isComment(next)) {
next = scanner.getNextToken();
}
return next == ITerminalSymbols.TokenNameEOF;
} catch (InvalidInputException e) {
// If there are lexical errors, the comment is invalid
}
return false;
}
示例6: isValidComment
import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
private boolean isValidComment(String template) {
IScanner scanner= ToolFactory.createScanner(true, false, false, false);
scanner.setSource(template.toCharArray());
try {
int next= scanner.getNextToken();
while (TokenScanner.isComment(next)) {
next= scanner.getNextToken();
}
return next == ITerminalSymbols.TokenNameEOF;
} catch (InvalidInputException e) {
}
return false;
}
示例7: JavaTokenComparator
import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
/**
* Creates a token comparator for the given string.
*
* @param text the text to be tokenized
*/
public JavaTokenComparator(String text) {
Assert.isLegal(text != null);
fText= text;
int length= fText.length();
fStarts= new int[length];
fLengths= new int[length];
fCount= 0;
IScanner scanner= ToolFactory.createScanner(true, true, false, false); // returns comments & whitespace
scanner.setSource(fText.toCharArray());
int endPos= 0;
try {
int tokenType;
while ((tokenType= scanner.getNextToken()) != ITerminalSymbols.TokenNameEOF) {
int start= scanner.getCurrentTokenStartPosition();
int end= scanner.getCurrentTokenEndPosition()+1;
// Comments and strings should not be treated as a single token, see https://bugs.eclipse.org/78063
if (TokenScanner.isComment(tokenType) || tokenType == ITerminalSymbols.TokenNameStringLiteral) {
// Line comments are often commented code, so lets treat them as code. See https://bugs.eclipse.org/216707
boolean parseAsJava= tokenType == ITerminalSymbols.TokenNameCOMMENT_LINE;
int dl= parseAsJava ? getCommentStartTokenLength(tokenType) : 0;
if (dl > 0)
recordTokenRange(start, dl);
parseSubrange(start + dl, text.substring(start + dl, end), parseAsJava);
} else {
recordTokenRange(start, end - start);
}
endPos= end;
}
} catch (InvalidInputException ex) {
// We couldn't parse part of the input. Fall through and make the rest a single token
}
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=13907
if (endPos < length) {
recordTokenRange(endPos, length - endPos);
}
}
示例8: JavaTokenComparator
import org.eclipse.jdt.internal.corext.dom.TokenScanner; //导入方法依赖的package包/类
/**
* Creates a token comparator for the given string.
*
* @param text the text to be tokenized
* @param textTokenComparatorFactory a factory to create text token comparators
*/
public JavaTokenComparator(String text, ITokenComparatorFactory textTokenComparatorFactory) {
fTextTokenComparatorFactory= textTokenComparatorFactory;
Assert.isLegal(text != null);
fText= text;
int length= fText.length();
fStarts= new int[length];
fLengths= new int[length];
fCount= 0;
IScanner scanner= ToolFactory.createScanner(true, true, false, false); // returns comments & whitespace
scanner.setSource(fText.toCharArray());
int endPos= 0;
try {
int tokenType;
while ((tokenType= scanner.getNextToken()) != ITerminalSymbols.TokenNameEOF) {
int start= scanner.getCurrentTokenStartPosition();
int end= scanner.getCurrentTokenEndPosition()+1;
// Comments are treated as a single token (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=78063)
if (TokenScanner.isComment(tokenType) || tokenType == ITerminalSymbols.TokenNameStringLiteral) {
int dl= fTextTokenComparatorFactory == null ? getCommentStartTokenLength(tokenType) : 0;
if (dl > 0)
recordTokenRange(start, dl);
parseText(start + dl, text.substring(start + dl, end));
} else {
recordTokenRange(start, end - start);
}
endPos= end;
}
} catch (InvalidInputException ex) {
// We couldn't parse part of the input. Fall through and make the rest a single token
}
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=13907
if (endPos < length) {
recordTokenRange(endPos, length - endPos);
}
}