Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/dsf
diff options
context:
space:
mode:
authorAnton Leherbauer2009-01-13 15:25:14 +0000
committerAnton Leherbauer2009-01-13 15:25:14 +0000
commitf4ce07488d8f308102ce9e4689e4bda602e578f1 (patch)
tree7cd9a2b16c29aa14224bcf5ec8223fb0e155a22b /dsf
parentcd81b282d5749c3249559e07cc3122d79bd78f2d (diff)
downloadorg.eclipse.cdt-f4ce07488d8f308102ce9e4689e4bda602e578f1.tar.gz
org.eclipse.cdt-f4ce07488d8f308102ce9e4689e4bda602e578f1.tar.xz
org.eclipse.cdt-f4ce07488d8f308102ce9e4689e4bda602e578f1.zip
Bug 251406 - Make CSourceViewerConfiguration and friends public API
Diffstat (limited to 'dsf')
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/CSourcePresentationCreator.java165
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/presentation/SourceTagDamagerRepairer.java15
2 files changed, 109 insertions, 71 deletions
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 <code>fLanguage</code>
*/
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,78 +117,116 @@ public class CSourcePresentationCreator extends PresentationReconciler implement
return null;
}
- private ITokenScanner getMultilineCommentScanner() {
- return new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT);
+ /*
+ * @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 fAsmConfig.getCodeScanner(language);
+ }
+ return super.getCodeScanner(language);
+ }
+
+ /*
+ * @see org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration#getPreprocessorScanner(org.eclipse.cdt.core.model.ILanguage)
+ */
+ @Override
+ protected RuleBasedScanner getPreprocessorScanner(ILanguage language) {
+ if (language instanceof IAsmLanguage) {
+ return fAsmConfig.getPreprocessorScanner(language);
+ }
+ return super.getPreprocessorScanner(language);
+ }
+
+ /*
+ * @see SourceViewerConfiguration#getAutoEditStrategies(ISourceViewer, String)
+ */
+ @Override
+ public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
+ return null;
}
- private ITokenScanner getSinglelineCommentScanner() {
- return new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT);
+ /*
+ * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
+ */
+ @Override
+ public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
+ return null;
}
- /**
- * Returns the ICProject associated with this CSourceViewerConfiguration, or null if
- * no ICProject could be determined
- * @return
+ /*
+ * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
*/
- private ICProject internalGetCProject() {
- ITextEditor editor= getEditor();
- if (editor == null)
- return null;
+ @Override
+ public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
+ 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);
- }
+ /*
+ * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
+ */
+ @Override
+ public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
+ return null;
+ }
- if (element == null)
- return null;
+ /*
+ * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
+ */
+ @Override
+ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
+ return null;
+ }
- return element.getCProject();
+ /*
+ * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
+ */
+ @Override
+ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
+ return null;
}
-
- /**
- * @return the IProject associated with this CSourceViewerConfiguration, or null if
- * no IProject could be determined
+ /*
+ * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
*/
- private IProject getProject() {
- ICProject cproject= internalGetCProject();
- return cproject!=null ? cproject.getProject() :null;
+ @Override
+ public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
+ return null;
}
- private ITokenStoreFactory getTokenStoreFactory() {
- return new ITokenStoreFactory() {
- public ITokenStore createTokenStore(String[] propertyColorNames) {
- return new TokenStore(getColorManager(), fPreferenceStore, propertyColorNames);
- }
- };
+ /*
+ * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
+ */
+ @Override
+ public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
+ return null;
}
/*
- * @see org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration#getCodeScanner(org.eclipse.cdt.core.model.ILanguage)
+ * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
*/
@Override
- protected RuleBasedScanner getCodeScanner(ILanguage language) {
- if (language instanceof IAsmLanguage) {
- return CUIPlugin.getDefault().getAsmTextTools().getCodeScanner();
- }
- return super.getCodeScanner(language);
+ public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
+ return null;
+ }
+
+ /*
+ * @see SourceViewerConfiguration#getHyperlinkDetectors(ISourceViewer)
+ */
+ @Override
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ return null;
}
/*
- * @see org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration#getPreprocessorScanner(org.eclipse.cdt.core.model.ILanguage)
+ * @see CSourceViewerConfiguration#getOutlinePresenter(ISourceViewer)
*/
@Override
- protected RuleBasedScanner getPreprocessorScanner(ILanguage language) {
- if (language instanceof IAsmLanguage) {
- return CUIPlugin.getDefault().getAsmTextTools().getPreprocessorScanner();
- }
- return super.getPreprocessorScanner(language);
+ 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);
}
}

Back to the top