Search in sources :

Example 1 with MarkupMonoReconciler

use of org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler in project mylyn.docs by eclipse.

the class MarkupEditor method setMarkupLanguage.

public void setMarkupLanguage(MarkupLanguage markupLanguage, boolean persistSetting) {
    if (markupLanguage instanceof AbstractMarkupLanguage) {
        ((AbstractMarkupLanguage) markupLanguage).setEnableMacros(false);
    }
    ((MarkupDocumentProvider) getDocumentProvider()).setMarkupLanguage(markupLanguage);
    IDocument document = getDocumentProvider().getDocument(getEditorInput());
    IDocumentPartitioner partitioner = document.getDocumentPartitioner();
    if (partitioner instanceof FastMarkupPartitioner) {
        final FastMarkupPartitioner fastMarkupPartitioner = (FastMarkupPartitioner) partitioner;
        fastMarkupPartitioner.setMarkupLanguage(markupLanguage);
    }
    sourceViewerConfiguration.setMarkupLanguage(markupLanguage);
    if (getSourceViewer() != null) {
        getSourceViewer().invalidateTextPresentation();
    }
    outlineDirty = true;
    scheduleOutlineUpdate();
    updateSourceTabLabel();
    if (viewer != null) {
        viewer.getTextWidget().setData(MarkupLanguage.class.getName(), getMarkupLanguage());
    }
    if (persistSetting && markupLanguage != null) {
        storeMarkupLanguagePreference(markupLanguage);
    }
    if (persistSetting) {
        ISourceViewer sourceViewer = getSourceViewer();
        if (sourceViewer instanceof MarkupProjectionViewer) {
            IReconciler reconciler = ((MarkupProjectionViewer) sourceViewer).getReconciler();
            if (reconciler instanceof MarkupMonoReconciler) {
                ((MarkupMonoReconciler) reconciler).forceReconciling();
            }
        }
    }
}
Also used : FastMarkupPartitioner(org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner) IReconciler(org.eclipse.jface.text.reconciler.IReconciler) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) MarkupMonoReconciler(org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) MarkupDocumentProvider(org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.MarkupDocumentProvider) IDocument(org.eclipse.jface.text.IDocument)

Example 2 with MarkupMonoReconciler

use of org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler in project mylyn.docs by eclipse.

the class MarkupSourceViewerConfiguration method getReconciler.

@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
    IReconcilingStrategy strategy;
    {
        if (markupValidationReconcilingStrategy == null) {
            markupValidationReconcilingStrategy = new MarkupValidationReconcilingStrategy(sourceViewer);
            markupValidationReconcilingStrategy.setMarkupLanguage(markupLanguage);
            markupValidationReconcilingStrategy.setResource(file);
        }
        IReconciler reconciler = super.getReconciler(sourceViewer);
        if (reconciler != null) {
            MultiReconcilingStrategy multiStrategy = new MultiReconcilingStrategy();
            for (String contentType : FastMarkupPartitioner.ALL_CONTENT_TYPES) {
                maybeAddReconcilingStrategyForContentType(multiStrategy, reconciler, contentType);
            }
            maybeAddReconcilingStrategyForContentType(multiStrategy, reconciler, IDocument.DEFAULT_CONTENT_TYPE);
            multiStrategy.add(markupValidationReconcilingStrategy);
            strategy = multiStrategy;
        } else {
            strategy = markupValidationReconcilingStrategy;
        }
    }
    MonoReconciler reconciler = new MarkupMonoReconciler(strategy, false);
    reconciler.setIsIncrementalReconciler(false);
    reconciler.setProgressMonitor(new NullProgressMonitor());
    reconciler.setDelay(500);
    return reconciler;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IReconciler(org.eclipse.jface.text.reconciler.IReconciler) IReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy) MarkupMonoReconciler(org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler) MarkupValidationReconcilingStrategy(org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupValidationReconcilingStrategy) MonoReconciler(org.eclipse.jface.text.reconciler.MonoReconciler) MarkupMonoReconciler(org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler) MultiReconcilingStrategy(org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MultiReconcilingStrategy)

Aggregations

IReconciler (org.eclipse.jface.text.reconciler.IReconciler)2 MarkupMonoReconciler (org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IDocument (org.eclipse.jface.text.IDocument)1 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)1 IReconcilingStrategy (org.eclipse.jface.text.reconciler.IReconcilingStrategy)1 MonoReconciler (org.eclipse.jface.text.reconciler.MonoReconciler)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 MarkupValidationReconcilingStrategy (org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupValidationReconcilingStrategy)1 MultiReconcilingStrategy (org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MultiReconcilingStrategy)1 FastMarkupPartitioner (org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner)1 MarkupDocumentProvider (org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.MarkupDocumentProvider)1 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)1 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)1