当前位置: 首页>>代码示例>>Java>>正文


Java LineMap类代码示例

本文整理汇总了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;
}
 
开发者ID:google,项目名称:error-prone,代码行数:11,代码来源:Comments.java

示例2: getLineMap

import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
public LineMap getLineMap() {
    return tokenizer.getLineMap();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:4,代码来源:Scanner.java

示例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();
}
 
开发者ID:google,项目名称:error-prone,代码行数:68,代码来源:Comments.java

示例4: TokenTracker

import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
TokenTracker(LineMap lineMap) {
  this.lineMap = lineMap;
}
 
开发者ID:google,项目名称:error-prone,代码行数:4,代码来源:Comments.java

示例5: getLineMap

import com.sun.tools.javac.util.Position.LineMap; //导入依赖的package包/类
public LineMap getLineMap() {
  return commentSavingTokenizer.getLineMap();
}
 
开发者ID:google,项目名称:error-prone,代码行数:4,代码来源:ErrorProneTokens.java

示例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();
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:8,代码来源:Lexer.java


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