diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java index fb27d72a16a..fdb79f94f5e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,7 +8,6 @@ * Contributors: * Anton Leherbauer (Wind River Systems) - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.ui.tests.text; import java.io.File; @@ -47,12 +46,12 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.tests.BaseUITestCase; +import org.eclipse.cdt.ui.text.ICColorConstants; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit; import org.eclipse.cdt.internal.ui.editor.CEditor; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; -import org.eclipse.cdt.internal.ui.text.util.CColorManager; import org.eclipse.cdt.internal.ui.util.EditorUtility; /** @@ -363,7 +362,7 @@ public class BasicCEditorTest extends BaseUITestCase { } public void testSyntaxHighlighting_Bug180433() throws Exception { - CColorManager colorMgr= CUIPlugin.getDefault().getTextTools().getColorManager(); + IColorManager colorMgr= CUIPlugin.getDefault().getTextTools().getColorManager(); colorMgr.unbindColor(ICColorConstants.PP_DIRECTIVE); colorMgr.bindColor(ICColorConstants.PP_DIRECTIVE, new RGB(7,7,7)); final Color ppDirectiveColor= colorMgr.getColor(ICColorConstants.PP_DIRECTIVE); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CPartitionerTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CPartitionerTest.java index 7ad9a314cdc..a287fd16f0e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CPartitionerTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CPartitionerTest.java @@ -16,7 +16,6 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.eclipse.jface.preference.PreferenceStore; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; @@ -30,6 +29,7 @@ import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.internal.ui.text.CTextTools; + /** * Tests to verify the C partitioning. * Derived from JavaPartitionerTest. @@ -45,9 +45,10 @@ public class CPartitionerTest extends TestCase { super(name); } + @Override protected void setUp() { - fTextTools= new CTextTools(new PreferenceStore()); + fTextTools= new CTextTools(); fDocument= new Document(); IDocumentPartitioner partitioner= fTextTools.createDocumentPartitioner(null); @@ -67,6 +68,7 @@ public class CPartitionerTest extends TestCase { return new TestSuite(CPartitionerTest.class); } + @Override protected void tearDown () { fTextTools.dispose(); fTextTools= null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java index 0fe7f3c056c..999a3334e07 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java @@ -28,9 +28,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.ui.text.ICPartitions; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; /** * Abstract implementation of a merge viewer. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java index 8e64ba8b532..68bdfa1fcd1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,7 +8,6 @@ * Contributors: * Anton Leherbauer (Wind River Systems) - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.ui.compare; import org.eclipse.compare.CompareConfiguration; @@ -18,10 +17,11 @@ import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.widgets.Composite; +import org.eclipse.cdt.ui.CDTUITools; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration; import org.eclipse.cdt.ui.text.ICPartitions; -import org.eclipse.cdt.internal.ui.editor.asm.AsmSourceViewerConfiguration; -import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools; +import org.eclipse.cdt.ui.text.IColorManager; /** * A merge viewer for assembly code. @@ -46,9 +46,9 @@ public class AsmMergeViewer extends AbstractMergeViewer { @Override protected SourceViewerConfiguration getSourceViewerConfiguration() { if (fSourceViewerConfiguration == null) { - AsmTextTools tools= CUIPlugin.getDefault().getAsmTextTools(); IPreferenceStore store= getPreferenceStore(); - fSourceViewerConfiguration= new AsmSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING); + final IColorManager colorManager = CDTUITools.getColorManager(); + fSourceViewerConfiguration= new AsmSourceViewerConfiguration(colorManager, store, null, ICPartitions.C_PARTITIONING); } return fSourceViewerConfiguration; } @@ -60,7 +60,7 @@ public class AsmMergeViewer extends AbstractMergeViewer { @Override protected IDocumentPartitioner getDocumentPartitioner() { - return CUIPlugin.getDefault().getAsmTextTools().createDocumentPartitioner(); + return CDTUITools.createAsmDocumentPartitioner(); } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java index 8ab9687f4f6..77ec6f10e79 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java @@ -20,10 +20,10 @@ import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java index bf0b7b9f32b..8298a302922 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.text.CTextTools; + /** * CDocumentSetupParticipant */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index bd504cb25ab..3cbf02d9138 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -178,6 +178,7 @@ import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.actions.GenerateActionGroup; import org.eclipse.cdt.ui.actions.OpenViewActionGroup; import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider; @@ -199,7 +200,6 @@ import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation; import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup; import org.eclipse.cdt.internal.ui.text.CHeuristicScanner; import org.eclipse.cdt.internal.ui.text.CPairMatcher; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration; import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.internal.ui.text.CWordFinder; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java index 02c5d76da8f..1682afe7baa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java @@ -48,8 +48,8 @@ import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; /** * Source viewer for C/C++ et al. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java index 5b6e5aac1dc..e964b1751fe 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2006 QNX Software Systems and others. + * Copyright (c) 2002, 2008 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,11 +8,12 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.ui.editor; -import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.text.CTextTools; + import org.eclipse.jface.text.IDocument; import org.eclipse.ui.editors.text.StorageDocumentProvider; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java index 95f69eec922..c1a7425eea0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java @@ -28,13 +28,11 @@ import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.ui.text.ICPartitions; - +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.internal.ui.text.CPresentationReconciler; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration; -import org.eclipse.cdt.internal.ui.text.IColorManager; -import org.eclipse.cdt.internal.ui.text.IColorManagerExtension; /** * Semantic highlighting manager. @@ -584,10 +582,9 @@ public class SemanticHighlightingManager implements IPropertyChangeListener { String property= event.getProperty(); Color color= fColorManager.getColor(property); - if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { - IColorManagerExtension ext= (IColorManagerExtension) fColorManager; - ext.unbindColor(property); - ext.bindColor(property, rgb); + if ((color == null || !rgb.equals(color.getRGB()))) { + fColorManager.unbindColor(property); + fColorManager.bindColor(property, rgb); color= fColorManager.getColor(property); } @@ -614,17 +611,13 @@ public class SemanticHighlightingManager implements IPropertyChangeListener { private void addColor(String colorKey) { if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey); - if (fColorManager instanceof IColorManagerExtension) { - IColorManagerExtension ext= (IColorManagerExtension) fColorManager; - ext.unbindColor(colorKey); - ext.bindColor(colorKey, rgb); - } + fColorManager.unbindColor(colorKey); + fColorManager.bindColor(colorKey, rgb); } } private void removeColor(String colorKey) { - if (fColorManager instanceof IColorManagerExtension) - ((IColorManagerExtension) fColorManager).unbindColor(colorKey); + fColorManager.unbindColor(colorKey); } /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java index 359ca21d221..5f7caf961b5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java @@ -23,11 +23,11 @@ import org.eclipse.jface.text.rules.WordPatternRule; import org.eclipse.jface.text.rules.WordRule; import org.eclipse.cdt.core.model.IAsmLanguage; +import org.eclipse.cdt.ui.text.AbstractCScanner; +import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.ui.text.ITokenStoreFactory; -import org.eclipse.cdt.internal.ui.text.AbstractCScanner; import org.eclipse.cdt.internal.ui.text.CWhitespaceRule; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; /* diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java index b9dd9bcfd6d..0d525ac1814 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,8 @@ import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentExtension3; import org.eclipse.jface.text.IDocumentPartitioner; -import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.ui.CDTUITools; import org.eclipse.cdt.ui.text.ICPartitions; /** @@ -34,7 +35,7 @@ public class AsmDocumentSetupParticipant implements IDocumentSetupParticipant, I * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument) */ public void setup(IDocument document) { - IDocumentPartitioner partitioner= CUIPlugin.getDefault().getAsmTextTools().createDocumentPartitioner(); + IDocumentPartitioner partitioner= CDTUITools.createAsmDocumentPartitioner(); if (document instanceof IDocumentExtension3) { IDocumentExtension3 extension3= (IDocumentExtension3) document; extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java index 0e44058f8e1..6546c3061a1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java @@ -19,12 +19,12 @@ import org.eclipse.jface.text.rules.EndOfLineRule; import org.eclipse.jface.text.rules.IRule; import org.eclipse.jface.text.rules.IToken; import org.eclipse.cdt.core.model.IAsmLanguage; +import org.eclipse.cdt.ui.text.AbstractCScanner; +import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.ui.text.ITokenStoreFactory; -import org.eclipse.cdt.internal.ui.text.AbstractCScanner; import org.eclipse.cdt.internal.ui.text.CHeaderRule; import org.eclipse.cdt.internal.ui.text.CWhitespaceRule; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; import org.eclipse.cdt.internal.ui.text.PreprocessorRule; import org.eclipse.cdt.internal.ui.text.util.CWordDetector; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java index dbe565245cb..8fbf7ad7dc2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java @@ -52,9 +52,12 @@ import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IWorkingCopy; +import org.eclipse.cdt.ui.CDTUITools; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.IWorkingCopyManager; +import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration; import org.eclipse.cdt.ui.text.ICPartitions; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.internal.ui.IContextMenuConstants; import org.eclipse.cdt.internal.ui.editor.AbstractCModelOutlinePage; @@ -99,8 +102,8 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen // For now we are sharing with the CEditor and any changes in the // setting of the CEditor will be reflected in this editor. setPreferenceStore(store); - AsmTextTools tools= CUIPlugin.getDefault().getAsmTextTools(); - setSourceViewerConfiguration(new AsmSourceViewerConfiguration(tools.getColorManager(), store, this, ICPartitions.C_PARTITIONING)); + final IColorManager colorManager = CDTUITools.getColorManager(); + setSourceViewerConfiguration(new AsmSourceViewerConfiguration(colorManager, store, this, ICPartitions.C_PARTITIONING)); setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider()); setEditorContextMenuId("#ASMEditorContext"); //$NON-NLS-1$ setRulerContextMenuId("#ASMEditorRulerContext"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java index 64c1dc00f3e..e737a31170a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.editor.asm; -import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.rules.FastPartitioner; @@ -23,12 +22,12 @@ import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.cdt.core.model.AssemblyLanguage; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.ITokenStore; import org.eclipse.cdt.ui.text.ITokenStoreFactory; import org.eclipse.cdt.internal.ui.text.CCommentScanner; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner; import org.eclipse.cdt.internal.ui.text.TokenStore; import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner; @@ -38,16 +37,16 @@ import org.eclipse.cdt.internal.ui.text.util.CColorManager; /** * This type shares all scanners and the color manager between * its clients. + * + * @deprecated No longer used within CDT. */ +@Deprecated public class AsmTextTools { - private class PreferenceListener implements IPropertyChangeListener, Preferences.IPropertyChangeListener { + private class PreferenceListener implements IPropertyChangeListener { public void propertyChange(PropertyChangeEvent event) { adaptToPreferenceChange(event); } - public void propertyChange(Preferences.PropertyChangeEvent event) { - adaptToPreferenceChange(new PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue())); - } } /** The color manager -- use the same as for C code */ @@ -65,26 +64,16 @@ public class AsmTextTools { /** The preference store */ private IPreferenceStore fPreferenceStore; - /** The core preference store */ - private Preferences fCorePreferenceStore; /** The preference change listener */ private PreferenceListener fPreferenceListener= new PreferenceListener(); - /** - * Creates a new Asm text tools collection and eagerly creates - * and initializes all members of this collection. - */ - public AsmTextTools(IPreferenceStore store) { - this(store, null); - } - /** * Creates a new Asm text tools collection and eagerly creates * and initializes all members of this collection. */ - public AsmTextTools(IPreferenceStore store, Preferences coreStore) { - fPreferenceStore = store != null ? store : CUIPlugin.getDefault().getPreferenceStore(); + public AsmTextTools(IPreferenceStore store) { + fPreferenceStore = store != null ? store : CUIPlugin.getDefault().getCombinedPreferenceStore(); fColorManager= new CColorManager(); ITokenStoreFactory factory= new ITokenStoreFactory() { @@ -95,17 +84,12 @@ public class AsmTextTools { fCodeScanner= new AsmCodeScanner(factory, AssemblyLanguage.getDefault()); fPreprocessorScanner= new AsmPreprocessorScanner(factory, AssemblyLanguage.getDefault()); - fMultilineCommentScanner= new CCommentScanner(factory, coreStore, ICColorConstants.C_MULTI_LINE_COMMENT); - fSinglelineCommentScanner= new CCommentScanner(factory, coreStore, ICColorConstants.C_SINGLE_LINE_COMMENT); + fMultilineCommentScanner= new CCommentScanner(factory, ICColorConstants.C_MULTI_LINE_COMMENT); + fSinglelineCommentScanner= new CCommentScanner(factory, ICColorConstants.C_SINGLE_LINE_COMMENT); fStringScanner= new SingleTokenCScanner(factory, ICColorConstants.C_STRING); // listener must be registered after initializing scanners fPreferenceStore.addPropertyChangeListener(fPreferenceListener); - - fCorePreferenceStore= coreStore; - if (fCorePreferenceStore != null) { - fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener); - } } /** @@ -135,11 +119,6 @@ public class AsmTextTools { fPreferenceStore.removePropertyChangeListener(fPreferenceListener); fPreferenceStore= null; - if (fCorePreferenceStore != null) { - fCorePreferenceStore.removePropertyChangeListener(fPreferenceListener); - fCorePreferenceStore= null; - } - fPreferenceListener= null; } } @@ -229,14 +208,7 @@ public class AsmTextTools { } public IDocumentPartitioner createDocumentPartitioner() { - String[] types= new String[] { - ICPartitions.C_MULTI_LINE_COMMENT, - ICPartitions.C_SINGLE_LINE_COMMENT, - ICPartitions.C_STRING, - ICPartitions.C_CHARACTER, - ICPartitions.C_PREPROCESSOR - }; - return new FastPartitioner(new AsmPartitionScanner(), types); + return new FastPartitioner(new AsmPartitionScanner(), ICPartitions.ALL_ASM_PARTITIONS); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index 8de5d0a1555..a3158726904 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -64,13 +64,13 @@ import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.ICPartitions; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.internal.ui.editor.CSourceViewer; import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedRange; -import org.eclipse.cdt.internal.ui.text.IColorManager; import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.text.util.CColorManager; import org.eclipse.cdt.internal.ui.util.PixelConverter; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java index 1466bdbe8a6..80091981dbd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 QNX Software Systems and others. + * Copyright (c) 2000, 2008 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,7 +9,6 @@ * QNX Software Systems - Initial API and implementation * Anton Leherbauer (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.preferences; import org.eclipse.core.runtime.Assert; @@ -23,8 +22,8 @@ import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Font; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; public class CSourcePreviewerUpdater { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java index e636a3c7cbb..60c3809c963 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems and others. + * Copyright (c) 2002, 2008 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,7 +9,6 @@ * QNX Software Systems - Initial API and implementation * Wind River Systems, Inc. - Bug fixes *******************************************************************************/ - package org.eclipse.cdt.internal.ui.preferences; import org.eclipse.jface.preference.IPreferenceStore; @@ -36,11 +35,11 @@ import org.eclipse.ui.texteditor.templates.TemplatePreferencePage; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.editor.CSourceViewer; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.text.CTextTools; /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java index 4ab4a444b0c..404802cbaa3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java @@ -33,11 +33,11 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.text.ICPartitions; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType; import org.eclipse.cdt.internal.ui.text.CWordFinder; -import org.eclipse.cdt.internal.ui.text.IColorManager; import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; import org.eclipse.cdt.internal.ui.text.template.TemplateVariableProcessor; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java index d7e1f39b954..37b7e629307 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java @@ -42,9 +42,9 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.refactoring.CTextFileChange; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.compare.CMergeViewer; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.text.CTextTools; /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java index 3e2ff1ecb46..05a2a4735a5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java @@ -24,10 +24,10 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.editor.CSourceViewer; import org.eclipse.cdt.internal.ui.refactoring.CreateFileChange; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.internal.ui.util.ViewerPane; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java index 1519f19af9c..81bfcefd3cf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java @@ -21,6 +21,8 @@ import org.eclipse.jface.text.rules.IToken; import org.eclipse.jface.text.rules.WordRule; import org.eclipse.cdt.core.model.ICLanguageKeywords; +import org.eclipse.cdt.ui.text.AbstractCScanner; +import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.ui.text.ITokenStoreFactory; import org.eclipse.cdt.internal.ui.text.util.CWordDetector; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java index 350fd6e91ec..1785ff49f36 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java @@ -15,11 +15,11 @@ package org.eclipse.cdt.internal.ui.text; import java.util.Collections; import java.util.List; -import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.rules.IRule; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.AbstractCScanner; import org.eclipse.cdt.ui.text.ITokenStoreFactory; import org.eclipse.cdt.ui.text.TaskTagRule; @@ -29,26 +29,20 @@ import org.eclipse.cdt.ui.text.TaskTagRule; */ public class CCommentScanner extends AbstractCScanner { private static String TASK_TAG_KEY= PreferenceConstants.EDITOR_TASK_TAG_COLOR; - private Preferences fCorePreferenceStore; public CCommentScanner(ITokenStoreFactory tokenStoreFactory, String defaultTokenProperty) { - this(tokenStoreFactory, null, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG_KEY }); + this(tokenStoreFactory, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG_KEY }); } - public CCommentScanner(ITokenStoreFactory tokenStoreFactory, Preferences coreStore, String defaultTokenProperty) { - this(tokenStoreFactory, coreStore, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG_KEY }); - } - - private CCommentScanner(ITokenStoreFactory tokenStoreFactory, Preferences coreStore, String defaultTokenProperty, String[] tokenProperties) { + private CCommentScanner(ITokenStoreFactory tokenStoreFactory, String defaultTokenProperty, String[] tokenProperties) { super(tokenStoreFactory.createTokenStore(tokenProperties)); - fCorePreferenceStore= coreStore; setRules(createRules(defaultTokenProperty)); } protected List createRules(String defaultTokenProperty) { setDefaultReturnToken(getToken(defaultTokenProperty)); IPreferenceStore store= fTokenStore.getPreferenceStore(); - String taskWords= TaskTagRule.getTaskWords(store, fCorePreferenceStore); + String taskWords= TaskTagRule.getTaskWords(store, null); TaskTagRule taskTagRule= new TaskTagRule(getToken(TASK_TAG_KEY), taskWords); addPropertyChangeParticipant(taskTagRule); return Collections.singletonList((IRule)taskTagRule); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java index c74413b8cb9..0548863a6ea 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java @@ -20,6 +20,8 @@ import org.eclipse.jface.text.rules.PatternRule; import org.eclipse.jface.text.rules.WordRule; import org.eclipse.cdt.core.model.ICLanguageKeywords; +import org.eclipse.cdt.ui.text.AbstractCScanner; +import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.ui.text.ITokenStoreFactory; import org.eclipse.cdt.internal.ui.text.util.CWordDetector; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java index b45f6a5284d..2efe3b16c30 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java @@ -18,6 +18,8 @@ import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.internal.ui.editor.CEditor; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java index 9c906510013..73ef698a0a7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java @@ -17,22 +17,14 @@ import org.eclipse.core.filebuffers.LocationKind; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentExtension3; import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.rules.IPartitionTokenScanner; -import org.eclipse.jface.text.rules.RuleBasedScanner; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage; -import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage; -import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.ui.text.ICPartitions; -import org.eclipse.cdt.ui.text.ITokenStore; -import org.eclipse.cdt.ui.text.ITokenStoreFactory; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner; import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager; @@ -40,153 +32,47 @@ import org.eclipse.cdt.internal.ui.text.util.CColorManager; /** - * This type shares all scanners and the color manager between - * its clients. + * Tools required to configure a C/C++ source viewer. + * Scanners must be configured using a {@link CSourceViewerConfiguration}. + *

+ * This class may be instantiated; it is not intended to be subclassed. + *

*/ public class CTextTools { - private class PreferenceListener implements IPropertyChangeListener, Preferences.IPropertyChangeListener { - public void propertyChange(PropertyChangeEvent event) { - adaptToPreferenceChange(event); - } - public void propertyChange(Preferences.PropertyChangeEvent event) { - adaptToPreferenceChange(new PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue())); - } - } - /** The color manager */ private CColorManager fColorManager; - /** The C source code scanner */ - private CCodeScanner fCodeScanner; - /** The C++ source code scanner */ - private CCodeScanner fCppCodeScanner; - /** The C multiline comment scanner */ - private CCommentScanner fMultilineCommentScanner; - /** The C singleline comment scanner */ - private CCommentScanner fSinglelineCommentScanner; - /** The C string scanner */ - private SingleTokenCScanner fStringScanner; - /** The C preprocessor scanner */ - private CPreprocessorScanner fCPreprocessorScanner; - /** The C++ preprocessor scanner */ - private CPreprocessorScanner fCppPreprocessorScanner; - /** The preference store */ - private IPreferenceStore fPreferenceStore; - /** The core preference store */ - private Preferences fCorePreferenceStore; - /** The preference change listener */ - private PreferenceListener fPreferenceListener= new PreferenceListener(); /** The document partitioning used for the C partitioner */ private String fDocumentPartitioning = ICPartitions.C_PARTITIONING; /** - * Creates a new C text tools collection and eagerly creates - * and initializes all members of this collection. - */ - public CTextTools(IPreferenceStore store) { - this(store, null, true); - } - - /** - * Creates a new C text tools collection and eagerly creates - * and initializes all members of this collection. - */ - public CTextTools(IPreferenceStore store, Preferences coreStore) { - this(store, coreStore, true); - } - - /** - * Creates a new C text tools collection and eagerly creates - * and initializes all members of this collection. - */ - public CTextTools(IPreferenceStore store, Preferences coreStore, boolean autoDisposeOnDisplayDispose) { - fPreferenceStore = store != null ? store : CUIPlugin.getDefault().getPreferenceStore(); - fColorManager= new CColorManager(autoDisposeOnDisplayDispose); - - ITokenStoreFactory factory= new ITokenStoreFactory() { - public ITokenStore createTokenStore(String[] propertyColorNames) { - return new TokenStore(getColorManager(), fPreferenceStore, propertyColorNames); - } - }; - - fMultilineCommentScanner= new CCommentScanner(factory, coreStore, ICColorConstants.C_MULTI_LINE_COMMENT); - fSinglelineCommentScanner= new CCommentScanner(factory, coreStore, ICColorConstants.C_SINGLE_LINE_COMMENT); - fCodeScanner= new CCodeScanner(factory, GCCLanguage.getDefault()); - fCppCodeScanner= new CCodeScanner(factory, GPPLanguage.getDefault()); - - fStringScanner= new SingleTokenCScanner(factory, ICColorConstants.C_STRING); - fCPreprocessorScanner= new CPreprocessorScanner(factory, GCCLanguage.getDefault()); - fCppPreprocessorScanner= new CPreprocessorScanner(factory, GPPLanguage.getDefault()); - - fPreferenceStore.addPropertyChangeListener(fPreferenceListener); - - fCorePreferenceStore= coreStore; - if (fCorePreferenceStore != null) { - fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener); - } - } - - /** - * Creates a new C text tools collection and eagerly creates - * and initializes all members of this collection. + * Creates a new C text tools instance. */ public CTextTools() { - this((IPreferenceStore)null); + fColorManager= new CColorManager(true); } /** * Disposes all members of this tools collection. */ public void dispose() { - - fCodeScanner= null; - fMultilineCommentScanner= null; - fSinglelineCommentScanner= null; - fStringScanner= null; - if (fColorManager != null) { fColorManager.dispose(); fColorManager= null; } - - if (fPreferenceStore != null) { - fPreferenceStore.removePropertyChangeListener(fPreferenceListener); - fPreferenceStore= null; - - if (fCorePreferenceStore != null) { - fCorePreferenceStore.removePropertyChangeListener(fPreferenceListener); - fCorePreferenceStore= null; - } - - fPreferenceListener= null; - } } /** * Gets the color manager. */ - public CColorManager getColorManager() { + public IColorManager getColorManager() { return fColorManager; } - /** - * Gets the code scanner used. - */ - public RuleBasedScanner getCCodeScanner() { - return fCodeScanner; - } - - /** - * Gets the code scanner used. - */ - public RuleBasedScanner getCppCodeScanner() { - return fCppCodeScanner; - } - /** * Returns a scanner which is configured to scan - * C-specific partitions, which are multi-line comments, + * C-specific partitions, which are preprocessor directives, comments, * and regular C source code. * * @param owner may be null @@ -203,97 +89,12 @@ public class CTextTools { return new FastCPartitioner(getPartitionScanner(owner), ICPartitions.ALL_CPARTITIONS); } - /** - * Returns a scanner which is configured to scan C multiline comments. - * - * @return a C multiline comment scanner - */ - public RuleBasedScanner getMultilineCommentScanner() { - return fMultilineCommentScanner; - } - - /** - * Returns a scanner which is configured to scan C singleline comments. - * - * @return a C singleline comment scanner - */ - public RuleBasedScanner getSinglelineCommentScanner() { - return fSinglelineCommentScanner; - } - - /** - * Returns a scanner which is configured to scan C strings. - * - * @return a C string scanner - */ - public RuleBasedScanner getStringScanner() { - return fStringScanner; - } - - /** - * Returns a scanner which is configured to scan C preprocessor directives. - * - * @return a C preprocessor directives scanner - */ - public RuleBasedScanner getCPreprocessorScanner() { - return fCPreprocessorScanner; - } - - /** - * Returns a scanner which is configured to scan C++ preprocessor directives. - * - * @return a C++ preprocessor directives scanner - */ - public RuleBasedScanner getCppPreprocessorScanner() { - return fCppPreprocessorScanner; - } - - /** - * Determines whether the preference change encoded by the given event - * changes the behavior of one its contained components. - * - * @param event the event to be investigated - * @return true if event causes a behavioral change - */ - public boolean affectsBehavior(PropertyChangeEvent event) { - return fCodeScanner.affectsBehavior(event) || - fCppCodeScanner.affectsBehavior(event) || - fMultilineCommentScanner.affectsBehavior(event) || - fSinglelineCommentScanner.affectsBehavior(event) || - fStringScanner.affectsBehavior(event) || - fCPreprocessorScanner.affectsBehavior(event); - } - - /** - * Adapts the behavior of the contained components to the change - * encoded in the given event. - * - * @param event the event to whch to adapt - */ - public void adaptToPreferenceChange(PropertyChangeEvent event) { - if (fCodeScanner.affectsBehavior(event)) - fCodeScanner.adaptToPreferenceChange(event); - if (fCppCodeScanner.affectsBehavior(event)) - fCppCodeScanner.adaptToPreferenceChange(event); - if (fMultilineCommentScanner.affectsBehavior(event)) - fMultilineCommentScanner.adaptToPreferenceChange(event); - if (fSinglelineCommentScanner.affectsBehavior(event)) - fSinglelineCommentScanner.adaptToPreferenceChange(event); - if (fStringScanner.affectsBehavior(event)) - fStringScanner.adaptToPreferenceChange(event); - if (fCPreprocessorScanner.affectsBehavior(event)) { - fCPreprocessorScanner.adaptToPreferenceChange(event); - fCppPreprocessorScanner.adaptToPreferenceChange(event); - } - } - /** * Sets up the document partitioner for the given document for the given partitioning. * * @param document * @param partitioning * @param owner may be null - * @since 5.0 */ public void setupCDocumentPartitioner(IDocument document, String partitioning, IDocCommentOwner owner) { IDocumentPartitioner partitioner= createDocumentPartitioner(owner); @@ -312,7 +113,6 @@ public class CTextTools { * @param document the document to be set up * @param location the path of the resource backing the document. May be null. * @param locationKind the type of path specified above. May be null. - * @since 3.0 */ public void setupCDocument(IDocument document, IPath location, LocationKind locationKind) { IDocCommentOwner owner= getDocumentationCommentOwner(location, locationKind); @@ -323,7 +123,6 @@ public class CTextTools { * Sets up the given document for the default partitioning. * * @param document the document to be set up - * @since 3.0 */ public void setupCDocument(IDocument document) { setupCDocumentPartitioner(document, fDocumentPartitioning, null); @@ -333,7 +132,6 @@ public class CTextTools { * Get the document partitioning used for the C partitioner. * * @return the document partitioning used for the C partitioner - * @since 3.1 */ public String getDocumentPartitioning() { return fDocumentPartitioning; @@ -341,8 +139,6 @@ public class CTextTools { /** * Set the document partitioning to be used for the C partitioner. - * - * @since 3.1 */ public void setDocumentPartitioning(String documentPartitioning) { fDocumentPartitioning = documentPartitioning; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManagerExtension.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManagerExtension.java deleted file mode 100644 index 838b1b395c8..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManagerExtension.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * QNX Software System - *******************************************************************************/ -package org.eclipse.cdt.internal.ui.text; - -import org.eclipse.swt.graphics.RGB; - - -/** - * For internal use only. Not API.

- * A color manager extension is for extending - * IColorManager instances with new functionality. - */ -public interface IColorManagerExtension { - - /** - * Remembers the given color specification under the given key. - * - * @param key the color key - * @param rgb the color specification - * @exception UnsupportedOperationException if there is already a - * color specification remembered under the given key - */ - void bindColor(String key, RGB rgb); - - - /** - * Forgets the color specification remembered under the given key. - * @param key the color key - */ - void unbindColor(String key); -} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java index 41cb1298ef4..f17685d082d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java @@ -23,9 +23,12 @@ import org.eclipse.jface.text.source.IAnnotationHover; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; +import org.eclipse.cdt.ui.text.IColorManager; + /** - * A simple {@linkplain org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration C source viewer configuration}. + * A simple {@linkplain org.eclipse.cdt.ui.text.CSourceViewerConfiguration C source viewer configuration}. *

* This simple source viewer configuration basically provides syntax coloring * and disables all other features like code assist, quick outlines, hyperlinking, etc. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java index e027e657886..b4f8f9db9c5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java @@ -12,70 +12,17 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.text; -import java.util.List; - -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.rules.IRule; -import org.eclipse.jface.text.rules.IToken; -import org.eclipse.jface.text.rules.Token; - +import org.eclipse.cdt.ui.text.AbstractCScanner; import org.eclipse.cdt.ui.text.ITokenStoreFactory; /** * */ public final class SingleTokenCScanner extends AbstractCScanner { - private String fProperty; - private int position, end; - private int size; - protected IToken fDefaultReturnToken; public SingleTokenCScanner(ITokenStoreFactory factory, String property) { super(factory.createTokenStore(new String[] {property}), 20); - fProperty= property; - setRules(createRules()); + setDefaultReturnToken(getToken(property)); } - protected List createRules() { - fDefaultReturnToken= getToken(fProperty); - setDefaultReturnToken(fDefaultReturnToken); - return null; - } - - /** - * setRange -- sets the range to be scanned - */ - @Override - public void setRange(IDocument document, int offset, int length) { - - super.setRange(document, offset, length); - position = offset; - size = length; - end = offset + length; - } - - /** - * Returns the next token in the document. - * - * @return the next token in the document - */ - @Override - public IToken nextToken() { - fTokenOffset = position; - - if(position < end) { - size = end - position; - position = end; - return fDefaultReturnToken; - } - return Token.EOF; - } - - @Override - public int getTokenLength() { - return size; - } } - - - diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java index 9a97d8c31a2..93189f46a6c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java @@ -29,6 +29,7 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.ui.text.ITokenStore; @@ -94,11 +95,8 @@ public class TokenStore implements ITokenStore { private void addToken(String colorKey) { if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey); - if (fColorManager instanceof IColorManagerExtension) { - IColorManagerExtension ext= (IColorManagerExtension) fColorManager; - ext.unbindColor(colorKey); - ext.bindColor(colorKey, rgb); - } + fColorManager.unbindColor(colorKey); + fColorManager.bindColor(colorKey, rgb); } if (!fNeedsLazyColorLoading) @@ -228,11 +226,9 @@ public class TokenStore implements ITokenStore { String property= event.getProperty(); Color color= fColorManager.getColor(property); - if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { - IColorManagerExtension ext= (IColorManagerExtension) fColorManager; - - ext.unbindColor(property); - ext.bindColor(property, rgb); + if ((color == null || !rgb.equals(color.getRGB()))) { + fColorManager.unbindColor(property); + fColorManager.bindColor(property, rgb); color= fColorManager.getColor(property); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java index 87d16a865f4..d4c5d607031 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java @@ -54,6 +54,7 @@ import org.eclipse.cdt.ui.text.ICCompletionProposal; import org.eclipse.cdt.internal.ui.text.CTextTools; + public class CCompletionProposal implements ICCompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3 { private String fDisplayString; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java index 80451fd239f..9a402871e45 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java @@ -14,10 +14,11 @@ package org.eclipse.cdt.internal.ui.text.contentassist; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; -import org.eclipse.cdt.internal.ui.text.CTextTools; -import org.eclipse.cdt.internal.ui.text.IColorManager; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.IColorManager; + +import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java index 2489ef0583e..7805f6d1814 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java @@ -48,12 +48,12 @@ import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.cdt.internal.core.model.ASTCache; import org.eclipse.cdt.internal.ui.editor.ASTProvider; import org.eclipse.cdt.internal.ui.text.CTextTools; -import org.eclipse.cdt.internal.ui.text.IColorManager; public class CCorrectionAssistant extends QuickAssistAssistant { private ITextViewer fViewer; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java index a2819935196..e748e53f1a9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.ui.text.spelling; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentExtension3; @@ -24,15 +25,19 @@ import org.eclipse.jface.text.TextUtilities; import org.eclipse.jface.text.TypedRegion; import org.eclipse.jface.text.rules.IToken; import org.eclipse.jface.text.rules.RuleBasedScanner; +import org.eclipse.jface.text.rules.Token; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector; -import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage; import org.eclipse.cdt.ui.text.ICPartitions; +import org.eclipse.cdt.ui.text.ITokenStore; +import org.eclipse.cdt.ui.text.ITokenStoreFactory; import org.eclipse.cdt.ui.text.doctools.IDocCommentDictionary; import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner; import org.eclipse.cdt.ui.text.doctools.IDocCommentSimpleDictionary; -import org.eclipse.cdt.internal.ui.text.CTextTools; +import org.eclipse.cdt.internal.ui.text.CPreprocessorScanner; import org.eclipse.cdt.internal.ui.text.FastCPartitioner; import org.eclipse.cdt.internal.ui.text.doctools.DocCommentSpellDictionary; import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker; @@ -43,6 +48,26 @@ import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEventListener; * C/C++ spelling engine */ public class CSpellingEngine extends SpellingEngine { + + /** + * A dummy token store for use with a token scanner. + */ + private static class SimpleTokenStore implements ITokenStore { + public void ensureTokensInitialised() { + } + public IPreferenceStore getPreferenceStore() { + return null; + } + public IToken getToken(String property) { + return new Token(property); + } + public void adaptToPreferenceChange(PropertyChangeEvent event) { + } + public boolean affectsBehavior(PropertyChangeEvent event) { + return false; + } + } + /* * @see org.eclipse.cdt.internal.ui.text.spelling.SpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor) */ @@ -95,8 +120,10 @@ public class CSpellingEngine extends SpellingEngine { } if (type.equals(ICPartitions.C_PREPROCESSOR)) { - CTextTools textTools = CUIPlugin.getDefault().getTextTools(); - RuleBasedScanner scanner = textTools.getCppPreprocessorScanner(); + RuleBasedScanner scanner = new CPreprocessorScanner(new ITokenStoreFactory() { + public ITokenStore createTokenStore(String[] propertyColorNames) { + return new SimpleTokenStore(); + }}, GPPLanguage.getDefault()); scanner.setRange(document, partition.getOffset(), partition.getLength()); int firstTokenOffset = -1; int firstTokenLength = -1; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java index ef8f522a60a..0cb899f5bea 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java @@ -20,13 +20,13 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; -import org.eclipse.cdt.internal.ui.text.IColorManager; -import org.eclipse.cdt.internal.ui.text.IColorManagerExtension; +import org.eclipse.cdt.ui.text.IColorManager; + /** * CDT color manager. */ -public class CColorManager implements IColorManager, IColorManagerExtension { +public class CColorManager implements IColorManager { protected Map fKeyTable= new HashMap(10); protected Map> fDisplayTable= new HashMap>(2); @@ -120,7 +120,7 @@ public class CColorManager implements IColorManager, IColorManagerExtension { } /* - * @see IColorManagerExtension#bindColor(String, RGB) + * @see IColorManager#bindColor(String, RGB) */ public void bindColor(String key, RGB rgb) { Object value= fKeyTable.get(key); @@ -131,7 +131,7 @@ public class CColorManager implements IColorManager, IColorManagerExtension { } /* - * @see IColorManagerExtension#unbindColor(String) + * @see IColorManager#unbindColor(String) */ public void unbindColor(String key) { fKeyTable.remove(key); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java index f5eb10c65f3..dbf2cffde35 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java @@ -307,7 +307,7 @@ public class EditorUtility { /** * Utility method to get an editor input for the given file system location. * If the location denotes a workspace file, a FileEditorInput - * is returned, otherwise, the input is an IStorageEditorInput + * is returned, otherwise, the input is an IURIEditorInput * assuming the location points to an existing file in the file system. * The ICElement is used to determine the associated project * in case the location can not be resolved to a workspace IFile. @@ -465,7 +465,7 @@ public class EditorUtility { * If a context element is given and there are multiple matches in the workspace, * a resource with the same project of the context element are preferred. * - * @param locationURI a valid file system location + * @param locationURI a valid Eclipse file system URI * @param context an element related to the target file, may be null * @return an IFile or null */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java new file mode 100644 index 00000000000..681984fcc1d --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java @@ -0,0 +1,210 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui; + +import java.net.URI; + +import org.eclipse.core.filebuffers.LocationKind; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IDocumentExtension3; +import org.eclipse.jface.text.IDocumentPartitioner; +import org.eclipse.jface.text.rules.FastPartitioner; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.texteditor.IDocumentProvider; + +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ISourceReference; +import org.eclipse.cdt.core.model.IWorkingCopy; +import org.eclipse.cdt.ui.text.ICPartitions; +import org.eclipse.cdt.ui.text.IColorManager; +import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput; +import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner; +import org.eclipse.cdt.internal.ui.util.EditorUtility; + +/** + * This class provides utilities for clients of the CDT UI plug-in. + * This class provides static methods for: + *

+ * + * @noinstantiate This class is not intended to be instantiated by clients. + * @since 5.1 + */ +public final class CDTUITools { + + private CDTUITools() { + // prevent instantiation + } + + /** + * Returns the color manager which is used to manage + * colors needed for syntax highlighting. + * + * @return the color manager to be used for C/C++ text viewers + */ + public static IColorManager getColorManager() { + return CUIPlugin.getDefault().getTextTools().getColorManager(); + } + + /** + * Opens an editor on the given C model element in the active page. Valid are elements that are {@link ISourceReference}. + * + * @param element the input element + * @return returns the editor part of the opened editor or null if the element is not a {@link ISourceReference} or the + * file was opened in an external editor. + * @exception PartInitException if the editor could not be initialized or no workbench page is active + * @exception CModelException if this element does not exist or if an exception occurs while accessing its underlying resource + */ + public static IEditorPart openInEditor(ICElement element) throws CModelException, PartInitException { + return openInEditor(element, true, true); + } + + /** + * Opens an editor on the given C model element in the active page. Valid are elements that are {@link ISourceReference}. + * + * @param element the input element + * @return returns the editor part of the opened editor or null if the element is not a {@link ISourceReference} or the + * file was opened in an external editor. + * @exception PartInitException if the editor could not be initialized or no workbench page is active + * @exception CModelException if this element does not exist or if an exception occurs while accessing its underlying resource + */ + public static IEditorPart openInEditor(ICElement element, boolean activate, boolean reveal) throws CModelException, PartInitException { + if (!(element instanceof ISourceReference)) { + return null; + } + IEditorPart part= EditorUtility.openInEditor(element, activate); + if (reveal && part != null) { + EditorUtility.revealInEditor(part, element); + } + return part; + } + + /** + * Reveals the given C model element in the given editor.. + * + * @param part the editor displaying a translation unit + * @param element the element to be revealed + */ + public static void revealInEditor(IEditorPart part, ICElement element) { + EditorUtility.revealInEditor(part, element); + } + + /** + * Returns the working copy manager for the CDT UI plug-in. + * + * @return the working copy manager for the CDT UI plug-in + */ + public static IWorkingCopyManager getWorkingCopyManager() { + return CUIPlugin.getDefault().getWorkingCopyManager(); + } + + /** + * Returns the document provider used for C/C++ files. + * + * @return the document provider for C/C++ files. + * + * @see IDocumentProvider + */ + public static IDocumentProvider getDocumentProvider() { + return CUIPlugin.getDefault().getDocumentProvider(); + } + + /** + * Returns the ICElement element wrapped by the given editor input. + * + * @param editorInput the editor input + * @return the ICElement wrapped by editorInput or null if none + */ + public static ICElement getEditorInputCElement(IEditorInput editorInput) { + if (editorInput instanceof ITranslationUnitEditorInput) { + return ((ITranslationUnitEditorInput) editorInput).getTranslationUnit(); + } + IWorkingCopy tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput); + if (tu != null) + return tu; + + return (ICElement)editorInput.getAdapter(ICElement.class); + } + + /** + * Utility method to get an editor input for the given file system location. + * If the location denotes a workspace file, a FileEditorInput + * is returned, otherwise, the input is an IURIEditorInput + * assuming the location points to an existing file in an Eclipse file system. + * The ICElement is used to determine the associated project + * in case the location can not be resolved to a workspace IFile. + * + * @param locationURI a valid Eclipse file system URI + * @param context an element related to the target file, may be null + * @return an editor input + */ + public static IEditorInput getEditorInputForLocation(URI locationURI, ICElement context) { + return EditorUtility.getEditorInputForLocation(locationURI, context); + } + + /** + * Utility method to get an editor input for the given file system location. + * If the location denotes a workspace file, a FileEditorInput + * is returned, otherwise, the input is an IURIEditorInput + * assuming the location points to an existing file in the file system. + * The ICElement is used to determine the associated project + * in case the location can not be resolved to a workspace IFile. + * + * @param location a valid file system location + * @param context an element related to the target file, may be null + * @return an editor input + */ + public static IEditorInput getEditorInputForLocation(IPath location, ICElement context) { + return EditorUtility.getEditorInputForLocation(location, context); + } + + /** + * Sets up the given document for the default C/C++ partitioning. + * + * @param document the document to be set up + * @param location the path of the resource backing the document. May be null. + * @param locationKind the type of path specified above. May be null. + */ + public void setupCDocument(IDocument document, IPath location, LocationKind locationKind) { + CUIPlugin.getDefault().getTextTools().setupCDocument(document, location, locationKind); + } + + /** + * Create a document partitioner suitable for Assembly source. + */ + public static IDocumentPartitioner createAsmDocumentPartitioner() { + return new FastPartitioner(new AsmPartitionScanner(), ICPartitions.ALL_ASM_PARTITIONS); + } + + /** + * Sets up the given document for the default Assembly partitioning. + * + * @param document the document to be set up + */ + public void setupAsmDocument(IDocument document) { + IDocumentPartitioner partitioner= createAsmDocumentPartitioner(); + if (document instanceof IDocumentExtension3) { + IDocumentExtension3 extension3= (IDocumentExtension3) document; + extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner); + } else { + document.setDocumentPartitioner(partitioner); + } + partitioner.connect(document); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index 96f0d37aaa7..b5f2a575f21 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -141,6 +141,7 @@ public class CUIPlugin extends AbstractUIPlugin { * (value "org.eclipse.cdt.ui.CHierarchyPerspective"). * * @deprecated This perspective no longer exists. + * @noreference This field is not intended to be referenced by clients. */ @Deprecated public static final String ID_CHIERARCHY_PERSPECTIVE = PLUGIN_ID + ".CHierarchyPerspective"; //$NON-NLS-1$ @@ -151,6 +152,7 @@ public class CUIPlugin extends AbstractUIPlugin { * * @since 2.0 * @deprecated This perspective no longer exists. + * @noreference This field is not intended to be referenced by clients. */ @Deprecated public static final String ID_CBROWSING_PERSPECTIVE = PLUGIN_ID + ".CBrowsingPerspective"; //$NON-NLS-1$ @@ -161,6 +163,7 @@ public class CUIPlugin extends AbstractUIPlugin { * * @since 2.0 * @deprecated This view no longer exists. + * @noreference This field is not intended to be referenced by clients. */ @Deprecated public static String ID_PROJECTS_VIEW = PLUGIN_ID + ".ProjectsView"; //$NON-NLS-1$ @@ -171,6 +174,7 @@ public class CUIPlugin extends AbstractUIPlugin { * * @since 2.0 * @deprecated This view no longer exists. + * @noreference This field is not intended to be referenced by clients. */ @Deprecated public static String ID_NAMESPACES_VIEW = PLUGIN_ID + ".NamespacesView"; //$NON-NLS-1$ @@ -181,6 +185,7 @@ public class CUIPlugin extends AbstractUIPlugin { * * @since 2.0 * @deprecated This view no longer exists. + * @noreference This field is not intended to be referenced by clients. */ @Deprecated public static String ID_TYPES_VIEW = PLUGIN_ID + ".TypesView"; //$NON-NLS-1$ @@ -191,6 +196,7 @@ public class CUIPlugin extends AbstractUIPlugin { * * @since 2.0 * @deprecated This view no longer exists. + * @noreference This field is not intended to be referenced by clients. */ @Deprecated public static String ID_MEMBERS_VIEW = PLUGIN_ID + ".MembersView"; //$NON-NLS-1$ @@ -317,7 +323,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Utility method with conventions - * @param logError TODO + * @param logError TODO */ public static void errorDialog(Shell shell, String title, String message, IStatus s, boolean logError) { if (logError) @@ -333,7 +339,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Utility method with conventions - * @param logError TODO + * @param logError TODO */ public static void errorDialog(Shell shell, String title, String message, Throwable t, boolean logError) { if (logError) @@ -443,20 +449,24 @@ public class CUIPlugin extends AbstractUIPlugin { } /** - * Returns the shared text tools + * Returns the shared C/C++ text tools. + * @noreference This method is not intended to be referenced by clients. */ public CTextTools getTextTools() { if (fTextTools == null) - fTextTools = new CTextTools(getPreferenceStore(), CCorePlugin.getDefault().getPluginPreferences()); + fTextTools = new CTextTools(); return fTextTools; } /** - * Returns the shared assembly text tools + * Returns the shared assembly text tools. + * @deprecated Use methods provided by {@link CDTUITools} instead. + * @noreference This method is not intended to be referenced by clients. */ + @Deprecated public AsmTextTools getAsmTextTools() { if (fAsmTextTools == null) - fAsmTextTools = new AsmTextTools(getPreferenceStore(), CCorePlugin.getDefault().getPluginPreferences()); + fAsmTextTools = new AsmTextTools(); return fAsmTextTools; } @@ -547,6 +557,10 @@ public class CUIPlugin extends AbstractUIPlugin { fTextTools.dispose(); fTextTools= null; } + if (fAsmTextTools != null) { + fAsmTextTools.dispose(); + fAsmTextTools= null; + } if (fImageDescriptorRegistry != null) { fImageDescriptorRegistry.dispose(); fImageDescriptorRegistry= null; @@ -624,7 +638,10 @@ public class CUIPlugin extends AbstractUIPlugin { manager.unregisterAdapters(fCElementAdapterFactory); } - /** @deprecated Use {@link EditorsUI#getSharedTextColors()} instead. */ + /** + * @deprecated Use {@link EditorsUI#getSharedTextColors()} instead. + * @noreference This method is not intended to be referenced by clients. + */ @Deprecated public ISharedTextColors getSharedTextColors() { return EditorsUI.getSharedTextColors(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java index 632079988de..2f06f87e5fd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java @@ -26,6 +26,8 @@ import org.eclipse.ui.texteditor.AbstractTextEditor; /** * This class implements the setting of the CUI initial preference store settings. + * + * @noextend This class is not intended to be subclassed by clients. */ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java index 13a614084bc..84a573edee7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java @@ -13,7 +13,8 @@ package org.eclipse.cdt.ui; import org.eclipse.cdt.ui.text.ICHelpInvocationContext; /** - * Represents the C/C++ help provider + * Represents a C/C++ help provider. This interface need to be implemented by + * contributors to extension point "org.eclipse.cdt.ui.CHelpProvider". *

* Clients may implement this interface. *

diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java index 8de427cc0d0..ab8d1dee4f8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java @@ -12,9 +12,11 @@ package org.eclipse.cdt.ui; /** + * A function summary provided by an {@link ICHelpProvider}. *

* Clients may implement this interface. *

+ * @see ICHelpProvider */ public interface IFunctionSummary { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java index 13bda30e99b..5712cc9406c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java @@ -11,15 +11,17 @@ package org.eclipse.cdt.ui; +/** + * Interface related to {@link IFunctionSummary} denoting an include required for a function. + *

+ * Clients may implement this interface. + *

+ * @see IFunctionSummary + */ public interface IRequiredInclude { /** - * Returns the name that has been imported. - * For an on-demand import, this includes the trailing ".*". - * For example, for the statement "import java.util.*", - * this returns "java.util.*". - * For the statement "import java.util.Hashtable", - * this returns "java.util.Hashtable". + * Get the include name. */ String getIncludeName(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java index c2917bc5fc4..df3c6758699 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -31,10 +31,10 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.internal.ui.ICThemeConstants; import org.eclipse.cdt.internal.ui.preferences.formatter.FormatterProfileManager; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; import org.eclipse.cdt.internal.ui.text.spelling.SpellCheckEngine; /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java similarity index 76% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java index 81d8f41657b..85442359cf6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java @@ -10,7 +10,7 @@ * QNX Software System * Andrew Ferguson (Symbian) *******************************************************************************/ -package org.eclipse.cdt.internal.ui.text; +package org.eclipse.cdt.ui.text; import java.util.ArrayList; import java.util.Iterator; @@ -23,28 +23,43 @@ import org.eclipse.jface.text.rules.IToken; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.cdt.ui.IPropertyChangeParticipant; -import org.eclipse.cdt.ui.text.ICTokenScanner; -import org.eclipse.cdt.ui.text.ITokenStore; /** - * Convenience implementation. + * Convenience implementation for {@link ICTokenScanner}. + * Subclasses need to initialize scanner rules by calling {@link #setRules(IRule[])} or {@link #setRules(List)}. + *

+ * Clients may instantiate and extend this class. + *

+ * + * @since 5.1 */ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implements ICTokenScanner { - private List pcps; + private List fParticipants; final protected ITokenStore fTokenStore; + /** + * Create a new scanner for the given token store with default buffer size. + * + * @param tokenStore + */ + public AbstractCScanner(ITokenStore tokenStore) { + fTokenStore= tokenStore; + fParticipants= new ArrayList(); + } + + /** + * Create a new scanner for the given token store and buffer size. + * + * @param tokenStore + * @param size + */ public AbstractCScanner(ITokenStore tokenStore, int size) { this(tokenStore); setBufferSize(size); } - public AbstractCScanner(ITokenStore tokenStore) { - fTokenStore= tokenStore; - pcps= new ArrayList(); - } - protected void addPropertyChangeParticipant(IPropertyChangeParticipant participant) { - pcps.add(participant); + fParticipants.add(participant); } /** @@ -86,7 +101,7 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen if(fTokenStore.affectsBehavior(event)) { fTokenStore.adaptToPreferenceChange(event); } - for (IPropertyChangeParticipant propertyChangeParticipant : pcps) { + for (IPropertyChangeParticipant propertyChangeParticipant : fParticipants) { propertyChangeParticipant.adaptToPreferenceChange(event); } } @@ -96,9 +111,9 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen */ public boolean affectsBehavior(PropertyChangeEvent event) { boolean result= fTokenStore.affectsBehavior(event); - for(Iterator i= pcps.iterator(); !result && i.hasNext(); ) { + for(Iterator i= fParticipants.iterator(); !result && i.hasNext(); ) { result |= (i.next()).affectsBehavior(event); } return result; } -} \ No newline at end of file +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java similarity index 90% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java index 0dcd75cfb6f..555062cf8a7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java @@ -9,7 +9,7 @@ * QNX Software Systems - Initial API and implementation * Anton Leherbauer (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.internal.ui.editor.asm; +package org.eclipse.cdt.ui.text; import org.eclipse.core.resources.IFile; @@ -43,20 +43,25 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.ILanguageUI; -import org.eclipse.cdt.ui.text.ICPartitions; -import org.eclipse.cdt.ui.text.ITokenStore; -import org.eclipse.cdt.ui.text.ITokenStoreFactory; -import org.eclipse.cdt.internal.ui.text.AbstractCScanner; +import org.eclipse.cdt.internal.ui.editor.asm.AsmCodeScanner; +import org.eclipse.cdt.internal.ui.editor.asm.AsmPreprocessorScanner; +import org.eclipse.cdt.internal.ui.editor.asm.AsmReconcilingStrategy; import org.eclipse.cdt.internal.ui.text.CCommentScanner; -import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; -import org.eclipse.cdt.internal.ui.text.IColorManager; import org.eclipse.cdt.internal.ui.text.PartitionDamager; import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner; import org.eclipse.cdt.internal.ui.text.TokenStore; - +/** + * Configuration for a source viewer which shows Assembly code. + *

+ * This class may be instantiated; it is not intended to be subclassed. + *

+ * + * @noextend This class is not intended to be subclassed by clients. + * + * @since 5.1 + */ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration { private ITextEditor fTextEditor; @@ -106,24 +111,6 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration initializeScanners(); } - /** - * Constructor for AsmSourceViewerConfiguration. - * @deprecated - */ - @Deprecated - public AsmSourceViewerConfiguration(AsmTextTools tools, IPreferenceStore store) { - this(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING); - } - - /** - * Constructor for AsmSourceViewerConfiguration. - * @deprecated - */ - @Deprecated - public AsmSourceViewerConfiguration(ITextEditor editor, IPreferenceStore store) { - this(CUIPlugin.getDefault().getAsmTextTools().getColorManager(), store, editor, ICPartitions.C_PARTITIONING); - } - /** * Initializes the scanners. */ @@ -138,7 +125,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration * * @return the ASM multiline comment scanner */ - protected RuleBasedScanner getMultilineCommentScanner() { + public RuleBasedScanner getMultilineCommentScanner() { return fMultilineCommentScanner; } @@ -147,7 +134,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration * * @return the ASM singleline comment scanner */ - protected RuleBasedScanner getSinglelineCommentScanner() { + public RuleBasedScanner getSinglelineCommentScanner() { return fSinglelineCommentScanner; } @@ -156,7 +143,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration * * @return the ASM string scanner */ - protected RuleBasedScanner getStringScanner() { + public RuleBasedScanner getStringScanner() { return fStringScanner; } @@ -166,7 +153,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration * * @return the assembly preprocessor scanner */ - protected RuleBasedScanner getPreprocessorScanner(ILanguage language) { + public RuleBasedScanner getPreprocessorScanner(ILanguage language) { if (fPreprocessorScanner != null) { return fPreprocessorScanner; } @@ -185,7 +172,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration * @param language * @return the assembly code scanner for the given language */ - protected RuleBasedScanner getCodeScanner(ILanguage language) { + public RuleBasedScanner getCodeScanner(ILanguage language) { if (fCodeScanner != null) { return fCodeScanner; } @@ -334,11 +321,11 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration * * @return the color manager */ - protected IColorManager getColorManager() { + public IColorManager getColorManager() { return fColorManager; } - protected ILanguage getLanguage() { + public ILanguage getLanguage() { if (fTextEditor == null) { return AssemblyLanguage.getDefault(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java similarity index 96% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java index 6a9f2f4f243..7a68153edec 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java @@ -12,7 +12,7 @@ * Sergey Prigogin (Google) * Markus Schorn (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.internal.ui.text; +package org.eclipse.cdt.ui.text; import java.util.Arrays; import java.util.Map; @@ -78,10 +78,6 @@ import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.ui.CElementContentProvider; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.ILanguageUI; -import org.eclipse.cdt.ui.text.ICPartitions; -import org.eclipse.cdt.ui.text.ICTokenScanner; -import org.eclipse.cdt.ui.text.ITokenStore; -import org.eclipse.cdt.ui.text.ITokenStoreFactory; import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy; import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner; import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration; @@ -90,6 +86,22 @@ import org.eclipse.cdt.internal.core.model.ProgressMonitorAndCanceler; import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil; import org.eclipse.cdt.internal.ui.editor.CDocumentProvider; +import org.eclipse.cdt.internal.ui.text.CAutoIndentStrategy; +import org.eclipse.cdt.internal.ui.text.CCodeScanner; +import org.eclipse.cdt.internal.ui.text.CCommentScanner; +import org.eclipse.cdt.internal.ui.text.CCompositeReconcilingStrategy; +import org.eclipse.cdt.internal.ui.text.CDoubleClickSelector; +import org.eclipse.cdt.internal.ui.text.CFormattingStrategy; +import org.eclipse.cdt.internal.ui.text.COutlineInformationControl; +import org.eclipse.cdt.internal.ui.text.CPreprocessorScanner; +import org.eclipse.cdt.internal.ui.text.CPresentationReconciler; +import org.eclipse.cdt.internal.ui.text.CReconciler; +import org.eclipse.cdt.internal.ui.text.CStringAutoIndentStrategy; +import org.eclipse.cdt.internal.ui.text.CStringDoubleClickSelector; +import org.eclipse.cdt.internal.ui.text.HTMLAnnotationHover; +import org.eclipse.cdt.internal.ui.text.PartitionDamager; +import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner; +import org.eclipse.cdt.internal.ui.text.TokenStore; import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor; import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy; import org.eclipse.cdt.internal.ui.text.c.hover.CInformationProvider; @@ -104,7 +116,12 @@ import org.eclipse.cdt.internal.ui.typehierarchy.THInformationProvider; /** - * Configuration for an SourceViewer which shows C/C++ code. + * Configuration for a SourceViewer which shows C/C++ code. + *

+ * This class may be instantiated and subclassed by clients. + *

+ * + * @since 5.1 */ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration { @@ -313,7 +330,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration { * * @return the C multi-line comment scanner */ - private ICTokenScanner getMultilineCommentScanner() { + protected ICTokenScanner getMultilineCommentScanner() { return fMultilineCommentScanner; } @@ -322,7 +339,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration { * * @return the C single-line comment scanner */ - private ICTokenScanner getSinglelineCommentScanner() { + protected ICTokenScanner getSinglelineCommentScanner() { return fSinglelineCommentScanner; } @@ -1011,12 +1028,12 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration { * @return the IProject associated with this CSourceViewerConfiguration, or null if * no IProject could be determined */ - private IProject getProject() { + protected IProject getProject() { ICProject cproject= getCProject(); return cproject!=null ? cproject.getProject() :null; } - private ITokenStoreFactory getTokenStoreFactory() { + protected ITokenStoreFactory getTokenStoreFactory() { return new ITokenStoreFactory() { public ITokenStore createTokenStore(String[] propertyColorNames) { return new TokenStore(getColorManager(), fPreferenceStore, propertyColorNames); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICColorConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java similarity index 79% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICColorConstants.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java index dc17ac69fac..d5a8954133b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICColorConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 QNX Software Systems and others. + * Copyright (c) 2000, 2008 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,14 +9,25 @@ * QNX Software Systems - Initial API and implementation * IBM Corporation *******************************************************************************/ -package org.eclipse.cdt.internal.ui.text; +package org.eclipse.cdt.ui.text; - -/* - * Color constants that we use for the preferences - */ +/** + * Color keys used for syntax highlighting C/C++ and Assembly code + * A IColorManager is responsible for mapping + * concrete colors to these keys. + *

+ * This interface declares static final fields only; it is not intended to be + * implemented. + *

+ * @see org.eclipse.cdt.ui.text.IColorManager + * + * @since 5.1 + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ public interface ICColorConstants { /** The color key for multi-line comments in C code. */ String C_MULTI_LINE_COMMENT= "c_multi_line_comment"; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java index d33898e88ed..1dc1a565b27 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java @@ -63,7 +63,7 @@ public interface ICPartitions { String C_MULTI_LINE_DOC_COMMENT= "__c_multiline_doc_comment"; //$NON-NLS-1$ /** - * All defined CDT editor partitions + * All defined CDT editor partitions. * @since 5.0 */ String[] ALL_CPARTITIONS= { @@ -75,4 +75,17 @@ public interface ICPartitions { ICPartitions.C_SINGLE_LINE_DOC_COMMENT, ICPartitions.C_MULTI_LINE_DOC_COMMENT }; + + /** + * Array of all assembly partitions. + * @since 5.1 + */ + String[] ALL_ASM_PARTITIONS= new String[] { + ICPartitions.C_MULTI_LINE_COMMENT, + ICPartitions.C_SINGLE_LINE_COMMENT, + ICPartitions.C_STRING, + ICPartitions.C_CHARACTER, + ICPartitions.C_PREPROCESSOR + }; + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java similarity index 68% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManager.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java index 86ef029c6c9..e225f983a44 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IColorManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,22 +9,26 @@ * IBM Corporation - initial API and implementation * QNX Software System *******************************************************************************/ -package org.eclipse.cdt.internal.ui.text; +package org.eclipse.cdt.ui.text; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; + /** - * Manages SWT color objects for given color keys and - * given RGB objects. Until the dispose + * Manages SWT color objects for the given color keys and + * given RGB objects. Until the dispose * method is called, the same color object is returned for * equal keys and equal RGB values. + * *

* This interface may be implemented by clients. *

* - * @see ICColorConstants + * @see org.eclipse.cdt.ui.text.ICColorConstants + * + * @since 5.1 */ public interface IColorManager { @@ -51,4 +55,21 @@ public interface IColorManager { * Disposes all color objects remembered by this color manager. */ void dispose(); + + /** + * Remembers the given color specification under the given key. + * + * @param key the color key + * @param rgb the color specification + * @throws UnsupportedOperationException if there is already a + * color specification remembered under the given key + */ + void bindColor(String key, RGB rgb); + + + /** + * Forgets the color specification remembered under the given key. + * @param key the color key + */ + void unbindColor(String key); } \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java index 71350735369..2a23879a4f8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java @@ -15,13 +15,13 @@ import org.eclipse.jface.text.ITextHover; import org.eclipse.ui.IEditorPart; /** - * ICEditorTextHover - * Provides a hover popup which appears on top of an editor with relevant - * display information. If the text hover does not provide information no - * hover popup is shown. + * Interface to be implemented by contributors to extension point + * "org.eclipse.cdt.ui.textHovers". Provides a hover popup which appears on top + * of an editor with relevant display information. If the text hover does not + * provide information no hover popup is shown. *

- * Clients may implement this interface.

- * + * Clients may implement this interface. + *

*/ public interface ICEditorTextHover extends ITextHover { diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/CSourcePresentationCreator.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/CSourcePresentationCreator.java index 8fb4f3620f3..4e32881569e 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/CSourcePresentationCreator.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/CSourcePresentationCreator.java @@ -13,43 +13,42 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.IAsmLanguage; -import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.internal.ui.editor.CDocumentProvider; import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput; -import org.eclipse.cdt.internal.ui.text.CCommentScanner; import org.eclipse.cdt.internal.ui.text.CTextTools; -import org.eclipse.cdt.internal.ui.text.ICColorConstants; -import org.eclipse.cdt.internal.ui.text.IColorManager; -import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration; -import org.eclipse.cdt.internal.ui.text.TokenStore; import org.eclipse.cdt.internal.ui.util.EditorUtility; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration; +import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.ui.text.ICPartitions; -import org.eclipse.cdt.ui.text.ITokenStore; -import org.eclipse.cdt.ui.text.ITokenStoreFactory; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFileState; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IStorage; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.IAutoEditStrategy; import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextPresentation; +import org.eclipse.jface.text.formatter.IContentFormatter; +import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; +import org.eclipse.jface.text.information.IInformationPresenter; import org.eclipse.jface.text.presentation.PresentationReconciler; import org.eclipse.jface.text.rules.ITokenScanner; import org.eclipse.jface.text.rules.RuleBasedScanner; +import org.eclipse.jface.text.source.IAnnotationHover; +import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; /** * A presentation creator based on CDT syntax highlighting. @@ -60,11 +59,12 @@ public class CSourcePresentationCreator extends PresentationReconciler implement /** * */ - private final static class CustomCSourceViewerConfiguration extends SimpleCSourceViewerConfiguration { + private final static class CustomCSourceViewerConfiguration extends CSourceViewerConfiguration { /** * Comment for fLanguage */ private final ILanguage fLanguage; + private AsmSourceViewerConfiguration fAsmConfig; /** * @param colorManager @@ -74,8 +74,11 @@ public class CSourcePresentationCreator extends PresentationReconciler implement private CustomCSourceViewerConfiguration( IColorManager colorManager, IPreferenceStore preferenceStore, ILanguage language) { - super(colorManager, preferenceStore, null, ICPartitions.C_PARTITIONING, false); + super(colorManager, preferenceStore, null, ICPartitions.C_PARTITIONING); fLanguage = language; + if (language instanceof IAsmLanguage) { + fAsmConfig= new AsmSourceViewerConfiguration(colorManager, preferenceStore, null, ICPartitions.C_PARTITIONING); + } } public void dispose() { @@ -114,63 +117,13 @@ public class CSourcePresentationCreator extends PresentationReconciler implement return null; } - private ITokenScanner getMultilineCommentScanner() { - return new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT); - } - - private ITokenScanner getSinglelineCommentScanner() { - return new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT); - } - - /** - * Returns the ICProject associated with this CSourceViewerConfiguration, or null if - * no ICProject could be determined - * @return - */ - private ICProject internalGetCProject() { - ITextEditor editor= getEditor(); - if (editor == null) - return null; - - ICElement element= null; - IEditorInput input= editor.getEditorInput(); - IDocumentProvider provider= editor.getDocumentProvider(); - if (provider instanceof CDocumentProvider) { - CDocumentProvider cudp= (CDocumentProvider) provider; - element= cudp.getWorkingCopy(input); - } - - if (element == null) - return null; - - return element.getCProject(); - } - - - /** - * @return the IProject associated with this CSourceViewerConfiguration, or null if - * no IProject could be determined - */ - private IProject getProject() { - ICProject cproject= internalGetCProject(); - return cproject!=null ? cproject.getProject() :null; - } - - private ITokenStoreFactory getTokenStoreFactory() { - return new ITokenStoreFactory() { - public ITokenStore createTokenStore(String[] propertyColorNames) { - return new TokenStore(getColorManager(), fPreferenceStore, propertyColorNames); - } - }; - } - /* * @see org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration#getCodeScanner(org.eclipse.cdt.core.model.ILanguage) */ @Override protected RuleBasedScanner getCodeScanner(ILanguage language) { if (language instanceof IAsmLanguage) { - return CUIPlugin.getDefault().getAsmTextTools().getCodeScanner(); + return fAsmConfig.getCodeScanner(language); } return super.getCodeScanner(language); } @@ -181,11 +134,99 @@ public class CSourcePresentationCreator extends PresentationReconciler implement @Override protected RuleBasedScanner getPreprocessorScanner(ILanguage language) { if (language instanceof IAsmLanguage) { - return CUIPlugin.getDefault().getAsmTextTools().getPreprocessorScanner(); + return fAsmConfig.getPreprocessorScanner(language); } return super.getPreprocessorScanner(language); } - } + + /* + * @see SourceViewerConfiguration#getAutoEditStrategies(ISourceViewer, String) + */ + @Override + public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { + return null; + } + + /* + * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer) + */ + @Override + public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { + return null; + } + + /* + * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer) + */ + @Override + public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) { + return null; + } + + /* + * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String) + */ + @Override + public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) { + return null; + } + + /* + * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int) + */ + @Override + public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) { + return null; + } + + /* + * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String) + */ + @Override + public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { + return null; + } + + /* + * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer) + */ + @Override + public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) { + return null; + } + + /* + * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer) + */ + @Override + public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) { + return null; + } + + /* + * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer) + */ + @Override + public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) { + return null; + } + + /* + * @see SourceViewerConfiguration#getHyperlinkDetectors(ISourceViewer) + */ + @Override + public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { + return null; + } + + /* + * @see CSourceViewerConfiguration#getOutlinePresenter(ISourceViewer) + */ + @Override + public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer) { + return null; + } +} private ITextViewer fViewer; private ISourceTagProvider fSourceTagProvider; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/SourceTagDamagerRepairer.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/SourceTagDamagerRepairer.java index 5aa049b3856..a0332bf8ad6 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/SourceTagDamagerRepairer.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/SourceTagDamagerRepairer.java @@ -18,10 +18,9 @@ import java.util.List; import java.util.Map; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; -import org.eclipse.cdt.internal.ui.text.IColorManager; -import org.eclipse.cdt.internal.ui.text.IColorManagerExtension; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.ICPartitions; +import org.eclipse.cdt.ui.text.IColorManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.IDocument; @@ -99,9 +98,8 @@ public class SourceTagDamagerRepairer extends DefaultDamagerRepairer implements private void removeTextAttribute(String key, String colorKey) { if (fColorManager != null && colorKey != null) { Color color= fColorManager.getColor(colorKey); - if (fColorManager instanceof IColorManagerExtension && color != null) { - IColorManagerExtension ext= (IColorManagerExtension) fColorManager; - ext.unbindColor(colorKey); + if (color != null) { + fColorManager.unbindColor(colorKey); } } @@ -109,13 +107,12 @@ public class SourceTagDamagerRepairer extends DefaultDamagerRepairer implements } private void addTextAttribute(String key, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { - if (fColorManager != null && colorKey != null && fColorManager instanceof IColorManagerExtension) { + if (fColorManager != null && colorKey != null) { RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey); Color color= fColorManager.getColor(colorKey); if (color == null || !rgb.equals(color.getRGB())) { - IColorManagerExtension ext= (IColorManagerExtension) fColorManager; - ext.unbindColor(colorKey); - ext.bindColor(colorKey, rgb); + fColorManager.unbindColor(colorKey); + fColorManager.bindColor(colorKey, rgb); } }