MCPcopy Index your code
hub / github.com/google/google-java-format / Token

Class Token

core/src/main/java/com/google/googlejavaformat/Doc.java:384–505  ·  view source on GitHub ↗

A leaf Doc for a token.

Source from the content-addressed store, hash-verified

382
383 /** A leaf {@link Doc} for a token. */
384 public static final class Token extends Doc implements Op {
385 /** Is a Token a real token, or imaginary (e.g., a token generated incorrectly, or an EOF)? */
386 public enum RealOrImaginary {
387 REAL,
388 IMAGINARY;
389
390 boolean isReal() {
391 return this == REAL;
392 }
393 }
394
395 private final Input.Token token;
396 private final RealOrImaginary realOrImaginary;
397 private final Indent plusIndentCommentsBefore;
398 private final Optional<Indent> breakAndIndentTrailingComment;
399
400 private Input.Tok tok() {
401 return token.getTok();
402 }
403
404 private Token(
405 Input.Token token,
406 RealOrImaginary realOrImaginary,
407 Indent plusIndentCommentsBefore,
408 Optional<Indent> breakAndIndentTrailingComment) {
409 this.token = token;
410 this.realOrImaginary = realOrImaginary;
411 this.plusIndentCommentsBefore = plusIndentCommentsBefore;
412 this.breakAndIndentTrailingComment = breakAndIndentTrailingComment;
413 }
414
415 /**
416 * How much extra to indent comments before the {@code Token}.
417 *
418 * @return the extra indent
419 */
420 Indent getPlusIndentCommentsBefore() {
421 return plusIndentCommentsBefore;
422 }
423
424 /** Force a line break and indent trailing javadoc or block comments. */
425 Optional<Indent> breakAndIndentTrailingComment() {
426 return breakAndIndentTrailingComment;
427 }
428
429 /**
430 * Make a {@code Token}.
431 *
432 * @param token the {@link Input.Token} to wrap
433 * @param realOrImaginary did this {@link Input.Token} appear in the input, or was it generated
434 * incorrectly?
435 * @param plusIndentCommentsBefore extra {@code plusIndent} for comments just before this token
436 * @return the new {@code Token}
437 */
438 static Op make(
439 Input.Token token,
440 Doc.Token.RealOrImaginary realOrImaginary,
441 Indent plusIndentCommentsBefore,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…