本文整理汇总了Java中com.sun.tools.javac.util.Position.LineMap类的典型用法代码示例。如果您正苦于以下问题:Java LineMap类的具体用法?Java LineMap怎么用?Java LineMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineMap类属于com.sun.tools.javac.util.Position包,在下文中一共展示了LineMap类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ArgumentTracker
import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
ArgumentTracker(
Iterable<? extends ExpressionTree> arguments,
int offset,
VisitorState state,
LineMap lineMap) {
this.state = state;
this.offset = offset;
this.argumentsIterator = arguments.iterator();
this.lineMap = lineMap;
}
示例2: getLineMap
import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
public LineMap getLineMap() {
return tokenizer.getLineMap();
}
示例3: findCommentsForArguments
import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
private static ImmutableList<Commented<ExpressionTree>> findCommentsForArguments(
Tree tree, List<? extends ExpressionTree> arguments, int startPosition, VisitorState state) {
if (arguments.isEmpty()) {
return ImmutableList.of();
}
CharSequence sourceCode = state.getSourceCode();
Optional<Integer> endPosition = computeEndPosition(tree, sourceCode, state);
if (!endPosition.isPresent()) {
return noComments(arguments);
}
CharSequence source = sourceCode.subSequence(startPosition, endPosition.get());
if (CharMatcher.is('/').matchesNoneOf(source)) {
return noComments(arguments);
}
// The token position of the end of the method invocation
int invocationEnd = state.getEndPosition(tree) - startPosition;
ErrorProneTokens errorProneTokens = new ErrorProneTokens(source.toString(), state.context);
ImmutableList<ErrorProneToken> tokens = errorProneTokens.getTokens();
LineMap lineMap = errorProneTokens.getLineMap();
ArgumentTracker argumentTracker = new ArgumentTracker(arguments, startPosition, state, lineMap);
TokenTracker tokenTracker = new TokenTracker(lineMap);
argumentTracker.advance();
tokenLoop:
for (ErrorProneToken token : tokens) {
tokenTracker.advance(token);
if (tokenTracker.atStartOfLine() && !tokenTracker.wasPreviousLineEmpty()) {
for (Comment c : token.comments()) {
if (tokenTracker.isCommentOnPreviousLine(c)
&& token.pos() <= argumentTracker.currentArgumentStartPosition
&& argumentTracker.isPreviousArgumentOnPreviousLine()) {
// token was on the previous line so therefore we should add it to the previous comment
// unless the previous argument was not on the the previous line with it
argumentTracker.addCommentToPreviousArgument(c);
} else {
// if the comment comes after the end of the invocation and its not on the same line
// as the final argument then we need to ignore it
if (c.getSourcePos(0) <= invocationEnd
|| lineMap.getLineNumber(c.getSourcePos(0))
<= lineMap.getLineNumber(argumentTracker.currentArgumentEndPosition)) {
argumentTracker.addCommentToCurrentArgument(c);
}
}
}
} else {
argumentTracker.addAllCommentsToCurrentArgument(token.comments());
}
if (token.pos() >= argumentTracker.currentArgumentEndPosition) {
// We are between arguments so wait for a (lexed) comma to delimit them
if (token.kind() == TokenKind.COMMA) {
if (!argumentTracker.hasMoreArguments()) {
break tokenLoop;
}
argumentTracker.advance();
}
}
}
return argumentTracker.build();
}
示例4: TokenTracker
import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
TokenTracker(LineMap lineMap) {
this.lineMap = lineMap;
}
示例5: getLineMap
import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
public LineMap getLineMap() {
return commentSavingTokenizer.getLineMap();
}
示例6: getLineMap
import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
/**
* Build a map for translating between line numbers and
* positions in the input.
*
* @return a LineMap
*/
LineMap getLineMap();