Mercurial > projects > dwt2
comparison org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/MonoReconciler.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
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 org.eclipse.jface.text.reconciler.MonoReconciler; | |
14 | |
15 import org.eclipse.jface.text.reconciler.IReconciler; // packageimport | |
16 import org.eclipse.jface.text.reconciler.DirtyRegionQueue; // packageimport | |
17 import org.eclipse.jface.text.reconciler.IReconcilingStrategy; // packageimport | |
18 import org.eclipse.jface.text.reconciler.AbstractReconcileStep; // packageimport | |
19 import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension; // packageimport | |
20 import org.eclipse.jface.text.reconciler.IReconcileStep; // packageimport | |
21 import org.eclipse.jface.text.reconciler.AbstractReconciler; // packageimport | |
22 import org.eclipse.jface.text.reconciler.Reconciler; // packageimport | |
23 import org.eclipse.jface.text.reconciler.IReconcilableModel; // packageimport | |
24 import org.eclipse.jface.text.reconciler.DirtyRegion; // packageimport | |
25 import org.eclipse.jface.text.reconciler.IReconcileResult; // packageimport | |
26 import org.eclipse.jface.text.reconciler.IReconcilerExtension; // packageimport | |
27 | |
28 | |
29 import java.lang.all; | |
30 import java.util.Set; | |
31 | |
32 | |
33 import org.eclipse.core.runtime.Assert; | |
34 import org.eclipse.core.runtime.IProgressMonitor; | |
35 import org.eclipse.jface.text.IDocument; | |
36 import org.eclipse.jface.text.Region; | |
37 | |
38 | |
39 /** | |
40 * Standard implementation of {@link org.eclipse.jface.text.reconciler.IReconciler}. | |
41 * The reconciler is configured with a single {@linkplain org.eclipse.jface.text.reconciler.IReconcilingStrategy reconciling strategy} | |
42 * that is used independently from where a dirty region is located in the reconciler's | |
43 * document. | |
44 * <p> | |
45 * Usually, clients instantiate this class and configure it before using it. | |
46 * </p> | |
47 * | |
48 * @see org.eclipse.jface.text.IDocumentListener | |
49 * @see org.eclipse.jface.text.ITextInputListener | |
50 * @see org.eclipse.jface.text.reconciler.DirtyRegion | |
51 * @since 2.0 | |
52 */ | |
53 public class MonoReconciler : AbstractReconciler { | |
54 | |
55 | |
56 /** The reconciling strategy. */ | |
57 private IReconcilingStrategy fStrategy; | |
58 | |
59 | |
60 /** | |
61 * Creates a new reconciler that uses the same reconciling strategy to | |
62 * reconcile its document independent of the type of the document's contents. | |
63 * | |
64 * @param strategy the reconciling strategy to be used | |
65 * @param isIncremental the indication whether strategy is incremental or not | |
66 */ | |
67 public this(IReconcilingStrategy strategy, bool isIncremental) { | |
68 Assert.isNotNull(cast(Object)strategy); | |
69 fStrategy= strategy; | |
70 if ( cast(IReconcilingStrategyExtension)fStrategy ) { | |
71 IReconcilingStrategyExtension extension= cast(IReconcilingStrategyExtension)fStrategy; | |
72 extension.setProgressMonitor(getProgressMonitor()); | |
73 } | |
74 | |
75 setIsIncrementalReconciler(isIncremental); | |
76 } | |
77 | |
78 /* | |
79 * @see IReconciler#getReconcilingStrategy(String) | |
80 */ | |
81 public IReconcilingStrategy getReconcilingStrategy(String contentType) { | |
82 Assert.isNotNull(contentType); | |
83 return fStrategy; | |
84 } | |
85 | |
86 /* | |
87 * @see AbstractReconciler#process(DirtyRegion) | |
88 */ | |
89 protected void process(DirtyRegion dirtyRegion) { | |
90 | |
91 if(dirtyRegion !is null) | |
92 fStrategy.reconcile(dirtyRegion, dirtyRegion); | |
93 else { | |
94 IDocument document= getDocument(); | |
95 if (document !is null) | |
96 fStrategy.reconcile(new Region(0, document.getLength())); | |
97 } | |
98 } | |
99 | |
100 /* | |
101 * @see AbstractReconciler#reconcilerDocumentChanged(IDocument) | |
102 */ | |
103 protected void reconcilerDocumentChanged(IDocument document) { | |
104 fStrategy.setDocument(document); | |
105 } | |
106 | |
107 /* | |
108 * @see AbstractReconciler#setProgressMonitor(IProgressMonitor) | |
109 */ | |
110 public void setProgressMonitor(IProgressMonitor monitor) { | |
111 super.setProgressMonitor(monitor); | |
112 if ( cast(IReconcilingStrategyExtension)fStrategy ) { | |
113 IReconcilingStrategyExtension extension= cast(IReconcilingStrategyExtension) fStrategy; | |
114 extension.setProgressMonitor(monitor); | |
115 } | |
116 } | |
117 | |
118 /* | |
119 * @see AbstractReconciler#initialProcess() | |
120 */ | |
121 protected void initialProcess() { | |
122 if ( cast(IReconcilingStrategyExtension)fStrategy ) { | |
123 IReconcilingStrategyExtension extension= cast(IReconcilingStrategyExtension) fStrategy; | |
124 extension.initialReconcile(); | |
125 } | |
126 } | |
127 } |