当前位置: 首页>>代码示例>>Java>>正文


Java WordRule.addWord方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.rules.WordRule.addWord方法的典型用法代码示例。如果您正苦于以下问题:Java WordRule.addWord方法的具体用法?Java WordRule.addWord怎么用?Java WordRule.addWord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.rules.WordRule的用法示例。


在下文中一共展示了WordRule.addWord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createRules

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
@Override
protected List<IRule> createRules() {
	IToken keywordToken = getToken(Prefs.EDITOR_HTML_KEYWORD_COLOR);
	IToken symbolToken = getToken(Prefs.EDITOR_HTML_SYMBOL_COLOR);
	IToken stringToken = getToken(Prefs.EDITOR_HTML_STRING_COLOR);
	IToken defaultToken = getToken(Prefs.EDITOR_DEFAULT_COLOR);

	WordRule wordRule = new WordRule(new HtmlWordDetector(), defaultToken, true);
	for (String keyword : keywords) {
		wordRule.addWord(keyword, keywordToken);
	}

	WordRule symbolRule = new WordRule(new HtmlSymbolDetector(), defaultToken, true);
	for (String symbol : symbols) {
		symbolRule.addWord(symbol, symbolToken);
	}

	List<IRule> rules = new ArrayList<IRule>();
	rules.add(new SingleLineRule("\"", "\"", stringToken, '\\', true));
	rules.add(new SingleLineRule("'", "'", stringToken, '\\', true));
	rules.add(wordRule);
	rules.add(symbolRule);
	rules.add(new WhitespaceRule(new WhitespaceDetector()));
	return rules;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:26,代码来源:ScannerHtml.java

示例2: attachWordRule

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
public void attachWordRule(List<IRule> rules) {
IToken tokenDefault = new Token(new TextAttribute(KSC_DEFAULT));
IToken tokenKeyword = new Token(new TextAttribute(KSC_KEYWORD));
IToken tokenNumber = new Token(new TextAttribute(KSC_NUMBER));
IToken tokenOperator = new Token(new TextAttribute(KSC_OPERATOR));

WordRule wordRule = new WordRule(new KernelSyntaxWordDetector(), tokenDefault, true);
for (String keyword : KSL_KEYWORD) {
	wordRule.addWord(keyword, tokenKeyword);
}
rules.add(wordRule);

KernelSyntaxNumberRule numberRule = new KernelSyntaxNumberRule(tokenNumber);
rules.add(numberRule);

KernelSyntaxOperatorRule opRule = new KernelSyntaxOperatorRule(tokenOperator);
rules.add(opRule);
}
 
开发者ID:yangyuan,项目名称:eclipse-kernelsyntax,代码行数:19,代码来源:KernelSyntaxLangC.java

示例3: update

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
/**
 * This method is called when the we need to recreate the scanning rules. 
 * It is called when the scanner is created and when colour preferences
 * and task preferences change. 
 */
/* Override */
protected void update()
{
   LinkedList<IRule> rules = new LinkedList<IRule>();
 
   this.setDefaultReturnToken( getTokenForPreference( Preference.COLOUR_COMMENT ) );
   
   // Add whitespace matcher
   rules.add( new WhitespaceRule( new WhiteSpaceDetector() ) );
   
   WordRule taskRule = new WordRule( new WordDetector(), getTokenForPreference( Preference.COLOUR_COMMENT ) );
   
   // Add all the task tags 
   for( String tag : TaskTag.getTaskTagStrings( 
      PreferenceManager.getPreference( Preference.TASK_TAGS ) ) ) 
   {
      taskRule.addWord( tag, getTokenForPreference( Preference.COLOUR_TASK ) );
   }

   rules.add( taskRule );
   
   // Set the rules
   this.setRules( rules.toArray( new IRule[rules.size()] ) );   
}
 
开发者ID:brocade,项目名称:vTM-eclipse,代码行数:30,代码来源:CommentScanner.java

示例4: JSDocScanner

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
/**
 * Create a new javadoc scanner for the given color provider.
 */
public JSDocScanner()
{
	super();

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

	// Add rule for tags.
	list.add(new SingleLineRule("<", ">", getToken("text.html.basic"))); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$

	// Add rule for links.
	list.add(new SingleLineRule("{", "}", getToken("markup.underline.link"))); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$

	// Add word rule for keywords.
	IToken keyword = getToken("meta.tag.documentation.js"); //$NON-NLS-1$
	WordRule wordRule = new WordRule(new JSDocWordDetector());
	for (String word : KEYWORDS)
	{
		wordRule.addWord(word, keyword);
	}
	list.add(wordRule);

	setDefaultReturnToken(getToken("comment.block.documentation.js")); //$NON-NLS-1$
	setRules(list.toArray(new IRule[list.size()]));
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:28,代码来源:JSDocScanner.java

示例5: createScannerSpecificRules

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
/**
 * createScannerSpecificRules
 * 
 * @return
 */
protected Collection<? extends IRule> createScannerSpecificRules()
{
	List<IRule> rules = new ArrayList<IRule>();
	WordRule wordRule = new WordRule(new KeywordIdentifierDetector(), Token.UNDEFINED);
	wordRule.addWord("em", createToken(CSSTokenType.EMS));
	wordRule.addWord("ex", createToken(CSSTokenType.EXS));
	wordRule.addWord("px", createToken(CSSTokenType.LENGTH));
	wordRule.addWord("cm", createToken(CSSTokenType.LENGTH));
	wordRule.addWord("mm", createToken(CSSTokenType.LENGTH));
	wordRule.addWord("in", createToken(CSSTokenType.LENGTH));
	wordRule.addWord("pt", createToken(CSSTokenType.LENGTH));
	wordRule.addWord("pc", createToken(CSSTokenType.LENGTH));
	wordRule.addWord("deg", createToken(CSSTokenType.ANGLE));
	wordRule.addWord("rad", createToken(CSSTokenType.ANGLE));
	wordRule.addWord("grad", createToken(CSSTokenType.ANGLE));
	wordRule.addWord("ms", createToken(CSSTokenType.TIME));
	wordRule.addWord("s", createToken(CSSTokenType.TIME));
	wordRule.addWord("hz", createToken(CSSTokenType.FREQUENCY));
	wordRule.addWord("khz", createToken(CSSTokenType.FREQUENCY));
	wordRule.addWord("Hz", createToken(CSSTokenType.FREQUENCY));
	wordRule.addWord("kHz", createToken(CSSTokenType.FREQUENCY));
	addWordsToRule(wordRule, FUNCTIONS, CSSTokenType.FUNCTION);
	rules.add(wordRule);
	return rules;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:31,代码来源:CSSCodeScannerRuleBased.java

示例6: createRules

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
/**
 * Creates the list of <code>IRule</code>.
 * If you have to customize rules, override this method.
 *
 * @return the list of <code>IRule</code>
 */
protected List<IRule> createRules() {
    IToken normal  = new Token(new TextAttribute(new Color(Display.getCurrent(),
            IHTMLColorConstants.FOREGROUND)));
    IToken string  = new Token(new TextAttribute(new Color(Display.getCurrent(),
            IHTMLColorConstants.JAVA_STRING)));
    IToken comment = new Token(new TextAttribute(new Color(Display.getCurrent(),
            IHTMLColorConstants.JAVA_COMMENT)));
    IToken keyword = new Token(new TextAttribute(new Color(Display.getCurrent(),
            IHTMLColorConstants.JAVA_KEYWORD)));
    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new SingleLineRule("\"", "\"", string, '\\'));
    rules.add(new SingleLineRule("'", "'", string, '\\'));
    rules.add(new SingleLineRule("\\//", null, normal));
    rules.add(new EndOfLineRule("//", comment));
    WordRule wordRule = new WordRule(new JavaWordDetector(), normal);
    for (int i = 0; i < KEYWORDS.length; i++) {
        wordRule.addWord(KEYWORDS[i], keyword);
    }
    rules.add(wordRule);
    return rules;
}
 
开发者ID:apache,项目名称:syncope,代码行数:28,代码来源:JavaScriptScanner.java

示例7: MinetweakerScanner

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
public MinetweakerScanner(ColorManager manager) {
	IToken comments = new Token(new TextAttribute(manager.getColor(ZSReferences.ZS_COMMENT)));
	IToken keywords = new Token(new TextAttribute(manager.getColor(ZSReferences.KEYWORD)));

	IRule[] rules = new IRule[4];
	rules[0] = new EndOfLineRule("#", comments);
	rules[1] = new EndOfLineRule("//", comments);
	rules[2] = new WhitespaceRule(new MinetweakerWhitespaceDetector());
	
	WordRule wordRule = new WordRule(new MinetweakerWordDetector(), Token.WHITESPACE);
	for(String keyword : ZSReferences.KEYWORDS)
		wordRule.addWord(keyword, keywords);
	
	rules[3] = wordRule;
	
	setRules(rules);
}
 
开发者ID:xbony2,项目名称:Minetweaker-IDE,代码行数:18,代码来源:MinetweakerScanner.java

示例8: createRules

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
@Override
protected List<IRule> createRules() {
  List<IRule> rules = new ArrayList<IRule>();
  IToken keyword = this.getToken(GnColorConstants.GN_KEYWORD);
  IToken numberToken = getToken(GnColorConstants.GN_NUMBER);
  IToken comment = this.getToken(GnColorConstants.GN_COMMENT);
  IToken other = this.getToken(GnColorConstants.GN_DEFAULT);

  rules.add(new EndOfLineRule("#", comment));
  rules.add(new WhitespaceRule(new GnWhitespaceDetector()));

  WordRule wordRule = new WordRule(new GnWordDetector(), other);
  for (int i = 0; i < GnCodeUtil.KEYWORDS.length; i++) {
    wordRule.addWord(GnCodeUtil.KEYWORDS[i], keyword);
  }
  rules.add(wordRule);

  NumberRule numberRule = new NumberRule(numberToken);
  rules.add(numberRule);

  this.setDefaultReturnToken(other);
  return rules;
}
 
开发者ID:chromium,项目名称:eclipse-gn,代码行数:24,代码来源:GnCodeScanner.java

示例9: initScanner

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
private void initScanner() {
	IToken string = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.STRING_COLOR)));
	IToken value = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.VALUE_COLOR)));
	IToken defaultText = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.DEFAULT_COLOR)));
	IToken nullValue = new Token(new TextAttribute(getPreferenceColor(JsonPreferenceStore.NULL_COLOR)));

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

	rules.add(new MultiLineRule(":\"", "\"", value, '\\'));
	rules.add(new MultiLineRule("\"", "\"", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
	WordRule wordRule= new WordRule(new JsonWordDetector(), defaultText);
	wordRule.addWord("null", nullValue);
	rules.add(wordRule);
	rules.add(new WhitespaceRule(new JsonWhitespaceDetector()));

	IRule[] result= new IRule[rules.size()];
	rules.toArray(result);
	setRules(result);
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:20,代码来源:JsonScanner.java

示例10: sqlSyntaxRules

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
private WordRule sqlSyntaxRules() {

        // Define a word rule and add SQL keywords to it.
        WordRule wordRule = new WordRule(new WordDetector(), Token.WHITESPACE, true);
        for (String reservedWord : sqlSyntax.getReservedwords()) {
            wordRule.addWord(reservedWord, new Token(
                    getTextAttribute(prefs, SQLEditorStatementTypes.RESERVED_WORDS)));
        }
        // TODO render unreserved keywords in the same way with reserved
        // keywords, should let user decide via preference
        for (String unreservedWord : sqlSyntax.getUnreservedwords()) {
            wordRule.addWord(unreservedWord, new Token(
                    getTextAttribute(prefs, SQLEditorStatementTypes.UN_RESERVED_WORDS)));
        }

        // Add the SQL datatype names to the word rule.
        for (String datatype : sqlSyntax.getTypes()) {
            wordRule.addWord(datatype, new Token(
                    getTextAttribute(prefs, SQLEditorStatementTypes.TYPES)));
        }

        // Add the SQL function names to the word rule.
        for (String function : sqlSyntax.getFunctions()) {
            wordRule.addWord(function, new Token(
                    getTextAttribute(prefs, SQLEditorStatementTypes.FUNCTIONS)));
        }

        // Add the SQL constants to the word rule.
        for (String constant : sqlSyntax.getConstants()) {
            wordRule.addWord(constant, new Token(
                    getTextAttribute(prefs, SQLEditorStatementTypes.CONSTANTS)));
        }

        return wordRule;
    }
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:36,代码来源:SQLEditorSourceViewerConfiguration.java

示例11: EiffelCodeScanner

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
public EiffelCodeScanner(EiffelColorProvider provider) {
	IToken keyword = new Token(new TextAttribute(provider
			.getColor(EiffelColorProvider.KEYWORD)));
	IToken string = new Token(new TextAttribute(provider
			.getColor(EiffelColorProvider.STRING)));
	IToken comment = new Token(new TextAttribute(provider
			.getColor(EiffelColorProvider.SINGLE_LINE_COMMENT)));
	IToken other = new Token(new TextAttribute(provider
			.getColor(EiffelColorProvider.DEFAULT)));
	
	List<Object> rules = new ArrayList<>();
	
	//add rule for single line comments.
	rules.add(new EndOfLineRule("--", comment));
	
	// Add rule for strings and character constants.
	rules.add(new SingleLineRule("\"", "\"", string, '\\'));
	rules.add(new SingleLineRule("'", "'", string, '\\'));
	
	//Add generic whitespace rule.
	rules.add(new WhitespaceRule(new EiffelWhitespaceDetector()));
	
	//Add word rule for keywords.
	WordRule wordRule = new WordRule(new EiffelWordDetector(), other);
	for (int i = 0; i < eKeywords.length; i++) {
		wordRule.addWord(eKeywords[i], keyword);
		rules.add(wordRule);
		
		IRule[] result = new IRule[rules.size()];
		rules.toArray(result);
		setRules(result);
	}
}
 
开发者ID:Imhotup,项目名称:LibertyEiffel-Eclipse-Plugin,代码行数:34,代码来源:EiffelCodeScanner.java

示例12: EiffelCodeScanner

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
public EiffelCodeScanner(EiffelColorProvider provider) {
	IToken keyword = new Token(new TextAttribute(provider
			.getColor(EiffelColorProvider.KEYWORD)));
	IToken string = new Token(new TextAttribute(provider
			.getColor(EiffelColorProvider.STRING)));
	IToken comment = new Token(new TextAttribute(provider
			.getColor(EiffelColorProvider.SINGLE_LINE_COMMENT)));
	IToken other = new Token(new TextAttribute(provider
			.getColor(EiffelColorProvider.DEFAULT)));
	
	List<Object> rules = new ArrayList<>();
	
	//add rule for single line comments.
	rules.add(new EndOfLineRule("--", comment));
	
	// Add rule for strings and character constants.
	rules.add(new SingleLineRule("\"", "\"", string, '\\'));
	rules.add(new SingleLineRule("'", "'", string, '\\'));
	
	//Add generic whitespace rule.
	rules.add(new WhitespaceRule(new EiffelWhitespaceDetector()));
	
	//Add word rule for keywords.
	WordRule wordRule = new WordRule(new EiffelWordDetector(), other);
	for (int i = 0; i < Parser.KEYWORDS.length; i++) {
		wordRule.addWord(Parser.KEYWORDS[i], keyword);
		rules.add(wordRule);
		
		IRule[] result = new IRule[rules.size()];
		rules.toArray(result);
		setRules(result);
	}
}
 
开发者ID:Imhotup,项目名称:LibertyEiffel-Eclipse-Plugin,代码行数:34,代码来源:EiffelCodeScanner.java

示例13: InstructionsRuleScanner

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
public InstructionsRuleScanner(ColorProvider provider) {
	IToken stringToken = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PreferenceConstants.P_STRING_COLOR))));
	IToken commentToken = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PreferenceConstants.P_COMMENT_COLOR))));
	IToken instructToken = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PreferenceConstants.P_INSTRUCT_COLOR)), null, Font.ITALIC));
	IToken definitionsToken = new Token(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PreferenceConstants.P_DEF_COLOR)), null, Font.ITALIC));

	List<IRule> rules = Lists.newArrayList();
	// rule for Strings - may spanning multiple lines
	rules.add(new MultiLineRule("\"", "\"", stringToken));
	rules.add(new MultiLineRule("\'", "\'", stringToken));
	rules.add(new EndOfLineRule("#%", instructToken));
	// rule for comments - ended by a line delimiter
	rules.add(new EndOfLineRule("//", commentToken));

	WordRule wordRule = RuleFactory.buildRule(ImpexRules.KEYWORD, null);		
	// rule for instructions
	for (String word : Formatter.INSTRUCTION_CLASS_PROPOSALS) {
		wordRule.addWord(word, instructToken);
	}

	rules.add(wordRule);

	// rule for definitions
	wordRule = RuleFactory.buildRule(ImpexRules.VARIABLE, definitionsToken);
	rules.add(wordRule);
	IRule[] ruleArray = new IRule[rules.size()];
	setRules(rules.toArray(ruleArray));
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:29,代码来源:InstructionsRuleScanner.java

示例14: TLACodeScanner

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
/**
 * Construct the rules
 */
public TLACodeScanner()
{
    TLAColorProvider provider = TLAEditorActivator.getDefault().getTLAColorProvider();

    IToken keyword = new Token(new TextAttribute(provider.getColor(TLAColorProvider.TLA_KEYWORD), null, SWT.BOLD));
    IToken value = new Token(new TextAttribute(provider.getColor(TLAColorProvider.TLA_VALUE)));
    IToken other = new Token(new TextAttribute(provider.getColor(TLAColorProvider.TLA_DEFAULT)));

    List rules = new ArrayList();

    // Add generic whitespace rule.
    // rules.add(new WhitespaceRule(DocumentHelper.getDefaultWhitespaceDetector()));

    // Add word rule for standard words
    WordRule wordRule = new WordRule(DocumentHelper.getDefaultWordDetector(), other);
    
    // add values
    for (int i = 0; i < ITLAReserveredWords.ALL_VALUES_ARRAY.length; i++)
    {
        wordRule.addWord(ITLAReserveredWords.ALL_VALUES_ARRAY[i], value);
    }
    
    // add reserved words
    for (int i = 0; i < ITLAReserveredWords.ALL_WORDS_ARRAY.length; i++)
    {
        wordRule.addWord(ITLAReserveredWords.ALL_WORDS_ARRAY[i], keyword);
    }
    
    rules.add(wordRule);

    IRule[] result = new IRule[rules.size()];
    rules.toArray(result);
    setRules(result);
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:38,代码来源:TLACodeScanner.java

示例15: createRules

import org.eclipse.jface.text.rules.WordRule; //导入方法依赖的package包/类
@Override
protected List<IRule> createRules() {
	IToken keywordToken = getToken(Prefs.EDITOR_DOT_KEYWORD_COLOR);
	IToken attribsToken = getToken(Prefs.EDITOR_DOT_ATTRIBS_COLOR);
	IToken symbolToken = getToken(Prefs.EDITOR_DOT_SYMBOL_COLOR);
	IToken stringToken = getToken(Prefs.EDITOR_DOT_STRING_COLOR);
	IToken commentToken = getToken(Prefs.EDITOR_DOT_COMMENT_COLOR);
	IToken defaultToken = getToken(Prefs.EDITOR_DEFAULT_COLOR);

	WordRule wordRule = new WordRule(new DotWordDetector(), defaultToken, true);
	for (String keyword : keywords) {
		wordRule.addWord(keyword, keywordToken);
	}

	WordRule attribRule = new WordRule(new DotWordDetector(), defaultToken, true);
	for (String attrib : attribs) {
		wordRule.addWord(attrib, attribsToken);
	}

	WordRule symbolRule = new WordRule(new DotSymbolDetector(), defaultToken, true);
	for (String symbol : symbols) {
		symbolRule.addWord(symbol, symbolToken);
	}

	List<IRule> rules = new ArrayList<IRule>();
	rules.add(new MultiLineRule("/*", "*/", commentToken, '\\', true));
	rules.add(new SingleLineRule("//", null, commentToken, '\\', true));
	rules.add(new SingleLineRule("\"", "\"", stringToken, '\\', true));
	rules.add(wordRule);
	rules.add(attribRule);
	rules.add(symbolRule);
	rules.add(new WhitespaceRule(new WhitespaceDetector()));
	return rules;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:35,代码来源:ScannerDot.java


注:本文中的org.eclipse.jface.text.rules.WordRule.addWord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。