Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] 2.0 mainline patch for bracket matching PR 57375

Folks,

  This patch cleans up the CEditor to remove unecessary retrieval of
the MarkerAnnotations and also restores the bracket matching that was
lost out of the editor a couple of revisions ago (PR 57375)

For the ChangeLog
- Restore bracket matching behaviour in the editor and use parent
  class code for setting up the editor's OverviewRuler.

Index: src/org/eclipse/cdt/internal/ui/editor/CEditor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java,v
retrieving revision 1.60
diff -u -r1.60 CEditor.java
--- src/org/eclipse/cdt/internal/ui/editor/CEditor.java	26 May 2004 14:22:37 -0000	1.60
+++ src/org/eclipse/cdt/internal/ui/editor/CEditor.java	27 May 2004 15:02:21 -0000
@@ -53,7 +53,6 @@
 import org.eclipse.jface.text.source.ISharedTextColors;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.OverviewRuler;
 import org.eclipse.jface.text.source.SourceViewer;
 import org.eclipse.jface.text.source.SourceViewerConfiguration;
 import org.eclipse.jface.util.PropertyChangeEvent;
@@ -81,13 +80,11 @@
 import org.eclipse.ui.part.IShowInSource;
 import org.eclipse.ui.part.ShowInContext;
 import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.ui.texteditor.AnnotationPreference;
 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
 import org.eclipse.ui.texteditor.ContentAssistAction;
 import org.eclipse.ui.texteditor.IEditorStatusLine;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
 import org.eclipse.ui.texteditor.MarkerUtilities;
 import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
 import org.eclipse.ui.texteditor.TextOperationAction;
@@ -117,15 +114,13 @@
     /** The mouse listener */
     private MouseClickListener fMouseListener;
 
-	protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']' };
+	protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
 
 	protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
 
 	/** The editor's tab converter */
 	private TabConverter fTabConverter;
 
-	private MarkerAnnotationPreferences fAnnotationPreferences;
-
 	/** Listener to annotation model changes that updates the error tick in the tab image */
 	private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
 
@@ -167,9 +162,6 @@
 	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
 	 */
 	protected void initializeEditor() {
-		//@@@ We should be able to get this from our parent
-		fAnnotationPreferences = new MarkerAnnotationPreferences();
-
 		CTextTools textTools = CUIPlugin.getDefault().getTextTools();
 		setSourceViewerConfiguration(new CSourceViewerConfiguration(textTools, this));
 		setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
@@ -485,8 +477,6 @@
 		stopTabConversion();
 		disableBrowserLikeLinks();
 		
-		fAnnotationPreferences = null;
-       
 		super.dispose();
 	}
 
@@ -916,16 +906,8 @@
 
 		fAnnotationAccess = createAnnotationAccess();
 		
-		//TODO: TF NOTE: This can be greatly cleaned up using the parent createOverviewRuler method
-		//It will also totally get rid of the need for the fAnnotationPreferences in this object
 		ISharedTextColors sharedColors = CUIPlugin.getDefault().getSharedTextColors();
-		fOverviewRuler = new OverviewRuler(fAnnotationAccess, VERTICAL_RULER_WIDTH, sharedColors);
-		Iterator e = fAnnotationPreferences.getAnnotationPreferences().iterator();
-		while (e.hasNext()) {
-			AnnotationPreference preference = (AnnotationPreference) e.next();
-			if (preference.contributesToHeader())
-				fOverviewRuler.addHeaderAnnotationType(preference.getAnnotationType());
-		}
+		fOverviewRuler = createOverviewRuler(sharedColors);
 
 		ISourceViewer sourceViewer =
 			new AdaptedSourceViewer(
@@ -940,8 +922,10 @@
 		
 		configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
 		
-		//TODO: TF NOTE: Add the bracket matching back in here!
-		
+		//Enhance the stock source viewer decorator with a bracket matcher
+		fSourceViewerDecorationSupport.setCharacterPairMatcher(fBracketMatcher);
+		fSourceViewerDecorationSupport.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
+
 		return sourceViewer;
 	}
 

Back to the top