Mercurial > projects > dwt2
comparison org.eclipse.jface.text/src/org/eclipse/jface/text/link/ProposalPosition.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 |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
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 module org.eclipse.jface.text.link.ProposalPosition; | |
14 | |
15 import org.eclipse.jface.text.link.LinkedModeModel; // packageimport | |
16 import org.eclipse.jface.text.link.LinkedPosition; // packageimport | |
17 import org.eclipse.jface.text.link.ILinkedModeListener; // packageimport | |
18 import org.eclipse.jface.text.link.TabStopIterator; // packageimport | |
19 import org.eclipse.jface.text.link.LinkedModeUI; // packageimport | |
20 import org.eclipse.jface.text.link.InclusivePositionUpdater; // packageimport | |
21 import org.eclipse.jface.text.link.LinkedPositionGroup; // packageimport | |
22 import org.eclipse.jface.text.link.LinkedModeManager; // packageimport | |
23 import org.eclipse.jface.text.link.LinkedPositionAnnotations; // packageimport | |
24 | |
25 | |
26 import java.lang.all; | |
27 import java.util.Arrays; | |
28 import java.util.Set; | |
29 | |
30 | |
31 import org.eclipse.jface.text.IDocument; | |
32 import org.eclipse.jface.text.contentassist.ICompletionProposal; | |
33 | |
34 /** | |
35 * LinkedPosition with added completion proposals. | |
36 * <p> | |
37 * Clients may instantiate or extend this class. | |
38 * </p> | |
39 * | |
40 * @since 3.0 | |
41 */ | |
42 public class ProposalPosition : LinkedPosition { | |
43 | |
44 /** | |
45 * The proposals | |
46 */ | |
47 private ICompletionProposal[] fProposals; | |
48 | |
49 /** | |
50 * Creates a new instance. | |
51 * | |
52 * @param document the document | |
53 * @param offset the offset of the position | |
54 * @param length the length of the position | |
55 * @param sequence the iteration sequence rank | |
56 * @param proposals the proposals to be shown when entering this position | |
57 */ | |
58 public this(IDocument document, int offset, int length, int sequence, ICompletionProposal[] proposals) { | |
59 super(document, offset, length, sequence); | |
60 fProposals= copy(proposals); | |
61 } | |
62 | |
63 /** | |
64 * Creates a new instance, with no sequence number. | |
65 * | |
66 * @param document the document | |
67 * @param offset the offset of the position | |
68 * @param length the length of the position | |
69 * @param proposals the proposals to be shown when entering this position | |
70 */ | |
71 public this(IDocument document, int offset, int length, ICompletionProposal[] proposals) { | |
72 super(document, offset, length, LinkedPositionGroup.NO_STOP); | |
73 fProposals= copy(proposals); | |
74 } | |
75 | |
76 /* | |
77 * @since 3.1 | |
78 */ | |
79 private ICompletionProposal[] copy(ICompletionProposal[] proposals) { | |
80 if (proposals !is null) { | |
81 ICompletionProposal[] copy= new ICompletionProposal[proposals.length]; | |
82 SimpleType!(ICompletionProposal).arraycopy(proposals, 0, copy, 0, proposals.length); | |
83 return copy; | |
84 } | |
85 return null; | |
86 } | |
87 | |
88 /* | |
89 * @see java.lang.Object#equals(java.lang.Object) | |
90 */ | |
91 public override int opEquals(Object o) { | |
92 if ( cast(ProposalPosition)o ) { | |
93 if (super.opEquals(o)) { | |
94 return Arrays.equals(fProposals, (cast(ProposalPosition)o).fProposals); | |
95 } | |
96 } | |
97 return false; | |
98 } | |
99 | |
100 /** | |
101 * Returns the proposals attached to this position. The returned array is owned by | |
102 * this <code>ProposalPosition</code> and may not be modified by clients. | |
103 * | |
104 * @return an array of choices, including the initial one. Callers must not | |
105 * modify it. | |
106 */ | |
107 public ICompletionProposal[] getChoices() { | |
108 return fProposals; | |
109 } | |
110 | |
111 /* | |
112 * @see org.eclipse.jdt.internal.ui.text.link.LinkedPosition#hashCode() | |
113 */ | |
114 public override hash_t toHash() { | |
115 return super.toHash() | (fProposals is null ? 0 : (cast(hash_t)fProposals.ptr)/+.toHash()+/); | |
116 } | |
117 } |