1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 499374 - Extend the preview code on the Syntax Coloring preference page

The code now includes a template parameter and a task tag, so their
respective colorings can be seen in the preview window.

Change-Id: Ie74a0af04b016ef506d665a9472775aa8f6d757c
This commit is contained in:
Nathan Ridge 2017-01-26 01:21:53 -05:00
parent 4ed57293e6
commit 52299c9124
2 changed files with 14 additions and 2 deletions

View file

@ -23,6 +23,7 @@ import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@ -62,6 +63,7 @@ import org.eclipse.ui.texteditor.ChainedPreferenceStore;
import com.ibm.icu.text.Collator;
import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ICPartitions;
@ -816,7 +818,16 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
private Control createPreviewer(Composite parent) {
IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), generalTextStore });
// Task tags can have their own coloring, and to demonstrate this, the preview code
// contains a "TODO" task tag. In order for the comment scanner to recognize this
// as a task tag and apply the coloring, "TODO" needs to be present under the
// TODO_TASK_TAGS preference key. Normally this is contained in the core preference
// store, but since the user can override the set of task tags, we provide a custom
// preference store that always has "TODO" under that key.
IPreferenceStore taskTagPreferenceStore= new PreferenceStore();
taskTagPreferenceStore.setValue(CCorePreferenceConstants.TODO_TASK_TAGS, "TODO"); //$NON-NLS-1$
IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(),
taskTagPreferenceStore, generalTextStore });
fPreviewViewer = new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration(fColorManager, store, null, ICPartitions.C_PARTITIONING, false);
fPreviewViewer.configure(configuration);

View file

@ -10,6 +10,7 @@ int static myfunc(uint parameter) {
return parameter - 1;
}
void mutator(int&);
template <typename Item>
class MyClass {
public:
enum Number { ZERO, ONE, TWO };
@ -21,7 +22,7 @@ public:
label: myfunc(local);
vmethod();
staticMethod();
problem();
problem(); // TODO: fix
mutator(local);
}
static void staticMethod();