comparison org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateVariableType.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children 5feec68b4556
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
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 org.eclipse.jface.text.templates.TemplateVariableType;
14
15 import org.eclipse.jface.text.templates.SimpleTemplateVariableResolver; // packageimport
16 import org.eclipse.jface.text.templates.TemplateBuffer; // packageimport
17 import org.eclipse.jface.text.templates.TemplateContext; // packageimport
18 import org.eclipse.jface.text.templates.TemplateContextType; // packageimport
19 import org.eclipse.jface.text.templates.Template; // packageimport
20 import org.eclipse.jface.text.templates.TemplateVariable; // packageimport
21 import org.eclipse.jface.text.templates.PositionBasedCompletionProposal; // packageimport
22 import org.eclipse.jface.text.templates.TemplateException; // packageimport
23 import org.eclipse.jface.text.templates.TemplateTranslator; // packageimport
24 import org.eclipse.jface.text.templates.DocumentTemplateContext; // packageimport
25 import org.eclipse.jface.text.templates.GlobalTemplateVariables; // packageimport
26 import org.eclipse.jface.text.templates.InclusivePositionUpdater; // packageimport
27 import org.eclipse.jface.text.templates.TemplateProposal; // packageimport
28 import org.eclipse.jface.text.templates.ContextTypeRegistry; // packageimport
29 import org.eclipse.jface.text.templates.JFaceTextTemplateMessages; // packageimport
30 import org.eclipse.jface.text.templates.TemplateCompletionProcessor; // packageimport
31 import org.eclipse.jface.text.templates.TextTemplateMessages; // packageimport
32 import org.eclipse.jface.text.templates.TemplateVariableResolver; // packageimport
33
34
35 import java.lang.all;
36 import java.util.Arrays;
37 import java.util.Collections;
38 import java.util.List;
39 import java.util.ArrayList;
40
41
42
43
44
45 import org.eclipse.core.runtime.Assert;
46
47
48 /**
49 * Value object that represents the type of a template variable. A type is defined by its name and
50 * may have parameters.
51 *
52 * @since 3.3
53 * @noinstantiate This class is not intended to be instantiated by clients.
54 */
55 public final class TemplateVariableType {
56
57 /** The name of the type. */
58 private const String fName;
59 /** The parameter list. */
60 private const List fParams;
61
62 this(String name) {
63 this(name, new String[0]);
64 }
65
66 this(String name, String[] params) {
67 Assert.isLegal(name !is null);
68 Assert.isLegal(params !is null);
69 fName= name;
70 fParams= Collections.unmodifiableList(new ArrayList(Arrays.asList(stringcast(params))));
71 }
72
73 /**
74 * Returns the type name of this variable type.
75 *
76 * @return the type name of this variable type
77 */
78 public String getName() {
79 return fName;
80 }
81
82 /**
83 * Returns the unmodifiable and possibly empty list of parameters (element type: {@link String})
84 *
85 * @return the list of parameters
86 */
87 public List getParams() {
88 return fParams;
89 }
90
91 /*
92 * @see java.lang.Object#equals(java.lang.Object)
93 */
94 public override int opEquals(Object obj) {
95 if ( cast(TemplateVariableType)obj ) {
96 TemplateVariableType other= cast(TemplateVariableType) obj;
97 return other.fName.equals(fName) && other.fParams.opEquals(cast(Object)fParams);
98 }
99 return false;
100 }
101
102 /*
103 * @see java.lang.Object#hashCode()
104 */
105 public override hash_t toHash() {
106 alias .toHash toHash;
107 return fName.toHash() + fParams.toHash();
108 }
109 /*
110 * @see java.lang.Object#toString()
111 * @since 3.3
112 */
113 public override String toString() {
114 return fName ~ (cast(Object)fParams).toString();
115 }
116 }