All files / src/lexer/statements use.ts

100% Statements 12/12
100% Branches 4/4
100% Functions 3/3
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31    15x 15x       8x 8x 22x 22x 8x   14x   14x 8x                 8x       15x  
import { Query } from "../../reader/query";
import { ILexer } from "../interface";
import { cleanUnquotedIdentifier } from "../lexer";
import { Keyword, Types } from "../tokens";
 
class Use implements ILexer {
  public tokenise(query: Query): Query {
    query.lines.forEach(line => {
      line.content.split(" ").forEach(word => {
        let item = word.toLowerCase().trim();
        if (item === Keyword.Use) {
          line.tokens.push([Types.Keyword, item]);
        } else {
          item = cleanUnquotedIdentifier(item);
 
          if (item.length > 0) {
            line.tokens.push([
              Types.TableReference,
              cleanUnquotedIdentifier(item)
            ]);
          }
        }
      });
    });
 
    return query;
  }
}
 
export { Use };