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.IContentFormatterExtension;
|
|
16
|
131
|
17 import dwtx.jface.text.formatter.MultiPassContentFormatter; // packageimport
|
|
18 import dwtx.jface.text.formatter.ContextBasedFormattingStrategy; // packageimport
|
|
19 import dwtx.jface.text.formatter.FormattingContext; // packageimport
|
|
20 import dwtx.jface.text.formatter.IFormattingStrategy; // 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
|
|
29 import dwtx.jface.text.IDocument;
|
|
30
|
|
31 /**
|
|
32 * Extension interface for {@link IContentFormatter}.
|
|
33 * <p>
|
|
34 * Updates the content formatter to be able to pass {@link IFormattingContext}
|
|
35 * context objects to {@link IFormattingStrategyExtension} objects
|
|
36 * operating in context based mode.
|
|
37 * <p>
|
|
38 * Clients using context based formatting call the method
|
|
39 * <code>format(IDocument, IFormattingContext)</code> with a properly
|
|
40 * initialized formatting context.<br>
|
|
41 * The formatting context must be set up according to the desired formatting mode:
|
|
42 * <ul>
|
|
43 * <li>For whole document formatting set the property {@link FormattingContextProperties#CONTEXT_DOCUMENT}.
|
|
44 * This is equivalent to setting {@link FormattingContextProperties#CONTEXT_REGION} with a region spanning
|
|
45 * the whole document.</li>
|
|
46 * <li>For multiple region formatting set the property {@link FormattingContextProperties#CONTEXT_REGION}.
|
|
47 * Note that the content formatter automatically aligns the region to a block selected region,
|
|
48 * and if the region spans multiple partitions, it also completes eventual partitions covered only
|
|
49 * partially by the region.</li>
|
|
50 * </ul>
|
|
51 * Depending on the registered formatting strategies, more context information must
|
|
52 * be passed in the formatting context, like e.g. {@link FormattingContextProperties#CONTEXT_PREFERENCES}.
|
|
53 * <p>
|
|
54 * Note that in context based mode the content formatter is fully reentrant, but not
|
|
55 * thread-safe.
|
|
56 * <p>
|
|
57 *
|
|
58 * @see IFormattingContext
|
|
59 * @see FormattingContextProperties
|
|
60 * @since 3.0
|
|
61 */
|
|
62 public interface IContentFormatterExtension {
|
|
63
|
|
64 /**
|
|
65 * Formats the given region of the specified document.
|
|
66 * <p>
|
|
67 * The formatter may safely assume that it is the only subject that
|
|
68 * modifies the document at this point in time. This method is fully
|
|
69 * reentrant, but not thread-safe.
|
|
70 * <p>
|
|
71 * The formatting process performed by <code>format(IDocument, IFormattingContext)</code>
|
|
72 * happens as follows:
|
|
73 * <ul>
|
|
74 * <li>In a first pass the content formatter formats the range of the
|
|
75 * document to be formatted by using the master formatting strategy. This
|
|
76 * happens regardless of the content type of the underlying partition.
|
|
77 * </li>
|
|
78 * <li>In the second pass, the range is formatted again, this time using
|
|
79 * the registered slave formatting strategies. For each partition contained
|
|
80 * in the range to be formatted, the content formatter determines its
|
|
81 * content type and formats the partition with the correct formatting
|
|
82 * strategy.
|
|
83 * </li>
|
|
84 *
|
|
85 * @param document
|
|
86 * The document to be formatted
|
|
87 * @param context
|
|
88 * The formatting context to pass to the formatting strategies.
|
|
89 * This argument must not be <code>null</code>.
|
|
90 */
|
|
91 void format(IDocument document, IFormattingContext context);
|
|
92 }
|