Mercurial > projects > dwt-addons
annotate dwtx/jface/text/formatter/ContextBasedFormattingStrategy.d @ 200:eb3414669eb0 default tip
fix for dmd 1.041 and tango 0.99.8
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 28 Mar 2009 03:09:57 +0100 |
parents | 1a5b8f8129df |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2005 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 | |
131 | 14 |
151 | 15 module dwtx.jface.text.formatter.ContextBasedFormattingStrategy; |
16 | |
131 | 17 import dwtx.jface.text.formatter.MultiPassContentFormatter; // packageimport |
18 import dwtx.jface.text.formatter.FormattingContext; // packageimport | |
19 import dwtx.jface.text.formatter.IFormattingStrategy; // packageimport | |
20 import dwtx.jface.text.formatter.IContentFormatterExtension; // packageimport | |
21 import dwtx.jface.text.formatter.IFormattingStrategyExtension; // packageimport | |
22 import dwtx.jface.text.formatter.IContentFormatter; // packageimport | |
23 import dwtx.jface.text.formatter.FormattingContextProperties; // packageimport | |
24 import dwtx.jface.text.formatter.ContentFormatter; // packageimport | |
25 import dwtx.jface.text.formatter.IFormattingContext; // packageimport | |
26 | |
129 | 27 import dwt.dwthelper.utils; |
28 | |
153
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
151
diff
changeset
|
29 import dwtx.dwtxhelper.Collection; |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
151
diff
changeset
|
30 |
129 | 31 |
32 /** | |
33 * Formatting strategy for context based content formatting. Retrieves the preferences | |
34 * set on the formatting context's {@link FormattingContextProperties#CONTEXT_PREFERENCES} | |
35 * property and makes them available to subclasses. | |
36 * <p> | |
37 * | |
38 * @since 3.0 | |
39 */ | |
40 public abstract class ContextBasedFormattingStrategy : IFormattingStrategy, IFormattingStrategyExtension { | |
41 | |
42 /** The current preferences for formatting */ | |
43 private Map fCurrentPreferences= null; | |
44 | |
45 /** The list of preferences for initiated the formatting steps */ | |
162 | 46 private const LinkedList fPreferences; |
47 | |
48 this(){ | |
49 fPreferences= new LinkedList(); | |
50 } | |
129 | 51 |
52 /* | |
53 * @see dwtx.jface.text.formatter.IFormattingStrategyExtension#format() | |
54 */ | |
55 public void format() { | |
134 | 56 fCurrentPreferences= cast(Map)fPreferences.removeFirst(); |
129 | 57 } |
58 | |
59 /* | |
60 * @see dwtx.jface.text.formatter.IFormattingStrategy#format(java.lang.String, bool, java.lang.String, int[]) | |
61 */ | |
62 public String format(String content, bool start, String indentation, int[] positions) { | |
63 return null; | |
64 } | |
65 | |
66 /* | |
67 * @see dwtx.jface.text.formatter.IFormattingStrategyExtension#formatterStarts(dwtx.jface.text.formatter.IFormattingContext) | |
68 */ | |
158 | 69 public void formatterStarts(IFormattingContext context) { |
162 | 70 fPreferences.addLast(context.getProperty(stringcast(FormattingContextProperties.CONTEXT_PREFERENCES))); |
129 | 71 } |
72 | |
73 /* | |
74 * @see IFormattingStrategy#formatterStarts(String) | |
75 */ | |
158 | 76 public void formatterStarts(String indentation) { |
129 | 77 // Do nothing |
78 } | |
79 | |
80 /* | |
81 * @see dwtx.jface.text.formatter.IFormattingStrategyExtension#formatterStops() | |
82 */ | |
83 public void formatterStops() { | |
84 fPreferences.clear(); | |
85 | |
86 fCurrentPreferences= null; | |
87 } | |
88 | |
89 /** | |
90 * Returns the preferences used for the current formatting step. | |
91 * | |
92 * @return The preferences for the current formatting step | |
93 */ | |
94 public final Map getPreferences() { | |
95 return fCurrentPreferences; | |
96 } | |
97 } |