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">
<viewer
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">
</viewer>
<contentTypeBinding
@ -1122,7 +1122,7 @@
</contentTypeBinding>
<viewer
class="org.eclipse.cdt.internal.ui.compare.AsmContentViewerCreator"
extensions="asm"
extensions="s,asm"
id="org.eclipse.cdt.ui.compare.AsmContentViewerCreator"/>
<contentTypeBinding
contentTypeId="org.eclipse.cdt.core.asmSource"
@ -1788,9 +1788,14 @@
<!-- MSVS Breakpoints -->
<key
sequence="M1+M3+B"
commandId="org.eclipse.debug.ui.BreakpointView"
schemeId="org.eclipse.cdt.ui.visualstudio"/>
commandId="org.eclipse.ui.views.showView"
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 -->
<!-- Text Editing Keys -->

View file

@ -16,7 +16,6 @@ import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
@ -136,11 +135,6 @@ abstract class AbstractMergeViewer extends TextMergeViewer {
return ICPartitions.C_PARTITIONING;
}
@Override
protected IDocumentPartitioner getDocumentPartitioner() {
return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(null);
}
@Override
protected void configureTextViewer(TextViewer textViewer) {
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.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.cdt.ui.CUIPlugin;
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;
@ -43,9 +43,6 @@ public class AsmMergeViewer extends AbstractMergeViewer {
super(parent, style, configuration);
}
/*
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#getSourceViewerConfiguration()
*/
@Override
protected SourceViewerConfiguration getSourceViewerConfiguration() {
if (fSourceViewerConfiguration == null) {
@ -56,17 +53,16 @@ public class AsmMergeViewer extends AbstractMergeViewer {
return fSourceViewerConfiguration;
}
/*
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#getTitle()
*/
@Override
public String getTitle() {
return CUIPlugin.getResourceString(TITLE);
}
/*
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#handlePropertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
@Override
protected IDocumentPartitioner getDocumentPartitioner() {
return CUIPlugin.getDefault().getAsmTextTools().createDocumentPartitioner();
}
@Override
protected void handlePropertyChange(PropertyChangeEvent 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.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.cdt.ui.CUIPlugin;
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;
/**
* A merge viewer for C/C++ code.
@ -47,14 +50,18 @@ public class CMergeViewer extends AbstractMergeViewer {
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
public String getTitle() {
return CUIPlugin.getResourceString(TITLE);
}
/*
* @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#handlePropertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
@Override
protected void handlePropertyChange(PropertyChangeEvent 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.ui.CUIPlugin;
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.ui.text.doctools.DocCommentOwnerManager;
/**
* A structure creator for C/C++ translation units.
*/
@ -151,20 +154,16 @@ public class CStructureCreator extends StructureCreator {
return language;
}
/*
* @see org.eclipse.compare.structuremergeviewer.StructureCreator#getDocumentPartitioning()
*/
@Override
protected String getDocumentPartitioning() {
return ICPartitions.C_PARTITIONING;
}
/*
* @see org.eclipse.compare.structuremergeviewer.StructureCreator#getDocumentPartitioner()
*/
@Override
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 {

View file

@ -17,12 +17,9 @@ 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.jface.text.rules.FastPartitioner;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner;
/**
* 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)
*/
public void setup(IDocument document) {
IDocumentPartitioner partitioner= createDocumentPartitioner();
IDocumentPartitioner partitioner= CUIPlugin.getDefault().getAsmTextTools().createDocumentPartitioner();
if (document instanceof IDocumentExtension3) {
IDocumentExtension3 extension3= (IDocumentExtension3) document;
extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
@ -47,17 +44,6 @@ public class AsmDocumentSetupParticipant implements IDocumentSetupParticipant, I
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)
*/

View file

@ -15,12 +15,15 @@ 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;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.util.IPropertyChangeListener;
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.ICPartitions;
import org.eclipse.cdt.ui.text.ITokenStore;
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.SingleTokenCScanner;
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;
@ -224,4 +228,15 @@ public class AsmTextTools {
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.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
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.
*
* @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) {
if (fMultilineDocCommentScanner == null) {
if (resource == null) {
resource= ResourcesPlugin.getWorkspace().getRoot();
}
IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getMultilineConfiguration();
fMultilineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
if (fMultilineDocCommentScanner == null) {
// fallback: normal comment highlighting
fMultilineDocCommentScanner= fMultilineCommentScanner;
}
}
return fMultilineDocCommentScanner;
}
@ -339,12 +347,19 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
/**
* 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) {
if (fSinglelineDocCommentScanner == null) {
if (resource == null) {
resource= ResourcesPlugin.getWorkspace().getRoot();
}
IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getSinglelineConfiguration();
fSinglelineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
if (fSinglelineDocCommentScanner == null) {
// fallback: normal comment highlighting
fSinglelineDocCommentScanner= fSinglelineCommentScanner;
}
}
return fSinglelineDocCommentScanner;
}