getParameter

Undocumented in source. Be warned that the author may not have intended to support it.
@safe
getParameter
(
const(Token)[] tokens
,
size_t startToken
)

Examples

Get the first parameter from a list of tokens

const(Token)[] tokens = [];
splitMultilinetokens(fileToDTokens("test/values.d"), tokens);

auto begin = getAssertIndex(tokens, 57) + 4;
auto end = getParameter(tokens, begin);
tokens[begin .. end].toString.strip.should.equal(`(5, (11))`);

Get the first list parameter from a list of tokens

const(Token)[] tokens = [];
splitMultilinetokens(fileToDTokens("test/values.d"), tokens);

auto begin = getAssertIndex(tokens, 89) + 4;
auto end = getParameter(tokens, begin);
tokens[begin .. end].toString.strip.should.equal(`[ new Value(1), new Value(2) ]`);

Get the previous array identifier from a list of tokens

const(Token)[] tokens = [];
splitMultilinetokens(fileToDTokens("test/values.d"), tokens);

auto scopeResult = getScope(tokens, 4);
auto end = scopeResult.end - 13;

auto result = getPreviousIdentifier(tokens, end);

tokens[result .. end].toString.strip.should.equal(`[1, 2, 3]`);

Get the previous array of instances identifier from a list of tokens

const(Token)[] tokens = [];
splitMultilinetokens(fileToDTokens("test/values.d"), tokens);

auto scopeResult = getScope(tokens, 90);
auto end = scopeResult.end - 16;

auto result = getPreviousIdentifier(tokens, end);

tokens[result .. end].toString.strip.should.equal(`[ new Value(1), new Value(2) ]`);

Meta