Package org.eclipse.jface.text.rules

Examples of org.eclipse.jface.text.rules.IToken


   *
   * @param colorProvider ColorProvider
   * @return the list of <code>IRule</code>
   */
  protected List createRules(ColorProvider colorProvider){
    IToken normal  = colorProvider.getToken(HTMLPlugin.PREF_COLOR_FG);
    IToken string  = colorProvider.getToken(HTMLPlugin.PREF_COLOR_JSSTRING);
    IToken comment = colorProvider.getToken(HTMLPlugin.PREF_COLOR_JSCOMMENT);
    IToken keyword = colorProvider.getToken(HTMLPlugin.PREF_COLOR_JSKEYWORD);
   
    List rules = new ArrayList();
    rules.add(new SingleLineRule("\"", "\"", string, '\\'));
    rules.add(new SingleLineRule("'", "'", string, '\\'));
    rules.add(new EndOfLineRule("//", comment));
View Full Code Here


import tool.editors.IToolColorConstants;

public class ToolScanner extends RuleBasedScanner {

  public ToolScanner(ColorManager manager) {
    IToken reservedWord =
      new Token(
        new TextAttribute(
          manager.getColor(IToolColorConstants.KEYWORD), null, Font.BOLD));
   
   
    IToken udsLibrary =
      new Token(
        new TextAttribute(
          manager.getColor(IToolColorConstants.UDS_LIBRARY), null, Font.BOLD | Font.ITALIC));
    IToken type =
      new Token(
          new TextAttribute(manager.getColor(IToolColorConstants.TYPE), null, Font.BOLD));
   
    IToken string =
      new Token(new TextAttribute(manager
        .getColor(IToolColorConstants.STRING)));
   
//    IToken comment =
//      new Token(new TextAttribute(manager
//        .getColor(IToolColorConstants.TOOL_COMMENT)));
   
    IToken operator =
      new Token(new TextAttribute(manager
        .getColor(IToolColorConstants.DEFAULT), null, Font.BOLD));
   
    IToken other =
      new Token(new TextAttribute(manager.getColor(IToolColorConstants.DEFAULT)));
   
    IRule[] rules = new IRule[4];
   
    // Add generic whitespace rule.
View Full Code Here

    public IToken nextToken() {
        if (m_currentOffset >= (m_docOffset + m_docLength)) {
            return Token.EOF;
        }

        IToken result = Token.UNDEFINED;
        int startOffset = m_currentOffset;
        int length = 0;
        try {
            // Get line information
            IRegion lineRegion = m_document.getLineInformationOfOffset(m_currentOffset);
View Full Code Here

import tool.editors.IToolColorConstants;

public class ToolScanner extends RuleBasedScanner {

  public ToolScanner(ColorManager manager) {
    IToken reservedWord =
      new Token(
        new TextAttribute(
          manager.getColor(IToolColorConstants.KEYWORD), null, Font.BOLD));
   
   
    IToken udsLibrary =
      new Token(
        new TextAttribute(
          manager.getColor(IToolColorConstants.UDS_LIBRARY), null, Font.BOLD | Font.ITALIC));
    IToken type =
      new Token(
          new TextAttribute(manager.getColor(IToolColorConstants.TYPE), null, Font.BOLD));
   
    IToken string =
      new Token(new TextAttribute(manager
        .getColor(IToolColorConstants.STRING)));
   
//    IToken comment =
//      new Token(new TextAttribute(manager
//        .getColor(IToolColorConstants.TOOL_COMMENT)));
   
    IToken operator =
      new Token(new TextAttribute(manager
        .getColor(IToolColorConstants.DEFAULT), null, Font.BOLD));
   
    IToken other =
      new Token(new TextAttribute(manager.getColor(IToolColorConstants.DEFAULT)));
   
    IRule[] rules = new IRule[4];
   
    // Add generic whitespace rule.
View Full Code Here

  public final static String TOOL_COMMENT = "__tool_comment";
  public final static String TOOL_SQL= "__tool_sql";
 
  public ToolPartitionScanner() {

    IToken toolComment = new Token(TOOL_COMMENT);
    IToken toolSQL = new Token(TOOL_SQL);

   
    ArrayList<IPredicateRule> rules = new ArrayList<IPredicateRule>();
    rules.add(new MultiLineCommentRule(toolComment));
    rules.add(new DoubleHyphenCommentRule(toolComment));
View Full Code Here

   * with a color and font. A list of rules with the corresponding token are
   * created. The method ends with setting the scanner's set of rules
   */
  public SQLScanner() {
    SQLColorProvider provider = new SQLColorProvider();
    IToken keyword = new Token(new TextAttribute(provider
        .getColor(SQLColorProvider.KEYWORD), provider
        .getColor(SQLColorProvider.BACKGROUND), SWT.BOLD | SWT.ITALIC));
    IToken type = new Token(new TextAttribute(provider
        .getColor(SQLColorProvider.TYPE), provider
        .getColor(SQLColorProvider.BACKGROUND), SWT.BOLD));
    IToken string = new Token(new TextAttribute(provider
        .getColor(SQLColorProvider.STRING)));
    IToken comment = new Token(new TextAttribute(provider
        .getColor(SQLColorProvider.SINGLE_LINE_COMMENT)));
//    IToken other = new Token(new TextAttribute(provider
//        .getColor(SQLColorProvider.DEFAULT)));
    IToken other = new Token(new TextAttribute(provider
        .getColor(SQLColorProvider.DEFAULT), provider
            .getColor(SQLColorProvider.BACKGROUND), SWT.ITALIC));

    setDefaultReturnToken(other);
    List<IRule> rules = new ArrayList<IRule>();
View Full Code Here

                      "-cmatch", "-cnotmatch", "-creplace", "-ccontains", "-cnotcontains", "-is", "-isnot", "-as", "-and", "-or", "-band", "-bor", "-not"};
  private static String[] scopes = {"$script", "$global", "$function", "$local", "$private"};
 
  public PowershellCodeScanner(PowershellColors pscolors) {

    IToken comment = new Token(new TextAttribute(new Color(Display.getCurrent(), PowershellColors.COMMENT)));
    IToken string = new Token(new TextAttribute(new Color(Display.getCurrent(), PowershellColors.STRING)));
    IToken variable = new Token(new TextAttribute(new Color(Display.getCurrent(), PowershellColors.VARIABLE)));
    IToken scope = new Token(new TextAttribute(new Color(Display.getCurrent(), PowershellColors.VARIABLE), null, SWT.BOLD));
    IToken keyword = new Token(new TextAttribute(new Color(Display.getCurrent(), PowershellColors.KEYWORD), null, SWT.BOLD));
    IToken dashKeyword = new Token(new TextAttribute(new Color(Display.getCurrent(), PowershellColors.DASH_KEYWORD), null, SWT.BOLD));

    List<IRule> rules= new ArrayList<IRule>();

    // Add rule for single line comments.
    rules.add(new EndOfLineRule("#", comment));
View Full Code Here

      String content = fDocument.get(typedRegion.getOffset(), typedRegion.getLength());
      IDocument document = new Document(content);

      int lastStart = 0;
      int length = 0;
      IToken lastToken = Token.UNDEFINED;

      int remainingLength = typedRegion.getLength();
      fScanner.setRange(document, lastStart, remainingLength);

      while (true) {

        IToken token = fScanner.nextToken();

        if (token.isEOF()) {
          if (!lastToken.isUndefined() && length != 0)
            addRange(holdResults, lastStart + offsetAdjustment, length, getTokenTextAttribute(lastToken));
          break;
        }

        if (token.isWhitespace()) {
          length += fScanner.getTokenLength();
          continue;
        }

        if (lastToken.isUndefined()) {
View Full Code Here

      // ideally, eventually, we'll have a "virtualDocument" we can
      // refer to, but for now ... we'll simple rescan the one region.
      // use simple adjustment (since "sub-content" starts at 0
      int lastStart = typedRegion.getOffset();
      int length = 0;
      IToken lastToken = Token.UNDEFINED;
      fScanner.setRange(getDocument(), lastStart, typedRegion.getLength());
      while (true) {
        IToken token = fScanner.nextToken();
        if (token.isEOF()) {
          if (!lastToken.isUndefined() && length != 0) {
            addRange(holdResults, lastStart, length, getTokenTextAttribute(lastToken));
          }
          break;
        }
        if (token.isWhitespace()) {
          length += fScanner.getTokenLength();
          continue;
        }
        if (lastToken.isUndefined()) {
          lastToken = token;
View Full Code Here

  }
 

  public BaseCodeScanner(DestecsColorProvider provider)
  {
    IToken type = new Token(new TextAttribute(provider.getColor(new RGB(0, 0, 192)), null, SWT.BOLD));
    IToken keyword = new Token(new TextAttribute(provider.getColor(DestecsColorProvider.KEYWORD), null, SWT.BOLD));
    IToken string = new Token(new TextAttribute(provider.getColor(DestecsColorProvider.STRING)));
    IToken comment = new Token(new TextAttribute(provider.getColor(DestecsColorProvider.SINGLE_LINE_COMMENT)));
    IToken other = new Token(new TextAttribute(provider.getColor(DestecsColorProvider.DEFAULT)));

    List<IRule> rules = new ArrayList<IRule>();
    // Add rule for single line comments.
    rules.add(new EndOfLineRule("--", comment));
    rules.add(new EndOfLineRule("//", comment));
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.rules.IToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.