use of org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor in project webtools.sourceediting by eclipse.
the class SemanticHighlightingManager method enable.
/**
* Enable semantic highlighting.
*/
private void enable() {
loadSemanticHighlightings();
fPresenter = new SemanticHighlightingPresenter();
fPresenter.install(fSourceViewer, fPresentationReconciler);
// if (fEditor != null) {
fReconciler = new SemanticHighlightingReconciler();
fReconciler.install(fSourceViewer, fPresenter, fHighlightings, fHighlightingStyles);
IReconciler reconciler = fConfiguration.getReconciler(fSourceViewer);
if (reconciler instanceof DocumentRegionProcessor)
((DocumentRegionProcessor) reconciler).setSemanticHighlightingStrategy(fReconciler);
// } else {
// fPresenter.updatePresentation(null, createHardcodedPositions(), new HighlightedPosition[0]);
// }
}
use of org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor in project webtools.sourceediting by eclipse.
the class TestSourceValidationFramework method getSourceValidatorIDs.
private List getSourceValidatorIDs(String fileName) throws Exception {
List validatorIds = new ArrayList(1);
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IFile file = ensureFileIsAccessible(PROJECT_NAME + SEPARATOR + fileName, null);
IEditorPart editor = IDE.openEditor(page, file, TestStructuredTextEditor.class.getName(), true);
ITextEditor textEditor = editor.getAdapter(ITextEditor.class);
TestStructuredTextEditor testTextEditor = (TestStructuredTextEditor) textEditor;
IReconciler reconciler = testTextEditor.textViewerConfiguration.getReconciler(testTextEditor.getTextViewer());
assertNotNull(reconciler);
assertTrue("unexpected IReconciler implementation: " + reconciler.getClass(), reconciler instanceof DocumentRegionProcessor);
Class reconcilerClass = reconciler.getClass();
Method method = null;
while (reconcilerClass != Object.class && method == null) {
Method[] methods = reconcilerClass.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals("getValidatorStrategy")) {
method = methods[i];
}
}
reconcilerClass = reconcilerClass.getSuperclass();
}
assertNotNull("no getValidatorStrategy method found on " + reconciler.getClass(), method);
method.setAccessible(true);
ValidatorStrategy strategy = (ValidatorStrategy) method.invoke(reconciler, new Object[0]);
assertNotNull(strategy);
Field fMetaData = strategy.getClass().getDeclaredField("fMetaData");
assertNotNull("validator metadata field \"fMetaData\" not found on strategy " + strategy.getClass(), fMetaData);
fMetaData.setAccessible(true);
List metadata = (List) fMetaData.get(strategy);
assertNotNull(metadata);
for (int i = 0; i < metadata.size(); i++) {
validatorIds.add(((ValidatorMetaData) metadata.get(i)).getValidatorId());
}
page.closeEditor(editor, false);
return validatorIds;
}
use of org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor in project webtools.sourceediting by eclipse.
the class TestStructuredTextEditor method addReconcilingListener.
private void addReconcilingListener(StructuredTextEditor editor, ISourceReconcilingListener listener) throws Exception {
Method mConfig = AbstractTextEditor.class.getDeclaredMethod("getSourceViewerConfiguration", null);
mConfig.setAccessible(true);
Object config = mConfig.invoke(editor, null);
assertTrue("Did not get a source viewer configuration", config instanceof SourceViewerConfiguration);
IReconciler reconciler = ((SourceViewerConfiguration) config).getReconciler(fEditor.getTextViewer());
assertTrue("Reconciler is not a DirtyRegionProcessor", reconciler instanceof DocumentRegionProcessor);
((DocumentRegionProcessor) reconciler).addReconcilingListener(listener);
}
use of org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method addReconcilingListeners.
private void addReconcilingListeners(SourceViewerConfiguration config, StructuredTextViewer stv) {
try {
List reconcilingListeners = new ArrayList(fReconcilingListeners.length);
String[] ids = getConfigurationPoints();
for (int i = 0; i < ids.length; i++) {
// $NON-NLS-1$
reconcilingListeners.addAll(ExtendedConfigurationBuilder.getInstance().getConfigurations("sourceReconcilingListener", ids[i]));
}
fReconcilingListeners = (ISourceReconcilingListener[]) reconcilingListeners.toArray(new ISourceReconcilingListener[reconcilingListeners.size()]);
} catch (ClassCastException e) {
// $NON-NLS-1$
Logger.log(Logger.ERROR, "Configuration has a reconciling listener that does not implement ISourceReconcilingListener.");
}
IReconciler reconciler = config.getReconciler(stv);
if (reconciler instanceof DocumentRegionProcessor) {
for (int i = 0; i < fReconcilingListeners.length; i++) ((DocumentRegionProcessor) reconciler).addReconcilingListener(fReconcilingListeners[i]);
}
}
use of org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method handlePreferenceStoreChanged.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent)
*/
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
String property = event.getProperty();
if (EditorPreferenceNames.EDITOR_TEXT_HOVER_MODIFIERS.equals(property)) {
updateHoverBehavior();
} else // enable or disable as you type validation
if (CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS.equals(property)) {
IReconciler reconciler = this.getSourceViewerConfiguration().getReconciler(this.getSourceViewer());
if (reconciler instanceof DocumentRegionProcessor) {
((DocumentRegionProcessor) reconciler).setValidatorStrategyEnabled(isValidationEnabled());
}
} else if (AbstractStructuredFoldingStrategy.FOLDING_ENABLED.equals(property)) {
if (getSourceViewer() instanceof ProjectionViewer) {
// installed yet
if (isFoldingEnabled() && (fProjectionSupport == null)) {
installProjectionSupport();
}
ProjectionViewer pv = (ProjectionViewer) getSourceViewer();
if (pv.isProjectionMode() != isFoldingEnabled()) {
if (pv.canDoOperation(ProjectionViewer.TOGGLE)) {
pv.doOperation(ProjectionViewer.TOGGLE);
}
}
}
} else // update content assist preferences
if (EditorPreferenceNames.CODEASSIST_PROPOSALS_BACKGROUND.equals(property)) {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer != null) {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
if (configuration != null) {
IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
if (contentAssistant instanceof ContentAssistant) {
ContentAssistant assistant = (ContentAssistant) contentAssistant;
RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), EditorPreferenceNames.CODEASSIST_PROPOSALS_BACKGROUND);
Color color = EditorUtility.getColor(rgb);
assistant.setProposalSelectorBackground(color);
}
}
}
} else // update content assist preferences
if (EditorPreferenceNames.CODEASSIST_PROPOSALS_FOREGROUND.equals(property)) {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer != null) {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
if (configuration != null) {
IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
if (contentAssistant instanceof ContentAssistant) {
ContentAssistant assistant = (ContentAssistant) contentAssistant;
RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), EditorPreferenceNames.CODEASSIST_PROPOSALS_FOREGROUND);
Color color = EditorUtility.getColor(rgb);
assistant.setProposalSelectorForeground(color);
}
}
}
} else // update content assist preferences
if (EditorPreferenceNames.CODEASSIST_PARAMETERS_BACKGROUND.equals(property)) {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer != null) {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
if (configuration != null) {
IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
if (contentAssistant instanceof ContentAssistant) {
ContentAssistant assistant = (ContentAssistant) contentAssistant;
RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), EditorPreferenceNames.CODEASSIST_PARAMETERS_BACKGROUND);
Color color = EditorUtility.getColor(rgb);
assistant.setContextInformationPopupBackground(color);
assistant.setContextSelectorBackground(color);
}
}
}
} else // update content assist preferences
if (EditorPreferenceNames.CODEASSIST_PARAMETERS_FOREGROUND.equals(property)) {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer != null) {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
if (configuration != null) {
IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
if (contentAssistant instanceof ContentAssistant) {
ContentAssistant assistant = (ContentAssistant) contentAssistant;
RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), EditorPreferenceNames.CODEASSIST_PARAMETERS_FOREGROUND);
Color color = EditorUtility.getColor(rgb);
assistant.setContextInformationPopupForeground(color);
assistant.setContextSelectorForeground(color);
}
}
}
}
super.handlePreferenceStoreChanged(event);
}
Aggregations