Get the the previous unittest identifier from a list of tokens
const(Token)[] tokens = []; splitMultilinetokens(fileToDTokens("test/values.d"), tokens); auto scopeResult = getScope(tokens, 81); auto result = getPreviousIdentifier(tokens, scopeResult.begin); tokens[result .. scopeResult.begin].toString.strip.should.equal(`unittest`);
Get the the previous paranthesis identifier from a list of tokens
const(Token)[] tokens = []; splitMultilinetokens(fileToDTokens("test/values.d"), tokens); auto scopeResult = getScope(tokens, 63); auto end = scopeResult.end - 11; auto result = getPreviousIdentifier(tokens, end); tokens[result .. end].toString.strip.should.equal(`(5, (11))`);
Get the the previous function call identifier from a list of tokens
const(Token)[] tokens = []; splitMultilinetokens(fileToDTokens("test/values.d"), tokens); auto scopeResult = getScope(tokens, 75); auto end = scopeResult.end - 11; auto result = getPreviousIdentifier(tokens, end); tokens[result .. end].toString.strip.should.equal(`found(4)`);
Get the the previous map!"" identifier from a list of tokens
const(Token)[] tokens = []; splitMultilinetokens(fileToDTokens("test/values.d"), tokens); auto scopeResult = getScope(tokens, 85); auto end = scopeResult.end - 12; auto result = getPreviousIdentifier(tokens, end); tokens[result .. end].toString.strip.should.equal(`[1, 2, 3].map!"a"`);