1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Fix for 237035: Syntax Coloring Preview and editors don't update

This commit is contained in:
Anton Leherbauer 2008-06-13 11:13:37 +00:00
parent d2beba7ee5
commit cc494247e8
2 changed files with 46 additions and 8 deletions

View file

@ -167,11 +167,15 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
textWidget.setBackground(null); textWidget.setBackground(null);
} }
if (configuration instanceof CSourceViewerConfiguration) {
CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
cConfiguration.resetScanners();
}
super.configure(configuration); super.configure(configuration);
if (configuration instanceof CSourceViewerConfiguration) { if (configuration instanceof CSourceViewerConfiguration) {
CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration; CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
cConfiguration.resetScanners();
fOutlinePresenter= cConfiguration.getOutlinePresenter(this); fOutlinePresenter= cConfiguration.getOutlinePresenter(this);
if (fOutlinePresenter != null) if (fOutlinePresenter != null)
fOutlinePresenter.install(this); fOutlinePresenter.install(this);

View file

@ -119,10 +119,18 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
/** /**
* The C multi-line comment scanner. * The C multi-line comment scanner.
*/ */
protected ICTokenScanner fMultilineDocCommentScanner; protected ICTokenScanner fMultilineCommentScanner;
/** /**
* The C single-line comment scanner. * The C single-line comment scanner.
*/ */
protected ICTokenScanner fSinglelineCommentScanner;
/**
* The C multi-line doc comment scanner.
*/
protected ICTokenScanner fMultilineDocCommentScanner;
/**
* The C single-line doc comment scanner.
*/
protected ICTokenScanner fSinglelineDocCommentScanner; protected ICTokenScanner fSinglelineDocCommentScanner;
/** /**
* The C string scanner. * The C string scanner.
@ -236,10 +244,12 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
} }
/** /**
* Initializes the scanners. * Initializes language independent scanners.
*/ */
protected void initializeScanners() { protected void initializeScanners() {
fStringScanner= new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING); fStringScanner= new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
fMultilineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT);
fSinglelineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT);
} }
/** /**
@ -258,11 +268,11 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
dr= new DefaultDamagerRepairer(new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT)); dr= new DefaultDamagerRepairer(getSinglelineCommentScanner());
reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_COMMENT); reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_COMMENT); reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
dr= new DefaultDamagerRepairer(new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT)); dr= new DefaultDamagerRepairer(getMultilineCommentScanner());
reconciler.setDamager(dr, ICPartitions.C_MULTI_LINE_COMMENT); reconciler.setDamager(dr, ICPartitions.C_MULTI_LINE_COMMENT);
reconciler.setRepairer(dr, ICPartitions.C_MULTI_LINE_COMMENT); reconciler.setRepairer(dr, ICPartitions.C_MULTI_LINE_COMMENT);
@ -300,6 +310,24 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* *
* @return the C multi-line comment scanner * @return the C multi-line comment scanner
*/ */
protected ICTokenScanner getMultilineCommentScanner() {
return fMultilineCommentScanner;
}
/**
* Returns the C single-line comment scanner for this configuration.
*
* @return the C single-line comment scanner
*/
protected ICTokenScanner getSinglelineCommentScanner() {
return fSinglelineCommentScanner;
}
/**
* Returns the C multi-line doc comment scanner for this configuration.
*
* @return the C multi-line doc comment scanner, may be <code>null</code>
*/
protected ICTokenScanner getMultilineDocCommentScanner(IResource resource) { protected ICTokenScanner getMultilineDocCommentScanner(IResource resource) {
if (fMultilineDocCommentScanner == null) { if (fMultilineDocCommentScanner == null) {
IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getMultilineConfiguration(); IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getMultilineConfiguration();
@ -309,9 +337,9 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
} }
/** /**
* Returns the C single-line comment scanner for this configuration. * Returns the C single-line doc comment scanner for this configuration.
* *
* @return the C single-line comment scanner * @return the C single-line doc comment scanner, may be <code>null</code>
*/ */
protected ICTokenScanner getSinglelineDocCommentScanner(IResource resource) { protected ICTokenScanner getSinglelineDocCommentScanner(IResource resource) {
if (fSinglelineDocCommentScanner == null) { if (fSinglelineDocCommentScanner == null) {
@ -717,6 +745,8 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
public boolean affectsBehavior(PropertyChangeEvent event) { public boolean affectsBehavior(PropertyChangeEvent event) {
if ((fMultilineDocCommentScanner != null && fMultilineDocCommentScanner.affectsBehavior(event)) if ((fMultilineDocCommentScanner != null && fMultilineDocCommentScanner.affectsBehavior(event))
|| (fSinglelineDocCommentScanner != null && fSinglelineDocCommentScanner.affectsBehavior(event)) || (fSinglelineDocCommentScanner != null && fSinglelineDocCommentScanner.affectsBehavior(event))
|| fMultilineCommentScanner.affectsBehavior(event)
|| fSinglelineCommentScanner.affectsBehavior(event)
|| fStringScanner.affectsBehavior(event)) { || fStringScanner.affectsBehavior(event)) {
return true; return true;
} }
@ -807,6 +837,10 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
fMultilineDocCommentScanner.adaptToPreferenceChange(event); fMultilineDocCommentScanner.adaptToPreferenceChange(event);
if (fSinglelineDocCommentScanner!=null && fSinglelineDocCommentScanner.affectsBehavior(event)) if (fSinglelineDocCommentScanner!=null && fSinglelineDocCommentScanner.affectsBehavior(event))
fSinglelineDocCommentScanner.adaptToPreferenceChange(event); fSinglelineDocCommentScanner.adaptToPreferenceChange(event);
if (fMultilineCommentScanner.affectsBehavior(event))
fMultilineCommentScanner.adaptToPreferenceChange(event);
if (fSinglelineCommentScanner.affectsBehavior(event))
fSinglelineCommentScanner.adaptToPreferenceChange(event);
if (fStringScanner.affectsBehavior(event)) if (fStringScanner.affectsBehavior(event))
fStringScanner.adaptToPreferenceChange(event); fStringScanner.adaptToPreferenceChange(event);
if (fPreprocessorScanner != null && fPreprocessorScanner.affectsBehavior(event)) if (fPreprocessorScanner != null && fPreprocessorScanner.affectsBehavior(event))