コード例 #1
0
    @Override
    public RuleBasedScanner createItemParser() {
      List<IRule> rules = new ArrayList<IRule>();
      for (Directive directive : Directive.values()) {
        if (!directive.isEndDirective()) {
          rules.add(new DirectiveRule(directive));
        }
      }

      RuleBasedScanner result = new SyntaxModeListenerRuleBasedScanner();
      result.setRules(rules.toArray(new IRule[rules.size()]));
      return result;
    }
コード例 #2
0
  public RuleBasedScanner getCodeScanner() {
    RuleBasedScanner scanner = new RuleBasedScanner();
    List rules = new ArrayList();
    Rule main = mode.getDefaultRuleSet();
    addWhitespaceRule(rules);

    IToken defaultToken = newToken(ColorsPreferencePage.NULL_COLOR);
    addTextSequenceRules(main, rules, defaultToken);

    IRule[] result = new IRule[rules.size()];
    rules.toArray(result);
    scanner.setRules(result);
    return scanner;
  }
コード例 #3
0
  private RuleBasedScanner getDelegateScanner(Rule rule) {
    RuleBasedScanner scanner = new RuleBasedScanner();
    List rules = new ArrayList();

    String colorName = colorManager.colorForType(rule.getDefaultTokenType());
    IToken defaultToken = newToken(colorName);
    scanner.setDefaultReturnToken(defaultToken);
    ColoringEditorTools.add(
        rule,
        rules,
        new ITokenFactory() {
          public IToken makeToken(Type type) {
            String color = colorManager.colorForType(type.getColor());
            return newToken(color);
          }
        });
    addTextSequenceRules(rule, rules, defaultToken);

    scanner.setRules((IRule[]) rules.toArray(new IRule[rules.size()]));
    return scanner;
  }
コード例 #4
0
  private ITokenScanner getDefaultScanner() {
    RuleBasedScanner scanner = new RuleBasedScanner();

    IRule[] rules = new IRule[14];
    rules[0] = createHeader6Rule();
    rules[1] = createHeader5Rule();
    rules[2] = createHeader4Rule();
    rules[3] = createHeader3Rule();
    rules[4] = createHeader2Rule();
    rules[5] = createHeader1Rule();
    rules[6] = createHRRule();
    rules[7] = createMacroRule();
    rules[8] = createExternalHTTPRule();
    rules[9] = createListRule();
    rules[10] = createNumberedListRule();
    rules[11] = createBoldItalicRule();
    rules[12] = createBoldRule();
    rules[13] = createItalicRule();

    scanner.setRules(rules);
    return scanner;
  }