Search in sources :

Example 11 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project eclipse.platform.text by eclipse.

the class WordRuleTest method testBug175712_1.

// https://bugs.eclipse.org/bugs/show_bug.cgi?id=175712
@Test
public void testBug175712_1() throws Exception {
    IRule[] rules = new IRule[2];
    IToken stepToken = new Token(new TextAttribute(null, null, SWT.BOLD));
    PatternRule stepRule = new PatternRule("(((", ")", stepToken, (char) 0, false);
    stepRule.setColumnConstraint(-1);
    rules[1] = stepRule;
    IToken titleToken = new Token(new TextAttribute(null, null, SWT.BOLD));
    WordRule wordRule = new WordRule(new SimpleWordDetector());
    wordRule.addWord("((", titleToken);
    rules[0] = wordRule;
    IDocument document = new Document("((( \n((\n- Cheese\n- Wine");
    RuleBasedScanner scanner = new RuleBasedScanner();
    scanner.setRules(rules);
    scanner.setRange(document, 0, document.getLength());
    IToken defaultToken = new Token(this);
    scanner.setDefaultReturnToken(defaultToken);
    IToken token = scanner.nextToken();
    assertSame(defaultToken, token);
    token = scanner.nextToken();
    assertSame(defaultToken, token);
    token = scanner.nextToken();
    assertSame(defaultToken, token);
    token = scanner.nextToken();
    assertSame(titleToken, token);
}
Also used : IToken(org.eclipse.jface.text.rules.IToken) PatternRule(org.eclipse.jface.text.rules.PatternRule) TextAttribute(org.eclipse.jface.text.TextAttribute) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) WordRule(org.eclipse.jface.text.rules.WordRule) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) RuleBasedScanner(org.eclipse.jface.text.rules.RuleBasedScanner) IRule(org.eclipse.jface.text.rules.IRule) IDocument(org.eclipse.jface.text.IDocument) Test(org.junit.Test)

Example 12 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project dbeaver by serge-rider.

the class XMLConfiguration method getPresentationReconciler.

@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();
    reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getXMLTagScanner());
    reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
    reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
    dr = new DefaultDamagerRepairer(getXMLScanner());
    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
    NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(COLOR_XML_COMMENT)));
    reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
    reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
    return reconciler;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) DefaultDamagerRepairer(org.eclipse.jface.text.rules.DefaultDamagerRepairer) PresentationReconciler(org.eclipse.jface.text.presentation.PresentationReconciler) IPresentationReconciler(org.eclipse.jface.text.presentation.IPresentationReconciler)

Example 13 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project dbeaver by serge-rider.

the class XMLConfiguration method getXMLTagScanner.

XMLTagScanner getXMLTagScanner() {
    XMLTagScanner tagScanner = new XMLTagScanner(colorManager);
    tagScanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(COLOR_TAG))));
    return tagScanner;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) Token(org.eclipse.jface.text.rules.Token)

Example 14 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project cubrid-manager by CUBRID.

the class PropConfiguration method getPropertiesCommentScanner.

/**
	 * Retrieves the XML Tag Scanner.
	 * 
	 * @return tagScanner
	 */
protected PropPartitionScanner getPropertiesCommentScanner() {
    if (commentScanner == null) {
        commentScanner = new PropPartitionScanner();
        commentScanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(IPropColorConstants.PROP_COMMENT))));
    }
    return commentScanner;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) Token(org.eclipse.jface.text.rules.Token)

Example 15 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project cubrid-manager by CUBRID.

the class PropConfiguration method getPresentationReconciler.

/**
	 * Retrieves the Presentation Reconciler
	 * 
	 * @param sourceViewer ISourceViewer
	 * @return object of IPresentationReconciler
	 */
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();
    NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(IPropColorConstants.PROP_COMMENT)));
    reconciler.setDamager(ndr, PropPartitionScanner.PROPERTIES_COMMENT);
    reconciler.setRepairer(ndr, PropPartitionScanner.PROPERTIES_COMMENT);
    ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(IPropColorConstants.DEFAULT)));
    reconciler.setDamager(ndr, PropPartitionScanner.PROPERTIES_CONTENT);
    reconciler.setRepairer(ndr, PropPartitionScanner.PROPERTIES_CONTENT);
    ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(IPropColorConstants.TAG)));
    reconciler.setDamager(ndr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(ndr, IDocument.DEFAULT_CONTENT_TYPE);
    return reconciler;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) PresentationReconciler(org.eclipse.jface.text.presentation.PresentationReconciler) IPresentationReconciler(org.eclipse.jface.text.presentation.IPresentationReconciler) NonRuleBasedDamagerRepairer(com.cubrid.tool.editor.NonRuleBasedDamagerRepairer)

Aggregations

TextAttribute (org.eclipse.jface.text.TextAttribute)21 Token (org.eclipse.jface.text.rules.Token)10 IPresentationReconciler (org.eclipse.jface.text.presentation.IPresentationReconciler)5 PresentationReconciler (org.eclipse.jface.text.presentation.PresentationReconciler)5 DefaultDamagerRepairer (org.eclipse.jface.text.rules.DefaultDamagerRepairer)4 IRule (org.eclipse.jface.text.rules.IRule)3 IToken (org.eclipse.jface.text.rules.IToken)3 RGB (org.eclipse.swt.graphics.RGB)3 NonRuleBasedDamagerRepairer (com.cubrid.tool.editor.NonRuleBasedDamagerRepairer)2 Document (org.eclipse.jface.text.Document)2 IDocument (org.eclipse.jface.text.IDocument)2 PatternRule (org.eclipse.jface.text.rules.PatternRule)2 RuleBasedScanner (org.eclipse.jface.text.rules.RuleBasedScanner)2 WordRule (org.eclipse.jface.text.rules.WordRule)2 Test (org.junit.Test)2 XMLTagDamageRepairScanner (com.cubrid.tool.editor.xml.scanner.XMLTagDamageRepairScanner)1 XMLTitleScanner (com.cubrid.tool.editor.xml.scanner.XMLTitleScanner)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 AnchorWordDetector (org.dadacoalition.yedit.editor.scanner.AnchorWordDetector)1