1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 237016: C Compare Viewer does not colorize doxygen comments

This commit is contained in:
Anton Leherbauer 2008-06-19 13:45:05 +00:00
parent a0a40cf21f
commit e4b026c274
8 changed files with 67 additions and 50 deletions

View file

@ -1101,7 +1101,7 @@
point="org.eclipse.compare.contentMergeViewers"> point="org.eclipse.compare.contentMergeViewers">
<viewer <viewer
class="org.eclipse.cdt.internal.ui.compare.CContentViewerCreator" class="org.eclipse.cdt.internal.ui.compare.CContentViewerCreator"
extensions="c2" extensions="c,cc,cxx,cpp,c++,h,hh,hxx,hpp,c2"
id="org.eclipse.cdt.ui.compare.CContentViewerCreator"> id="org.eclipse.cdt.ui.compare.CContentViewerCreator">
</viewer> </viewer>
<contentTypeBinding <contentTypeBinding
@ -1122,7 +1122,7 @@
</contentTypeBinding> </contentTypeBinding>
<viewer <viewer
class="org.eclipse.cdt.internal.ui.compare.AsmContentViewerCreator" class="org.eclipse.cdt.internal.ui.compare.AsmContentViewerCreator"
extensions="asm" extensions="s,asm"
id="org.eclipse.cdt.ui.compare.AsmContentViewerCreator"/> id="org.eclipse.cdt.ui.compare.AsmContentViewerCreator"/>
<contentTypeBinding <contentTypeBinding
contentTypeId="org.eclipse.cdt.core.asmSource" contentTypeId="org.eclipse.cdt.core.asmSource"
@ -1788,9 +1788,14 @@
<!-- MSVS Breakpoints --> <!-- MSVS Breakpoints -->
<key <key
sequence="M1+M3+B" commandId="org.eclipse.ui.views.showView"
commandId="org.eclipse.debug.ui.BreakpointView" schemeId="org.eclipse.cdt.ui.visualstudio"
schemeId="org.eclipse.cdt.ui.visualstudio"/> sequence="M1+M3+B">
<parameter
id="org.eclipse.ui.views.showView.viewId"
value="org.eclipse.debug.ui.BreakpointView">
</parameter>
</key>
<!-- Search Keys --> <!-- Search Keys -->
<!-- Text Editing Keys --> <!-- Text Editing Keys -->

View file

@ -16,7 +16,6 @@ import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer; import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.text.source.SourceViewerConfiguration;
@ -136,11 +135,6 @@ abstract class AbstractMergeViewer extends TextMergeViewer {
return ICPartitions.C_PARTITIONING; return ICPartitions.C_PARTITIONING;
} }
@Override
protected IDocumentPartitioner getDocumentPartitioner() {
return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(null);
}
@Override @Override
protected void configureTextViewer(TextViewer textViewer) { protected void configureTextViewer(TextViewer textViewer) {
if (textViewer instanceof SourceViewer) { if (textViewer instanceof SourceViewer) {

View file

@ -13,13 +13,13 @@ package org.eclipse.cdt.internal.ui.compare;
import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.CompareConfiguration;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.ui.editor.asm.AsmSourceViewerConfiguration; import org.eclipse.cdt.internal.ui.editor.asm.AsmSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools; import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
@ -43,9 +43,6 @@ public class AsmMergeViewer extends AbstractMergeViewer {
super(parent, style, configuration); super(parent, style, configuration);
} }
/*
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#getSourceViewerConfiguration()
*/
@Override @Override
protected SourceViewerConfiguration getSourceViewerConfiguration() { protected SourceViewerConfiguration getSourceViewerConfiguration() {
if (fSourceViewerConfiguration == null) { if (fSourceViewerConfiguration == null) {
@ -56,17 +53,16 @@ public class AsmMergeViewer extends AbstractMergeViewer {
return fSourceViewerConfiguration; return fSourceViewerConfiguration;
} }
/*
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#getTitle()
*/
@Override @Override
public String getTitle() { public String getTitle() {
return CUIPlugin.getResourceString(TITLE); return CUIPlugin.getResourceString(TITLE);
} }
/* @Override
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#handlePropertyChange(org.eclipse.jface.util.PropertyChangeEvent) protected IDocumentPartitioner getDocumentPartitioner() {
*/ return CUIPlugin.getDefault().getAsmTextTools().createDocumentPartitioner();
}
@Override @Override
protected void handlePropertyChange(PropertyChangeEvent event) { protected void handlePropertyChange(PropertyChangeEvent event) {
super.handlePropertyChange(event); super.handlePropertyChange(event);

View file

@ -14,15 +14,18 @@ package org.eclipse.cdt.internal.ui.compare;
import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.CompareConfiguration;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICPartitions; 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.CSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
/** /**
* A merge viewer for C/C++ code. * A merge viewer for C/C++ code.
@ -47,14 +50,18 @@ public class CMergeViewer extends AbstractMergeViewer {
return fSourceViewerConfiguration; return fSourceViewerConfiguration;
} }
@Override
protected IDocumentPartitioner getDocumentPartitioner() {
// use workspace default for highlighting doc comments in compare viewer
IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
}
@Override @Override
public String getTitle() { public String getTitle() {
return CUIPlugin.getResourceString(TITLE); return CUIPlugin.getResourceString(TITLE);
} }
/*
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#handlePropertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
@Override @Override
protected void handlePropertyChange(PropertyChangeEvent event) { protected void handlePropertyChange(PropertyChangeEvent event) {
super.handlePropertyChange(event); super.handlePropertyChange(event);

View file

@ -48,9 +48,12 @@ import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
import org.eclipse.cdt.internal.core.dom.NullCodeReaderFactory; import org.eclipse.cdt.internal.core.dom.NullCodeReaderFactory;
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
/** /**
* A structure creator for C/C++ translation units. * A structure creator for C/C++ translation units.
*/ */
@ -151,20 +154,16 @@ public class CStructureCreator extends StructureCreator {
return language; return language;
} }
/*
* @see org.eclipse.compare.structuremergeviewer.StructureCreator#getDocumentPartitioning()
*/
@Override @Override
protected String getDocumentPartitioning() { protected String getDocumentPartitioning() {
return ICPartitions.C_PARTITIONING; return ICPartitions.C_PARTITIONING;
} }
/*
* @see org.eclipse.compare.structuremergeviewer.StructureCreator#getDocumentPartitioner()
*/
@Override @Override
protected IDocumentPartitioner getDocumentPartitioner() { protected IDocumentPartitioner getDocumentPartitioner() {
return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(null); // use workspace default for highlighting doc comments in compare viewer
IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
} }
private static String readString(IStreamContentAccessor sa) throws CoreException { private static String readString(IStreamContentAccessor sa) throws CoreException {

View file

@ -17,12 +17,9 @@ import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension3; import org.eclipse.jface.text.IDocumentExtension3;
import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner;
/** /**
* Document setup participant for asesembly content. * Document setup participant for asesembly content.
*/ */
@ -37,7 +34,7 @@ public class AsmDocumentSetupParticipant implements IDocumentSetupParticipant, I
* @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument) * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
*/ */
public void setup(IDocument document) { public void setup(IDocument document) {
IDocumentPartitioner partitioner= createDocumentPartitioner(); IDocumentPartitioner partitioner= CUIPlugin.getDefault().getAsmTextTools().createDocumentPartitioner();
if (document instanceof IDocumentExtension3) { if (document instanceof IDocumentExtension3) {
IDocumentExtension3 extension3= (IDocumentExtension3) document; IDocumentExtension3 extension3= (IDocumentExtension3) document;
extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner); extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
@ -47,17 +44,6 @@ public class AsmDocumentSetupParticipant implements IDocumentSetupParticipant, I
partitioner.connect(document); partitioner.connect(document);
} }
private 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);
}
/* /*
* @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object) * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
*/ */

View file

@ -15,12 +15,15 @@ package org.eclipse.cdt.internal.ui.editor.asm;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.jface.text.rules.RuleBasedScanner; import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.cdt.core.model.AssemblyLanguage; import org.eclipse.cdt.core.model.AssemblyLanguage;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.ui.text.ITokenStore; import org.eclipse.cdt.ui.text.ITokenStore;
import org.eclipse.cdt.ui.text.ITokenStoreFactory; import org.eclipse.cdt.ui.text.ITokenStoreFactory;
@ -28,6 +31,7 @@ import org.eclipse.cdt.internal.ui.text.CCommentScanner;
import org.eclipse.cdt.internal.ui.text.ICColorConstants; import org.eclipse.cdt.internal.ui.text.ICColorConstants;
import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner; import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
import org.eclipse.cdt.internal.ui.text.TokenStore; import org.eclipse.cdt.internal.ui.text.TokenStore;
import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner;
import org.eclipse.cdt.internal.ui.text.util.CColorManager; import org.eclipse.cdt.internal.ui.text.util.CColorManager;
@ -224,4 +228,15 @@ public class AsmTextTools {
fPreprocessorScanner.adaptToPreferenceChange(event); fPreprocessorScanner.adaptToPreferenceChange(event);
} }
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);
}
} }

View file

@ -20,6 +20,7 @@ import java.util.Map;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -326,12 +327,19 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
/** /**
* Returns the C multi-line doc comment scanner for this configuration. * Returns the C multi-line doc comment scanner for this configuration.
* *
* @return the C multi-line doc comment scanner, may be <code>null</code> * @return the C multi-line doc comment scanner
*/ */
protected ICTokenScanner getMultilineDocCommentScanner(IResource resource) { protected ICTokenScanner getMultilineDocCommentScanner(IResource resource) {
if (fMultilineDocCommentScanner == null) { if (fMultilineDocCommentScanner == null) {
if (resource == null) {
resource= ResourcesPlugin.getWorkspace().getRoot();
}
IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getMultilineConfiguration(); IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getMultilineConfiguration();
fMultilineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory()); fMultilineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
if (fMultilineDocCommentScanner == null) {
// fallback: normal comment highlighting
fMultilineDocCommentScanner= fMultilineCommentScanner;
}
} }
return fMultilineDocCommentScanner; return fMultilineDocCommentScanner;
} }
@ -339,12 +347,19 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
/** /**
* Returns the C single-line doc comment scanner for this configuration. * Returns the C single-line doc comment scanner for this configuration.
* *
* @return the C single-line doc comment scanner, may be <code>null</code> * @return the C single-line doc comment scanner
*/ */
protected ICTokenScanner getSinglelineDocCommentScanner(IResource resource) { protected ICTokenScanner getSinglelineDocCommentScanner(IResource resource) {
if (fSinglelineDocCommentScanner == null) { if (fSinglelineDocCommentScanner == null) {
if (resource == null) {
resource= ResourcesPlugin.getWorkspace().getRoot();
}
IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getSinglelineConfiguration(); IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getSinglelineConfiguration();
fSinglelineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory()); fSinglelineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
if (fSinglelineDocCommentScanner == null) {
// fallback: normal comment highlighting
fSinglelineDocCommentScanner= fSinglelineCommentScanner;
}
} }
return fSinglelineDocCommentScanner; return fSinglelineDocCommentScanner;
} }