use of org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML in project webtools.sourceediting by eclipse.
the class ViewerTestHTML method setupViewerForEditor.
/**
* Sets up the viewer with the same document/input as the given editor
*
* @param ITextEditor
* editor - the editor to use *cannot to be null*
*/
void setupViewerForEditor(ITextEditor editor) {
// if was following selection, stop
stopFollowSelection();
IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
fSourceViewer.setDocument(doc);
// need to reconfigure after set document just so highlighter works
fSourceViewer.configure(new StructuredTextViewerConfigurationHTML());
}
use of org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML in project webtools.sourceediting by eclipse.
the class ContentAssistTestUtilities method getProposals.
/**
* <p>
* Invoke content assist on the given editor at the given offset, for the given number of pages
* and return the results of each page
* </p>
*/
private static ICompletionProposal[][] getProposals(AbstractTextEditor editor, int offset, int pageCount) throws Exception {
ICompletionProposal[][] pages = null;
/* if JS editor
* else if HTML editor */
if (editor instanceof JavaEditor) {
// setup the viewer
ISourceViewer viewer = ((JavaEditor) editor).getViewer();
JavaScriptSourceViewerConfiguration configuration = new JavaScriptSourceViewerConfiguration(JavaScriptPlugin.getDefault().getJavaTextTools().getColorManager(), JavaScriptPlugin.getDefault().getCombinedPreferenceStore(), editor, IJavaScriptPartitions.JAVA_PARTITIONING);
ContentAssistant contentAssistant = (ContentAssistant) configuration.getContentAssistant(viewer);
// get the processor
String partitionTypeID = viewer.getDocument().getPartition(offset).getType();
IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(partitionTypeID);
// fire content assist session about to start
Method privateFireSessionBeginEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionBeginEvent", new Class[] { boolean.class });
privateFireSessionBeginEventMethod.setAccessible(true);
privateFireSessionBeginEventMethod.invoke(contentAssistant, new Object[] { Boolean.TRUE });
// get content assist suggestions
pages = new ICompletionProposal[pageCount][];
for (int p = 0; p < pageCount; ++p) {
pages[p] = processor.computeCompletionProposals(viewer, offset);
}
// fire content assist session ending
Method privateFireSessionEndEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionEndEvent", null);
privateFireSessionEndEventMethod.setAccessible(true);
privateFireSessionEndEventMethod.invoke(contentAssistant, null);
} else if (editor instanceof StructuredTextEditor) {
// setup the viewer
StructuredTextViewer viewer = ((StructuredTextEditor) editor).getTextViewer();
StructuredTextViewerConfigurationHTML configuration = new StructuredTextViewerConfigurationHTML();
ContentAssistant contentAssistant = (ContentAssistant) configuration.getContentAssistant(viewer);
viewer.configure(configuration);
viewer.setSelectedRange(offset, 0);
// get the processor
String partitionTypeID = viewer.getDocument().getPartition(offset).getType();
IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(partitionTypeID);
// fire content assist session about to start
Method privateFireSessionBeginEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionBeginEvent", new Class[] { boolean.class });
privateFireSessionBeginEventMethod.setAccessible(true);
privateFireSessionBeginEventMethod.invoke(contentAssistant, new Object[] { Boolean.TRUE });
// get content assist suggestions
pages = new ICompletionProposal[pageCount][];
for (int p = 0; p < pageCount; ++p) {
pages[p] = processor.computeCompletionProposals(viewer, offset);
}
// fire content assist session ending
Method privateFireSessionEndEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionEndEvent", null);
privateFireSessionEndEventMethod.setAccessible(true);
privateFireSessionEndEventMethod.invoke(contentAssistant, null);
}
return pages;
}
use of org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML in project webtools.sourceediting by eclipse.
the class TestEmbededCSSContentAssistComputers method getProposals.
/**
* <p>Invoke content assist on the given viewer at the given offset, for the given number of pages
* and return the results of each page</p>
*
* @param viewer
* @param offset
* @param pageCount
* @return
* @throws Exception
*/
private static ICompletionProposal[][] getProposals(StructuredTextViewer viewer, int offset, int pageCount) throws Exception {
// setup the viewer
StructuredTextViewerConfigurationHTML configuration = new StructuredTextViewerConfigurationHTML();
ContentAssistant contentAssistant = (ContentAssistant) configuration.getContentAssistant(viewer);
viewer.configure(configuration);
viewer.setSelectedRange(offset, 0);
// get the processor
String partitionTypeID = viewer.getDocument().getPartition(offset).getType();
IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(partitionTypeID);
// fire content assist session about to start
Method privateFireSessionBeginEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionBeginEvent", new Class[] { boolean.class });
privateFireSessionBeginEventMethod.setAccessible(true);
privateFireSessionBeginEventMethod.invoke(contentAssistant, new Object[] { Boolean.TRUE });
// get content assist suggestions
ICompletionProposal[][] pages = new ICompletionProposal[pageCount][];
for (int p = 0; p < pageCount; ++p) {
pages[p] = processor.computeCompletionProposals(viewer, offset);
}
// fire content assist session ending
Method privateFireSessionEndEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionEndEvent", null);
privateFireSessionEndEventMethod.setAccessible(true);
privateFireSessionEndEventMethod.invoke(contentAssistant, null);
return pages;
}
Aggregations