Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java48
2 files changed, 46 insertions, 8 deletions
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 b032c205d0..02c5d76da8 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
@@ -167,11 +167,15 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
textWidget.setBackground(null);
}
+ if (configuration instanceof CSourceViewerConfiguration) {
+ CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
+ cConfiguration.resetScanners();
+ }
+
super.configure(configuration);
if (configuration instanceof CSourceViewerConfiguration) {
CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
- cConfiguration.resetScanners();
fOutlinePresenter= cConfiguration.getOutlinePresenter(this);
if (fOutlinePresenter != null)
fOutlinePresenter.install(this);
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/internal/ui/text/CSourceViewerConfiguration.java
index 379498aaab..259a59976f 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/internal/ui/text/CSourceViewerConfiguration.java
@@ -119,10 +119,18 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
/**
* The C multi-line comment scanner.
*/
- protected ICTokenScanner fMultilineDocCommentScanner;
+ protected ICTokenScanner fMultilineCommentScanner;
/**
* 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;
/**
* The C string scanner.
@@ -236,10 +244,12 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
}
/**
- * Initializes the scanners.
+ * Initializes language independent scanners.
*/
protected void initializeScanners() {
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.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.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.setRepairer(dr, ICPartitions.C_MULTI_LINE_COMMENT);
@@ -294,12 +304,30 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
return reconciler;
}
-
+
/**
* Returns the C multi-line comment scanner for this configuration.
*
* @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) {
if (fMultilineDocCommentScanner == null) {
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) {
if (fSinglelineDocCommentScanner == null) {
@@ -717,6 +745,8 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
public boolean affectsBehavior(PropertyChangeEvent event) {
if ((fMultilineDocCommentScanner != null && fMultilineDocCommentScanner.affectsBehavior(event))
|| (fSinglelineDocCommentScanner != null && fSinglelineDocCommentScanner.affectsBehavior(event))
+ || fMultilineCommentScanner.affectsBehavior(event)
+ || fSinglelineCommentScanner.affectsBehavior(event)
|| fStringScanner.affectsBehavior(event)) {
return true;
}
@@ -807,6 +837,10 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
fMultilineDocCommentScanner.adaptToPreferenceChange(event);
if (fSinglelineDocCommentScanner!=null && fSinglelineDocCommentScanner.affectsBehavior(event))
fSinglelineDocCommentScanner.adaptToPreferenceChange(event);
+ if (fMultilineCommentScanner.affectsBehavior(event))
+ fMultilineCommentScanner.adaptToPreferenceChange(event);
+ if (fSinglelineCommentScanner.affectsBehavior(event))
+ fSinglelineCommentScanner.adaptToPreferenceChange(event);
if (fStringScanner.affectsBehavior(event))
fStringScanner.adaptToPreferenceChange(event);
if (fPreprocessorScanner != null && fPreprocessorScanner.affectsBehavior(event))

Back to the top