Search in sources :

Example 1 with IReconcilingStrategy

use of org.eclipse.jface.text.reconciler.IReconcilingStrategy in project eclipse.platform.text by eclipse.

the class TextSourceViewerConfiguration method getReconciler.

/**
 * Returns the reconciler ready to be used with the given source viewer.
 * <p>
 * This implementation currently returns a {@link MonoReconciler} which
 * is responsible for spell checking. In the future a different reconciler
 * taking over more responsibilities might be returned.</p>
 *
 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getReconciler(org.eclipse.jface.text.source.ISourceViewer)
 * @since 3.3
 */
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
        return null;
    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null)
        return null;
    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService);
    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
Also used : IReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy) SpellingReconcileStrategy(org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy) MonoReconciler(org.eclipse.jface.text.reconciler.MonoReconciler) SpellingService(org.eclipse.ui.texteditor.spelling.SpellingService)

Example 2 with IReconcilingStrategy

use of org.eclipse.jface.text.reconciler.IReconcilingStrategy in project eclipse.platform.text by eclipse.

the class AbstractReconcilerTest method setUp.

@Before
public void setUp() {
    fBarrier = new Barrier();
    fCallLog = Collections.synchronizedList(new ArrayList<String>());
    fReconciler = new AbstractReconciler() {

        @Override
        protected void initialProcess() {
            fCallLog.add("initialProcess");
            fBarrier.await();
        }

        @Override
        protected void process(DirtyRegion dirtyRegion) {
            fCallLog.add("process");
            fBarrier.await();
        }

        @Override
        protected void reconcilerDocumentChanged(IDocument newDocument) {
            fCallLog.add("reconcilerDocumentChanged");
        }

        @Override
        protected void aboutToBeReconciled() {
            fCallLog.add("aboutToBeReconciled");
        }

        @Override
        protected void reconcilerReset() {
            fCallLog.add("reconcilerReset");
        }

        @Override
        public IReconcilingStrategy getReconcilingStrategy(String contentType) {
            return null;
        }
    };
    fReconciler.setIsIncrementalReconciler(false);
    // make tests run faster
    fReconciler.setDelay(50);
    fProgressMonitor = new NullProgressMonitor();
    fReconciler.setProgressMonitor(fProgressMonitor);
    fViewer = new TestTextViewer();
    fReconciler.install(fViewer);
    fAccessor = new Accessor(fReconciler, AbstractReconciler.class);
    Object object = fAccessor.get("fThread");
    fAccessor = new Accessor(object, object.getClass());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy) TestTextViewer(org.eclipse.jface.text.tests.TestTextViewer) ArrayList(java.util.ArrayList) DirtyRegion(org.eclipse.jface.text.reconciler.DirtyRegion) Accessor(org.eclipse.text.tests.Accessor) IDocument(org.eclipse.jface.text.IDocument) AbstractReconciler(org.eclipse.jface.text.reconciler.AbstractReconciler) Before(org.junit.Before)

Example 3 with IReconcilingStrategy

use of org.eclipse.jface.text.reconciler.IReconcilingStrategy in project eclipse.platform.text by eclipse.

the class CodeMiningDemo method main.

public static void main(String[] args) throws Exception {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.setText("Code Mining demo");
    ISourceViewer sourceViewer = new SourceViewer(shell, null, SWT.V_SCROLL | SWT.BORDER);
    sourceViewer.setDocument(new Document("// Type class & new keyword and see references CodeMining\n" + "// Name class with a number N to emulate Nms before resolving the references CodeMining \n\n" + "class A\n" + "new A\n" + "new A\n\n" + "class 5\n" + "new 5\n" + "new 5\n" + "new 5"), new AnnotationModel());
    // Add AnnotationPainter (required by CodeMining)
    addAnnotationPainter(sourceViewer);
    // Initialize codemining providers
    ((ISourceViewerExtension5) sourceViewer).setCodeMiningProviders(new ICodeMiningProvider[] { new ClassReferenceCodeMiningProvider(), new ClassImplementationsCodeMiningProvider() });
    // Execute codemining in a reconciler
    MonoReconciler reconciler = new MonoReconciler(new IReconcilingStrategy() {

        @Override
        public void setDocument(IDocument document) {
            ((ISourceViewerExtension5) sourceViewer).updateCodeMinings();
        }

        @Override
        public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
        }

        @Override
        public void reconcile(IRegion partition) {
            ((ISourceViewerExtension5) sourceViewer).updateCodeMinings();
        }
    }, false);
    reconciler.install(sourceViewer);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) ISourceViewerExtension5(org.eclipse.jface.text.source.ISourceViewerExtension5) FillLayout(org.eclipse.swt.layout.FillLayout) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) MonoReconciler(org.eclipse.jface.text.reconciler.MonoReconciler) IRegion(org.eclipse.jface.text.IRegion) Shell(org.eclipse.swt.widgets.Shell) IReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy) AnnotationModel(org.eclipse.jface.text.source.AnnotationModel) DirtyRegion(org.eclipse.jface.text.reconciler.DirtyRegion) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IDocument(org.eclipse.jface.text.IDocument) Display(org.eclipse.swt.widgets.Display)

Example 4 with IReconcilingStrategy

use of org.eclipse.jface.text.reconciler.IReconcilingStrategy in project eclipse.platform.text by eclipse.

the class InlinedAnnotationDemo method main.

public static void main(String[] args) throws Exception {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.setText("Inlined annotation demo");
    // Create source viewer and initialize the content
    ISourceViewer sourceViewer = new SourceViewer(shell, null, SWT.V_SCROLL | SWT.BORDER);
    sourceViewer.setDocument(new Document("\ncolor:rgb(255, 255, 0)"), new AnnotationModel());
    // Initialize inlined annotations support
    InlinedAnnotationSupport support = new InlinedAnnotationSupport();
    support.install(sourceViewer, createAnnotationPainter(sourceViewer));
    // Refresh inlined annotation in none UI Thread with reconciler.
    MonoReconciler reconciler = new MonoReconciler(new IReconcilingStrategy() {

        @Override
        public void setDocument(IDocument document) {
            Set<AbstractInlinedAnnotation> annotations = getInlinedAnnotation(sourceViewer, support);
            support.updateAnnotations(annotations);
        }

        @Override
        public void reconcile(IRegion partition) {
            Set<AbstractInlinedAnnotation> anns = getInlinedAnnotation(sourceViewer, support);
            support.updateAnnotations(anns);
        }

        @Override
        public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
        }
    }, false);
    reconciler.setDelay(1);
    reconciler.install(sourceViewer);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) HashSet(java.util.HashSet) Set(java.util.Set) InlinedAnnotationSupport(org.eclipse.jface.text.source.inlined.InlinedAnnotationSupport) FillLayout(org.eclipse.swt.layout.FillLayout) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) MonoReconciler(org.eclipse.jface.text.reconciler.MonoReconciler) IRegion(org.eclipse.jface.text.IRegion) Shell(org.eclipse.swt.widgets.Shell) IReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy) AnnotationModel(org.eclipse.jface.text.source.AnnotationModel) DirtyRegion(org.eclipse.jface.text.reconciler.DirtyRegion) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IDocument(org.eclipse.jface.text.IDocument) Display(org.eclipse.swt.widgets.Display)

Example 5 with IReconcilingStrategy

use of org.eclipse.jface.text.reconciler.IReconcilingStrategy in project linuxtools by eclipse.

the class DockerConfiguration method getReconciler.

@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
    Reconciler reconciler = new Reconciler();
    IReconcilingStrategy strategy = new SyntaxReconcilingStrategy(editor);
    reconciler.setReconcilingStrategy(strategy, IDocument.DEFAULT_CONTENT_TYPE);
    return reconciler;
}
Also used : SyntaxReconcilingStrategy(org.eclipse.linuxtools.internal.docker.editor.syntax.SyntaxReconcilingStrategy) Reconciler(org.eclipse.jface.text.reconciler.Reconciler) IPresentationReconciler(org.eclipse.jface.text.presentation.IPresentationReconciler) IReconciler(org.eclipse.jface.text.reconciler.IReconciler) IReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy)

Aggregations

IReconcilingStrategy (org.eclipse.jface.text.reconciler.IReconcilingStrategy)5 IDocument (org.eclipse.jface.text.IDocument)3 DirtyRegion (org.eclipse.jface.text.reconciler.DirtyRegion)3 MonoReconciler (org.eclipse.jface.text.reconciler.MonoReconciler)3 Document (org.eclipse.jface.text.Document)2 IRegion (org.eclipse.jface.text.IRegion)2 AnnotationModel (org.eclipse.jface.text.source.AnnotationModel)2 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)2 SourceViewer (org.eclipse.jface.text.source.SourceViewer)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Display (org.eclipse.swt.widgets.Display)2 Shell (org.eclipse.swt.widgets.Shell)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IPresentationReconciler (org.eclipse.jface.text.presentation.IPresentationReconciler)1 AbstractReconciler (org.eclipse.jface.text.reconciler.AbstractReconciler)1 IReconciler (org.eclipse.jface.text.reconciler.IReconciler)1 Reconciler (org.eclipse.jface.text.reconciler.Reconciler)1