org.eclipse.jface.text.rules.DefaultDamagerRepairer Java Examples

The following examples show how to use org.eclipse.jface.text.rules.DefaultDamagerRepairer. 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: DSLSourceViewerConfiguration.java    From dsl-compiler-client with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
	
	DSLPresentationReconciler reconciler = new DSLPresentationReconciler(sourceViewer);
	ITokenScanner scanner = new TokenScanner();
	String contentType = IDocument.DEFAULT_CONTENT_TYPE;
	// TODO preference store
	long delay = 300;
	DefaultDamagerRepairer dr = new DelayedDamagerRepairer(scanner, reconciler, delay);
	reconciler.setDamager(dr, contentType);
	reconciler.setRepairer(dr, contentType);
	
	// IResource file = this.extractResource(this.editor);
	
	return reconciler;
}
 
Example #2
Source File: JSSourceViewerConfiguration.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see SourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
 */
public IPresentationReconciler getPresentationReconciler(
		ISourceViewer sourceViewer )
{
	PresentationReconciler reconciler = new PresentationReconciler( );

	DefaultDamagerRepairer dr = new DefaultDamagerRepairer( getDefaultScanner( ) );
	reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE );
	reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE );

	NonRuleBasedDamagerRepairer commentRepairer = new NonRuleBasedDamagerRepairer( UIUtil.getAttributeFor( ReportPlugin.EXPRESSION_COMMENT_COLOR_PREFERENCE ) );
	reconciler.setDamager( commentRepairer, JSPartitionScanner.JS_COMMENT );
	reconciler.setRepairer( commentRepairer, JSPartitionScanner.JS_COMMENT );

	NonRuleBasedDamagerRepairer stringRepairer = new NonRuleBasedDamagerRepairer( UIUtil.getAttributeFor( ReportPlugin.EXPRESSION_STRING_COLOR_PREFERENCE ) );
	reconciler.setDamager( stringRepairer, JSPartitionScanner.JS_STRING );
	reconciler.setRepairer( stringRepairer, JSPartitionScanner.JS_STRING );

	NonRuleBasedDamagerRepairer keywordRepairer = new NonRuleBasedDamagerRepairer( UIUtil.getAttributeFor( ReportPlugin.EXPRESSION_KEYWORD_COLOR_PREFERENCE ) );
	reconciler.setDamager( keywordRepairer, JSPartitionScanner.JS_KEYWORD );
	reconciler.setRepairer( keywordRepairer, JSPartitionScanner.JS_KEYWORD );

	return reconciler;
}
 
Example #3
Source File: SQLSourceViewerConfiguration.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public IPresentationReconciler getPresentationReconciler(
		ISourceViewer sourceViewer )
{
	PresentationReconciler reconciler = new PresentationReconciler( );
	
	NonRuleBasedDamagerRepairer dr = new NonRuleBasedDamagerRepairer( quoteString );
	reconciler.setDamager( dr, SQLPartitionScanner.QUOTE_STRING );
	reconciler.setRepairer( dr, SQLPartitionScanner.QUOTE_STRING );
	
	
	dr = new NonRuleBasedDamagerRepairer( comment );
	reconciler.setDamager( dr, SQLPartitionScanner.COMMENT );
	reconciler.setRepairer( dr, SQLPartitionScanner.COMMENT );
	
	
	DefaultDamagerRepairer  ddr = new DefaultDamagerRepairer( new SQLKeywordScanner( ) );
	reconciler.setDamager( ddr, IDocument.DEFAULT_CONTENT_TYPE );
	reconciler.setRepairer( ddr, IDocument.DEFAULT_CONTENT_TYPE );

	return reconciler;
}
 
Example #4
Source File: TextUMLSourceViewerConfiguration.java    From textuml with Eclipse Public License 1.0 6 votes vote down vote up
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    final PresentationReconciler reconciler = new PresentationReconciler();
    reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    final SyntaxHighlighter scanner = new SyntaxHighlighter(
            com.abstratt.mdd.frontend.textuml.core.TextUMLConstants.KEYWORDS);
    final DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
    reconciler.setDamager(dr, ContentTypes.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, ContentTypes.DEFAULT_CONTENT_TYPE);

    // fix bug 2127735 --multiline comment is broken
    final ITokenScanner commentScanner = scanner.getCommentScanner();
    final DefaultDamagerRepairer commentDamagerRepairer = new DefaultDamagerRepairer(commentScanner);
    reconciler.setDamager(commentDamagerRepairer, ContentTypes.COMMENT_CONTENT_TYPE);
    reconciler.setRepairer(commentDamagerRepairer, ContentTypes.COMMENT_CONTENT_TYPE);

    return reconciler;
}
 
Example #5
Source File: DTDSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer) {
	NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(getToken("#text")); //$NON-NLS-1$
	reconciler.setDamager(ndr, IDocument.DEFAULT_CONTENT_TYPE);
	reconciler.setRepairer(ndr, IDocument.DEFAULT_CONTENT_TYPE);

	reconciler.setDamager(ndr, DEFAULT);
	reconciler.setRepairer(ndr, DEFAULT);

	DefaultDamagerRepairer dr = new ThemeingDamagerRepairer(getPIScanner());
	reconciler.setDamager(dr, PI);
	reconciler.setRepairer(dr, PI);

	reconciler.setDamager(dr, PROLOG);
	reconciler.setRepairer(dr, PROLOG);

	dr = new ThemeingDamagerRepairer(getDTDTagScanner());
	reconciler.setDamager(dr, TAG);
	reconciler.setRepairer(dr, TAG);

	reconciler.setDamager(dr, SECTION);
	reconciler.setRepairer(dr, SECTION);

	dr = new ThemeingDamagerRepairer(getCommentScanner());
	reconciler.setDamager(dr, COMMENT);
	reconciler.setRepairer(dr, COMMENT);
}
 
Example #6
Source File: CSSSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer)
{
	DefaultDamagerRepairer dr = new ThemeingDamagerRepairer(new CSSCodeScannerFlex());
	reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
	reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

	reconciler.setDamager(dr, DEFAULT);
	reconciler.setRepairer(dr, DEFAULT);

	dr = new ThemeingDamagerRepairer(getCommentScanner());
	reconciler.setDamager(dr, MULTILINE_COMMENT);
	reconciler.setRepairer(dr, MULTILINE_COMMENT);

	dr = new ThemeingDamagerRepairer(getStringScanner());
	reconciler.setDamager(dr, STRING_DOUBLE);
	reconciler.setRepairer(dr, STRING_DOUBLE);

	dr = new ThemeingDamagerRepairer(getStringScanner());
	reconciler.setDamager(dr, STRING_SINGLE);
	reconciler.setRepairer(dr, STRING_SINGLE);
}
 
Example #7
Source File: AbstractLangBasicSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer) {
	// Must be called from UI thread
	assertTrue(Display.getCurrent() != null);
	
	// Create a token registry for given sourceViewer
	TokenRegistry tokenRegistry = new TokenRegistry(colorManager, stylingPrefs) {
		@Override
		protected void handleTokenModified(Token token) {
			sourceViewer.invalidateTextPresentation();
		}
	};
	addConfigurationScopedOwned(sourceViewer, tokenRegistry);
	
	ArrayList2<AbstractLangScanner> scanners = new ArrayList2<>();
	
	for(LangPartitionTypes partitionType : getPartitionTypes()) {
		
		String contentType = partitionType.getId();
		AbstractLangScanner scanner = createScannerFor(Display.getCurrent(), partitionType, tokenRegistry);
		scanners.add(scanner);
		
		DefaultDamagerRepairer dr = getDamagerRepairer(scanner, contentType);
		reconciler.setDamager(dr, contentType);
		reconciler.setRepairer(dr, contentType);
	}
	
}
 
Example #8
Source File: AbstractSimpleLangSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer) {
	// Must be called from UI thread
	assertTrue(Display.getCurrent() != null);
	
	// Create a token registry for given sourceViewer
	TokenRegistry tokenRegistry = new TokenRegistry(colorManager, stylingPrefs) {
		@Override
		protected void handleTokenModified(Token token) {
			sourceViewer.invalidateTextPresentation();
		}
	};
	addConfigurationScopedOwned(sourceViewer, tokenRegistry);
	
	ArrayList2<AbstractLangScanner> scanners = new ArrayList2<>();
	
	for(LangPartitionTypes partitionType : getPartitionTypes()) {
		
		String contentType = partitionType.getId();
		AbstractLangScanner scanner = createScannerFor(Display.getCurrent(), partitionType, tokenRegistry);
		scanners.add(scanner);
		
		DefaultDamagerRepairer dr = getDamagerRepairer(scanner, contentType);
		reconciler.setDamager(dr, contentType);
		reconciler.setRepairer(dr, contentType);
	}
	
}
 
Example #9
Source File: CompositeSourceViewerConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
	PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);

	DefaultDamagerRepairer dr = new ThemeingDamagerRepairer(getStartEndTokenScanner());
	reconciler.setDamager(dr, CompositePartitionScanner.START_SWITCH_TAG);
	reconciler.setRepairer(dr, CompositePartitionScanner.START_SWITCH_TAG);
	reconciler.setDamager(dr, CompositePartitionScanner.END_SWITCH_TAG);
	reconciler.setRepairer(dr, CompositePartitionScanner.END_SWITCH_TAG);

	defaultSourceViewerConfiguration.setupPresentationReconciler(reconciler, sourceViewer);
	primarySourceViewerConfiguration.setupPresentationReconciler(reconciler, sourceViewer);

	return reconciler;
}
 
Example #10
Source File: XtendSourceViewerConfiguration.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
	XtextPresentationReconciler reconciler = (XtextPresentationReconciler) super
			.getPresentationReconciler(sourceViewer);
	IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
	IColorManager colorManager = JavaPlugin.getDefault().getJavaTextTools().getColorManager();
	JavaDocScanner javaDocScanner = new JavaDocScanner(colorManager, store, null);
	DefaultDamagerRepairer dr = new DefaultDamagerRepairer(javaDocScanner);
	reconciler.setRepairer(dr, TokenTypeToPartitionMapper.JAVA_DOC_PARTITION);
	reconciler.setDamager(dr, TokenTypeToPartitionMapper.JAVA_DOC_PARTITION);
	return reconciler;
}
 
Example #11
Source File: JSSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer)
{
	DefaultDamagerRepairer dr = new ThemeingDamagerRepairer(getCodeScanner());
	reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
	reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

	reconciler.setDamager(dr, DEFAULT);
	reconciler.setRepairer(dr, DEFAULT);

	dr = new ThemeingDamagerRepairer(getJSDocScanner());
	reconciler.setDamager(dr, JS_DOC);
	reconciler.setRepairer(dr, JS_DOC);

	dr = new ThemeingDamagerRepairer(getMultiLineCommentScanner());
	reconciler.setDamager(dr, JS_MULTILINE_COMMENT);
	reconciler.setRepairer(dr, JS_MULTILINE_COMMENT);

	dr = new ThemeingDamagerRepairer(getSingleQuotedStringScanner());
	reconciler.setDamager(dr, STRING_SINGLE);
	reconciler.setRepairer(dr, STRING_SINGLE);

	dr = new ThemeingDamagerRepairer(getDoubleQuotedStringScanner());
	reconciler.setDamager(dr, STRING_DOUBLE);
	reconciler.setRepairer(dr, STRING_DOUBLE);

	dr = new ThemeingDamagerRepairer(getSingleLineCommentScanner());
	reconciler.setDamager(dr, JS_SINGLELINE_COMMENT);
	reconciler.setRepairer(dr, JS_SINGLELINE_COMMENT);

	dr = new ThemeingDamagerRepairer(getRegexpScanner());
	reconciler.setDamager(dr, JS_REGEXP);
	reconciler.setRepairer(dr, JS_REGEXP);
}
 
Example #12
Source File: XMLSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer)
{
	DTDSourceConfiguration.getDefault().setupPresentationReconciler(reconciler, sourceViewer);

	DefaultDamagerRepairer dr = new ThemeingDamagerRepairer(getXMLScanner());
	reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
	reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

	reconciler.setDamager(dr, DEFAULT);
	reconciler.setRepairer(dr, DEFAULT);

	dr = new ThemeingDamagerRepairer(getPreProcessorScanner());
	reconciler.setDamager(dr, PRE_PROCESSOR);
	reconciler.setRepairer(dr, PRE_PROCESSOR);

	dr = new ThemeingDamagerRepairer(getCDATAScanner());
	reconciler.setDamager(dr, CDATA);
	reconciler.setRepairer(dr, CDATA);

	dr = new ThemeingDamagerRepairer(getXMLTagScanner());
	reconciler.setDamager(dr, TAG);
	reconciler.setRepairer(dr, TAG);

	dr = new ThemeingDamagerRepairer(getCommentScanner());
	reconciler.setDamager(dr, COMMENT);
	reconciler.setRepairer(dr, COMMENT);
}
 
Example #13
Source File: SVGSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer)
{
	JSSourceConfiguration.getDefault().setupPresentationReconciler(reconciler, sourceViewer);
	CSSSourceConfiguration.getDefault().setupPresentationReconciler(reconciler, sourceViewer);

	DefaultDamagerRepairer dr = new ThemeingDamagerRepairer(getXMLScanner());
	reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
	reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
	reconciler.setDamager(dr, DEFAULT);
	reconciler.setRepairer(dr, DEFAULT);

	DefaultDamagerRepairer preprocessorScanner = new ThemeingDamagerRepairer(getPreProcessorScanner());
	reconciler.setDamager(preprocessorScanner, PRE_PROCESSOR);
	reconciler.setRepairer(preprocessorScanner, PRE_PROCESSOR);

	DefaultDamagerRepairer cdataScanner = new ThemeingDamagerRepairer(getCDATAScanner());
	reconciler.setDamager(cdataScanner, CDATA);
	reconciler.setRepairer(cdataScanner, CDATA);

	DefaultDamagerRepairer tagScanner = new ThemeingDamagerRepairer(getXMLTagScanner());
	reconciler.setDamager(tagScanner, SCRIPT);
	reconciler.setRepairer(tagScanner, SCRIPT);
	reconciler.setDamager(tagScanner, STYLE);
	reconciler.setRepairer(tagScanner, STYLE);
	reconciler.setDamager(tagScanner, TAG);
	reconciler.setRepairer(tagScanner, TAG);

	DefaultDamagerRepairer commentScanner = new ThemeingDamagerRepairer(getCommentScanner());
	reconciler.setDamager(commentScanner, XMLSourceConfiguration.COMMENT);
	reconciler.setRepairer(commentScanner, XMLSourceConfiguration.COMMENT);
}
 
Example #14
Source File: CSVTextSourceViewerConfiguration.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IPresentationReconciler getPresentationReconciler(
        ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();
    /*
     * Reconciler configuration
     */
    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(new CSVTokenScanner(m_delimiter));
    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
    return reconciler;
}
 
Example #15
Source File: GWTSourceViewerConfiguration.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IPresentationReconciler getPresentationReconciler(
    ISourceViewer sourceViewer) {
  PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);

  DefaultDamagerRepairer dr = new DefaultDamagerRepairer(jsniScanner);
  reconciler.setDamager(dr, GWTPartitions.JSNI_METHOD);
  reconciler.setRepairer(dr, GWTPartitions.JSNI_METHOD);

  return reconciler;
}
 
Example #16
Source File: TypeScriptSourceViewerConfiguration.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
	if (preferenceStore.getBoolean(TypeScriptUIPreferenceConstants.USE_TEXMATE_FOR_SYNTAX_COLORING)) {
		// Advanced Syntax coloration with TextMate
		return new TMPresentationReconciler();
	}
	// Use classic Eclipse ITokenScaner.
	PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);
	DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getJSXScanner());
	reconciler.setDamager(dr, IJSXPartitions.JSX);
	reconciler.setRepairer(dr, IJSXPartitions.JSX);

	return reconciler;
}
 
Example #17
Source File: ObligationSourceViewerConfiguration.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * This registers one damager repairer for all content in the source viewer.
 * The damager-repairer scans the content for TLA keywords and sets them to the
 * same color used in the tla editor.
 */
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
{
    PresentationReconciler reconciler = new PresentationReconciler();

    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(TLAEditorActivator.getDefault().getTLACodeScanner());
    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

    return reconciler;
}
 
Example #18
Source File: AbstractLangBasicSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("unused")
protected DefaultDamagerRepairer getDamagerRepairer(AbstractLangScanner scanner, String contentType) {
	return new DefaultDamagerRepairer(scanner);
}
 
Example #19
Source File: AbstractSimpleLangSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("unused")
protected DefaultDamagerRepairer getDamagerRepairer(AbstractLangScanner scanner, String contentType) {
	return new DefaultDamagerRepairer(scanner);
}
 
Example #20
Source File: HTMLSourceConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void setupPresentationReconciler(PresentationReconciler reconciler, ISourceViewer sourceViewer)
{
	JSSourceConfiguration.getDefault().setupPresentationReconciler(reconciler, sourceViewer);
	CSSSourceConfiguration.getDefault().setupPresentationReconciler(reconciler, sourceViewer);
	SVGSourceConfiguration.getDefault().setupPresentationReconciler(reconciler, sourceViewer);

	DefaultDamagerRepairer dr = new ThemeingDamagerRepairer(getHTMLScanner());
	reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
	reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

	reconciler.setDamager(dr, DEFAULT);
	reconciler.setRepairer(dr, DEFAULT);

	dr = new ThemeingDamagerRepairer(getHTMLTagScanner());
	reconciler.setDamager(dr, HTMLSourceConfiguration.HTML_SCRIPT);
	reconciler.setRepairer(dr, HTMLSourceConfiguration.HTML_SCRIPT);

	reconciler.setDamager(dr, HTMLSourceConfiguration.HTML_STYLE);
	reconciler.setRepairer(dr, HTMLSourceConfiguration.HTML_STYLE);

	reconciler.setDamager(dr, HTMLSourceConfiguration.HTML_SVG);
	reconciler.setRepairer(dr, HTMLSourceConfiguration.HTML_SVG);

	reconciler.setDamager(dr, HTMLSourceConfiguration.HTML_TAG);
	reconciler.setRepairer(dr, HTMLSourceConfiguration.HTML_TAG);

	reconciler.setDamager(dr, HTMLSourceConfiguration.HTML_TAG_CLOSE);
	reconciler.setRepairer(dr, HTMLSourceConfiguration.HTML_TAG_CLOSE);

	dr = new ThemeingDamagerRepairer(getHTMLCommentScanner());
	reconciler.setDamager(dr, HTMLSourceConfiguration.HTML_COMMENT);
	reconciler.setRepairer(dr, HTMLSourceConfiguration.HTML_COMMENT);

	dr = new ThemeingDamagerRepairer(getDoctypeScanner());
	reconciler.setDamager(dr, HTMLSourceConfiguration.HTML_DOCTYPE);
	reconciler.setRepairer(dr, HTMLSourceConfiguration.HTML_DOCTYPE);

	dr = new ThemeingDamagerRepairer(getCDATAScanner());
	reconciler.setDamager(dr, CDATA);
	reconciler.setRepairer(dr, CDATA);
}