Search in sources :

Example 6 with PatternRule

use of org.eclipse.jface.text.rules.PatternRule in project netxms by netxms.

the class AgentConfigSourceViewerConfiguration method getPresentationReconciler.

/* (non-Javadoc)
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
	 */
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();
    RuleBasedScanner scanner = new RuleBasedScanner();
    scanner.setRules(codeRules);
    scanner.setDefaultReturnToken(AgentConfigTextAttributeProvider.getTextAttributeToken(AgentConfigTextAttributeProvider.DEFAULT));
    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
    dr = new DefaultDamagerRepairer(new SingleTokenScanner(AgentConfigTextAttributeProvider.getTextAttribute(AgentConfigTextAttributeProvider.COMMENT)));
    reconciler.setDamager(dr, AgentConfigDocument.CONTENT_COMMENTS);
    reconciler.setRepairer(dr, AgentConfigDocument.CONTENT_COMMENTS);
    dr = new DefaultDamagerRepairer(new SingleTokenScanner(AgentConfigTextAttributeProvider.getTextAttribute(AgentConfigTextAttributeProvider.SECTION)));
    reconciler.setDamager(dr, AgentConfigDocument.CONTENT_SECTION);
    reconciler.setRepairer(dr, AgentConfigDocument.CONTENT_SECTION);
    scanner = new RuleBasedScanner();
    // $NON-NLS-1$ //$NON-NLS-2$
    scanner.setRules(new IRule[] { new PatternRule("\"", "\n", AgentConfigTextAttributeProvider.getTextAttributeToken(AgentConfigTextAttributeProvider.ERROR), (char) 0, false) });
    scanner.setDefaultReturnToken(AgentConfigTextAttributeProvider.getTextAttributeToken(AgentConfigTextAttributeProvider.STRING));
    dr = new DefaultDamagerRepairer(scanner);
    reconciler.setDamager(dr, AgentConfigDocument.CONTENT_STRING);
    reconciler.setRepairer(dr, AgentConfigDocument.CONTENT_STRING);
    return reconciler;
}
Also used : PatternRule(org.eclipse.jface.text.rules.PatternRule) DefaultDamagerRepairer(org.eclipse.jface.text.rules.DefaultDamagerRepairer) PresentationReconciler(org.eclipse.jface.text.presentation.PresentationReconciler) IPresentationReconciler(org.eclipse.jface.text.presentation.IPresentationReconciler) RuleBasedScanner(org.eclipse.jface.text.rules.RuleBasedScanner)

Aggregations

PatternRule (org.eclipse.jface.text.rules.PatternRule)6 RuleBasedScanner (org.eclipse.jface.text.rules.RuleBasedScanner)6 Document (org.eclipse.jface.text.Document)4 IDocument (org.eclipse.jface.text.IDocument)4 TextAttribute (org.eclipse.jface.text.TextAttribute)4 IRule (org.eclipse.jface.text.rules.IRule)4 IToken (org.eclipse.jface.text.rules.IToken)4 Token (org.eclipse.jface.text.rules.Token)4 WordRule (org.eclipse.jface.text.rules.WordRule)4 IPresentationReconciler (org.eclipse.jface.text.presentation.IPresentationReconciler)2 PresentationReconciler (org.eclipse.jface.text.presentation.PresentationReconciler)2 DefaultDamagerRepairer (org.eclipse.jface.text.rules.DefaultDamagerRepairer)2 Test (org.junit.Test)2