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


Java WordRule类代码示例

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


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

示例1: TexArgScanner

import org.eclipse.jface.text.rules.WordRule; //导入依赖的package包/类
/**
 * A default constructor.
 * @param manager
 */
public TexArgScanner(ColorManager manager) {
    IToken commentToken = new Token(new TextAttribute(manager
            .getColor(ColorManager.COMMENT),
            null,
            manager.getStyle(ColorManager.COMMENT_STYLE)));

    //Commands are colored in argument color with command styles 
    IToken commandToken = new Token(
            new TextAttribute(
                    manager.getColor(ColorManager.CURLY_BRACKETS),
                    null,
                    manager.getStyle(ColorManager.COMMAND_STYLE)));

    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new EndOfLineRule("%", commentToken, '\\'));
    rules.add(new WhitespaceRule(new WhitespaceDetector()));
    rules.add(new WordRule(new TexWord(), commandToken));

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

示例2: TexOptArgScanner

import org.eclipse.jface.text.rules.WordRule; //导入依赖的package包/类
/**
 * A default constructor.
 * @param manager
 */
public TexOptArgScanner(ColorManager manager) {
    IToken commentToken = new Token(new TextAttribute(manager
            .getColor(ColorManager.COMMENT),
            null,
            manager.getStyle(ColorManager.COMMENT_STYLE)));

    //Commands are colored in argument color with command styles 
    IToken commandToken = new Token(
            new TextAttribute(
                    manager.getColor(ColorManager.SQUARE_BRACKETS),
                    null,
                    manager.getStyle(ColorManager.COMMAND_STYLE)));

    List<IRule> rules = new ArrayList<IRule>();
    rules.add(new EndOfLineRule("%", commentToken, '\\'));
    rules.add(new WhitespaceRule(new WhitespaceDetector()));
    rules.add(new WordRule(new TexWord(), commandToken));

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

示例3: buildRule

import org.eclipse.jface.text.rules.WordRule; //导入依赖的package包/类
public static WordRule buildRule(ImpexRules ruleType, IToken token) {
	WordRule result = null;
	switch (ruleType) {
	case KEYWORD:
		result = buildKeywordRule(token);
		break;
	case VARIABLE:
		result = buildVariableRule('$', token);
		break;
	case REFERENCE:
		result = buildVariableRule('&', token);
		break;
	case SEMICOLON:
		result = buildCharRule(';', token);
		break;
	case COMMA:
		result = buildCharRule(',', token);
		break;
	default:
		result = null;
		break;
	}
	return result;
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:25,代码来源:RuleFactory.java

示例4: 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

示例5: createRules

import org.eclipse.jface.text.rules.WordRule; //导入依赖的package包/类
@Override
protected List<IRule> createRules() {
	IToken keywordToken = getToken(Prefs.EDITOR_MATH_KEYWORD_COLOR);
	IToken symbolToken = getToken(Prefs.EDITOR_MATH_SYMBOL_COLOR);
	IToken commentToken = getToken(Prefs.EDITOR_MATH_COMMENT_COLOR);
	// IToken defaultToken = getToken(Prefs.EDITOR_DEFAULT_COLOR);

	WordRule wordRule = new WordRule(new MathWordDetector(), keywordToken, true);
	WordRule symbolRule = new WordRule(new MathSymbolDetector(), symbolToken, true);

	List<IRule> rules = new ArrayList<IRule>();
	rules.add(wordRule);
	rules.add(symbolRule);
	rules.add(new EndOfLineRule("%", commentToken));
	rules.add(new WhitespaceRule(new WhitespaceDetector()));
	return rules;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:18,代码来源:ScannerMath.java

示例6: createRules

import org.eclipse.jface.text.rules.WordRule; //导入依赖的package包/类
@Override
protected List<IRule> createRules() {
	List<IRule> rules = new ArrayList<IRule>();

	Token tagBorder = getToken(IJSXColorConstants.TAG_BORDER);
	Token tagName = getToken(IJSXColorConstants.TAG_NAME);
	Token tagAttributeName = getToken(IJSXColorConstants.TAG_ATTRIBUTE_NAME);
	Token tagAttributeEquals = getToken(IJSXColorConstants.TAG_ATTRIBUTE_EQUALS);
	Token tagAttributeValue = getToken(IJSXColorConstants.TAG_ATTRIBUTE_VALUE);

	rules.add(new SingleLineRule("\"", "\"", tagAttributeValue, '\\'));
	rules.add(new SingleLineRule("'", "'", tagAttributeValue, '\\'));
	rules.add(new SingleLineRule("{", "}", tagAttributeValue, '\\'));
	rules.add(new JSXTagRule(tagName, tagBorder));
	rules.add(new WordRule(new NameDetector(), tagAttributeName));

	// setDefaultReturnToken(token);
	return rules;
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:20,代码来源:JSXScanner.java

示例7: 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

示例8: 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

示例9: XMLTokenScanner

import org.eclipse.jface.text.rules.WordRule; //导入依赖的package包/类
/**
 * XMLTokenScanner
 */
public XMLTokenScanner()
{
	List<IRule> rules = new ArrayList<IRule>();

	rules.add(new WhitespaceRule(new WhitespaceDetector()));
	rules.add(new MultiLineRule("<!--", "-->", createToken(XMLTokenType.COMMENT))); //$NON-NLS-1$ //$NON-NLS-2$
	rules.add(new DocTypeRule(createToken(XMLTokenType.DOCTYPE), false));
	rules.add(new MultiLineRule("<![CDATA[", "]]>", createToken(XMLTokenType.CDATA))); //$NON-NLS-1$ //$NON-NLS-2$
	rules.add(new TagRule("?xml", createToken(XMLTokenType.DECLARATION))); //$NON-NLS-1$
	rules.add(new TagRule("/", createToken(XMLTokenType.END_TAG))); //$NON-NLS-1$
	rules.add(new TagRule(createToken(XMLTokenType.START_TAG)));

	// text
	IToken token = createToken(XMLTokenType.TEXT);
	rules.add(new WordRule(new WordDetector(), token));

	setRules(rules.toArray(new IRule[rules.size()]));
	setDefaultReturnToken(token);
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:23,代码来源:XMLTokenScanner.java

示例10: 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

示例11: 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

示例12: createRules

import org.eclipse.jface.text.rules.WordRule; //导入依赖的package包/类
@Override
protected List<IRule> createRules() {
	setDefaultReturnToken(getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_VALUE));
	List<IRule> rules= new ArrayList<IRule>();

	// Add rule for arguments.
	IToken token= getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_ARGUMENT);
	rules.add(new ArgumentRule(token));

	// Add word rule for assignment operator.
	token= getToken(PreferenceConstants.PROPERTIES_FILE_COLORING_ASSIGNMENT);
	WordRule wordRule= new WordRule(new AssignmentDetector(), token);
	rules.add(wordRule);

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

	return rules;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:PropertyValueScanner.java

示例13: 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

示例14: 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

示例15: 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


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