Mercurial > projects > dwt-addons
comparison dwtx/jface/text/contentassist/ContextInformationValidator.d @ 129:eb30df5ca28b
Added JFace Text sources
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 23 Aug 2008 19:10:48 +0200 |
parents | |
children | c4fb132a086c |
comparison
equal
deleted
inserted
replaced
128:8df1d4193877 | 129:eb30df5ca28b |
---|---|
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 dwtx.jface.text.contentassist.ContextInformationValidator; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 import dwtx.jface.text.ITextViewer; | |
18 | |
19 | |
20 /** | |
21 * A default implementation of the <code>IContextInfomationValidator</code> interface. | |
22 * This implementation determines whether the information is valid by asking the content | |
23 * assist processor for all context information objects for the current position. If the | |
24 * currently displayed information is in the result set, the context information is | |
25 * considered valid. | |
26 */ | |
27 public final class ContextInformationValidator : IContextInformationValidator { | |
28 | |
29 /** The content assist processor. */ | |
30 private IContentAssistProcessor fProcessor; | |
31 /** The context information to be validated. */ | |
32 private IContextInformation fContextInformation; | |
33 /** The associated text viewer. */ | |
34 private ITextViewer fViewer; | |
35 | |
36 /** | |
37 * Creates a new context information validator which is ready to be installed on | |
38 * a particular context information. | |
39 * | |
40 * @param processor the processor to be used for validation | |
41 */ | |
42 public ContextInformationValidator(IContentAssistProcessor processor) { | |
43 fProcessor= processor; | |
44 } | |
45 | |
46 /* | |
47 * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int) | |
48 */ | |
49 public void install(IContextInformation contextInformation, ITextViewer viewer, int offset) { | |
50 fContextInformation= contextInformation; | |
51 fViewer= viewer; | |
52 } | |
53 | |
54 /* | |
55 * @see IContentAssistTipCloser#isContextInformationValid(int) | |
56 */ | |
57 public bool isContextInformationValid(int offset) { | |
58 IContextInformation[] infos= fProcessor.computeContextInformation(fViewer, offset); | |
59 if (infos !is null && infos.length > 0) { | |
60 for (int i= 0; i < infos.length; i++) | |
61 if (fContextInformation.equals(infos[i])) | |
62 return true; | |
63 } | |
64 return false; | |
65 } | |
66 } |