Mercurial > projects > dwt-addons
annotate dwtx/jface/text/templates/TemplateBuffer.d @ 133:7d818bd32d63
Fix ctors to this with gvim regexp
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 01:29:22 +0200 |
parents | c4fb132a086c |
children | 1a5b8f8129df |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 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.templates.TemplateBuffer; | |
14 | |
131 | 15 import dwtx.jface.text.templates.SimpleTemplateVariableResolver; // packageimport |
16 import dwtx.jface.text.templates.TemplateContext; // packageimport | |
17 import dwtx.jface.text.templates.TemplateContextType; // packageimport | |
18 import dwtx.jface.text.templates.Template; // packageimport | |
19 import dwtx.jface.text.templates.TemplateVariable; // packageimport | |
20 import dwtx.jface.text.templates.PositionBasedCompletionProposal; // packageimport | |
21 import dwtx.jface.text.templates.TemplateException; // packageimport | |
22 import dwtx.jface.text.templates.TemplateTranslator; // packageimport | |
23 import dwtx.jface.text.templates.DocumentTemplateContext; // packageimport | |
24 import dwtx.jface.text.templates.GlobalTemplateVariables; // packageimport | |
25 import dwtx.jface.text.templates.InclusivePositionUpdater; // packageimport | |
26 import dwtx.jface.text.templates.TemplateProposal; // packageimport | |
27 import dwtx.jface.text.templates.ContextTypeRegistry; // packageimport | |
28 import dwtx.jface.text.templates.JFaceTextTemplateMessages; // packageimport | |
29 import dwtx.jface.text.templates.TemplateCompletionProcessor; // packageimport | |
30 import dwtx.jface.text.templates.TextTemplateMessages; // packageimport | |
31 import dwtx.jface.text.templates.TemplateVariableType; // packageimport | |
32 import dwtx.jface.text.templates.TemplateVariableResolver; // packageimport | |
33 | |
34 | |
129 | 35 import dwt.dwthelper.utils; |
36 | |
37 import dwtx.core.runtime.Assert; | |
38 | |
39 /** | |
40 * A template buffer is a container for a string and variables. | |
41 * <p> | |
42 * Clients may instantiate this class. | |
43 * </p> | |
44 * | |
45 * @since 3.0 | |
46 */ | |
47 public final class TemplateBuffer { | |
48 | |
49 /** The string of the template buffer */ | |
50 private String fString; | |
51 /** The variable positions of the template buffer */ | |
52 private TemplateVariable[] fVariables; | |
53 | |
54 /** | |
55 * Creates a template buffer. | |
56 * | |
57 * @param string the string | |
58 * @param variables the variable positions | |
59 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
60 public this(String string, TemplateVariable[] variables) { |
129 | 61 setContent(string, variables); |
62 } | |
63 | |
64 /** | |
65 * Sets the content of the template buffer. | |
66 * | |
67 * @param string the string | |
68 * @param variables the variable positions | |
69 */ | |
70 public final void setContent(String string, TemplateVariable[] variables) { | |
71 Assert.isNotNull(string); | |
72 Assert.isNotNull(variables); | |
73 | |
74 // XXX assert non-overlapping variable properties | |
75 | |
76 fString= string; | |
77 fVariables= copy(variables); | |
78 } | |
79 | |
80 /** | |
81 * Returns a copy of the given array. | |
82 * | |
83 * @param array the array to be copied | |
84 * @return a copy of the given array or <code>null</code> when <code>array</code> is <code>null</code> | |
85 * @since 3.1 | |
86 */ | |
87 private static TemplateVariable[] copy(TemplateVariable[] array) { | |
88 if (array !is null) { | |
89 TemplateVariable[] copy= new TemplateVariable[array.length]; | |
90 System.arraycopy(array, 0, copy, 0, array.length); | |
91 return copy; | |
92 } | |
93 return null; | |
94 } | |
95 | |
96 /** | |
97 * Returns the string of the template buffer. | |
98 * | |
99 * @return the string representation of the template buffer | |
100 */ | |
101 public final String getString() { | |
102 return fString; | |
103 } | |
104 | |
105 /** | |
106 * Returns the variable positions of the template buffer. The returned array is | |
107 * owned by this variable and must not be modified. | |
108 * | |
109 * @return the variable positions of the template buffer | |
110 */ | |
111 public final TemplateVariable[] getVariables() { | |
112 return fVariables; | |
113 } | |
114 | |
115 } |