Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] open type fix

This patch fixes a small bug where the wrong type would sometimes get highlighted in a typedef declaration.
Index: browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java,v
retrieving revision 1.4
diff -u -r1.4 OpenTypeAction.java
--- browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java	17 May 2004 15:49:07 -0000	1.4
+++ browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java	26 May 2004 22:00:23 -0000
@@ -19,7 +19,6 @@
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.ICElement;
 import org.eclipse.cdt.core.resources.FileStorage;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
 import org.eclipse.cdt.internal.ui.util.EditorUtility;
 import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
 import org.eclipse.cdt.ui.CUIPlugin;
@@ -161,8 +160,13 @@
 					editorPart = EditorUtility.openInEditor(storage);
 				}
 			}
-			if (editorPart == null)
-				return false;
+
+			// highlight the type in the editor
+			if (editorPart != null && editorPart instanceof ITextEditor) {
+				ITextEditor editor = (ITextEditor) editorPart;
+				editor.selectAndReveal(location.getOffset(), location.getLength());
+				return true;
+			}
 		} catch (CModelException ex) {
 			ex.printStackTrace();
 			return false;
@@ -171,16 +175,6 @@
 			return false;
 		}
 		
-		// highlight the type in the editor
-		if (cElement != null && editorPart instanceof CEditor) {
-			CEditor editor = (CEditor) editorPart;
-			editor.setSelection(cElement);
-			return true;
-		} else if (editorPart instanceof ITextEditor) {
-			ITextEditor editor = (ITextEditor) editorPart;
-			editor.selectAndReveal(location.getOffset(), location.getLength());
-			return true;
-		}
 		return false;
 	}
 

Back to the top