org.eclipse.jface.text.rules.IRule Java Examples
The following examples show how to use
org.eclipse.jface.text.rules.IRule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSSCodeScannerRuleBased.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #2
Source File: JSXScanner.java From typescript.java with MIT License | 6 votes |
@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; }
Example #3
Source File: DynamicRuleBasedScanner.java From LogViewer with Eclipse Public License 2.0 | 6 votes |
public IToken nextToken() { IToken token; tokenOffset = offset; column = UNDEFINED; Iterator<?> ruleIterator = rules.iterator(); while(ruleIterator.hasNext()) { IRule rule = (IRule)ruleIterator.next(); token = rule.evaluate(this); if(!token.isUndefined()) { return token; } if(ruleIterator.hasNext()) { offset = tokenOffset; } } if(rules.size() <= 0) { read(); } if (read() == EOF) { return Token.EOF; } else { unread(); return defaultToken; } }
Example #4
Source File: JSDocScanner.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * 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()])); }
Example #5
Source File: TexOptArgScanner.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * 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); }
Example #6
Source File: TexArgScanner.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * 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); }
Example #7
Source File: JavaCommentScanner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected List<IRule> createRules() { List<IRule> list= new ArrayList<IRule>(); Token defaultToken= getToken(fDefaultTokenProperty); List<WordMatcher> matchers= createMatchers(); if (matchers.size() > 0) { CombinedWordRule combinedWordRule= new CombinedWordRule(new AtJavaIdentifierDetector(), defaultToken); for (int i= 0, n= matchers.size(); i < n; i++) combinedWordRule.addWordMatcher(matchers.get(i)); list.add(combinedWordRule); } setDefaultReturnToken(defaultToken); return list; }
Example #8
Source File: PropertyValueScanner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@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; }
Example #9
Source File: CSSTokenScanner.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * createUnitRules * * @return */ protected List<IRule> createUnitRules() { List<IRule> rules = new ArrayList<IRule>(); // FIXME These are all really just numbers followed by measurements. Can't we modify scanner/parser to grab // number and then a measurement // XXX: The number and the units have to be connected without intermediate whitespace. Alternately, we could // make the parser changes as suggested but we would need to make sure the validators point out the error // condition rules.add(createUnitRule("em", CSSTokenType.EMS)); rules.add(createUnitRule("px|cm|mm|in|pt|pc", CSSTokenType.LENGTH)); rules.add(createUnitRule("%", CSSTokenType.PERCENTAGE)); rules.add(createUnitRule("deg|rad|grad", CSSTokenType.ANGLE)); rules.add(createUnitRule("ex", CSSTokenType.EXS)); rules.add(createUnitRule("k?[Hh]z", CSSTokenType.FREQUENCY)); rules.add(createUnitRule("m?s", CSSTokenType.TIME)); return rules; }
Example #10
Source File: XMLTextScanner.java From http4e with Apache License 2.0 | 6 votes |
public XMLTextScanner( ColorManager colorManager) { ESCAPED_CHAR = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.ESCAPED_CHAR))); CDATA_START = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA))); CDATA_END = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA))); CDATA_TEXT = new Token(new TextAttribute(colorManager.getColor(IXMLColorConstants.CDATA_TEXT))); IRule[] rules = new IRule[2]; // Add rule to pick up escaped chars // Add rule to pick up start of CDATA section rules[0] = new CDataRule(CDATA_START, true); // Add a rule to pick up end of CDATA sections rules[1] = new CDataRule(CDATA_END, false); setRules(rules); }
Example #11
Source File: SQLKeywordScanner.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * */ 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 )))); }
Example #12
Source File: JSScanner.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * 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 ); }
Example #13
Source File: InnerTagScanner.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 创建标记正文规则 * @return ; */ private IRule createInnerTagRule() { InnerTagRule wordRule = new InnerTagRule(new InnerTagDetector()); wordRule.addWord("[" + PlaceHolderEditModeBuilder.MIN + "-" + PlaceHolderEditModeBuilder.MAX + "]", tagContentToken); return wordRule; }
Example #14
Source File: InnerTagScanner.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
private void initialize(String foregroundKey, String backgroundKey) { updateToken(foregroundKey, backgroundKey); IRule[] rules = new IRule[3]; rules[0] = createTagStartIndexRule(); // 创建标记开始索引规则 rules[1] = createTagEndIndexRule(); // 创建标记结束索引规则 rules[2] = createTagContentRule(); // 创建标记正文规则 setRules(rules); }
Example #15
Source File: JavaDocScanner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected List<IRule> createRules() { List<IRule> list= new ArrayList<IRule>(); // Add rule for tags Token token= getToken(IJavaColorConstants.JAVADOC_TAG); list.add(new TagRule(token)); // Add rule for HTML comments WordRule wordRule= new WordRule(new HTMLCommentDetector(), token); wordRule.addWord("<!--", token); //$NON-NLS-1$ wordRule.addWord("--!>", token); //$NON-NLS-1$ list.add(wordRule); // Add rules for links token= getToken(IJavaColorConstants.JAVADOC_LINK); list.add(new MultiLineRule("{@link", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@value", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@inheritDoc", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ // Add rules for @code and @literals token= getToken(IJavaColorConstants.JAVADOC_DEFAULT); list.add(new MultiLineRule("{@code", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@literal", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ // Add generic whitespace rule token= getToken(IJavaColorConstants.JAVADOC_DEFAULT); list.add(new WhitespaceRule(new JavaWhitespaceDetector(), token)); list.addAll(super.createRules()); return list; }
Example #16
Source File: InnerTagScanner.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
private void initialize() { updateToken(); IRule[] rules = new IRule[1]; rules[0] = createInnerTagRule(); // 创建内部标记规则 setRules(rules); }
Example #17
Source File: InnerTagScanner.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 创建标记正文规则 * @return ; */ private IRule createTagContentRule() { InnerTagRule wordRule = new InnerTagRule(InnerTagRule.TYPE_TAG_Content, new TagContentDetector()); // "^_(x|bx|ex|ph|g|bpt|ept|ph|it|mrk|sub)_$" 匹配简单标记和完整标记 wordRule.addWord("^" + InnerTagUtil.INVISIBLE_CHAR + "((x|bx|ex|ph|g|bpt|ept|ph|it|mrk|sub)"+ "|(<(x|bx|ex|ph|bpt|ept|ph|it|mrk|sub)\\s*(\\w*\\s*=\\s*('|\")(.|\n)*('|\"))*>?(.|\n)*<?/(x|bx|ex|ph|bpt|ept|ph|it|mrk|sub)?>)"+ "|(<g(\\s*\\w*\\s*=\\s*('|\")(.|\n)*('|\"))*>)|</g>)" + InnerTagUtil.INVISIBLE_CHAR + "$", tagContentToken); return wordRule; }
Example #18
Source File: InnerTagScanner.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 创建标记开始索引规则 * @return ; */ private IRule createTagStartIndexRule() { InnerTagRule wordRule = new InnerTagRule(InnerTagRule.TYPE_TAG_START_INDEX, new TagStartIndexDetector()); wordRule.addWord("^((" + InnerTagUtil.INVISIBLE_CHAR + "\\d+)|(\\d+" + InnerTagUtil.INVISIBLE_CHAR + "))$", tagIndexToken); return wordRule; }
Example #19
Source File: InnerTagScanner.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 创建标记结束索引规则 * @return ; */ private IRule createTagEndIndexRule() { InnerTagRule wordRule = new InnerTagRule(InnerTagRule.TYPE_TAG_END_INDEX, new TagEndIndexDetector()); wordRule.addWord("^\\d+" + InnerTagUtil.INVISIBLE_CHAR + "$", tagIndexToken); return wordRule; }
Example #20
Source File: InnerTagScanner.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 创建标记开始索引规则 * @return ; */ private IRule createTagStartIndexRule() { InnerTagRule wordRule = new InnerTagRule(InnerTagRule.TYPE_TAG_START_INDEX, new TagStartIndexDetector()); wordRule.addWord("^((" + InnerTagUtil.INVISIBLE_CHAR + "\\d+)|(\\d+" + InnerTagUtil.INVISIBLE_CHAR + "))$", tagIndexToken); return wordRule; }
Example #21
Source File: AbstractLangScanner.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public AbstractLangScanner(TokenRegistry tokenRegistry) { this.tokenRegistry = assertNotNull(tokenRegistry); ArrayList2<IRule> arrayList2 = new ArrayList2<>(); initRules(arrayList2); setRules(arrayList2.toArray(IRule.class)); }
Example #22
Source File: InnerTagScanner.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private void initialize(String foregroundKey, String backgroundKey) { updateToken(foregroundKey, backgroundKey); IRule[] rules = new IRule[3]; rules[0] = createTagStartIndexRule(); // 创建标记开始索引规则 rules[1] = createTagEndIndexRule(); // 创建标记结束索引规则 rules[2] = createTagContentRule(); // 创建标记正文规则 setRules(rules); }
Example #23
Source File: InnerTagScanner.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 创建标记正文规则 * @return ; */ private IRule createInnerTagRule() { InnerTagRule wordRule = new InnerTagRule(new InnerTagDetector()); wordRule.addWord("[" + PlaceHolderEditModeBuilder.MIN + "-" + PlaceHolderEditModeBuilder.MAX + "]", tagContentToken); return wordRule; }
Example #24
Source File: InnerTagScanner.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private void initialize() { updateToken(); IRule[] rules = new IRule[1]; rules[0] = createInnerTagRule(); // 创建内部标记规则 setRules(rules); }
Example #25
Source File: HTMLTokenScanner.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void setInsideSpecialTag(boolean special) { List<IRule> rules = new ArrayList<IRule>(); rules.addAll(Arrays.asList(fRules)); if (special) { rules.remove(generalTagRule); } else { rules.add(generalTagRule); } setRules(rules.toArray(new IRule[rules.size()])); }
Example #26
Source File: AbstractJavaScanner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void initializeRules() { List<IRule> rules= createRules(); if (rules != null) { IRule[] result= new IRule[rules.size()]; rules.toArray(result); setRules(result); } }
Example #27
Source File: CompositeSourceViewerConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private ITokenScanner getStartEndTokenScanner() { if (startEndTokenScanner == null) { RuleBasedScanner ts = new RuleBasedScanner(); IToken seqToken = new Token(getStartEndTokenType()); List<IRule> rules = new ArrayList<IRule>(); for (String[] pair : getPartitionerSwitchStrategy().getSwitchTagPairs()) { rules.add(new SingleTagRule(pair[0], seqToken)); rules.add(new SingleTagRule(pair[1], seqToken)); } ts.setRules(rules.toArray(new IRule[rules.size()])); ts.setDefaultReturnToken(new Token("text")); //$NON-NLS-1$ startEndTokenScanner = ts; } return startEndTokenScanner; }
Example #28
Source File: CommentScanner.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected List<IRule> createRules() { List<IRule> rules = new ArrayList<IRule>(); WordRule wordRule = new WordRule(new WordDetector(), Token.UNDEFINED, !TaskTag.isCaseSensitive()); IToken taskToken = new Token(TASK_TAG_SCOPE); for (TaskTag tag : TaskTag.getTaskTags()) { wordRule.addWord(tag.getName(), taskToken); } rules.add(wordRule); return rules; }
Example #29
Source File: CommentScanner.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public CommentScanner(IToken defaultToken) { super(); setDefaultReturnToken(defaultToken); List<IRule> rules = createRules(); setRules(rules.toArray(new IRule[rules.size()])); }
Example #30
Source File: HCommentScanner.java From http4e with Apache License 2.0 | 5 votes |
public HCommentScanner() { // IToken comment = new Token(HPartitionScanner.COMMENT); setRules(new IRule[] { // new SingleLineRule("#", null, comment, '\\', true, true), // new WhitespaceRule(new WhitespaceDetector()) }); }