• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Utility methods for interacting with the java rules"""
2
3def _tokenize_javacopts(ctx, opts):
4    """Tokenizes a list or depset of options to a list.
5
6    Iff opts is a depset, we reverse the flattened list to ensure right-most
7    duplicates are preserved in their correct position.
8
9    Args:
10        ctx: (RuleContext) the rule context
11        opts: (depset[str]|[str]) the javac options to tokenize
12    Returns:
13        [str] list of tokenized options
14    """
15    if hasattr(opts, "to_list"):
16        opts = reversed(opts.to_list())
17    return [
18        token
19        for opt in opts
20        for token in ctx.tokenize(opt)
21    ]
22
23utils = struct(
24    tokenize_javacopts = _tokenize_javacopts,
25)
26