129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2006, 2008 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.TemplateVariableType;
|
|
14
|
131
|
15 import dwtx.jface.text.templates.SimpleTemplateVariableResolver; // packageimport
|
|
16 import dwtx.jface.text.templates.TemplateBuffer; // packageimport
|
|
17 import dwtx.jface.text.templates.TemplateContext; // packageimport
|
|
18 import dwtx.jface.text.templates.TemplateContextType; // packageimport
|
|
19 import dwtx.jface.text.templates.Template; // packageimport
|
|
20 import dwtx.jface.text.templates.TemplateVariable; // packageimport
|
|
21 import dwtx.jface.text.templates.PositionBasedCompletionProposal; // packageimport
|
|
22 import dwtx.jface.text.templates.TemplateException; // packageimport
|
|
23 import dwtx.jface.text.templates.TemplateTranslator; // packageimport
|
|
24 import dwtx.jface.text.templates.DocumentTemplateContext; // packageimport
|
|
25 import dwtx.jface.text.templates.GlobalTemplateVariables; // packageimport
|
|
26 import dwtx.jface.text.templates.InclusivePositionUpdater; // packageimport
|
|
27 import dwtx.jface.text.templates.TemplateProposal; // packageimport
|
|
28 import dwtx.jface.text.templates.ContextTypeRegistry; // packageimport
|
|
29 import dwtx.jface.text.templates.JFaceTextTemplateMessages; // packageimport
|
|
30 import dwtx.jface.text.templates.TemplateCompletionProcessor; // packageimport
|
|
31 import dwtx.jface.text.templates.TextTemplateMessages; // packageimport
|
|
32 import dwtx.jface.text.templates.TemplateVariableResolver; // packageimport
|
|
33
|
|
34
|
129
|
35 import dwt.dwthelper.utils;
|
|
36
|
|
37 import java.util.ArrayList;
|
|
38 import java.util.Arrays;
|
|
39 import java.util.Collections;
|
|
40 import java.util.List;
|
|
41
|
|
42 import dwtx.core.runtime.Assert;
|
|
43
|
|
44
|
|
45 /**
|
|
46 * Value object that represents the type of a template variable. A type is defined by its name and
|
|
47 * may have parameters.
|
|
48 *
|
|
49 * @since 3.3
|
|
50 * @noinstantiate This class is not intended to be instantiated by clients.
|
|
51 */
|
|
52 public final class TemplateVariableType {
|
|
53
|
|
54 /** The name of the type. */
|
|
55 private final String fName;
|
|
56 /** The parameter list. */
|
|
57 private final List fParams;
|
|
58
|
|
59 TemplateVariableType(String name) {
|
|
60 this(name, new String[0]);
|
|
61 }
|
|
62
|
|
63 TemplateVariableType(String name, String[] params) {
|
|
64 Assert.isLegal(name !is null);
|
|
65 Assert.isLegal(params !is null);
|
|
66 fName= name;
|
|
67 fParams= Collections.unmodifiableList(new ArrayList(Arrays.asList(params)));
|
|
68 }
|
|
69
|
|
70 /**
|
|
71 * Returns the type name of this variable type.
|
|
72 *
|
|
73 * @return the type name of this variable type
|
|
74 */
|
|
75 public String getName() {
|
|
76 return fName;
|
|
77 }
|
|
78
|
|
79 /**
|
|
80 * Returns the unmodifiable and possibly empty list of parameters (element type: {@link String})
|
|
81 *
|
|
82 * @return the list of parameters
|
|
83 */
|
|
84 public List getParams() {
|
|
85 return fParams;
|
|
86 }
|
|
87
|
|
88 /*
|
|
89 * @see java.lang.Object#equals(java.lang.Object)
|
|
90 */
|
|
91 public bool equals(Object obj) {
|
|
92 if (obj instanceof TemplateVariableType) {
|
|
93 TemplateVariableType other= (TemplateVariableType) obj;
|
|
94 return other.fName.equals(fName) && other.fParams.equals(fParams);
|
|
95 }
|
|
96 return false;
|
|
97 }
|
|
98
|
|
99 /*
|
|
100 * @see java.lang.Object#hashCode()
|
|
101 */
|
|
102 public int hashCode() {
|
|
103 return fName.hashCode() + fParams.hashCode();
|
|
104 }
|
|
105
|
|
106 /*
|
|
107 * @see java.lang.Object#toString()
|
|
108 * @since 3.3
|
|
109 */
|
|
110 public String toString() {
|
|
111 return fName + fParams.toString();
|
|
112 }
|
|
113 }
|