Java Code Examples for com.google.googlejavaformat.Input#Token

The following examples show how to use com.google.googlejavaformat.Input#Token . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Does this declaration have javadoc preceding it?
 */
private boolean hasJavaDoc(Tree bodyDeclaration) {
    int position = ((JCTree) bodyDeclaration).getStartPosition();
    Input.Token token = builder.getInput().getPositionTokenMap().get(position);
    if (token != null) {
        for (Input.Tok tok : token.getToksBefore()) {
            if (tok.getText().startsWith("/**")) {
                return true;
            }
        }
    }
    return false;
}
 
Example 2
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Does this list of trees end with the specified token?
 */
private boolean hasTrailingToken(Input input, List<? extends Tree> nodes, String token) {
    if (nodes.isEmpty()) {
        return false;
    }
    Tree lastNode = getLast(nodes);
    Optional<? extends Input.Token> nextToken =
            getNextToken(input, getEndPosition(lastNode, getCurrentPath()));
    return nextToken.isPresent() && nextToken.get().getTok().getText().equals(token);
}
 
Example 3
Source File: JavaInputAstVisitor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Does this declaration have javadoc preceding it?
 */
private boolean hasJavaDoc(Tree bodyDeclaration) {
    int position = ((JCTree) bodyDeclaration).getStartPosition();
    Input.Token token = builder.getInput().getPositionTokenMap().get(position);
    if (token != null) {
        for (Input.Tok tok : token.getToksBefore()) {
            if (tok.getText().startsWith("/**")) {
                return true;
            }
        }
    }
    return false;
}
 
Example 4
Source File: JavaInputAstVisitor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Does this list of trees end with the specified token?
 */
private boolean hasTrailingToken(Input input, List<? extends Tree> nodes, String token) {
    if (nodes.isEmpty()) {
        return false;
    }
    Tree lastNode = getLast(nodes);
    Optional<? extends Input.Token> nextToken =
            getNextToken(input, getEndPosition(lastNode, getCurrentPath()));
    return nextToken.isPresent() && nextToken.get().getTok().getText().equals(token);
}
 
Example 5
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
/** Does this declaration have javadoc preceding it? */
private boolean hasJavaDoc(Tree bodyDeclaration) {
  int position = ((JCTree) bodyDeclaration).getStartPosition();
  Input.Token token = builder.getInput().getPositionTokenMap().get(position);
  if (token != null) {
    for (Input.Tok tok : token.getToksBefore()) {
      if (tok.getText().startsWith("/**")) {
        return true;
      }
    }
  }
  return false;
}
 
Example 6
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
/** Does this list of trees end with the specified token? */
private boolean hasTrailingToken(Input input, List<? extends Tree> nodes, String token) {
  if (nodes.isEmpty()) {
    return false;
  }
  Tree lastNode = getLast(nodes);
  Optional<? extends Input.Token> nextToken =
      getNextToken(input, getEndPosition(lastNode, getCurrentPath()));
  return nextToken.isPresent() && nextToken.get().getTok().getText().equals(token);
}
 
Example 7
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
private static Optional<? extends Input.Token> getNextToken(Input input, int position) {
    return Optional.fromNullable(input.getPositionTokenMap().get(position));
}
 
Example 8
Source File: JavaInputAstVisitor.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
private static Optional<? extends Input.Token> getNextToken(Input input, int position) {
    return Optional.fromNullable(input.getPositionTokenMap().get(position));
}
 
Example 9
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 4 votes vote down vote up
private static Optional<? extends Input.Token> getNextToken(Input input, int position) {
  return Optional.ofNullable(input.getPositionTokenMap().get(position));
}
 
Example 10
Source File: JavaInput.java    From java-n-IDE-for-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Get the input tokens.
 *
 * @return the input tokens
 */
@Override
public ImmutableList<? extends Input.Token> getTokens() {
    return tokens;
}
 
Example 11
Source File: JavaInput.java    From javaide with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the input tokens.
 *
 * @return the input tokens
 */
@Override
public ImmutableList<? extends Input.Token> getTokens() {
    return tokens;
}
 
Example 12
Source File: JavaInput.java    From google-java-format with Apache License 2.0 2 votes vote down vote up
/**
 * Get the input tokens.
 *
 * @return the input tokens
 */
@Override
public ImmutableList<? extends Input.Token> getTokens() {
  return tokens;
}