Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2004-09-07 19:29:33 +0000
committerAlain Magloire2004-09-07 19:29:33 +0000
commit482188a79876476a4ec6a4dd3b785800f420e4ab (patch)
tree748a02caf5e1186c0c43a3c00389b0dabd9754c0
parent373ace7ff48fb2647a79718c2fe147b716c9bd85 (diff)
downloadorg.eclipse.cdt-482188a79876476a4ec6a4dd3b785800f420e4ab.tar.gz
org.eclipse.cdt-482188a79876476a4ec6a4dd3b785800f420e4ab.tar.xz
org.eclipse.cdt-482188a79876476a4ec6a4dd3b785800f420e4ab.zip
Define the open declaration action properly
-rw-r--r--build/org.eclipse.cdt.make.ui/plugin.properties6
-rw-r--r--build/org.eclipse.cdt.make.ui/plugin.xml21
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/IMakefileEditorActionDefinitionIds.java2
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java31
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java18
5 files changed, 75 insertions, 3 deletions
diff --git a/build/org.eclipse.cdt.make.ui/plugin.properties b/build/org.eclipse.cdt.make.ui/plugin.properties
index 153298f7c55..6a748a7f8a6 100644
--- a/build/org.eclipse.cdt.make.ui/plugin.properties
+++ b/build/org.eclipse.cdt.make.ui/plugin.properties
@@ -45,6 +45,9 @@ ViewMake.name=Make Targets
ActionSetMake.label=Make Actions
ActionSetUpdateMake.label=Update Make Projects
+# Scope and Key Commands
+scope.makefileEditor.name=Makefile Editor
+makefileEditor.description=Editor for makefiles
category.source.name=Makefile Source
category.source.description= Makefile Source Actions
@@ -54,6 +57,9 @@ ActionDefinition.comment.description= Turn the selected lines into # style comme
ActionDefinition.uncomment.name= Uncomment
ActionDefinition.uncomment.description= Uncomment the selected # style comment lines
+
+ActionDefinition.opendecl.name= Open declation
+ActionDefinition.opendecl.description=Follow to the directive definition
MakefileEditor.name=Makefile Editor
diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml
index 4eeb54489fb..0b46097ce07 100644
--- a/build/org.eclipse.cdt.make.ui/plugin.xml
+++ b/build/org.eclipse.cdt.make.ui/plugin.xml
@@ -225,7 +225,13 @@
</objectContribution>
</extension>
<extension
- point="org.eclipse.ui.commands">
+ point="org.eclipse.ui.commands">
+ <scope
+ name="%scope.makefileEditor.name"
+ parent="org.eclipse.ui.textEditorScope"
+ description="%makefileEditor.description"
+ id="org.eclipse.cdt.make.ui.makefileEditorScope">
+ </scope>
<command
name="%CommandTargetBuild.name"
description="%CommandTargetBuild.description"
@@ -268,6 +274,19 @@
command="org.eclipse.cdt.make.ui.edit.text.makefile.uncomment"
configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
</keyBinding>
+ <command
+ name="%ActionDefinition.opendecl.name"
+ category="org.eclipse.cdt.make.ui.category.source"
+ description="%ActionDefinition.opendecl.description"
+ id="org.eclipse.cdt.make.ui.edit.text.makefile.opendecl">
+ </command>
+ <keyBinding
+ string="F3"
+ scope="org.eclipse.cdt.make.ui.makefileEditorScope"
+ command="org.eclipse.cdt.make.ui.edit.text.makefile.opendecl"
+ configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </keyBinding>
+
</extension>
<extension
point="org.eclipse.ui.preferencePages">
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/IMakefileEditorActionDefinitionIds.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/IMakefileEditorActionDefinitionIds.java
index 9048602b005..340dd0d1187 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/IMakefileEditorActionDefinitionIds.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/IMakefileEditorActionDefinitionIds.java
@@ -21,6 +21,6 @@ public interface IMakefileEditorActionDefinitionIds extends ITextEditorActionDef
final String COMMENT = "org.eclipse.cdt.make.ui.edit.text.makefile.uncomment"; //$NON-NLS-1$
- final String OPEN_DECLARATION = "org.eclipse.cdt.make.ui.edit.text.makefile.open_declaration"; //$NON-NLS-1$
+ final String OPEN_DECLARATION = "org.eclipse.cdt.make.ui.edit.text.makefile.opendcl"; //$NON-NLS-1$
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java
index 146d833dee1..760ad306930 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileEditor.java
@@ -25,7 +25,9 @@ import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.ITextViewerExtension;
import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
@@ -78,6 +80,33 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
}
};
+ /**
+ * Adapted source viewer for CEditor
+ */
+
+ public class AdaptedSourceViewer extends ProjectionViewer implements ITextViewerExtension {
+
+
+ public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler,
+ IOverviewRuler overviewRuler, boolean showsAnnotation, int styles) {
+ super(parent, ruler, overviewRuler, showsAnnotation, styles);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.ISourceViewer#setRangeIndication(int, int, boolean)
+ */
+ public void setRangeIndication(int offset, int length, boolean moveCursor) {
+ // Fixin a bug in the ProjectViewer implemenation
+ // PR: https://bugs.eclipse.org/bugs/show_bug.cgi?id=72914
+ if (isProjectionMode()) {
+ super.setRangeIndication(offset, length, moveCursor);
+ } else {
+ super.setRangeIndication(offset, length, false);
+ }
+ }
+ }
+
+
MakefileSourceConfiguration getMakefileSourceConfiguration() {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
if (configuration instanceof MakefileSourceConfiguration) {
@@ -159,7 +188,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
}
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
+ ISourceViewer viewer = new AdaptedSourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
// ensure decoration support has been created and configured.
getSourceViewerDecorationSupport(viewer);
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java
index 01d2d424fde..03dd38d5363 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java
@@ -10,18 +10,22 @@
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.editor;
+import org.eclipse.cdt.core.resources.FileStorage;
+import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.make.core.makefile.IDirective;
import org.eclipse.cdt.make.core.makefile.IMakefile;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.text.WordPartDetector;
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
@@ -94,6 +98,20 @@ public class OpenDeclarationAction extends TextEditorAction {
}
return editorPart;
}
+ } else {
+ // External file
+ IStorage storage = new FileStorage(path);
+ IStorageEditorInput input = new ExternalEditorInput(storage);
+ IWorkbenchPage p = MakeUIPlugin.getActivePage();
+ if (p != null) {
+ String editorID = "org.eclipse.cdt.make.editor"; //$NON-NLS-1$
+ IEditorPart editorPart = IDE.openEditor(p, input, editorID, true);
+ if (editorPart instanceof MakefileEditor) {
+ ((MakefileEditor)editorPart).setSelection(directive, true);
+ }
+ return editorPart;
+ }
+
}
return null;
}

Back to the top