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;
}
Aggregations