コード例 #1
0
  @Override
  public List<Embedding> getEmbeddings() {
    // Initializes template counters.
    TemplateResolver.init();
    // TODO: neprochazet celou sekvenci (ale par radku pred a po caret)
    // jestli je to vubec mozny...
    TokenSequence<LatteTopTokenId> sequence =
        LexUtils.getTopSequence(getSnapshot().getText().toString());

    sequence.moveStart();

    LatteResolver latteResolver = new LatteResolver(this);
    HtmlPhpResolver htmlPhpResolver = new HtmlPhpResolver(this);

    while (sequence.moveNext()) {
      Token t = sequence.token();
      if (t.id() == LatteTopTokenId.LATTE) {
        latteResolver.solve(t, sequence); // deals with all latte macros
        SyntaxUtils.findArrayForHint(getSnapshot().getSource().getDocument(false), sequence);
      } else {
        htmlPhpResolver.solve(t, sequence);
      }
    }

    return super.getEmbeddings();
  }
コード例 #2
0
 private static TokenSequence<SQLTokenId> getTokenSequence(String sql)
     throws BadLocationException {
   Document doc = new ModificationTextDocument();
   doc.insertString(0, sql, null);
   doc.putProperty(Language.class, SQLTokenId.language());
   TokenHierarchy<?> hi = TokenHierarchy.get(doc);
   TokenSequence<SQLTokenId> seq = hi.tokenSequence(SQLTokenId.language());
   seq.moveStart();
   return seq;
 }
コード例 #3
0
 private static CharSequence dumpTokens(TokenSequence<?> seq) {
   seq.moveStart();
   StringBuilder builder = new StringBuilder();
   Token<?> token = null;
   while (seq.moveNext()) {
     if (token != null) {
       builder.append('\n');
     }
     token = seq.token();
     builder.append(token.id());
     PartType part = token.partType();
     if (part != PartType.COMPLETE) {
       builder.append(' ');
       builder.append(token.partType());
     }
     builder.append(' ');
     builder.append('\'');
     builder.append(token.text());
     builder.append('\'');
   }
   return builder;
 }