Java 类org.eclipse.jface.text.rules.IWhitespaceDetector 实例源码

项目:Eclipse-Markdown-Editor-Plugin    文件:MDScanner.java   
public MDScanner(ColorManager cm) {
this.cm = cm;      
Token heading = new Token(new TextAttribute(cm.getColor(MDColorConstants.HEADER), null, SWT.BOLD));
   Token comment = new Token(new TextAttribute(cm.getColor(MDColorConstants.COMMENT)));
   Token emphasis = new Token(new TextAttribute(cm.getColor(MDColorConstants.DEFAULT), null, SWT.ITALIC));
   setRules(new IRule[] {           
      new HeaderRule(heading),
      new EmphasisRule("_", emphasis),
      new EmphasisRule("***", emphasis),
      new EmphasisRule("**", emphasis),
      new EmphasisRule("*", emphasis),
      new MultiLineRule("<!--", "-->", comment),
      new WhitespaceRule(new IWhitespaceDetector() {
         public boolean isWhitespace(char c) {
            return Character.isWhitespace(c);
         }
      }),
   });
}
项目:birt    文件:SQLKeywordScanner.java   
/**
 *  
 */
public SQLKeywordScanner( )
{
    super( );
    IToken sqlKeywordsToken = new Token( new TextAttribute( ColorManager.getColor(127, 0, 85), null, SWT.BOLD ) );
    ArrayList rules = new ArrayList( );
    rules.add( new SQLKeywordRule( sqlKeywordsToken, reservedwords ) );
    rules.add( new SQLKeywordRule( sqlKeywordsToken, types ) );
    rules.add( new SQLKeywordRule( sqlKeywordsToken, constants ) );
    rules.add( new SQLKeywordRule( sqlKeywordsToken, functions ) );
    rules.add( new SQLKeywordRule( sqlKeywordsToken, predicates ) );

    // Add generic whitespace rule.
    rules.add( new WhitespaceRule( new IWhitespaceDetector( ) {

        public boolean isWhitespace( char c )
        {
            return Character.isWhitespace( c );
        }
    } ) );

    setRules( (IRule[]) rules.toArray( new IRule[rules.size( )] ) );
    this.setDefaultReturnToken( new Token( new TextAttribute( Display.getDefault( ).getSystemColor( SWT.COLOR_LIST_FOREGROUND ))));
}
项目:birt    文件:JSScanner.java   
/**
 * Creates a new JSScanner object.
 * 
 */
public JSScanner( )
{
    List rules = new ArrayList( );

    // Add generic whitespace rule.
    rules.add( new WhitespaceRule( new IWhitespaceDetector( ) {

        public boolean isWhitespace( char c )
        {
            return Character.isWhitespace( c );
        }
    } ) );

    IRule[] result = new IRule[rules.size( )];
    rules.toArray( result );
    setRules( result );
}
项目:Tarski    文件:RelBoundScanner.java   
public RelBoundScanner(final ColorManager manager) {
  final IToken token = new Token(new TextAttribute(manager.getColor(IColorConstants.REL_BOUND)));
  final IToken bracketsToken =
      new Token(new TextAttribute(manager.getColor(IColorConstants.REL_BOUND_BRACKETS)));
  final IToken commentToken =
      new Token(new TextAttribute(manager.getColor(IColorConstants.COMMENT)));

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

  rules.add(new MultiLineRule("/**", "**/", commentToken));
  rules.add(new EndOfLineRule("--", commentToken));
  // rules.add(new EndOfLineRule("//", commentToken));
  rules.add(new BracketsRule(bracketsToken));

  rules.add(new WhitespaceRule(new IWhitespaceDetector() {

    @Override
    public boolean isWhitespace(final char c) {
      return Character.isWhitespace(c);
    }
  }));
  this.setDefaultReturnToken(token);

  final IRule[] result = new IRule[rules.size()];
  rules.toArray(result);
  this.setRules(result);
}
项目:GradleEditor    文件:GradleCodeScanner.java   
/**
 * Use the default Eclipse higlighting scheme.
 */
private void createRules() {
    Token keywordToken = new Token(keywordAttribute);
    Token commentToken = new Token(commentAttribute);
    Token docToken = new Token(docAttribute);
    Token stringToken = new Token(stringAttribute);
    Token numberToken = new Token(numberAttribute);
    Token normalToken = new Token(normalAttribute);

    setDefaultReturnToken(normalToken);

    setRules(new IRule[] { new EndOfLineRule("//", commentToken),//$NON-NLS-2$
            new KeywordRule(keywordToken),//$NON-NLS-2$
            new MultiLineRule("/**", "*/", docToken, (char) 0, false), //$NON-NLS-2$
            new MultiLineRule("/*", "*/", commentToken, (char) 0, false), //$NON-NLS-2$
            new SingleLineRule("\"", "\"", stringToken, '\\'), //$NON-NLS-2$
            // Regexp
            new SingleLineRule("/", "/", stringToken, '\\'), //$NON-NLS-2$
            new SingleLineRule("'", "'", stringToken, '\\'), //$NON-NLS-2$
            new WhitespaceRule(new IWhitespaceDetector() {
                public boolean isWhitespace(char c) {
                    return Character.isWhitespace(c);
                }
            }),//$NON-NLS-2$
            new WordRule(new WordDetector(), normalToken),//$NON-NLS-2$
            new NumberRule(numberToken) });
}
项目:GLSL-Eclipse    文件:GlslScanner.java   
public GlslScanner() {
    Activator plugin = Activator.getDefault();
    final WordRule wordRule = GlslScanners.createWordRule();

    final Token keywordToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.KEYWORD_COLOR), null, SWT.BOLD));
    final Token typeToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.TYPE_COLOR)));
    final Token qualifierToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.QUALIFIER_COLOR), null, SWT.BOLD));
    final Token functionToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.FUNCTION_COLOR)));
    final Token builtInVariableToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.BUILT_IN_VARIABLES_COLOR)));
    final Token commentToken = new Token(new TextAttribute(plugin.getColor(GlslEditor.COMMENTS_COLOR)));

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

    // Rules which affect entire lines at once
    rules.add(new SingleLineRule("//", null, commentToken, '\0', true, false));

    // Rules which don't affect entire lines
    rules.add(new SingleLineRule("/*", "*/", commentToken));
    rules.add(wordRule);

    GlslScanners.addToWordRule(wordRule, Glsl.KEYWORDS, keywordToken);
    GlslScanners.addToWordRule(wordRule, Glsl.TYPES, typeToken);
    GlslScanners.addToWordRule(wordRule, Glsl.QUALIFIERS, qualifierToken);
    GlslScanners.addToWordRule(wordRule, Glsl.FUNCTIONS, functionToken);
    GlslScanners.addToWordRule(wordRule, Glsl.VARIABLES, builtInVariableToken);

    rules.add(new WhitespaceRule(new IWhitespaceDetector() {
        @Override
        public boolean isWhitespace(char c) {
           return Character.isWhitespace(c);
        }
       }));

    IRule[] rulesArray = new IRule[rules.size()];
    for (int i = 0; i < rulesArray.length; i++) {
        rulesArray[i] = rules.get(i);
    }

    setRules(rulesArray);
}
项目:chromedevtools    文件:JsCodeScanner.java   
/**
 * Use the default Eclipse higlighting scheme.
 */
private void createRules() {
  Token keywordToken = new Token(
      new TextAttribute(EditorColors.getColor(new RGB(127, 0, 85)), null, SWT.BOLD));

  commentToken = new Token(commentAttribute);

  Token jsDocToken = new Token(jsDocAttribute);

  Token stringToken = new Token(
      new TextAttribute(EditorColors.getColor(new RGB(42, 0, 255)), null, SWT.NORMAL));

  RGB blackRgb = new RGB(0, 0, 0);

  Token numberToken = new Token(
      new TextAttribute(EditorColors.getColor(blackRgb), null, SWT.NORMAL));

  Token normalToken = new Token(
      new TextAttribute(EditorColors.getColor(blackRgb), null, SWT.NORMAL));
  setDefaultReturnToken(normalToken);

  setRules(new IRule[] {
      new EndOfLineRule("//", commentToken), //$NON-NLS-1$
      new KeywordRule(keywordToken),
      new MultiLineRule("/**", "*/", jsDocToken, (char) 0, false),  //$NON-NLS-1$ //$NON-NLS-2$
      new MultiLineRule("/*", "*/", commentToken, (char) 0, false),  //$NON-NLS-1$ //$NON-NLS-2$
      new SingleLineRule("\"", "\"", stringToken, '\\'), //$NON-NLS-1$ //$NON-NLS-2$
      // Regexp
      new SingleLineRule("/", "/", stringToken, '\\'), //$NON-NLS-1$ //$NON-NLS-2$
      new SingleLineRule("'", "'", stringToken, '\\'), //$NON-NLS-1$ //$NON-NLS-2$
      new WhitespaceRule(new IWhitespaceDetector() {
        public boolean isWhitespace(char c) {
          return Character.isWhitespace(c);
        }
      }),

      new WordRule(new WordDetector(), normalToken),
      new NumberRule(numberToken),
  });
}
项目:WP3    文件:RelBoundScanner.java   
public RelBoundScanner(final ColorManager manager) {
  final IToken token = new Token(new TextAttribute(manager.getColor(IColorConstants.REL_BOUND)));
  final IToken bracketsToken =
      new Token(new TextAttribute(manager.getColor(IColorConstants.REL_BOUND_BRACKETS)));
  final IToken commentToken =
      new Token(new TextAttribute(manager.getColor(IColorConstants.COMMENT)));

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

  rules.add(new MultiLineRule("/**", "**/", commentToken));
  rules.add(new EndOfLineRule("--", commentToken));
  // rules.add(new EndOfLineRule("//", commentToken));
  rules.add(new BracketsRule(bracketsToken));

  rules.add(new WhitespaceRule(new IWhitespaceDetector() {

    @Override
    public boolean isWhitespace(final char c) {
      return Character.isWhitespace(c);
    }
  }));
  this.setDefaultReturnToken(token);

  final IRule[] result = new IRule[rules.size()];
  rules.toArray(result);
  this.setRules(result);
}
项目:myLOGO4Eclipse    文件:LogoScriptSourceViewerConfiguration.java   
private IRule createWhitespaceRule() {
    IWhitespaceDetector detector = new IWhitespaceDetector() {
        @Override
        public boolean isWhitespace(char c) {
            return Character.isWhitespace(c);
        }
    };
    return new WhitespaceRule(detector);
}
项目:tlaplus    文件:DocumentHelper.java   
/**
 * Factory method for the whitespace detector
 */
public static IWhitespaceDetector getDefaultWhitespaceDetector()
{
    return new TLAWhitespaceDetector();
}