View | Details | Raw Unified | Return to bug 259721 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (-1 / +2 lines)
Lines 31-34 Link Here
31
pageSyntaxColoring = Syntax Coloring
31
pageSyntaxColoring = Syntax Coloring
32
XSL_Property_validation = XSLT Validation
32
XSL_Property_validation = XSLT Validation
33
33
34
specification.label.0 = Override
34
specification.label.0 = Override
35
XSLContentAssistExtension = XSL Content Assistance
(-)plugin.xml (+11 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
2
<?eclipse version="3.4"?>
3
<plugin>
3
<plugin>
4
   <extension-point id="contentAssistProcessor" name="%XSLContentAssistExtension" schema="/schema/contentAssistProcessor.exsd"/>
4
5
5
	<extension point="org.eclipse.ui.editors">
6
	<extension point="org.eclipse.ui.editors">
6
		<editor name="%editorName" 
7
		<editor name="%editorName" 
Lines 252-255 Link Here
252
		</enablement>
253
		</enablement>
253
	</commonWizard>
254
	</commonWizard>
254
 </extension>
255
 </extension>
256
 <extension
257
       point="org.eclipse.wst.xsl.ui.contentAssistProcessor">
258
    <processor
259
          class="org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor">
260
    </processor>
261
    <processor
262
          class="org.eclipse.wst.xsl.ui.internal.contentassist.XSLContentAssistProcessor">
263
    </processor>
264
 </extension>
265
  
255
</plugin>
266
</plugin>
(-)build.properties (-1 / +3 lines)
Lines 7-10 Link Here
7
               plugin.properties,\
7
               plugin.properties,\
8
               templates/,\
8
               templates/,\
9
               about.html,\
9
               about.html,\
10
               xslfiles/
10
               xslfiles/,\
11
               schema/
12
src.includes = schema/
(-)src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistProcessor.java (-290 / +12 lines)
Lines 22-38 Link Here
22
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
22
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
23
import org.eclipse.jface.text.contentassist.IContextInformation;
23
import org.eclipse.jface.text.contentassist.IContextInformation;
24
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
24
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
25
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
26
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
27
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
28
import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
29
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
30
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
31
import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
25
import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
32
import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor;
26
import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor;
33
import org.eclipse.wst.xsl.core.XSLCore;
27
import org.eclipse.wst.xsl.core.XSLCore;
34
import org.eclipse.wst.xsl.ui.internal.Messages;
28
import org.eclipse.wst.xsl.ui.internal.Messages;
35
import org.w3c.dom.Node;
36
29
37
/**
30
/**
38
 * The XSL Content Assist Processor provides content assistance for various
31
 * The XSL Content Assist Processor provides content assistance for various
Lines 42-61 Link Here
42
 * @author David Carver
35
 * @author David Carver
43
 * @since 1.0
36
 * @since 1.0
44
 */
37
 */
45
public class XSLContentAssistProcessor implements IContentAssistProcessor {
38
public class XSLContentAssistProcessor extends AbstractXSLContentAssistProcessor implements IContentAssistProcessor {
46
39
47
	private String errorMessage = ""; //$NON-NLS-1$
48
	private ITextViewer textViewer = null;
49
	private ArrayList<ICompletionProposal> xslProposals;
40
	private ArrayList<ICompletionProposal> xslProposals;
50
	private ArrayList<ICompletionProposal> additionalProposals;
41
	private ArrayList<ICompletionProposal> additionalProposals;
51
	private IndexedRegion treeNode;
42
	private ArrayList<String> namespaces;
52
	private Node node;
53
	private IDOMNode xmlNode;
54
	private IStructuredDocumentRegion sdRegion;
55
	private ITextRegion completionRegion;
56
	private String matchString;
57
	private int cursorPosition;
58
59
	/**
43
	/**
60
	 * Provides an XSL Content Assist Processor class that is XSL aware and XML
44
	 * Provides an XSL Content Assist Processor class that is XSL aware and XML
61
	 * aware.
45
	 * aware.
Lines 64-69 Link Here
64
		super();
48
		super();
65
		xslProposals = new ArrayList<ICompletionProposal>();
49
		xslProposals = new ArrayList<ICompletionProposal>();
66
		additionalProposals = new ArrayList<ICompletionProposal>();
50
		additionalProposals = new ArrayList<ICompletionProposal>();
51
		namespaces = new ArrayList<String>();
52
		namespaces.add(XSLCore.XSL_NAMESPACE_URI);
67
	}
53
	}
68
54
69
	/**
55
	/**
Lines 83-96 Link Here
83
			ITextViewer textViewer, int documentPosition) {
69
			ITextViewer textViewer, int documentPosition) {
84
		initializeProposalVariables(textViewer, documentPosition);
70
		initializeProposalVariables(textViewer, documentPosition);
85
71
86
		ICompletionProposal[] xmlProposals = getXMLProposals();
87
88
		additionalProposals = getAdditionalXSLElementProposals();
72
		additionalProposals = getAdditionalXSLElementProposals();
89
73
90
		xslProposals = getXSLNamespaceProposals();
74
		xslProposals = getXSLNamespaceProposals();
91
75
92
		ArrayList<ICompletionProposal> proposalList = new ArrayList<ICompletionProposal>();
76
		ArrayList<ICompletionProposal> proposalList = new ArrayList<ICompletionProposal>();
93
		addProposals(xmlProposals, proposalList);
94
		proposalList.addAll(additionalProposals);
77
		proposalList.addAll(additionalProposals);
95
		proposalList.addAll(xslProposals);
78
		proposalList.addAll(xslProposals);
96
79
Lines 103-124 Link Here
103
		return combinedProposals;
86
		return combinedProposals;
104
	}
87
	}
105
88
106
	/**
107
	 * @param textViewer
108
	 * @param documentPosition
109
	 */
110
	private void initializeProposalVariables(ITextViewer textViewer,
111
			int documentPosition) {
112
		this.textViewer = textViewer;
113
		cursorPosition = documentPosition;
114
		treeNode = ContentAssistUtils.getNodeAt(textViewer, cursorPosition);
115
		node = getActualDOMNode((Node) treeNode);
116
		xmlNode = (IDOMNode) node;
117
		sdRegion = getStructuredDocumentRegion();
118
		completionRegion = getCompletionRegion(cursorPosition, node);
119
		matchString = getMatchString(sdRegion, completionRegion, cursorPosition);
120
	}
121
122
	private ArrayList<ICompletionProposal> getXSLNamespaceProposals() {
89
	private ArrayList<ICompletionProposal> getXSLNamespaceProposals() {
123
		if (XSLCore.isXSLNamespace(xmlNode)) {
90
		if (XSLCore.isXSLNamespace(xmlNode)) {
124
			XSLContentAssistRequestFactory requestFactory = new XSLContentAssistRequestFactory(
91
			XSLContentAssistRequestFactory requestFactory = new XSLContentAssistRequestFactory(
Lines 141-163 Link Here
141
		return additionalProposals;
108
		return additionalProposals;
142
	}
109
	}
143
110
144
	private ICompletionProposal[] getXMLProposals() {
145
		AbstractContentAssistProcessor processor = new XMLContentAssistProcessor();
146
147
		ICompletionProposal proposals[] = processor.computeCompletionProposals(
148
				textViewer, cursorPosition);
149
		return proposals;
150
	}
151
152
	private void addProposals(ICompletionProposal[] proposals,
153
			ArrayList<ICompletionProposal> proposalList) {
154
		if (proposals != null) {
155
			for (int cnt = 0; cnt < proposals.length; cnt++) {
156
				proposalList.add(proposals[cnt]);
157
			}
158
		}
159
	}
160
161
	private ICompletionProposal[] combineProposals(
111
	private ICompletionProposal[] combineProposals(
162
			ArrayList<ICompletionProposal> proposalList) {
112
			ArrayList<ICompletionProposal> proposalList) {
163
		ICompletionProposal[] combinedProposals = new ICompletionProposal[proposalList
113
		ICompletionProposal[] combinedProposals = new ICompletionProposal[proposalList
Lines 167-394 Link Here
167
	}
117
	}
168
118
169
	/**
119
	/**
170
	 * @param node
171
	 * @return
172
	 */
173
	private Node getActualDOMNode(Node node) {
174
		while ((node != null) && (node.getNodeType() == Node.TEXT_NODE)
175
				&& (node.getParentNode() != null)) {
176
			node = node.getParentNode();
177
		}
178
		return node;
179
	}
180
181
	/**
182
	 * StructuredTextViewer must be set before using this.
183
	 * 
184
	 * @param pos
185
	 * @return
186
	 */
187
	private IStructuredDocumentRegion getStructuredDocumentRegion() {
188
		return ContentAssistUtils.getStructuredDocumentRegion(textViewer,
189
				cursorPosition);
190
	}
191
192
	/**
193
	 * Return the region whose content's require completion. This is something
194
	 * of a misnomer as sometimes the user wants to be prompted for contents of
195
	 * a non-existent ITextRegion, such as for enumerated attribute values
196
	 * following an '=' sign.
197
	 * 
198
	 * Copied from AbstractContentAssist Processor.
199
	 */
200
	protected ITextRegion getCompletionRegion(int documentPosition, Node domnode) {
201
		if (domnode == null) {
202
			return null;
203
		}
204
205
		ITextRegion region = null;
206
		int offset = documentPosition;
207
		IStructuredDocumentRegion flatNode = null;
208
		IDOMNode node = (IDOMNode) domnode;
209
210
		if (node.getNodeType() == Node.DOCUMENT_NODE) {
211
			if (node.getStructuredDocument().getLength() == 0) {
212
				return null;
213
			}
214
			ITextRegion result = node.getStructuredDocument()
215
					.getRegionAtCharacterOffset(offset)
216
					.getRegionAtCharacterOffset(offset);
217
			while (result == null) {
218
				offset--;
219
				result = node.getStructuredDocument()
220
						.getRegionAtCharacterOffset(offset)
221
						.getRegionAtCharacterOffset(offset);
222
			}
223
			return result;
224
		}
225
226
		IStructuredDocumentRegion startTag = node
227
				.getStartStructuredDocumentRegion();
228
		IStructuredDocumentRegion endTag = node
229
				.getEndStructuredDocumentRegion();
230
231
		if ((startTag != null) && (startTag.getStartOffset() <= offset)
232
				&& (offset < startTag.getStartOffset() + startTag.getLength())) {
233
			flatNode = startTag;
234
		} else if ((endTag != null) && (endTag.getStartOffset() <= offset)
235
				&& (offset < endTag.getStartOffset() + endTag.getLength())) {
236
			flatNode = endTag;
237
		}
238
239
		if (flatNode != null) {
240
			region = getCompletionRegion(offset, flatNode);
241
		} else {
242
			flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(
243
					offset);
244
			if ((flatNode.getStartOffset() <= documentPosition)
245
					&& (flatNode.getEndOffset() >= documentPosition)) {
246
				if ((offset == flatNode.getStartOffset())
247
						&& (flatNode.getPrevious() != null)
248
						&& (((flatNode
249
								.getRegionAtCharacterOffset(documentPosition) != null) && (flatNode
250
								.getRegionAtCharacterOffset(documentPosition)
251
								.getType() != DOMRegionContext.XML_CONTENT))
252
								|| (flatNode.getPrevious().getLastRegion()
253
										.getType() == DOMRegionContext.XML_TAG_OPEN) || (flatNode
254
								.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) {
255
					region = flatNode.getPrevious().getLastRegion();
256
				} else if (flatNode.getEndOffset() == documentPosition) {
257
					region = flatNode.getLastRegion();
258
				} else {
259
					region = flatNode.getFirstRegion();
260
				}
261
			} else {
262
				region = flatNode.getLastRegion();
263
			}
264
		}
265
266
		return region;
267
	}
268
269
	protected ITextRegion getCompletionRegion(int offset,
270
			IStructuredDocumentRegion sdRegion) {
271
		ITextRegion region = sdRegion.getRegionAtCharacterOffset(offset);
272
		if (region == null) {
273
			return null;
274
		}
275
276
		if (sdRegion.getStartOffset(region) == offset) {
277
			// The offset is at the beginning of the region
278
			if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset())
279
					&& (sdRegion.getPrevious() != null)
280
					&& (!sdRegion.getPrevious().isEnded())) {
281
				region = sdRegion.getPrevious().getRegionAtCharacterOffset(
282
						offset - 1);
283
			} else {
284
				// Is there no separating whitespace from the previous region?
285
				// If not,
286
				// then that region is the important one
287
				ITextRegion previousRegion = sdRegion
288
						.getRegionAtCharacterOffset(offset - 1);
289
				if ((previousRegion != null)
290
						&& (previousRegion != region)
291
						&& (previousRegion.getTextLength() == previousRegion
292
								.getLength())) {
293
					region = previousRegion;
294
				}
295
			}
296
		} else {
297
			// The offset is NOT at the beginning of the region
298
			if (offset > sdRegion.getStartOffset(region)
299
					+ region.getTextLength()) {
300
				// Is the offset within the whitespace after the text in this
301
				// region?
302
				// If so, use the next region
303
				ITextRegion nextRegion = sdRegion
304
						.getRegionAtCharacterOffset(sdRegion
305
								.getStartOffset(region)
306
								+ region.getLength());
307
				if (nextRegion != null) {
308
					region = nextRegion;
309
				}
310
			} else {
311
				// Is the offset within the important text for this region?
312
				// If so, then we've already got the right one.
313
			}
314
		}
315
316
		// valid WHITE_SPACE region handler (#179924)
317
		if ((region != null)
318
				&& (region.getType() == DOMRegionContext.WHITE_SPACE)) {
319
			ITextRegion previousRegion = sdRegion
320
					.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) - 1);
321
			if (previousRegion != null) {
322
				region = previousRegion;
323
			}
324
		}
325
326
		return region;
327
	}
328
329
	private String getMatchString(IStructuredDocumentRegion parent,
330
			ITextRegion aRegion, int offset) {
331
		String matchString = ""; //$NON-NLS-1$
332
		
333
		if (isNotMatchStringRegion(parent, aRegion, offset)) {
334
			return matchString; 
335
		}
336
337
		if (hasMatchString(parent, aRegion, offset)) {
338
			matchString = extractMatchString(parent, aRegion, offset);
339
		}
340
		return matchString;
341
	}
342
343
	private boolean isNotMatchStringRegion(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
344
		if (aRegion == null || parent == null)
345
			return true;
346
		
347
		String regionType = aRegion.getType();
348
		int totalRegionOffset = parent.getStartOffset(aRegion)
349
				+ aRegion.getTextLength();
350
		return (isCloseRegion(aRegion)
351
				|| hasNoMatchString(offset, regionType, totalRegionOffset));
352
	}
353
354
	private boolean isCloseRegion(ITextRegion region) {
355
		String type = region.getType();
356
		return ((type == DOMRegionContext.XML_PI_CLOSE)
357
				|| (type == DOMRegionContext.XML_TAG_CLOSE)
358
				|| (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)
359
				|| (type == DOMRegionContext.XML_CDATA_CLOSE)
360
				|| (type == DOMRegionContext.XML_COMMENT_CLOSE)
361
				|| (type == DOMRegionContext.XML_ATTLIST_DECL_CLOSE)
362
				|| (type == DOMRegionContext.XML_ELEMENT_DECL_CLOSE)
363
				|| (type == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE));
364
	}
365
366
	private boolean hasMatchString(IStructuredDocumentRegion parent,
367
			ITextRegion aRegion, int offset) {
368
		return (parent.getText(aRegion).length() > 0)
369
				&& (parent.getStartOffset(aRegion) < offset);
370
	}
371
372
	private boolean hasNoMatchString(int offset, String regionType,
373
			int totalRegionOffset) {
374
		return regionType.equals(DOMRegionContext.XML_CONTENT)
375
				|| regionType.equals(DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS)
376
				|| regionType.equals(DOMRegionContext.XML_TAG_OPEN)
377
				|| offset > totalRegionOffset;
378
	}
379
380
	private String extractMatchString(IStructuredDocumentRegion parent,
381
			ITextRegion aRegion, int offset) {
382
		String matchString;
383
		matchString = parent.getText(aRegion).substring(0,
384
				offset - parent.getStartOffset(aRegion));
385
		if (matchString.startsWith("\"")) { //$NON-NLS-1$
386
			matchString = matchString.substring(1);
387
		}
388
		return matchString;
389
	}
390
391
	/**
392
	 * (non-Javadoc)
120
	 * (non-Javadoc)
393
	 * 
121
	 * 
394
	 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer,
122
	 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer,
Lines 432-453 Link Here
432
		return null;
160
		return null;
433
	}
161
	}
434
162
435
	/**
163
	public String getMaximumVersion() {
436
	 * (non-Javadoc)
164
		return "2.0"; //$NON-NLS-1$
437
	 * 
438
	 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
439
	 */
440
	public String getErrorMessage() {
441
		return errorMessage;
442
	}
165
	}
443
166
444
	/**
167
	public String getMinimumVersion() {
445
	 * Sets the error message for why content assistance didn't complete.
168
		return "1.0"; //$NON-NLS-1$
446
	 * 
169
	}
447
	 * @param errorMessage
170
448
	 */
171
	public ArrayList<String> getNamespaces() {
449
	public void setErrorMessage(String errorMessage) {
172
		return null;
450
		this.errorMessage = errorMessage;
451
	}
173
	}
452
174
453
}
175
}
(-)src/org/eclipse/wst/xsl/ui/internal/StructuredTextViewerConfigurationXSL.java (-1 / +10 lines)
Lines 11-16 Link Here
11
11
12
package org.eclipse.wst.xsl.ui.internal;
12
package org.eclipse.wst.xsl.ui.internal;
13
13
14
import java.util.ArrayList;
15
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IExtensionPoint;
19
import org.eclipse.core.runtime.IExtensionRegistry;
20
import org.eclipse.core.runtime.Platform;
14
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
21
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
15
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
22
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
16
import org.eclipse.jface.text.source.ISourceViewer;
23
import org.eclipse.jface.text.source.ISourceViewer;
Lines 20-28 Link Here
20
																			// org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML;
27
																			// org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML;
21
import org.eclipse.wst.xml.core.text.IXMLPartitions;
28
import org.eclipse.wst.xml.core.text.IXMLPartitions;
22
import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
29
import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
30
import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
23
import org.eclipse.wst.xml.ui.internal.contentassist.NoRegionContentAssistProcessor;
31
import org.eclipse.wst.xml.ui.internal.contentassist.NoRegionContentAssistProcessor;
24
import org.eclipse.wst.xsl.core.internal.text.IXSLPartitions;
32
import org.eclipse.wst.xsl.core.internal.text.IXSLPartitions;
25
import org.eclipse.wst.xsl.core.internal.text.rules.StructuredTextPartitionerForXSL;
33
import org.eclipse.wst.xsl.core.internal.text.rules.StructuredTextPartitionerForXSL;
34
import org.eclipse.wst.xsl.ui.internal.contentassist.ContentAssistProcessorFactory;
26
import org.eclipse.wst.xsl.ui.internal.contentassist.XSLContentAssistProcessor;
35
import org.eclipse.wst.xsl.ui.internal.contentassist.XSLContentAssistProcessor;
27
import org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector;
36
import org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector;
28
import org.eclipse.wst.xsl.ui.internal.style.LineStyleProviderForXSL;
37
import org.eclipse.wst.xsl.ui.internal.style.LineStyleProviderForXSL;
Lines 59-65 Link Here
59
		if ((partitionType.equals(IStructuredPartitions.DEFAULT_PARTITION))
68
		if ((partitionType.equals(IStructuredPartitions.DEFAULT_PARTITION))
60
				|| (partitionType.equals(IXMLPartitions.XML_DEFAULT))
69
				|| (partitionType.equals(IXMLPartitions.XML_DEFAULT))
61
				|| (partitionType.equals(IXSLPartitions.XSL_XPATH))) {
70
				|| (partitionType.equals(IXSLPartitions.XSL_XPATH))) {
62
			processors = new IContentAssistProcessor[] { new XSLContentAssistProcessor() };
71
				processors = ContentAssistProcessorFactory.createProcessors();		
63
		} else if (partitionType.equals(IStructuredPartitions.UNKNOWN_PARTITION)) {
72
		} else if (partitionType.equals(IStructuredPartitions.UNKNOWN_PARTITION)) {
64
			processors = new IContentAssistProcessor[] { new NoRegionContentAssistProcessor() };
73
			processors = new IContentAssistProcessor[] { new NoRegionContentAssistProcessor() };
65
		}
74
		}
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.wst.xsl.ui;singleton:=true
4
Bundle-SymbolicName: org.eclipse.wst.xsl.ui;singleton:=true
5
Bundle-Version: 1.0.200.qualifier
5
Bundle-Version: 1.1.0.qualifier
6
Bundle-Activator: org.eclipse.wst.xsl.ui.internal.XSLUIPlugin
6
Bundle-Activator: org.eclipse.wst.xsl.ui.internal.XSLUIPlugin
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Require-Bundle: org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
8
Require-Bundle: org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
Lines 35-40 Link Here
35
 org.eclipse.wst.xsl.ui.internal.editor;x-internal:=true,
35
 org.eclipse.wst.xsl.ui.internal.editor;x-internal:=true,
36
 org.eclipse.wst.xsl.ui.internal.handlers;x-internal:=true,
36
 org.eclipse.wst.xsl.ui.internal.handlers;x-internal:=true,
37
 org.eclipse.wst.xsl.ui.internal.preferences;x-internal:=true,
37
 org.eclipse.wst.xsl.ui.internal.preferences;x-internal:=true,
38
 org.eclipse.wst.xsl.ui.internal.quickassist;x-internal:=true,
38
 org.eclipse.wst.xsl.ui.internal.style;x-internal:=true,
39
 org.eclipse.wst.xsl.ui.internal.style;x-internal:=true,
39
 org.eclipse.wst.xsl.ui.internal.templates;x-internal:=true,
40
 org.eclipse.wst.xsl.ui.internal.templates;x-internal:=true,
40
 org.eclipse.wst.xsl.ui.internal.util;x-internal:=true,
41
 org.eclipse.wst.xsl.ui.internal.util;x-internal:=true,
(-).settings/org.eclipse.pde.prefs (-1 / +4 lines)
Lines 1-4 Link Here
1
#Fri Sep 05 23:58:31 GMT 2008
1
#Tue Sep 22 02:22:18 GMT 2009
2
compilers.f.unresolved-features=1
2
compilers.f.unresolved-features=1
3
compilers.f.unresolved-plugins=1
3
compilers.f.unresolved-plugins=1
4
compilers.incompatible-environment=1
4
compilers.incompatible-environment=1
Lines 7-12 Link Here
7
compilers.p.discouraged-class=1
7
compilers.p.discouraged-class=1
8
compilers.p.internal=1
8
compilers.p.internal=1
9
compilers.p.missing-packages=2
9
compilers.p.missing-packages=2
10
compilers.p.missing-version-export-package=2
11
compilers.p.missing-version-import-package=2
12
compilers.p.missing-version-require-bundle=2
10
compilers.p.no-required-att=0
13
compilers.p.no-required-att=0
11
compilers.p.not-externalized-att=1
14
compilers.p.not-externalized-att=1
12
compilers.p.unknown-attribute=1
15
compilers.p.unknown-attribute=1
(-)src/org/eclipse/wst/xsl/ui/internal/contentassist/ContentAssistProcessorFactory.java (+69 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Standards for Technology in Automotive Retail 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
 *     David Carver (STAR) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.xsl.ui.internal.contentassist;
12
13
import java.util.ArrayList;
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.core.runtime.IExtensionPoint;
18
import org.eclipse.core.runtime.IExtensionRegistry;
19
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
21
import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin;
22
23
/**
24
 * A factory class that reads an eclipse extension point for Content Assist
25
 * Processors.
26
 * @author dcarver
27
 * @since 1.1
28
 */
29
public class ContentAssistProcessorFactory {
30
	private static IContentAssistProcessor[] processors = null;
31
	
32
	/**
33
	 * Creates the necessary Content Assist Processors that have been
34
	 * Contributed to the XSL Editor configuration.
35
	 * @return
36
	 */
37
	public static IContentAssistProcessor[] createProcessors() {
38
		IExtensionPoint point = getExtensionPoint();
39
		if (point == null) {
40
			return processors;
41
		}
42
		getProcessors(point);
43
		return processors;
44
	}
45
46
	private static void getProcessors(IExtensionPoint point) {
47
		ArrayList<Object> eprocessors = new ArrayList<Object>();
48
		IConfigurationElement[] configElems = point.getConfigurationElements();
49
		
50
		for (IConfigurationElement processor : configElems) {
51
			try {
52
				final Object o = processor.createExecutableExtension("class"); //$NON-NLS-1$
53
				eprocessors.add(o);
54
			} catch (CoreException ex) {
55
				
56
			}
57
		}
58
		if (!eprocessors.isEmpty()) {
59
			processors = new IContentAssistProcessor[eprocessors.size()];
60
			eprocessors.toArray(processors);
61
		}
62
	}
63
64
	private static IExtensionPoint getExtensionPoint() {
65
		IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
66
		IExtensionPoint point = pluginRegistry.getExtensionPoint(XSLUIPlugin.PLUGIN_ID, "contentAssistProcessor"); //$NON-NLS-1$
67
		return point;
68
	}
69
}
(-)schema/contentAssistProcessor.exsd (+79 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.wst.xsl.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
 <annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.eclipse.wst.xsl.ui" id="contentAssistProcessor" name="XSL Content Assistance"/>
7
      </appinfo>
8
      <documentation>
9
         XSL Content Asisstance processor extension point, allows for the contribution of adopter defined XSL processor extensions.
10
11
      </documentation>
12
   </annotation>
13
14
   <element name="extension">
15
      <annotation>
16
         <appinfo>
17
            <meta.element />
18
         </appinfo>
19
      </annotation>
20
      <complexType>
21
         <sequence>
22
            <element ref="processor" minOccurs="1" maxOccurs="unbounded"/>
23
         </sequence>
24
         <attribute name="point" type="string" use="required">
25
            <annotation>
26
               <documentation>
27
                  
28
               </documentation>
29
            </annotation>
30
         </attribute>
31
         <attribute name="id" type="string">
32
            <annotation>
33
               <documentation>
34
                  
35
               </documentation>
36
            </annotation>
37
         </attribute>
38
         <attribute name="name" type="string">
39
            <annotation>
40
               <documentation>
41
                  
42
               </documentation>
43
               <appinfo>
44
                  <meta.attribute translatable="true"/>
45
               </appinfo>
46
            </annotation>
47
         </attribute>
48
      </complexType>
49
   </element>
50
51
   <element name="processor">
52
      <annotation>
53
         <documentation>
54
            Processor that provides content assistance
55
         </documentation>
56
      </annotation>
57
      <complexType>
58
         <attribute name="class" type="string" use="required">
59
            <annotation>
60
               <documentation>
61
                  
62
               </documentation>
63
               <appinfo>
64
                  <meta.attribute kind="java"/>
65
               </appinfo>
66
            </annotation>
67
         </attribute>
68
      </complexType>
69
   </element>
70
71
   <annotation>
72
      <appinfo>
73
         <meta.section type="since"/>
74
      </appinfo>
75
      <documentation>
76
         1.1
77
      </documentation>
78
   </annotation>
79
</schema>
(-)src/org/eclipse/wst/xsl/ui/internal/contentassist/AbstractXSLContentAssistProcessor.java (+292 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Standards for Technology in Automotive Retail 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
 *     David Carver (STAR) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.xsl.ui.internal.contentassist;
12
13
import org.eclipse.jface.text.ITextViewer;
14
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
15
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
16
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
17
import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
18
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
19
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
20
import org.w3c.dom.Node;
21
22
/**
23
 * This is an Abstract class that implementors should extend for implementing
24
 * XSL Content Assist Processors.   It provides common convience methods for
25
 * information that is needed to construct a content assist processor.
26
 * 
27
 * @author dcarver
28
 * @since 1.1
29
 */
30
public abstract class AbstractXSLContentAssistProcessor implements IXSLContentAssistProcessor {
31
32
	protected String errorMessage = ""; //$NON-NLS-1$
33
	protected ITextViewer textViewer = null;
34
	private IndexedRegion treeNode;
35
	private Node node;
36
	protected IDOMNode xmlNode;
37
	protected IStructuredDocumentRegion sdRegion;
38
	protected ITextRegion completionRegion;
39
	protected String matchString;
40
	protected int cursorPosition;
41
42
	/**
43
	 * @param textViewer
44
	 * @param documentPosition
45
	 */
46
	protected void initializeProposalVariables(ITextViewer textViewer, int documentPosition) {
47
		this.textViewer = textViewer;
48
		cursorPosition = documentPosition;
49
		treeNode = ContentAssistUtils.getNodeAt(textViewer, cursorPosition);
50
		node = getActualDOMNode((Node) treeNode);
51
		xmlNode = (IDOMNode) node;
52
		sdRegion = getStructuredDocumentRegion();
53
		completionRegion = getCompletionRegion(cursorPosition, node);
54
		matchString = getMatchString(sdRegion, completionRegion, cursorPosition);
55
	}
56
57
	/**
58
	 * @param node
59
	 * @return
60
	 */
61
	private Node getActualDOMNode(Node node) {
62
		while ((node != null) && (node.getNodeType() == Node.TEXT_NODE)
63
				&& (node.getParentNode() != null)) {
64
			node = node.getParentNode();
65
		}
66
		return node;
67
	}
68
69
	/**
70
	 * StructuredTextViewer must be set before using this.
71
	 * 
72
	 * @param pos
73
	 * @return
74
	 */
75
	private IStructuredDocumentRegion getStructuredDocumentRegion() {
76
		return ContentAssistUtils.getStructuredDocumentRegion(textViewer,
77
				cursorPosition);
78
	}
79
80
	/**
81
	 * Return the region whose content's require completion. This is something
82
	 * of a misnomer as sometimes the user wants to be prompted for contents of
83
	 * a non-existent ITextRegion, such as for enumerated attribute values
84
	 * following an '=' sign.
85
	 * 
86
	 * Copied from AbstractContentAssist Processor.
87
	 */
88
	protected ITextRegion getCompletionRegion(int documentPosition, Node domnode) {
89
		if (domnode == null) {
90
			return null;
91
		}
92
	
93
		ITextRegion region = null;
94
		int offset = documentPosition;
95
		IStructuredDocumentRegion flatNode = null;
96
		IDOMNode node = (IDOMNode) domnode;
97
	
98
		if (node.getNodeType() == Node.DOCUMENT_NODE) {
99
			if (node.getStructuredDocument().getLength() == 0) {
100
				return null;
101
			}
102
			ITextRegion result = node.getStructuredDocument()
103
					.getRegionAtCharacterOffset(offset)
104
					.getRegionAtCharacterOffset(offset);
105
			while (result == null) {
106
				offset--;
107
				result = node.getStructuredDocument()
108
						.getRegionAtCharacterOffset(offset)
109
						.getRegionAtCharacterOffset(offset);
110
			}
111
			return result;
112
		}
113
	
114
		IStructuredDocumentRegion startTag = node
115
				.getStartStructuredDocumentRegion();
116
		IStructuredDocumentRegion endTag = node
117
				.getEndStructuredDocumentRegion();
118
	
119
		if ((startTag != null) && (startTag.getStartOffset() <= offset)
120
				&& (offset < startTag.getStartOffset() + startTag.getLength())) {
121
			flatNode = startTag;
122
		} else if ((endTag != null) && (endTag.getStartOffset() <= offset)
123
				&& (offset < endTag.getStartOffset() + endTag.getLength())) {
124
			flatNode = endTag;
125
		}
126
	
127
		if (flatNode != null) {
128
			region = getCompletionRegion(offset, flatNode);
129
		} else {
130
			flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(
131
					offset);
132
			if ((flatNode.getStartOffset() <= documentPosition)
133
					&& (flatNode.getEndOffset() >= documentPosition)) {
134
				if ((offset == flatNode.getStartOffset())
135
						&& (flatNode.getPrevious() != null)
136
						&& (((flatNode
137
								.getRegionAtCharacterOffset(documentPosition) != null) && (flatNode
138
								.getRegionAtCharacterOffset(documentPosition)
139
								.getType() != DOMRegionContext.XML_CONTENT))
140
								|| (flatNode.getPrevious().getLastRegion()
141
										.getType() == DOMRegionContext.XML_TAG_OPEN) || (flatNode
142
								.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) {
143
					region = flatNode.getPrevious().getLastRegion();
144
				} else if (flatNode.getEndOffset() == documentPosition) {
145
					region = flatNode.getLastRegion();
146
				} else {
147
					region = flatNode.getFirstRegion();
148
				}
149
			} else {
150
				region = flatNode.getLastRegion();
151
			}
152
		}
153
	
154
		return region;
155
	}
156
157
	protected ITextRegion getCompletionRegion(int offset, IStructuredDocumentRegion sdRegion) {
158
		ITextRegion region = sdRegion.getRegionAtCharacterOffset(offset);
159
		if (region == null) {
160
			return null;
161
		}
162
	
163
		if (sdRegion.getStartOffset(region) == offset) {
164
			// The offset is at the beginning of the region
165
			if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset())
166
					&& (sdRegion.getPrevious() != null)
167
					&& (!sdRegion.getPrevious().isEnded())) {
168
				region = sdRegion.getPrevious().getRegionAtCharacterOffset(
169
						offset - 1);
170
			} else {
171
				// Is there no separating whitespace from the previous region?
172
				// If not,
173
				// then that region is the important one
174
				ITextRegion previousRegion = sdRegion
175
						.getRegionAtCharacterOffset(offset - 1);
176
				if ((previousRegion != null)
177
						&& (previousRegion != region)
178
						&& (previousRegion.getTextLength() == previousRegion
179
								.getLength())) {
180
					region = previousRegion;
181
				}
182
			}
183
		} else {
184
			// The offset is NOT at the beginning of the region
185
			if (offset > sdRegion.getStartOffset(region)
186
					+ region.getTextLength()) {
187
				// Is the offset within the whitespace after the text in this
188
				// region?
189
				// If so, use the next region
190
				ITextRegion nextRegion = sdRegion
191
						.getRegionAtCharacterOffset(sdRegion
192
								.getStartOffset(region)
193
								+ region.getLength());
194
				if (nextRegion != null) {
195
					region = nextRegion;
196
				}
197
			} else {
198
				// Is the offset within the important text for this region?
199
				// If so, then we've already got the right one.
200
			}
201
		}
202
	
203
		// valid WHITE_SPACE region handler (#179924)
204
		if ((region != null)
205
				&& (region.getType() == DOMRegionContext.WHITE_SPACE)) {
206
			ITextRegion previousRegion = sdRegion
207
					.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) - 1);
208
			if (previousRegion != null) {
209
				region = previousRegion;
210
			}
211
		}
212
	
213
		return region;
214
	}
215
216
	private String getMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
217
		String matchString = ""; //$NON-NLS-1$
218
		
219
		if (isNotMatchStringRegion(parent, aRegion, offset)) {
220
			return matchString; 
221
		}
222
	
223
		if (hasMatchString(parent, aRegion, offset)) {
224
			matchString = extractMatchString(parent, aRegion, offset);
225
		}
226
		return matchString;
227
	}
228
229
	private boolean isNotMatchStringRegion(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
230
		if (aRegion == null || parent == null)
231
			return true;
232
		
233
		String regionType = aRegion.getType();
234
		int totalRegionOffset = parent.getStartOffset(aRegion)
235
				+ aRegion.getTextLength();
236
		return (isCloseRegion(aRegion)
237
				|| hasNoMatchString(offset, regionType, totalRegionOffset));
238
	}
239
240
	private boolean isCloseRegion(ITextRegion region) {
241
		String type = region.getType();
242
		return ((type == DOMRegionContext.XML_PI_CLOSE)
243
				|| (type == DOMRegionContext.XML_TAG_CLOSE)
244
				|| (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)
245
				|| (type == DOMRegionContext.XML_CDATA_CLOSE)
246
				|| (type == DOMRegionContext.XML_COMMENT_CLOSE)
247
				|| (type == DOMRegionContext.XML_ATTLIST_DECL_CLOSE)
248
				|| (type == DOMRegionContext.XML_ELEMENT_DECL_CLOSE)
249
				|| (type == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE));
250
	}
251
252
	private boolean hasMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
253
		return (parent.getText(aRegion).length() > 0)
254
				&& (parent.getStartOffset(aRegion) < offset);
255
	}
256
257
	private boolean hasNoMatchString(int offset, String regionType, int totalRegionOffset) {
258
		return regionType.equals(DOMRegionContext.XML_CONTENT)
259
				|| regionType.equals(DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS)
260
				|| regionType.equals(DOMRegionContext.XML_TAG_OPEN)
261
				|| offset > totalRegionOffset;
262
	}
263
264
	private String extractMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
265
		String matchString;
266
		matchString = parent.getText(aRegion).substring(0,
267
				offset - parent.getStartOffset(aRegion));
268
		if (matchString.startsWith("\"")) { //$NON-NLS-1$
269
			matchString = matchString.substring(1);
270
		}
271
		return matchString;
272
	}
273
274
	/**
275
	 * (non-Javadoc)
276
	 * 
277
	 * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
278
	 */
279
	public String getErrorMessage() {
280
		return errorMessage;
281
	}
282
283
	/**
284
	 * Sets the error message for why content assistance didn't complete.
285
	 * 
286
	 * @param errorMessage
287
	 */
288
	public void setErrorMessage(String errorMessage) {
289
		this.errorMessage = errorMessage;
290
	}
291
292
}
(-)src/org/eclipse/wst/xsl/ui/internal/contentassist/IXSLContentAssistProcessor.java (+17 lines)
Added Link Here
1
package org.eclipse.wst.xsl.ui.internal.contentassist;
2
3
import java.util.ArrayList;
4
5
public interface IXSLContentAssistProcessor {
6
7
	/**
8
	 * ArrayList of Strings for the namespaces this processor activates against.
9
	 * @return
10
	 */
11
	public ArrayList<String> getNamespaces();
12
	
13
	public String getMinimumVersion();
14
	
15
	public String getMaximumVersion();
16
	
17
}
(-)src/org/eclipse/wst/xsl/ui/tests/XSLUITestSuite.java (+2 lines)
Lines 24-29 Link Here
24
import org.eclipse.wst.xsl.ui.tests.contentassist.TestTemplateModeCompletionProposal;
24
import org.eclipse.wst.xsl.ui.tests.contentassist.TestTemplateModeCompletionProposal;
25
import org.eclipse.wst.xsl.ui.tests.contentassist.TestXPathXMLCompletionProposal;
25
import org.eclipse.wst.xsl.ui.tests.contentassist.TestXPathXMLCompletionProposal;
26
import org.eclipse.wst.xsl.ui.tests.contentassist.XSLCompletionTest;
26
import org.eclipse.wst.xsl.ui.tests.contentassist.XSLCompletionTest;
27
import org.eclipse.wst.xsl.ui.tests.extensions.TestContentAssistProcessorFactory;
27
import org.eclipse.wst.xsl.ui.tests.hyperlinkdetector.TestXSLHyperlinkDetector;
28
import org.eclipse.wst.xsl.ui.tests.hyperlinkdetector.TestXSLHyperlinkDetector;
28
import org.eclipse.wst.xsl.ui.tests.style.TestXMLRegionMap;
29
import org.eclipse.wst.xsl.ui.tests.style.TestXMLRegionMap;
29
import org.eclipse.wst.xsl.ui.tests.style.TestXSLLineStyleProvider;
30
import org.eclipse.wst.xsl.ui.tests.style.TestXSLLineStyleProvider;
Lines 53-57 Link Here
53
		addTestSuite(TestXPathXMLCompletionProposal.class);
54
		addTestSuite(TestXPathXMLCompletionProposal.class);
54
		addTestSuite(TestTemplateContextTypeXSL.class);
55
		addTestSuite(TestTemplateContextTypeXSL.class);
55
		addTestSuite(TestEmptyFileCompletionProposal.class);
56
		addTestSuite(TestEmptyFileCompletionProposal.class);
57
		addTestSuite(TestContentAssistProcessorFactory.class);
56
	}
58
	}
57
}
59
}
(-)src/org/eclipse/wst/xsl/ui/tests/AbstractSourceViewerTest.java (+12 lines)
Lines 39-44 Link Here
39
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
39
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
40
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
40
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
41
import org.eclipse.wst.xml.core.internal.encoding.XMLDocumentLoader;
41
import org.eclipse.wst.xml.core.internal.encoding.XMLDocumentLoader;
42
import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor;
42
import org.eclipse.wst.xsl.ui.internal.StructuredTextViewerConfigurationXSL;
43
import org.eclipse.wst.xsl.ui.internal.StructuredTextViewerConfigurationXSL;
43
import org.eclipse.wst.xsl.ui.internal.contentassist.XSLContentAssistProcessor;
44
import org.eclipse.wst.xsl.ui.internal.contentassist.XSLContentAssistProcessor;
44
45
Lines 135-140 Link Here
135
				sourceViewer, offset);
136
				sourceViewer, offset);
136
	}
137
	}
137
	
138
	
139
	protected ICompletionProposal[] getXMLProposals(int offset) throws Exception {
140
		return new XMLContentAssistProcessor().computeCompletionProposals(
141
				sourceViewer, offset);
142
	}
143
	
138
	/**
144
	/**
139
	 * Get the content completion proposals at <code>lineNumber</code>, <code>numberOfCharacters</code>.
145
	 * Get the content completion proposals at <code>lineNumber</code>, <code>numberOfCharacters</code>.
140
	 * Number of characters refers to how many total characters from the starting offset of the line.  This is
146
	 * Number of characters refers to how many total characters from the starting offset of the line.  This is
Lines 150-155 Link Here
150
		int offset = calculateOffset(lineNumber, numberOfCharacters);
156
		int offset = calculateOffset(lineNumber, numberOfCharacters);
151
		return new XSLContentAssistProcessor().computeCompletionProposals(sourceViewer, offset);
157
		return new XSLContentAssistProcessor().computeCompletionProposals(sourceViewer, offset);
152
	}
158
	}
159
	
160
	protected ICompletionProposal[] getXMLProposals(int lineNumber, int numberOfCharacters) throws BadLocationException {
161
		int offset = calculateOffset(lineNumber, numberOfCharacters);
162
		return new XMLContentAssistProcessor().computeCompletionProposals(sourceViewer, offset);
163
	}
164
	
153
165
154
	protected int calculateOffset(int lineNumber, int columnNumber)
166
	protected int calculateOffset(int lineNumber, int columnNumber)
155
			throws BadLocationException {
167
			throws BadLocationException {
(-)src/org/eclipse/wst/xsl/ui/tests/contentassist/TestTemplateModeCompletionProposal.java (-1 / +4 lines)
Lines 42-51 Link Here
42
			// assertEquals("Wrong offset returned", 471, offset);
42
			// assertEquals("Wrong offset returned", 471, offset);
43
43
44
			ICompletionProposal[] proposals = getProposals(offset);
44
			ICompletionProposal[] proposals = getProposals(offset);
45
			assertProposalExists("\"#all\"", proposals);
46
			assertProposalExists("mode1", proposals);
45
			assertProposalExists("mode1", proposals);
47
			assertProposalExists("mode2", proposals);
46
			assertProposalExists("mode2", proposals);
48
			assertProposalExists("mode3", proposals);
47
			assertProposalExists("mode3", proposals);
48
			
49
			proposals = getXMLProposals(offset);
50
			assertProposalExists("\"#all\"", proposals);
51
49
		} finally {
52
		} finally {
50
			model.releaseFromEdit();
53
			model.releaseFromEdit();
51
		}
54
		}
(-)src/org/eclipse/wst/xsl/ui/tests/contentassist/XSLCompletionTest.java (-2 / +2 lines)
Lines 146-152 Link Here
146
		loadFileForTesting(xslFilePath);
146
		loadFileForTesting(xslFilePath);
147
147
148
		try {
148
		try {
149
			ICompletionProposal[] proposals = getProposals(37,18);
149
			ICompletionProposal[] proposals = getXMLProposals(37,18);
150
			assertTrue(proposals.length >= 1);
150
			assertTrue(proposals.length >= 1);
151
			ICompletionProposal proposal = proposals[0];
151
			ICompletionProposal proposal = proposals[0];
152
			assertTrue("Wrong attribute proposal returned:", proposal
152
			assertTrue("Wrong attribute proposal returned:", proposal
Lines 162-168 Link Here
162
		loadFileForTesting(xslFilePath);
162
		loadFileForTesting(xslFilePath);
163
163
164
		try {
164
		try {
165
			ICompletionProposal[] proposals = getProposals(31,58);
165
			ICompletionProposal[] proposals = getXMLProposals(31,58);
166
			assertTrue(proposals.length >= 2);
166
			assertTrue(proposals.length >= 2);
167
167
168
			ICompletionProposal proposal = proposals[1];
168
			ICompletionProposal proposal = proposals[1];
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 29-34 Link Here
29
   org.eclipse.core.resources,
29
   org.eclipse.core.resources,
30
   org.eclipse.core.runtime",
30
   org.eclipse.core.runtime",
31
 org.eclipse.wst.xsl.ui.tests.contentassist,
31
 org.eclipse.wst.xsl.ui.tests.contentassist,
32
 org.eclipse.wst.xsl.ui.tests.extensions,
32
 org.eclipse.wst.xsl.ui.tests.hyperlinkdetector,
33
 org.eclipse.wst.xsl.ui.tests.hyperlinkdetector,
33
 org.eclipse.wst.xsl.ui.tests.style,
34
 org.eclipse.wst.xsl.ui.tests.style,
34
 org.eclipse.wst.xsl.ui.tests.templates
35
 org.eclipse.wst.xsl.ui.tests.templates
(-)src/org/eclipse/wst/xsl/ui/tests/extensions/TestContentAssistProcessorFactory.java (+44 lines)
Added Link Here
1
package org.eclipse.wst.xsl.ui.tests.extensions;
2
3
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
4
import org.eclipse.wst.xsl.ui.internal.contentassist.ContentAssistProcessorFactory;
5
6
import junit.framework.TestCase;
7
8
public class TestContentAssistProcessorFactory extends TestCase {
9
10
	private static final String XML_CONTENT_ASSIST_PROCESSOR = "org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor";
11
	private static final String XSL_CONTENT_ASSIST_PROCESSOR = "org.eclipse.wst.xsl.ui.internal.contentassist.XSLContentAssistProcessor";
12
13
	public void testContentAssistProcessorsExist() {
14
		IContentAssistProcessor[] processors = ContentAssistProcessorFactory.createProcessors();
15
		assertNotNull(processors);
16
	}
17
	
18
	public void testXMLContentAssistProcessorExists() {
19
		IContentAssistProcessor[] processors = ContentAssistProcessorFactory.createProcessors();
20
		if (processors == null) {
21
			fail("Missing Content Assist Processors.");
22
		}
23
		assertTrue("Did not find XML Content Assist Processor", findProcessor(processors, XML_CONTENT_ASSIST_PROCESSOR));
24
	}
25
26
	
27
	public void testXSLContentAssistProcessorExists() {
28
		IContentAssistProcessor[] processors = ContentAssistProcessorFactory.createProcessors();
29
		if (processors == null) {
30
			fail("Missing Content Assist Processors.");
31
		}
32
		assertTrue("Did not find XSL Content Assist Processor", findProcessor(processors, XSL_CONTENT_ASSIST_PROCESSOR));
33
	}
34
	
35
	private boolean findProcessor(IContentAssistProcessor[] processors, String name) {
36
		boolean fndsw = false;
37
		for (IContentAssistProcessor processor : processors) {
38
			if (processor.getClass().getName().equals(name)) {
39
				fndsw = true;
40
			}
41
		}
42
		return fndsw;
43
	}
44
}

Return to bug 259721