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

The following examples show how to use com.google.googlejavaformat.Input#Tok . 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: JavaOutput.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * The earliest non-whitespace Tok in the Token.
 */
public static Input.Tok startTok(Token token) {
    for (Input.Tok tok : token.getToksBefore()) {
        if (tok.getIndex() >= 0) {
            return tok;
        }
    }
    return token.getTok();
}
 
Example 2
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 3
Source File: JavaOutput.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
/** The last non-whitespace Tok in the Token. */
public static Input.Tok endTok(Token token) {
  for (int i = token.getToksAfter().size() - 1; i >= 0; i--) {
    Input.Tok tok = token.getToksAfter().get(i);
    if (tok.getIndex() >= 0) {
      return tok;
    }
  }
  return token.getTok();
}
 
Example 4
Source File: JavaOutput.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
/** The earliest non-whitespace Tok in the Token. */
public static Input.Tok startTok(Token token) {
  for (Input.Tok tok : token.getToksBefore()) {
    if (tok.getIndex() >= 0) {
      return tok;
    }
  }
  return token.getTok();
}
 
Example 5
Source File: JavaOutput.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
/** The earliest position of any Tok in the Token, including leading whitespace. */
public static int startPosition(Token token) {
  int min = token.getTok().getPosition();
  for (Input.Tok tok : token.getToksBefore()) {
    min = Math.min(min, tok.getPosition());
  }
  return min;
}
 
Example 6
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 7
Source File: JavaOutput.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The last non-whitespace Tok in the Token.
 */
public static Input.Tok endTok(Token token) {
    for (int i = token.getToksAfter().size() - 1; i >= 0; i--) {
        Input.Tok tok = token.getToksAfter().get(i);
        if (tok.getIndex() >= 0) {
            return tok;
        }
    }
    return token.getTok();
}
 
Example 8
Source File: JavaOutput.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The earliest non-whitespace Tok in the Token.
 */
public static Input.Tok startTok(Token token) {
    for (Input.Tok tok : token.getToksBefore()) {
        if (tok.getIndex() >= 0) {
            return tok;
        }
    }
    return token.getTok();
}
 
Example 9
Source File: JavaOutput.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The earliest position of any Tok in the Token, including leading whitespace.
 */
public static int startPosition(Token token) {
    int min = token.getTok().getPosition();
    for (Input.Tok tok : token.getToksBefore()) {
        min = Math.min(min, tok.getPosition());
    }
    return min;
}
 
Example 10
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 11
Source File: JavaOutput.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * The last non-whitespace Tok in the Token.
 */
public static Input.Tok endTok(Token token) {
    for (int i = token.getToksAfter().size() - 1; i >= 0; i--) {
        Input.Tok tok = token.getToksAfter().get(i);
        if (tok.getIndex() >= 0) {
            return tok;
        }
    }
    return token.getTok();
}
 
Example 12
Source File: JavaOutput.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * The earliest position of any Tok in the Token, including leading whitespace.
 */
public static int startPosition(Token token) {
    int min = token.getTok().getPosition();
    for (Input.Tok tok : token.getToksBefore()) {
        min = Math.min(min, tok.getPosition());
    }
    return min;
}
 
Example 13
Source File: JavaInput.java    From java-n-IDE-for-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Get the later {@link Tok}s assigned to this {@code Token}.
 *
 * @return the later {@link Tok}s assigned to this {@code Token}
 */
@Override
public ImmutableList<? extends Input.Tok> getToksAfter() {
    return toksAfter;
}
 
Example 14
Source File: JavaInput.java    From javaide with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the earlier {@link Tok}s assigned to this {@code Token}.
 *
 * @return the earlier {@link Tok}s assigned to this {@code Token}
 */
@Override
public ImmutableList<? extends Input.Tok> getToksBefore() {
    return toksBefore;
}
 
Example 15
Source File: JavaInput.java    From javaide with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the later {@link Tok}s assigned to this {@code Token}.
 *
 * @return the later {@link Tok}s assigned to this {@code Token}
 */
@Override
public ImmutableList<? extends Input.Tok> getToksAfter() {
    return toksAfter;
}
 
Example 16
Source File: JavaInput.java    From java-n-IDE-for-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Get the earlier {@link Tok}s assigned to this {@code Token}.
 *
 * @return the earlier {@link Tok}s assigned to this {@code Token}
 */
@Override
public ImmutableList<? extends Input.Tok> getToksBefore() {
    return toksBefore;
}
 
Example 17
Source File: JavaInput.java    From google-java-format with Apache License 2.0 2 votes vote down vote up
/**
 * Get the earlier {@link Tok}s assigned to this {@code Token}.
 *
 * @return the earlier {@link Tok}s assigned to this {@code Token}
 */
@Override
public ImmutableList<? extends Input.Tok> getToksBefore() {
  return toksBefore;
}
 
Example 18
Source File: JavaInput.java    From google-java-format with Apache License 2.0 2 votes vote down vote up
/**
 * Get the later {@link Tok}s assigned to this {@code Token}.
 *
 * @return the later {@link Tok}s assigned to this {@code Token}
 */
@Override
public ImmutableList<? extends Input.Tok> getToksAfter() {
  return toksAfter;
}