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
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17
|
|
18 import dwtx.core.runtime.Assert;
|
|
19 import dwtx.core.runtime.IProgressMonitor;
|
|
20 import dwtx.jface.text.IDocument;
|
|
21 import dwtx.jface.text.Region;
|
|
22
|
|
23
|
|
24 /**
|
|
25 * Standard implementation of {@link dwtx.jface.text.reconciler.IReconciler}.
|
|
26 * The reconciler is configured with a single {@linkplain dwtx.jface.text.reconciler.IReconcilingStrategy reconciling strategy}
|
|
27 * that is used independently from where a dirty region is located in the reconciler's
|
|
28 * document.
|
|
29 * <p>
|
|
30 * Usually, clients instantiate this class and configure it before using it.
|
|
31 * </p>
|
|
32 *
|
|
33 * @see dwtx.jface.text.IDocumentListener
|
|
34 * @see dwtx.jface.text.ITextInputListener
|
|
35 * @see dwtx.jface.text.reconciler.DirtyRegion
|
|
36 * @since 2.0
|
|
37 */
|
|
38 public class MonoReconciler : AbstractReconciler {
|
|
39
|
|
40
|
|
41 /** The reconciling strategy. */
|
|
42 private IReconcilingStrategy fStrategy;
|
|
43
|
|
44
|
|
45 /**
|
|
46 * Creates a new reconciler that uses the same reconciling strategy to
|
|
47 * reconcile its document independent of the type of the document's contents.
|
|
48 *
|
|
49 * @param strategy the reconciling strategy to be used
|
|
50 * @param isIncremental the indication whether strategy is incremental or not
|
|
51 */
|
|
52 public MonoReconciler(IReconcilingStrategy strategy, bool isIncremental) {
|
|
53 Assert.isNotNull(strategy);
|
|
54 fStrategy= strategy;
|
|
55 if (fStrategy instanceof IReconcilingStrategyExtension) {
|
|
56 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension)fStrategy;
|
|
57 extension.setProgressMonitor(getProgressMonitor());
|
|
58 }
|
|
59
|
|
60 setIsIncrementalReconciler(isIncremental);
|
|
61 }
|
|
62
|
|
63 /*
|
|
64 * @see IReconciler#getReconcilingStrategy(String)
|
|
65 */
|
|
66 public IReconcilingStrategy getReconcilingStrategy(String contentType) {
|
|
67 Assert.isNotNull(contentType);
|
|
68 return fStrategy;
|
|
69 }
|
|
70
|
|
71 /*
|
|
72 * @see AbstractReconciler#process(DirtyRegion)
|
|
73 */
|
|
74 protected void process(DirtyRegion dirtyRegion) {
|
|
75
|
|
76 if(dirtyRegion !is null)
|
|
77 fStrategy.reconcile(dirtyRegion, dirtyRegion);
|
|
78 else {
|
|
79 IDocument document= getDocument();
|
|
80 if (document !is null)
|
|
81 fStrategy.reconcile(new Region(0, document.getLength()));
|
|
82 }
|
|
83 }
|
|
84
|
|
85 /*
|
|
86 * @see AbstractReconciler#reconcilerDocumentChanged(IDocument)
|
|
87 */
|
|
88 protected void reconcilerDocumentChanged(IDocument document) {
|
|
89 fStrategy.setDocument(document);
|
|
90 }
|
|
91
|
|
92 /*
|
|
93 * @see AbstractReconciler#setProgressMonitor(IProgressMonitor)
|
|
94 */
|
|
95 public void setProgressMonitor(IProgressMonitor monitor) {
|
|
96 super.setProgressMonitor(monitor);
|
|
97 if (fStrategy instanceof IReconcilingStrategyExtension) {
|
|
98 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategy;
|
|
99 extension.setProgressMonitor(monitor);
|
|
100 }
|
|
101 }
|
|
102
|
|
103 /*
|
|
104 * @see AbstractReconciler#initialProcess()
|
|
105 */
|
|
106 protected void initialProcess() {
|
|
107 if (fStrategy instanceof IReconcilingStrategyExtension) {
|
|
108 IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategy;
|
|
109 extension.initialReconcile();
|
|
110 }
|
|
111 }
|
|
112 }
|