Mercurial > projects > dwt-addons
annotate dwtx/jface/text/templates/TemplateVariableType.d @ 160:3678e4f1a766
toHash, toString
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 02:07:22 +0200 |
parents | f70d9508c95c |
children | 1a5b8f8129df |
rev | line source |
---|---|
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 | |
153
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
146
diff
changeset
|
37 import dwtx.dwtxhelper.Collection; |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
146
diff
changeset
|
38 |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
146
diff
changeset
|
39 |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
146
diff
changeset
|
40 |
129 | 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. */ | |
146 | 55 private const String fName; |
129 | 56 /** The parameter list. */ |
146 | 57 private const List fParams; |
129 | 58 |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
59 this(String name) { |
129 | 60 this(name, new String[0]); |
61 } | |
62 | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
63 this(String name, String[] params) { |
129 | 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) { | |
138 | 92 if ( cast(TemplateVariableType)obj ) { |
134 | 93 TemplateVariableType other= cast(TemplateVariableType) obj; |
129 | 94 return other.fName.equals(fName) && other.fParams.equals(fParams); |
95 } | |
96 return false; | |
97 } | |
98 | |
99 /* | |
100 * @see java.lang.Object#hashCode() | |
101 */ | |
160 | 102 public override hash_t toHash() { |
103 return fName.toHash() + fParams.toHash(); | |
129 | 104 } |
105 | |
106 /* | |
107 * @see java.lang.Object#toString() | |
108 * @since 3.3 | |
109 */ | |
160 | 110 public override String toString() { |
129 | 111 return fName + fParams.toString(); |
112 } | |
113 } |