129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.text.reconciler.MonoReconciler;
|
|
14
|
131
|
15 import dwtx.jface.text.reconciler.IReconciler; // packageimport
|
|
16 import dwtx.jface.text.reconciler.DirtyRegionQueue; // packageimport
|
|
17 import dwtx.jface.text.reconciler.IReconcilingStrategy; // packageimport
|
|
18 import dwtx.jface.text.reconciler.AbstractReconcileStep; // packageimport
|
|
19 import dwtx.jface.text.reconciler.IReconcilingStrategyExtension; // packageimport
|
|
20 import dwtx.jface.text.reconciler.IReconcileStep; // packageimport
|
|
21 import dwtx.jface.text.reconciler.AbstractReconciler; // packageimport
|
|
22 import dwtx.jface.text.reconciler.Reconciler; // packageimport
|
|
23 import dwtx.jface.text.reconciler.IReconcilableModel; // packageimport
|
|
24 import dwtx.jface.text.reconciler.DirtyRegion; // packageimport
|
|
25 import dwtx.jface.text.reconciler.IReconcileResult; // packageimport
|
|
26 import dwtx.jface.text.reconciler.IReconcilerExtension; // packageimport
|
|
27
|
|
28
|
129
|
29 import dwt.dwthelper.utils;
|
|
30
|
|
31
|
|
32 import dwtx.core.runtime.Assert;
|
|
33 import dwtx.core.runtime.IProgressMonitor;
|
|
34 import dwtx.jface.text.IDocument;
|
|
35 import dwtx.jface.text.Region;
|
|
36
|
|
37
|
|
38 /**
|
|
39 * Standard implementation of {@link dwtx.jface.text.reconciler.IReconciler}.
|
|
40 * The reconciler is configured with a single {@linkplain dwtx.jface.text.reconciler.IReconcilingStrategy reconciling strategy}
|
|
41 * that is used independently from where a dirty region is located in the reconciler's
|
|
42 * document.
|
|
43 * <p>
|
|
44 * Usually, clients instantiate this class and configure it before using it.
|
|
45 * </p>
|
|
46 *
|
|
47 * @see dwtx.jface.text.IDocumentListener
|
|
48 * @see dwtx.jface.text.ITextInputListener
|
|
49 * @see dwtx.jface.text.reconciler.DirtyRegion
|
|
50 * @since 2.0
|
|
51 */
|
|
52 public class MonoReconciler : AbstractReconciler {
|
|
53
|
|
54
|
|
55 /** The reconciling strategy. */
|
|
56 private IReconcilingStrategy fStrategy;
|
|
57
|
|
58
|
|
59 /**
|
|
60 * Creates a new reconciler that uses the same reconciling strategy to
|
|
61 * reconcile its document independent of the type of the document's contents.
|
|
62 *
|
|
63 * @param strategy the reconciling strategy to be used
|
|
64 * @param isIncremental the indication whether strategy is incremental or not
|
|
65 */
|
|
66 public MonoReconciler(IReconcilingStrategy strategy, bool isIncremental) {
|
|
67 Assert.isNotNull(strategy);
|
|
68 fStrategy= strategy;
|
|
69 if (fStrategy instanceof IReconcilingStrategyExtension) {
|
|
70 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension)fStrategy;
|
|
71 extension.setProgressMonitor(getProgressMonitor());
|
|
72 }
|
|
73
|
|
74 setIsIncrementalReconciler(isIncremental);
|
|
75 }
|
|
76
|
|
77 /*
|
|
78 * @see IReconciler#getReconcilingStrategy(String)
|
|
79 */
|
|
80 public IReconcilingStrategy getReconcilingStrategy(String contentType) {
|
|
81 Assert.isNotNull(contentType);
|
|
82 return fStrategy;
|
|
83 }
|
|
84
|
|
85 /*
|
|
86 * @see AbstractReconciler#process(DirtyRegion)
|
|
87 */
|
|
88 protected void process(DirtyRegion dirtyRegion) {
|
|
89
|
|
90 if(dirtyRegion !is null)
|
|
91 fStrategy.reconcile(dirtyRegion, dirtyRegion);
|
|
92 else {
|
|
93 IDocument document= getDocument();
|
|
94 if (document !is null)
|
|
95 fStrategy.reconcile(new Region(0, document.getLength()));
|
|
96 }
|
|
97 }
|
|
98
|
|
99 /*
|
|
100 * @see AbstractReconciler#reconcilerDocumentChanged(IDocument)
|
|
101 */
|
|
102 protected void reconcilerDocumentChanged(IDocument document) {
|
|
103 fStrategy.setDocument(document);
|
|
104 }
|
|
105
|
|
106 /*
|
|
107 * @see AbstractReconciler#setProgressMonitor(IProgressMonitor)
|
|
108 */
|
|
109 public void setProgressMonitor(IProgressMonitor monitor) {
|
|
110 super.setProgressMonitor(monitor);
|
|
111 if (fStrategy instanceof IReconcilingStrategyExtension) {
|
|
112 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategy;
|
|
113 extension.setProgressMonitor(monitor);
|
|
114 }
|
|
115 }
|
|
116
|
|
117 /*
|
|
118 * @see AbstractReconciler#initialProcess()
|
|
119 */
|
|
120 protected void initialProcess() {
|
|
121 if (fStrategy instanceof IReconcilingStrategyExtension) {
|
|
122 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategy;
|
|
123 extension.initialReconcile();
|
|
124 }
|
|
125 }
|
|
126 }
|