Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2003-02-27 16:56:22 -0500
committerDoug Schaefer2003-02-27 16:56:22 -0500
commit8d34573e773eb229c4716fe06ef2c0d6658de506 (patch)
treeb88a7ccd54a9e629b0322d6e48c59c07ddd2974b
parent754a5bb7f930780a6eb87fa5eae5570c6c074d27 (diff)
downloadorg.eclipse.cdt-8d34573e773eb229c4716fe06ef2c0d6658de506.tar.gz
org.eclipse.cdt-8d34573e773eb229c4716fe06ef2c0d6658de506.tar.xz
org.eclipse.cdt-8d34573e773eb229c4716fe06ef2c0d6658de506.zip
Merge from Head.
-rw-r--r--core/org.eclipse.cdt.ui/.classpath2
-rw-r--r--core/org.eclipse.cdt.ui/ChangeLog100
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml92
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/core/DocumentInputStream.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml94
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CContentProvider.java294
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageDescriptor.java223
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementLabelProvider.java165
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java169
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java67
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java241
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedDamagerRepairer.java210
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedPartitioner.java501
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java5
27 files changed, 607 insertions, 1666 deletions
diff --git a/core/org.eclipse.cdt.ui/.classpath b/core/org.eclipse.cdt.ui/.classpath
index ee0472f689..9aecda4f3a 100644
--- a/core/org.eclipse.cdt.ui/.classpath
+++ b/core/org.eclipse.cdt.ui/.classpath
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="utils.ui/"/>
- <classpathentry kind="src" path="newparser"/>
+ <classpathentry kind="src" path="build"/>
<classpathentry kind="src" path="/org.eclipse.ui"/>
<classpathentry kind="src" path="/org.eclipse.core.resources"/>
<classpathentry kind="src" path="/org.apache.xerces"/>
diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index b7cdce9ab3..d9f33aef4a 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,3 +1,103 @@
+2003-02-24 Alain Magloire
+
+ * src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java:
+ Reorganized import to remove warnings.
+ * src/org/eclipse/cdt/ui/CelementLabelProvider.java: Reorganize imports.
+
+2003-02-24 Alain Magloire
+
+ * src/org/eclipse/cdt/internal/ui/editor/CEditor.java (isOverviewRulerVisible):
+ Change scope for protected to comply with Eclipse-2.1
+
+ * src/org/eclipse/cdt/ui/CelementContentProvider.java: Reorganize imports.
+
+2003-02-20 Alain Magloire
+
+ This patch provides the UI controls and filters to use the working set
+ concept and apply it to the CView. The UI mimics the behaviour of what is
+ used by the Java packages view (rather than incorporating it as a part of
+ the Filters... dialog as was done in the Navigator). I didn't create a
+ specific C/C++ Working Set type since I figured that for C and C++
+ projects which might include other projects it wasn't required.
+ This can be re-examined at a later date if required.
+
+ * src/org/eclipse/cdt/internal/ui/cview/CView.java:
+ Listener of the property change for Working sets.
+ * src/org/eclipse/cdt/internal/ui/cview/AdjustWorkingSetFilterAction.java:
+ New file.
+ * src/org/eclipse/cdt/internal/ui/cview/CWorkingSetFilter.java:
+ New file.
+ * src/org/eclipse/cdt/internal/ui/cview/NewWorkingSetFilterAction.java:
+ New file.
+
+2003-02 -20 David Inglis
+
+ * src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
+ Fixed minor label problem.
+
+2003-02-19 David Inglis
+ * src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java
+ * src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java
+ Due to CDT extensions interface cleanup.
+
+2003-02-17 Doug Schaefer
+
+ Merged in Sam Robb's source for the build model. The source can be
+ found in the build source folder. There are new extension point schema
+ in the schema folder. There are build icons in the icons/full/build16
+ folder. As well a number of extension points and extensions have been
+ added to the plugin.xml file.
+
+2003-02-17 Judy N. Green
+ * plugin.xml
+ * icons/full/ctool16/convert-normal.gif
+
+ Added a new icon for the conversion wizard
+
+2003-02-13 Alain Magloire
+
+ * src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java:
+ Comment out old the reference to the builder.
+
+2003-02-13 Thomas Fletcher
+ * src/org/eclipse/cdt/internal/ui/cview/CView.java
+ * src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java
+ Cleaned up some text strings.
+
+ * src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java
+ * src/org/eclipse/cdt/internal/corext/template/default-templates.xml
+ * src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java
+ * src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
+ Adds a C++ context and moves those templates which are C++ specific to that context
+ Allows you to use the C++ and C contexts when you are working in C++ code,
+ but only giving you the C contexts when you are working in C code.
+
+2003-02-06 David Inglis
+ * src/org/eclipse/cdt/internal/core/DocumentInputStream.java (Removed)
+ * src/org/eclipse/cdt/internal/ui/DocumentInputStream.java (Added)
+ cleanup - moved to ui package
+
+ * src/org/eclipse/cdt/internal/ui/CContentProvider.java (Removed)
+ * src/org/eclipse/cdt/internal/ui/CElementImageDescriptor.java (Removed)
+ * src/org/eclipse/cdt/internal/ui/CElementLabelProvider.java (Removed)
+ * src/org/eclipse/cdt/ui/CElementContentProvider.java (Added)
+ * src/org/eclipse/cdt/ui/CElementImageDescriptor.java (Added)
+ * src/org/eclipse/cdt/ui/CElementLabelProvider.java (Added)
+ * src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java
+ * src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
+ * src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
+ * src/org/eclipse/cdt/internal/ui/cview/CView.java
+ * src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
+ * src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
+ * src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
+ * src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
+ cleanup - moved CElementContentProvider/LableProvider/ImageDescrptor out of internal package
+ to ui so it can be cleanly used by others.
+
+ * src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedDamagerRepairer.java (Removed)
+ * src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedPartitioner.java (Removed)
+ cleanup - No longer needed.
+
2003-02-04 Alain Magloire
Cleanup of the annoying error generate by the JDT 2.1 compiler
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 7a79d3e7d7..4216b2cbe5 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -162,7 +162,7 @@
<!-- For C Conversion Wizard -->
<wizard
name="%StdMakeConversionWizard.name"
- icon="icons/full/ctool16/newcc_app.gif"
+ icon="icons/full/ctool16/convert-normal.gif"
category="org.eclipse.cdt.ui.newCWizards"
class="org.eclipse.cdt.ui.wizards.conversion.ConvertToStdMakeConversionWizard"
project="true"
@@ -192,7 +192,7 @@
<!-- For C++ Conversion Wizard -->
<wizard
name="%StdMakeConversionWizard.name"
- icon="icons/full/ctool16/newcc_app.gif"
+ icon="icons/full/ctool16/convert-normal.gif"
category="org.eclipse.cdt.ui.newCCWizards"
class="org.eclipse.cdt.ui.wizards.conversion.ConvertToStdMakeConversionWizard"
project="true"
@@ -424,4 +424,92 @@
</CBuildConsole>
</extension>
+ <extension-point id="CToolTabGroup" name="C/C++ Tool Configuration Tabs" schema="schema/CToolTabGroup.exsd"/>
+
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ name="Build Configurations"
+ icon="icons/full/build16/build_configs.gif"
+ category="org.eclipse.cdt.ui.views"
+ class="org.eclipse.cdt.ui.builder.internal.CBuildConfigView"
+ id="org.eclipse.cdt.ui.builder.internal.BuildConfigView">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.cdt.core.CBuildConfiguration">
+ <configuration
+ natures="*"
+ name="Debug"
+ class="org.eclipse.cdt.core.builder.CDebugBuildConfigurationProvider"
+ id="org.eclipse.cdt.core.builder.debugBuildConfiguration">
+ </configuration>
+ <configuration
+ natures="*"
+ name="Release"
+ class="org.eclipse.cdt.core.builder.CReleaseBuildConfigurationProvider"
+ id="org.eclipse.cdt.core.builder.releaseBuildConfiguration">
+ </configuration>
+ <configuration
+ natures="*"
+ name="Profile"
+ class="org.eclipse.cdt.core.builder.CProfileBuildConfigurationProvider"
+ id="org.eclipse.cdt.core.builder.profileBuildConfiguration">
+ </configuration>
+ </extension>
+ <extension
+ point="org.eclipse.cdt.core.CToolchain">
+ <provider
+ natures="*"
+ class="org.eclipse.cdt.gnu.tools.CGnuToolchainProvider"
+ id="org.eclipse.cdt.gnu.tools.native">
+ </provider>
+ </extension>
+ <extension
+ point="org.eclipse.cdt.core.CToolType">
+ <type
+ name="RPC Protocol Compiler"
+ id="org.eclipse.cdt.core.tool.rpcgen">
+ </type>
+ </extension>
+ <extension
+ point="org.eclipse.cdt.core.CTool">
+ <tool
+ name="RPC Protocol Compiler"
+ type="org.eclipse.cdt.gnu.tools.rpcgen"
+ class="org.eclipse.cdt.gnu.tools.CToolRpcgen"
+ id="org.eclipse.cdt.gnu.tool.rpcgen">
+ </tool>
+ </extension>
+ <extension
+ point="org.eclipse.cdt.core.CBuildVariable">
+ <variable
+ class="org.eclipse.cdt.gnu.tools.CStandardCVars"
+ id="org.eclipse.cdt.gnu.tools.stdCVars">
+ </variable>
+ </extension>
+ <extension
+ point="org.eclipse.cdt.ui.CToolTabGroup">
+ <toolTabGroup
+ toolId="org.eclipse.cdt.gnu.tools.cc"
+ class="org.eclipse.cdt.gnu.tools.CTabGroupCC"
+ id="org.eclipse.cdt.gnu.tools.tabGroupCC">
+ </toolTabGroup>
+ <toolTabGroup
+ toolId="org.eclipse.cdt.gnu.tools.cxx"
+ class="org.eclipse.cdt.gnu.tools.CTabGroupCXX"
+ id="org.eclipse.cdt.gnu.tools.tabGroupCXX">
+ </toolTabGroup>
+ <toolTabGroup
+ toolId="org.eclipse.cdt.gnu.tools.cpp"
+ class="org.eclipse.cdt.gnu.tools.CTabGroupCPP"
+ id="org.eclipse.cdt.gnu.tools.tabGroupCPP">
+ </toolTabGroup>
+ <toolTabGroup
+ toolId="org.eclipse.cdt.gnu.tools.ld"
+ class="org.eclipse.cdt.gnu.tools.CTabGroupLD"
+ id="org.eclipse.cdt.gnu.tools.tabGroupLD">
+ </toolTabGroup>
+ </extension>
+
</plugin>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/core/DocumentInputStream.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/core/DocumentInputStream.java
deleted file mode 100644
index cadd14d459..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/core/DocumentInputStream.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.cdt.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
- import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
- /**
- * Input stream which reads from a document
- */
-public class DocumentInputStream extends InputStream {
-
- private IDocument fDocument;
- private int fCurrPos;
-
- public DocumentInputStream(IDocument document) {
- fDocument= document;
- fCurrPos= 0;
- }
-
- public IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * @see InputStream#read
- */
- public int read() throws IOException {
- try {
- if (fCurrPos < fDocument.getLength()) {
- return fDocument.getChar(fCurrPos++);
- }
- } catch (BadLocationException e) {
- }
- return -1;
- }
-
-} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java
index 0a20913792..9770579c51 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/ContextTypeRegistry.java
@@ -5,11 +5,13 @@ package org.eclipse.cdt.internal.corext.template;
* All Rights Reserved.
*/
-import org.eclipse.cdt.internal.corext.template.c.CContextType;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import org.eclipse.cdt.internal.corext.template.c.CContextType;
+import org.eclipse.cdt.internal.corext.template.c.CppContextType;
+
/**
* A singleton to keep track of all known context types.
@@ -63,7 +65,7 @@ public class ContextTypeRegistry {
// XXX bootstrap with C and C++ types
private ContextTypeRegistry() {
add(new CContextType());
- //add(new CppContextType());
+ add(new CppContextType());
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml
index 9508183d20..abc24fbc4d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/default-templates.xml
@@ -7,89 +7,99 @@ All Rights Reserved.
<templates>
- <!-- C++ -->
+<!-- C++ -->
- <template description="for loop" name="for" context="C"
->for (${var} = 0; ${var} &lt; ${max}; ${var}++) {
+<template description="for loop" name="for" context="C">
+for (${var} = 0; ${var} &lt; ${max}; ${var}++) {
${cursor}
-}</template>
+}
+</template>
- <template description="for loop with temporary variable" name="for" context="C"
->for (int ${var} = 0; ${var} &lt; ${max}; ${var}++) {
+<template description="for loop with temporary variable" name="for" context="C">
+for (int ${var} = 0; ${var} &lt; ${max}; ${var}++) {
${cursor}
-}</template>
+}
+</template>
- <template description="do while statement" name="do" context="C"
->do {
+<template description="do while statement" name="do" context="C">
+do {
${cursor}
-} while (${condition});</template>
+} while (${condition});
+</template>
- <template description="switch case statement" name="switch" context="C"
->switch (${key}) {
+<template description="switch case statement" name="switch" context="C">
+switch (${key}) {
case ${value}:
${cursor}
break;
-
default:
break;
-}</template>
+}
+</template>
- <template description="if statement" name="if" context="C"
->if (${condition}) {
+<template description="if statement" name="if" context="C">
+if (${condition}) {
${cursor}
-}</template>
+}
+</template>
- <template description="if else statement" name="ifelse" context="C"
->if (${condition}) {
+<template description="if else statement" name="ifelse" context="C">
+if (${condition}) {
${cursor}
} else {
-}</template>
+}
+</template>
- <template description="else if block" name="elseif" context="C"
->else if (${condition}) {
+<template description="else if block" name="elseif" context="C">
+else if (${condition}) {
${cursor}
-}</template>
+}
+</template>
- <template description="else block" name="else" context="C"
->else {
+<template description="else block" name="else" context="C">
+else {
${cursor}
-}</template>
+}
+</template>
- <template description="try catch block" name="try" context="C"
->try {
+<template description="try catch block" name="try" context="C++">
+try {
${cursor}
} catch (${Exception} e) {
-}</template>
+}
+</template>
- <template description="catch block" name="catch" context="C"
->catch (${Exception} e) {
+<template description="catch block" name="catch" context="C++">
+catch (${Exception} e) {
${cursor}
-}</template>
+}
+</template>
- <template description="main method" name="main" context="C"
->
+<template description="main method" name="main" context="C">
int
main(int argc, char **argv) {
${cursor}
-}</template>
+}
+</template>
- <template description="class declaration" name="class" context="C"
->class ${name} {
+<template description="class declaration" name="class" context="C++">
+class ${name} {
${cursor}
private:
-};</template>
+};
+</template>
- <template description="using a namespace" name="using" context="C"
- >using namespace ${namespace};
+<template description="using a namespace" name="using" context="C++">
+using namespace ${namespace};
</template>
- <template description="namespace declaration" name="namespace" context="C"
+ <template description="namespace declaration" name="namespace" context="C++"
>namespace ${namespace} {
${cursor}
}</template>
- <template description="create new object" name="new" context="C"
+ <template description="create new object" name="new" context="C++"
>${type} ${name} = new ${type}(${arguments});
</template>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CContentProvider.java
deleted file mode 100644
index 221cfb7592..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CContentProvider.java
+++ /dev/null
@@ -1,294 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- */
-
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IArchive;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.core.model.ElementChangedEvent;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICFile;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ICRoot;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.ui.*;
-
-public class CContentProvider extends BaseCElementContentProvider implements ITreeContentProvider, IElementChangedListener {
-
- protected StructuredViewer fViewer;
- protected Object fInput;
-
- /* (non-Cdoc)
- * Method declared on IContentProvider.
- */
- public void dispose() {
- super.dispose();
- CoreModel.getDefault().removeElementChangedListener(this);
- }
-
- /* (non-Cdoc)
- * Method declared on IContentProvider.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- super.inputChanged(viewer, oldInput, newInput);
-
- fViewer = (StructuredViewer)viewer;
-
- if (oldInput == null && newInput != null) {
- if (newInput instanceof ICRoot)
- CoreModel.getDefault().addElementChangedListener(this);
- } else if (oldInput != null && newInput == null) {
- CoreModel.getDefault().removeElementChangedListener(this);
- }
- fInput= newInput;
- }
-
- /**
- * Creates a new content provider for C elements.
- */
- public CContentProvider() {
- }
-
- /**
- * Creates a new content provider for C elements.
- */
- public CContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
- super(provideMembers, provideWorkingCopy);
- }
-
- /* (non-Cdoc)
- * Method declared on IElementChangedListener.
- */
- public void elementChanged(final ElementChangedEvent event) {
- try {
- processDelta(event.getDelta());
- } catch(CModelException e) {
- CUIPlugin.getDefault().log(e);
- e.printStackTrace();
- }
- }
-
- /**
- * Processes a delta recursively. When more than two children are affected the
- * tree is fully refreshed starting at this node. The delta is processed in the
- * current thread but the viewer updates are posted to the UI thread.
- */
- protected void processDelta(ICElementDelta delta) throws CModelException {
- int kind= delta.getKind();
- int flags= delta.getFlags();
- ICElement element= delta.getElement();
-
- //System.out.println("Processing " + element);
- // handle open and closing of a solution or project
- if (((flags & ICElementDelta.F_CLOSED) != 0)
- || ((flags & ICElementDelta.F_OPENED) != 0)) {
- postRefresh(element);
- }
-
- if (kind == ICElementDelta.REMOVED) {
- Object parent = getParent(element);
- postRemove(element);
- if (element instanceof ICFile) {
- ICFile cfile = (ICFile)element;
- if (updateContainer(cfile)) {
- postRefresh(parent);
- }
- }
- }
-
- if (kind == ICElementDelta.ADDED) {
- Object parent= getParent(element);
- postAdd(parent, element);
- if (element instanceof ICFile) {
- ICFile cfile = (ICFile)element;
- if (updateContainer(cfile)) {
- postRefresh(parent);
- }
- }
- }
-
- if (kind == ICElementDelta.CHANGED) {
- if ((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0) {
- // throw the towel and do a full refresh of the affected C project.
- postRefresh(element.getCProject());
- return;
- } else if (element instanceof ITranslationUnit ||
- element instanceof IBinary || element instanceof IArchive) {
- postRefresh(element);
- return;
- }
-
- }
-
- ICElementDelta[] affectedChildren= delta.getAffectedChildren();
- for (int i= 0; i < affectedChildren.length; i++) {
- processDelta(affectedChildren[i]);
- }
-
- // Make sure that containers are updated.
- //if (element instanceof ICRoot) {
- // updateContainer((ICRoot)element);
- //}
- }
-
- private void updateContainer(ICRoot root) {
- postRunnable(new Runnable() {
- public void run () {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- IStructuredSelection s = (IStructuredSelection)fViewer.getSelection();
- if (s.isEmpty())
- return;
- Object element = s.getFirstElement();
- if (element instanceof ICProject) {
- updateContainer((ICProject)element);
- }
- }
- }
- });
- }
-
- protected boolean updateContainer(ICProject cproject) {
- IParent binContainer = cproject.getBinaryContainer();
- IParent libContainer = cproject.getArchiveContainer();
- if (binContainer != null) {
- postContainerRefresh(binContainer, cproject);
- }
- if (libContainer != null) {
- postContainerRefresh(libContainer, cproject);
- }
- return false;
- }
-
- private boolean updateContainer(ICFile cfile) {
- IParent container = null;
- ICProject cproject = null;
- if (cfile.isBinary()) {
- IBinary bin = (IBinary)cfile;
- if (bin.isExecutable() || bin.isSharedLib()) {
- cproject = bin.getCProject();
- container = cproject.getBinaryContainer();
- }
- } else if (cfile.isArchive()) {
- cproject = cfile.getCProject();
- container = cproject.getArchiveContainer();
- }
- if (container != null) {
- postContainerRefresh(container, cproject);
- return true;
- }
- return false;
- }
-
- private void postContainerRefresh(final IParent container, final ICProject cproject) {
- //System.out.println("UI Container:" + cproject + " " + container);
- postRunnable(new Runnable() {
- public void run () {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- if (container.hasChildren()) {
- if (fViewer.testFindItem(container) != null) {
- fViewer.refresh(container);
- } else {
- fViewer.refresh(cproject);
- }
- } else {
- fViewer.refresh(cproject);
- }
- }
- }
- });
- }
-
- private void postRefresh(final Object root) {
- //System.out.println("UI refresh:" + root);
- postRunnable(new Runnable() {
- public void run() {
- // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed())
- fViewer.refresh(root);
- }
- });
- }
-
- private void postAdd(final Object parent, final Object element) {
- //System.out.println("UI add:" + parent + " " + element);
- postRunnable(new Runnable() {
- public void run() {
- // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed())
-// fViewer.add(parent, element);
- fViewer.refresh(parent);
- }
- });
- }
-
- private void postRemove(final Object element) {
- //System.out.println("UI remove:" + element);
- postRunnable(new Runnable() {
- public void run() {
- // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed())
-// fViewer.remove(element);
- fViewer.refresh(getParent(element));
- }
- });
- }
-
- private void postRunnable(final Runnable r) {
- Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed())
- ctrl.getDisplay().asyncExec(r);
- }
-
- /**
- * The workbench has changed. Process the delta and issue updates to the viewer,
- * inside the UI thread.
- *
- * @see IResourceChangeListener#resourceChanged
- */
- //public void resourceChanged(final IResourceChangeEvent event) {
- // final IResourceDelta delta = event.getDelta();
- // Control ctrl = viewer.getControl();
- // if (ctrl != null && !ctrl.isDisposed()) {
- // ctrl.getDisplay().syncExec(new Runnable() {
- // public void run() {
- // processDelta(delta);
- // }
- // });
- // }
- //}
-
-
- /**
- * Returns the implementation of IWorkbenchAdapter for the given
- * object. Returns null if the adapter is not defined or the
- * object is not adaptable.
- */
- protected ICElement getAdapter(Object o) {
- if (!(o instanceof IAdaptable)) {
- return null;
- }
- return (ICElement)((IAdaptable)o).getAdapter(ICElement.class);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageDescriptor.java
deleted file mode 100644
index 5d88050320..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageDescriptor.java
+++ /dev/null
@@ -1,223 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-
-
-/**
- * A JavaImageDescriptor consists of a base image and several adornments. The adornments
- * are computed according to the flags either passed during creation or set via the method
- * <code>setAdornments</code>.
- * </p>
- * It is guaranteed that objects that conform to this interface are also instances of type
- * <code>ImageDescriptor</code>
- * </p>
- * <b>Note:</b> This class/interface is part of an interim API that is still under development
- * and expected to change before reaching stability.
- * </p>
- *
- * @since 2.0
- */
-public class CElementImageDescriptor extends CompositeImageDescriptor {
-
- /** Flag to render the abstract adornment */
- public final static int ABSTRACT= 0x001;
-
- /** Flag to render the final adornment */
- public final static int FINAL= 0x002;
-
- /** Flag to render the synchronized adornment */
- public final static int SYNCHRONIZED= 0x004;
-
- /** Flag to render the static adornment */
- public final static int STATIC= 0x008;
-
- /** Flag to render the runnable adornment */
- public final static int RUNNABLE= 0x010;
-
- /** Flag to render the waring adornment */
- public final static int WARNING= 0x020;
-
- /** Flag to render the error adornment */
- public final static int ERROR= 0x040;
-
- /** Flag to render the 'override' adornment */
- public final static int OVERRIDES= 0x080;
-
- /** Flag to render the 'implements' adornment */
- public final static int IMPLEMENTS= 0x100;
-
- private ImageDescriptor fBaseImage;
- private int fFlags;
- private Point fSize;
-
- /**
- * Create a new JavaElementImageDescriptor.
- *
- * @param baseImage an image descriptor used as the base image
- * @param flags flags indicating which adornments are to be rendered. See <code>setAdornments</code>
- * for valid values.
- * @param size the size of the resulting image
- * @see #setAdornments(int)
- */
- public CElementImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
- fBaseImage= baseImage;
- Assert.isNotNull(fBaseImage);
- fFlags= flags;
- Assert.isTrue(fFlags >= 0);
- fSize= size;
- Assert.isNotNull(fSize);
- }
-
- /**
- * Sets the descriptors adornments. Valid values are: <code>ABSTRACT</code>, <code>FINAL</code>,
- * <code>SYNCHRONIZED</code>, </code>STATIC<code>, </code>RUNNABLE<code>, </code>WARNING<code>,
- * </code>ERROR<code>, </code>OVERRIDDEN<code>, or any combination of those.
- *
- * @param adornments the image descritpors adornments
- */
- public void setAdornments(int adornments) {
- Assert.isTrue(adornments >= 0);
- fFlags= adornments;
- }
-
- /**
- * Returns the current adornments.
- *
- * @return the current adornments
- */
- public int getAdronments() {
- return fFlags;
- }
-
- /**
- * Sets the size of the image created by calling <code>createImage()</code>.
- *
- * @param size the size of the image returned from calling <code>createImage()</code>
- */
- public void setImageSize(Point size) {
- Assert.isNotNull(size);
- Assert.isTrue(size.x >= 0 && size.y >= 0);
- fSize= size;
- }
-
- /**
- * Returns the size of the image created by calling <code>createImage()</code>.
- *
- * @return the size of the image created by calling <code>createImage</code>
- */
- public Point getImageSize() {
- return new Point(fSize.x, fSize.y);
- }
-
- /* (non-Javadoc)
- * Method declared in CompositeImageDescriptor
- */
- protected Point getSize() {
- return fSize;
- }
-
- /* (non-Javadoc)
- * Method declared on Object.
- */
- public boolean equals(Object object) {
- if (!CElementImageDescriptor.class.equals(object.getClass()))
- return false;
-
- CElementImageDescriptor other= (CElementImageDescriptor)object;
- return (fBaseImage.equals(other.fBaseImage) && fFlags == other.fFlags && fSize.equals(other.fSize));
- }
-
- /* (non-Javadoc)
- * Method declared on Object.
- */
- public int hashCode() {
- return fBaseImage.hashCode() | fFlags | fSize.hashCode();
- }
-
- /* (non-Javadoc)
- * Method declared in CompositeImageDescriptor
- */
- protected void drawCompositeImage(int width, int height) {
- ImageData bg;
- if ((bg= fBaseImage.getImageData()) == null)
- bg= DEFAULT_IMAGE_DATA;
-
- drawImage(bg, 0, 0);
- drawTopRight();
- drawBottomRight();
- drawBottomLeft();
- }
-
- private void drawTopRight() {
- //int x= getSize().x;
- //ImageData data= null;
- /* if ((fFlags & ABSTRACT) != 0) {
- data= CPluginImages.DESC_OVR_ABSTRACT.getImageData();
- x-= data.width;
- drawImage(data, x, 0);
- }
- if ((fFlags & FINAL) != 0) {
- data= CPluginImages.DESC_OVR_FINAL.getImageData();
- x-= data.width;
- drawImage(data, x, 0);
- }
- if ((fFlags & STATIC) != 0) {
- data= CPluginImages.DESC_OVR_STATIC.getImageData();
- x-= data.width;
- drawImage(data, x, 0);
- } */
- }
-
- private void drawBottomRight() {
- //Point size= getSize();
- //int x= size.x;
- //ImageData data= null;
- /* if ((fFlags & SYNCHRONIZED) != 0) {
- data= CPluginImages.DESC_OVR_SYNCH.getImageData();
- x-= data.width;
- drawImage(data, x, size.y - data.height);
- }
- if ((fFlags & RUNNABLE) != 0) {
- data= CPluginImages.DESC_OVR_RUN.getImageData();
- x-= data.width;
- drawImage(data, x, size.y - data.height);
- }
- if ((fFlags & OVERRIDES) != 0) {
- data= CPluginImages.DESC_OVR_OVERRIDES.getImageData();
- x-= data.width;
- drawImage(data, x, size.y - data.height);
- }
- if ((fFlags & IMPLEMENTS) != 0) {
- data= CPluginImages.DESC_OVR_IMPLEMENTS.getImageData();
- x-= data.width;
- drawImage(data, x, size.y - data.height);
- } */
- }
-
- private void drawBottomLeft() {
- Point size= getSize();
- int x= 0;
- ImageData data= null;
- if ((fFlags & ERROR) != 0) {
- data= CPluginImages.DESC_OVR_ERROR.getImageData();
- drawImage(data, x, size.y - data.height);
- x+= data.width;
- }
- if ((fFlags & WARNING) != 0) {
- data= CPluginImages.DESC_OVR_WARNING.getImageData();
- drawImage(data, x, size.y - data.height);
- x+= data.width;
- }
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementLabelProvider.java
deleted file mode 100644
index 50c3e02eaf..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementLabelProvider.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package org.eclipse.cdt.internal.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.resource.ImageRegistry;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICFile;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.ui.*;
-
-/**
- * The label provider for the c model elements.
- */
-public class CElementLabelProvider extends LabelProvider {
-
- private ImageRegistry fImageRegistry;
- private WorkbenchLabelProvider fWorkbenchLabelProvider;
-
- private CElementImageProvider fImageLabelProvider;
-
- private IAdornmentProvider[] fAdornmentProviders;
-
- private int fImageFlags;
- private int fTextFlags;
-
- public CElementLabelProvider() {
- this(0 /* CElementLabels.M_PARAMETER_TYPES */, CElementImageProvider.OVERLAY_ICONS, null);
- }
-
- /**
- * @param textFlags Flags defined in <code>JavaElementLabels</code>.
- * @param imageFlags Flags defined in <code>JavaElementImageProvider</code>.
- */
- public CElementLabelProvider(int textFlags, int imageFlags, IAdornmentProvider[] adormentProviders) {
- fImageRegistry= CUIPlugin.getDefault().getImageRegistry();
- fWorkbenchLabelProvider= new WorkbenchLabelProvider();
-
- fImageLabelProvider= new CElementImageProvider();
- fAdornmentProviders= adormentProviders;
-
- fImageFlags= imageFlags;
- fTextFlags= textFlags;
- }
-
- /**
- * @see ILabelProvider#getText
- */
- public String getText(Object element) {
- if (element instanceof ICElement) {
- ICElement celem= (ICElement)element;
-
- String name= celem.getElementName();
- if (celem.getElementType() == ICElement.C_FUNCTION) {
- name += "()";
- } else if(celem.getElementType() == ICElement.C_FUNCTION_DECLARATION) {
- name += "();";
- }
- if (celem instanceof IBinary) {
- IBinary bin = (IBinary)celem;
- name += " - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]";
- }
- return name;
- }
- return fWorkbenchLabelProvider.getText(element);
- }
-
- /**
- * @see ILabelProvider#getImage
- */
- public Image getImage(Object element) {
- int imageFlags= getImageFlags();
- if (fAdornmentProviders != null) {
- for (int i= 0; i < fAdornmentProviders.length; i++) {
- imageFlags |= fAdornmentProviders[i].computeAdornmentFlags(element);
- }
- }
-
- if(element instanceof ICElement) {
- Image result= fImageLabelProvider.getImageLabel(element, imageFlags);
- if (result != null) {
- return result;
- }
- }
- if(element instanceof ICFile) {
- //element = ((ICFile)element).getFile();
- }
- return fWorkbenchLabelProvider.getImage(element);
-
- }
-
- /**
- * @see IBaseLabelProvider#dispose()
- */
- public void dispose() {
- if (fAdornmentProviders != null) {
- for (int i= 0; i < fAdornmentProviders.length; i++) {
- fAdornmentProviders[i].dispose();
- }
- }
- if (fWorkbenchLabelProvider != null) {
- fWorkbenchLabelProvider.dispose();
- fWorkbenchLabelProvider= null;
- }
- fImageRegistry= null;
- if(fImageLabelProvider != null) {
- fImageLabelProvider.dispose();
- }
- }
-
- /**
- * Sets the textFlags.
- * @param textFlags The textFlags to set
- */
- public void setTextFlags(int textFlags) {
- fTextFlags= textFlags;
- }
-
- /**
- * Sets the imageFlags
- * @param imageFlags The imageFlags to set
- */
- public void setImageFlags(int imageFlags) {
- fImageFlags= imageFlags;
- }
-
- /**
- * Gets the image flags.
- * Can be overwriten by super classes.
- * @return Returns a int
- */
- public int getImageFlags() {
- return fImageFlags;
- }
-
- /**
- * Gets the text flags. Can be overwriten by super classes.
- * @return Returns a int
- */
- public int getTextFlags() {
- return fTextFlags;
- }
-
- public static IAdornmentProvider[] getAdornmentProviders(boolean errortick, IAdornmentProvider extra) {
- if (errortick) {
- if (extra == null) {
- return new IAdornmentProvider[] { new ErrorTickAdornmentProvider() };
- } else {
- return new IAdornmentProvider[] { new ErrorTickAdornmentProvider(), extra };
- }
- }
- if (extra != null) {
- return new IAdornmentProvider[] { extra };
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java
index 30f0994840..804d4f2389 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CFileElementWorkingCopy.java
@@ -18,7 +18,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.internal.core.model.TranslationUnit;
-import org.eclipse.cdt.internal.core.DocumentInputStream;
public class CFileElementWorkingCopy extends TranslationUnit {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
index 788ff6f0f9..54f588df24 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
@@ -4,26 +4,34 @@ package org.eclipse.cdt.internal.ui;
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
-
+
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.ui.CElementLabelProvider;
/**
* An imlementation of the IWorkbenchAdapter for CElements.
*/
public class CWorkbenchAdapter implements IWorkbenchAdapter {
-
- private static final Object[] fgEmptyArray= new Object[0];
+
+ private static final Object[] fgEmptyArray = new Object[0];
+ private CElementImageProvider fImageProvider;
+ private CElementLabelProvider fLabelProvider;
+
+ public CWorkbenchAdapter() {
+ fImageProvider = new CElementImageProvider();
+ fLabelProvider = new CElementLabelProvider();
+ }
/**
* @see IWorkbenchAdapter#getChildren
- */
+ */
public Object[] getChildren(Object o) {
if (o instanceof IParent) {
- Object[] members= ((IParent)o).getChildren();
+ Object[] members = ((IParent) o).getChildren();
if (members != null) {
return members;
}
@@ -34,7 +42,12 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter {
/**
* @see IWorkbenchAdapter#getImageDescriptor
*/
- public ImageDescriptor getImageDescriptor(Object object) {
+ public ImageDescriptor getImageDescriptor(Object element) {
+ if (element instanceof ICElement) {
+ return fImageProvider.getCImageDescriptor(
+ (ICElement) element,
+ CElementImageProvider.OVERLAY_ICONS | CElementImageProvider.SMALL_ICONS);
+ }
return null;
}
@@ -43,7 +56,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter {
*/
public String getLabel(Object o) {
if (o instanceof ICElement) {
- return ((ICElement)o).getElementName();
+ return fLabelProvider.getText((ICElement) o);
}
return null;
}
@@ -53,7 +66,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter {
*/
public Object getParent(Object o) {
if (o instanceof ICElement) {
- return ((ICElement)o).getParent();
+ return ((ICElement) o).getParent();
}
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java
index 6d8fba889d..2331263901 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java
@@ -279,7 +279,7 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
IProject convertSelectionToProject(ISelection selection) {
IProject project = null;
- if (selection == null) {
+ if (selection == null || !(selection instanceof IStructuredSelection)) {
return project;
}
try {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
index 888d041178..eb8c529697 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
@@ -27,10 +27,10 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.core.DocumentInputStream;
import org.eclipse.cdt.internal.parser.CStructurizer;
import org.eclipse.cdt.internal.parser.IStructurizerCallback;
import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.DocumentInputStream;
import org.eclipse.cdt.ui.CUIPlugin;
/**
*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
index 773802bc1b..346376d422 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
@@ -18,7 +18,6 @@ import org.eclipse.cdt.core.model.ICFile;
import org.eclipse.cdt.core.model.ICRoot;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.resources.MakeUtil;
-import org.eclipse.cdt.internal.ui.CContentProvider;
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
@@ -28,6 +27,7 @@ import org.eclipse.cdt.internal.ui.makeview.MakeTargetAction;
import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
+import org.eclipse.cdt.ui.CElementContentProvider;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -40,6 +40,9 @@ import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
@@ -85,6 +88,8 @@ import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.AddBookmarkAction;
@@ -147,6 +152,9 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
ForwardAction forwardAction;
GoIntoAction goIntoAction;
UpAction upAction;
+ NewWorkingSetFilterAction wsFilterAction;
+ AdjustWorkingSetFilterAction wsClearFilterAction;
+
FrameList frameList;
CViewFrameSource frameSource;
@@ -156,6 +164,8 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
CLibFilter clibFilter = new CLibFilter ();
ShowLibrariesAction clibFilterAction;
+ CWorkingSetFilter workingSetFilter = new CWorkingSetFilter ();
+ ActionContributionItem adjustWorkingSetContributions [] = new ActionContributionItem[5];
// Persistance tags.
static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
@@ -167,6 +177,11 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
static final String TAG_FILTERS = "filters"; //$NON-NLS-1$
static final String TAG_FILTER = "filter"; //$NON-NLS-1$
static final String TAG_SHOWLIBRARIES = "showLibraries"; //$NON-NLS-1$
+ static final String TAG_WORKINGSET = "workingSet"; //$NON-NLS-1$
+
+ //Menu tags
+ final String WORKING_GROUP_MARKER = "workingSetGroup";
+ final String WORKING_GROUP_MARKER_END = "end-workingSetGroup";
private IPartListener partListener = new IPartListener() {
public void partActivated(IWorkbenchPart part) {
@@ -179,8 +194,46 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
public void partDeactivated(IWorkbenchPart part) {}
public void partOpened(IWorkbenchPart part) {}
};
+
+ private IPropertyChangeListener workingSetListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent ev) {
+ String prop = ev.getProperty();
+ if(prop == null) {
+ return;
+ }
-
+ if(prop.equals(CWorkingSetFilter.WORKING_SET_ACTIVE_CHANGED)) {
+ updateWorkingSetMenu();
+ viewer.getControl().setRedraw(false);
+ viewer.refresh();
+ viewer.getControl().setRedraw(true);
+ } else if(prop.equals(IWorkingSetManager.CHANGE_WORKING_SET_ADD)) {
+ updateWorkingSetMenu();
+ } else if(prop.equals(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE)) {
+ updateWorkingSetMenu();
+ } else if(prop.equals(IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE)){
+ if(ev.getOldValue() instanceof IWorkingSet) {
+ String name = ((IWorkingSet)(ev.getOldValue())).getName();
+ String wsName = workingSetFilter.getWorkingSetName();
+ if(wsName != null && name.equals(wsName)) {
+ viewer.getControl().setRedraw(false);
+ viewer.refresh();
+ viewer.getControl().setRedraw(true);
+ }
+ }
+ } else if(prop.equals(IWorkingSetManager.CHANGE_WORKING_SET_REMOVE)) {
+ if(ev.getOldValue() instanceof IWorkingSet) {
+ String name = ((IWorkingSet)(ev.getOldValue())).getName();
+ String wsName = workingSetFilter.getWorkingSetName();
+ if(wsName != null && name.equals(wsName)) {
+ workingSetFilter.setWorkingSetName(null);
+ }
+ }
+ updateWorkingSetMenu();
+ }
+ }
+ };
+
public CView() {
super();
}
@@ -368,19 +421,24 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
viewer= new ProblemTreeViewer (parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
boolean showCUChildren= CPluginPreferencePage.showCompilationUnitChildren();
viewer.setUseHashlookup (true);
- viewer.setContentProvider(new CContentProvider (showCUChildren, true));
+ viewer.setContentProvider(new CElementContentProvider (showCUChildren, true));
viewer.setLabelProvider (new DecoratingLabelProvider(
new StandardCElementLabelProvider (),
PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
CUIPlugin.getDefault().getProblemMarkerManager().addListener(viewer);
CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+ IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
+ workingSetFilter.setWorkingSetManager(wsmanager);
+
+
// FIXME: Add Drag and Drop support.
initFrameList();
initRefreshKey();
updateTitle();
initDragAndDrop();
viewer.addFilter(patternFilter);
+ viewer.addFilter(workingSetFilter);
//viewer.addFilter(clibFilter);
viewer.setSorter(new CViewSorter ());
// FIXME: Add different Sorting.
@@ -402,6 +460,10 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
// Make the Actions for the Context Menu
makeActions();
+ //Add the property changes after all of the UI work has been done.
+ wsmanager.addPropertyChangeListener(workingSetListener);
+ workingSetFilter.addChangeListener(workingSetListener);
+
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
handleDoubleClick(event);
@@ -447,6 +509,10 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
IWorkspace workspace = CUIPlugin.getWorkspace();
workspace.removeResourceChangeListener(closeProjectAction);
workspace.removeResourceChangeListener(openProjectAction);
+
+ IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
+ wsmanager.removePropertyChangeListener(workingSetListener);
+
super.dispose();
}
@@ -478,14 +544,21 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
return clibFilter;
}
- /**
- * Returns the pattern filter for this view.
- * @return the pattern filter
- */
+ /**
+ * Returns the pattern filter for this view.
+ * @return the pattern filter
+ */
CPatternFilter getPatternFilter() {
return patternFilter;
}
-
+
+ /**
+ * Returns the working set filter for this view.
+ * @return the working set filter
+ */
+ CWorkingSetFilter getWorkingSetFilter() {
+ return workingSetFilter;
+ }
TreeViewer getViewer () {
return viewer;
@@ -519,10 +592,12 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
//sortByNameAction = new SortViewAction(this, false);
//sortByTypeAction = new SortViewAction(this, true);
-
- patternFilterAction = new FilterSelectionAction(shell, this, "Filters..");
+ patternFilterAction = new FilterSelectionAction(shell, this, "Filters...");
clibFilterAction = new ShowLibrariesAction(shell, this, "Show Referenced Libs");
+ wsFilterAction = new NewWorkingSetFilterAction(getViewSite().getShell(), this, "Select Working Set...");
+ wsClearFilterAction = new AdjustWorkingSetFilterAction("Deselect Working Set", null, workingSetFilter);
+
goIntoAction = new GoIntoAction(frameList);
backAction = new BackAction(frameList);
forwardAction = new ForwardAction(frameList);
@@ -583,8 +658,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
propertyDialogAction.selectionChanged(selection);
renameResourceAction.selectionChanged(selection);
//sortByTypeAction.selectionChanged(selection);
- //sortByNameAction.selectionChanged(selection);
- updateGlobalActions(selection);
+ //sortByNameAction.selectionChanged(selection);
}
/**
@@ -957,9 +1031,63 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
actionBars.updateActionBars();
IMenuManager menu = actionBars.getMenuManager();
+ menu.add(wsFilterAction);
+ menu.add(wsClearFilterAction);
+
+ menu.add(new Separator());
+ menu.add(new GroupMarker(WORKING_GROUP_MARKER));
+ menu.add(new GroupMarker(WORKING_GROUP_MARKER_END));
+ menu.add(new Separator());
+
+ updateWorkingSetMenu();
+
//menu.add (clibFilterAction);
menu.add (patternFilterAction);
}
+
+ void updateWorkingSetMenu() {
+ IMenuManager menu = getViewSite().getActionBars().getMenuManager();
+
+ //Remove the previous entries
+ for(int i = 0; i < adjustWorkingSetContributions.length; i++) {
+ if(adjustWorkingSetContributions[i] != null) {
+ menu.remove(adjustWorkingSetContributions[i]);
+ }
+ }
+
+ //Find out what we are currently using
+ String currentWorkingSetName = workingSetFilter.getWorkingSetName();
+
+ //If we have no working set, then we can't disable it
+ if(wsClearFilterAction != null) {
+ wsClearFilterAction.setEnabled((currentWorkingSetName != null));
+ }
+
+ IWorkingSetManager manager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
+ IWorkingSet recentsets [] = manager.getWorkingSets();
+ for(int i = 0; i < adjustWorkingSetContributions.length; i++) {
+ if(i < recentsets.length) {
+ Action action = new AdjustWorkingSetFilterAction(recentsets[i].getName(),
+ recentsets[i].getName(),
+ workingSetFilter);
+ adjustWorkingSetContributions[i] = new ActionContributionItem(action);
+ if(currentWorkingSetName != null &&
+ currentWorkingSetName.equals(recentsets[i].getName())) {
+ adjustWorkingSetContributions[i].getAction().setChecked(true);
+ }
+ } else {
+ adjustWorkingSetContributions[i] = null;
+ }
+ }
+
+ //Put the new entries in
+ for(int i = 0; i < adjustWorkingSetContributions.length; i++) {
+ if(adjustWorkingSetContributions[i] != null) {
+ menu.appendToGroup(WORKING_GROUP_MARKER, adjustWorkingSetContributions[i]);
+ }
+ }
+ }
+
/**
* Sets the decorator for the package explorer.
@@ -983,7 +1111,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
if (event.getProperty() == CPluginPreferencePage.PREF_SHOW_CU_CHILDREN) {
boolean showCUChildren= CPluginPreferencePage.showCompilationUnitChildren();
- ((CContentProvider)viewer.getContentProvider()).setProvideMembers(showCUChildren);
+ ((CElementContentProvider)viewer.getContentProvider()).setProvideMembers(showCUChildren);
refreshViewer= true;
}
@@ -1060,6 +1188,15 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
}
else
initFilterFromPreferences();
+
+ //restore working set
+ String wsname = memento.getString(TAG_WORKINGSET);
+ if(wsname != null && workingSetFilter != null) {
+ IWorkingSet set = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager().getWorkingSet(wsname);
+ if(set != null) {
+ workingSetFilter.setWorkingSetName(wsname);
+ }
+ }
}
void restoreState(IMemento memento) {
@@ -1179,11 +1316,17 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
child.putString(TAG_ELEMENT,filters[i]);
}
}
+
//save library filter
boolean showLibraries= getLibraryFilter().getShowLibraries();
String show= "true"; //$NON-NLS-1$
if (!showLibraries)
show= "false"; //$NON-NLS-1$
memento.putString(TAG_SHOWLIBRARIES, show);
+
+ String wsname = workingSetFilter.getWorkingSetName();
+ if(wsname != null) {
+ memento.putString(TAG_WORKINGSET, wsname);
+ }
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java
index 7a14c3b37c..51f77ec9e0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/FilterSelectionAction.java
@@ -53,9 +53,10 @@ class FilterSelectionAction extends SelectionProviderAction {
cview.getViewer(),
contentProvider,
new LabelProvider(),
- "Select Filter"); //$NON-NLS-1$
+ "Select the filters to apply (matching files will be hidden):");
dialog.setInitialSelections(contentProvider.getInitialSelections());
+ dialog.setTitle("C/C++ File Filters");
dialog.open();
if (dialog.getReturnCode() == Window.OK) {
Object[] results= dialog.getResult();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
index 47c80da21a..006da940cb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
@@ -41,8 +41,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy;
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
-import org.eclipse.cdt.internal.ui.CContentProvider;
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
+import org.eclipse.cdt.ui.CElementContentProvider;
import org.eclipse.cdt.ui.CUIPlugin;
public class CContentOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener {
@@ -132,7 +132,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
treeViewer.addSelectionChangedListener(this);
//treeViewer.setContentProvider(new CModelContentProvider());
- treeViewer.setContentProvider(new CContentProvider(true, true));
+ treeViewer.setContentProvider(new CElementContentProvider(true, true));
treeViewer.setLabelProvider(new StandardCElementLabelProvider());
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
treeViewer.addSelectionChangedListener(this);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
index d9487f4057..8c23209880 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
@@ -1561,7 +1561,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener {
asv.hideOverviewRuler();
}
- private boolean isOverviewRulerVisible() {
+ protected boolean isOverviewRulerVisible() {
IPreferenceStore store= getPreferenceStore();
return store.getBoolean(OVERVIEW_RULER);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
index 5e33667f8f..3221baa8c9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
@@ -105,8 +105,8 @@ public class CEditorActionContributor extends TextEditorActionContributor {
CPluginImages.setImageDescriptors(fShiftLeft, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_LEFT);
fContentAssist = new RetargetTextEditorAction(bundle, "ContentAssistProposal.");
- fAddInclude = new RetargetTextEditorAction(bundle, "AddIncludeOnSelection");
- fOpenOnSelection = new RetargetTextEditorAction(bundle, "OpenOnSelection");
+ fAddInclude = new RetargetTextEditorAction(bundle, "AddIncludeOnSelection.");
+ fOpenOnSelection = new RetargetTextEditorAction(bundle, "OpenOnSelection.");
//fToggleTextHover= new ToggleTextHoverAction();
fPreviousError= new GotoErrorAction("Editor.PreviousError.", false); //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
index 0154837046..55ee1a7614 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
@@ -10,7 +10,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModelListener;
import org.eclipse.jface.util.Assert;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
index fff2780f0c..cd475620ea 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
@@ -8,14 +8,18 @@ package org.eclipse.cdt.internal.ui.editor;
import java.util.ArrayList;
import java.util.List;
-
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
@@ -23,23 +27,11 @@ import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
-
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.builder.ICBuilder;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-
-
public class OpenIncludeAction extends Action {
@@ -87,29 +79,30 @@ public class OpenIncludeAction extends Action {
EditorUtility.openInEditor(fileToOpen);
} else { // Try to get via the include path.
- ICBuilder[] builders = CCorePlugin.getDefault().getBuilders(res.getProject());
-
- IPath includePath = null;
- for( int j = 0; includePath == null && j < builders.length; j++ ) {
- IPath[] paths = builders[j].getIncludePaths();
-
- for (int i = 0; i < paths.length; i++) {
- if (res != null) {
- // We've already scan the project.
- if (paths[i].isPrefixOf(res.getProject().getLocation()))
- continue;
- }
- IPath path = paths[i].append(include.getElementName());
- if (path.toFile().exists()) {
- includePath = path;
- break;
- }
- }
- }
-
- if (includePath != null) {
- EditorUtility.openInEditor(includePath);
- }
+// This code is for getting the include paths from the builder.
+// ICBuilder[] builders = CCorePlugin.getDefault().getBuilders(res.getProject());
+//
+// IPath includePath = null;
+// for( int j = 0; includePath == null && j < builders.length; j++ ) {
+// IPath[] paths = builders[j].getIncludePaths();
+//
+// for (int i = 0; i < paths.length; i++) {
+// if (res != null) {
+// // We've already scan the project.
+// if (paths[i].isPrefixOf(res.getProject().getLocation()))
+// continue;
+// }
+// IPath path = paths[i].append(include.getElementName());
+// if (path.toFile().exists()) {
+// includePath = path;
+// break;
+// }
+// }
+// }
+//
+// if (includePath != null) {
+// EditorUtility.openInEditor(includePath);
+// }
}
} catch (CModelException e) {
CUIPlugin.getDefault().log(e.getStatus());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java
index 844e4c0400..c50e4481b6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TemplatePreferencePage.java
@@ -357,7 +357,7 @@ public class TemplatePreferencePage extends PreferencePage implements IWorkbench
Template template= new Template();
ContextTypeRegistry registry=ContextTypeRegistry.getInstance();
- ContextType type= registry.getContextType("java");
+ ContextType type= registry.getContextType("C");
String contextTypeName;
if (type != null)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
index 1ea8d5578c..a4e3963d6a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompletionProcessor.java
@@ -5,24 +5,23 @@ package org.eclipse.cdt.internal.ui.text;
* All Rights Reserved.
*/
+import java.util.ArrayList;
+import java.util.Arrays;
+
import org.eclipse.cdt.core.index.ITagEntry;
import org.eclipse.cdt.core.index.IndexModel;
import org.eclipse.cdt.core.index.TagFlags;
+import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.internal.corext.template.ContextType;
import org.eclipse.cdt.internal.corext.template.ContextTypeRegistry;
import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
-import org.eclipse.cdt.internal.ui.CElementLabelProvider;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.template.TemplateEngine;
+import org.eclipse.cdt.ui.CElementLabelProvider;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IFunctionSummary;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
@@ -33,7 +32,8 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
@@ -42,33 +42,67 @@ import org.eclipse.ui.IFileEditorInput;
* C completion processor.
*/
public class CCompletionProcessor implements IContentAssistProcessor {
-
+
private CEditor fEditor;
private char[] fProposalAutoActivationSet;
private CCompletionProposalComparator fComparator;
- private TemplateEngine fTemplateEngine;
-
+ private TemplateEngine[] fTemplateEngine;
+
private boolean fRestrictToMatchingCase;
private boolean fAllowAddIncludes;
-
+
private CElementLabelProvider fElementLabelProvider;
//private ImageRegistry fImageRegistry;
-
-
+
public CCompletionProcessor(IEditorPart editor) {
- fEditor= (CEditor)editor;
- ContextType contextType= ContextTypeRegistry.getInstance().getContextType("C"); //$NON-NLS-1$
- if (contextType != null)
- fTemplateEngine= new TemplateEngine(contextType);
- fRestrictToMatchingCase= false;
- fAllowAddIncludes= true;
-
- fComparator= new CCompletionProposalComparator();
-
+ fEditor = (CEditor) editor;
+
+ //Determine if this is a C or a C++ file for the context completion + //This is _totally_ ugly and likely belongs in the main editor class.
+ String contextNames[] = new String[2];
+ ArrayList templateList = new ArrayList(2);
+ String filename = null;
+ if (fEditor != null && fEditor.getEditorInput() != null) {
+ filename = fEditor.getEditorInput().getName();
+ }
+ if (filename == null) {
+ contextNames[0] = "C"; //$NON-NLS-1$
+ contextNames[1] = "C++"; //$NON-NLS-1$
+ } else if (filename.endsWith(".c")) { //Straight C files are always C
+ contextNames[0] = "C"; //$NON-NLS-1$
+ } else if (
+ filename.endsWith(".cpp")
+ || filename.endsWith(".cc")
+ || filename.endsWith(".cxx")
+ || filename.endsWith(".C")
+ || filename.endsWith(".hxx")) {
+ contextNames[0] = "C++"; //$NON-NLS-1$
+ contextNames[1] = "C"; //$NON-NLS-1$
+ } else { //Defer to the nature of the project
+ IFile file = fEditor.getInputFile();
+ if (file != null && CoreModel.getDefault().hasCCNature(file.getProject())) {
+ contextNames[0] = "C++"; //$NON-NLS-1$
+ contextNames[1] = "C"; //$NON-NLS-1$
+ } else {
+ contextNames[0] = "C"; //$NON-NLS-1$
+ }
+ }
+ ContextType contextType;
+ for (int i = 0; i < contextNames.length; i++) {
+ contextType = ContextTypeRegistry.getInstance().getContextType(contextNames[i]);
+ if (contextType != null) {
+ templateList.add(new TemplateEngine(contextType));
+ }
+ }
+ fTemplateEngine = (TemplateEngine[]) templateList.toArray(new TemplateEngine[templateList.size()]);
+ fRestrictToMatchingCase = false;
+ fAllowAddIncludes = true;
+
+ fComparator = new CCompletionProposalComparator();
+
fElementLabelProvider = new CElementLabelProvider();
//fImageRegistry= CUIPlugin.getDefault().getImageRegistry();
}
-
+
/**
* Tells this processor to order the proposals alphabetically.
*
@@ -77,7 +111,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
public void orderProposalsAlphabetically(boolean order) {
fComparator.setOrderAlphabetically(order);
}
-
+
/**
* @see IContentAssistProcessor#getErrorMessage()
*/
@@ -105,7 +139,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
public char[] getCompletionProposalAutoActivationCharacters() {
return fProposalAutoActivationSet;
}
-
+
/**
* Sets this processor's set of characters triggering the activation of the
* completion proposal computation.
@@ -113,7 +147,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
* @param activationSet the activation set
*/
public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
- fProposalAutoActivationSet= activationSet;
+ fProposalAutoActivationSet = activationSet;
}
/**
@@ -122,7 +156,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
return null;
}
-
+
/**
* Tells this processor to restrict is proposals to those
* starting with matching cases.
@@ -132,7 +166,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
public void restrictProposalsToMatchingCases(boolean restrict) {
// not yet supported
}
-
+
/**
* Tells this processor to add include statement for proposals that have
* a fully qualified type name
@@ -140,7 +174,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
* @param restrict <code>true</code> if import can be added
*/
public void allowAddingIncludes(boolean allowAddingIncludes) {
- fAllowAddIncludes= allowAddingIncludes;
+ fAllowAddIncludes = allowAddingIncludes;
}
/**
@@ -148,51 +182,54 @@ public class CCompletionProcessor implements IContentAssistProcessor {
*/
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
//IDocument unit= fManager.getWorkingCopy(fEditor.getEditorInput());
- IDocument document= viewer.getDocument();
+ IDocument document = viewer.getDocument();
ICCompletionProposal[] results = null;
try {
if (document != null) {
-
- int offset= documentOffset;
- int length= 0;
-
- Point selection= viewer.getSelectedRange();
+
+ int offset = documentOffset;
+ int length = 0;
+
+ Point selection = viewer.getSelectedRange();
if (selection.y > 0) {
- offset= selection.x;
- length= selection.y;
+ offset = selection.x;
+ length = selection.y;
}
-
+
//CCompletionEvaluator evaluator= new CCompletionEvaluator(document, offset, length);
//evaluator.restrictProposalsToMatchingCases(fRestrictToMatchingCase);
- results= evalProposals(document, offset, length);
+ results = evalProposals(document, offset, length);
}
} catch (Exception e) {
CUIPlugin.getDefault().log(e);
}
-
- if(results == null)
+
+ if (results == null)
results = new ICCompletionProposal[0];
- if (fTemplateEngine != null) {
+ for (int i = 0; i < fTemplateEngine.length; i++) {
+ if (fTemplateEngine[i] == null) {
+ continue;
+ }
try {
- fTemplateEngine.reset();
- fTemplateEngine.complete(viewer, documentOffset, null);
+ fTemplateEngine[i].reset();
+ fTemplateEngine[i].complete(viewer, documentOffset, null);
} catch (Exception x) {
System.out.println("Template Exception");
CUIPlugin.getDefault().log(x);
- }
-
- ICCompletionProposal[] templateResults= fTemplateEngine.getResults();
+ }
+
+ ICCompletionProposal[] templateResults = fTemplateEngine[i].getResults();
if (results.length == 0) {
- results= templateResults;
+ results = templateResults;
} else {
// concatenate arrays
- ICCompletionProposal[] total= new ICCompletionProposal[results.length + templateResults.length];
+ ICCompletionProposal[] total = new ICCompletionProposal[results.length + templateResults.length];
System.arraycopy(templateResults, 0, total, 0, templateResults.length);
System.arraycopy(results, 0, total, templateResults.length, results.length);
- results= total;
+ results = total;
}
}
@@ -201,7 +238,8 @@ public class CCompletionProcessor implements IContentAssistProcessor {
* applies to all proposals and not just those of the compilation unit.
*/
order(results);
- if((results.length == 1) && (CUIPlugin.getDefault().getPreferenceStore().getBoolean(ContentAssistPreference.AUTOINSERT))) {
+ if ((results.length == 1)
+ && (CUIPlugin.getDefault().getPreferenceStore().getBoolean(ContentAssistPreference.AUTOINSERT))) {
results[0].apply(document);
// Trick the content assistant into thinking we have no proposals
return new ICCompletionProposal[0];
@@ -209,61 +247,56 @@ public class CCompletionProcessor implements IContentAssistProcessor {
return results;
}
}
-
+
/**
* Order the given proposals.
*/
private ICCompletionProposal[] order(ICCompletionProposal[] proposals) {
Arrays.sort(proposals, fComparator);
- return proposals;
+ return proposals;
}
-
+
private void addProjectCompletions(IProject project, IRegion region, String frag, ArrayList completions) {
IndexModel model = IndexModel.getDefault();
-
- ITagEntry[] tags= model.query(project, frag+"*", false, false);
- if(tags != null && tags.length > 0) {
+
+ ITagEntry[] tags = model.query(project, frag + "*", false, false);
+ if (tags != null && tags.length > 0) {
// We have some matches!
- for(int i = 0; i < tags.length; i++) {
+ for (int i = 0; i < tags.length; i++) {
String fname = tags[i].getTagName();
int kind = tags[i].getKind();
- if(kind == TagFlags.T_FUNCTION || kind == TagFlags.T_PROTOTYPE) {
+ if (kind == TagFlags.T_FUNCTION || kind == TagFlags.T_PROTOTYPE) {
fname = fname + "()";
}
String proto = fname + " - " + tags[i].getPattern();
//System.out.println("tagmatch " + fname + " proto " + proto + " type" + tags[i].getKind());
- if(tags[i].getKind() != TagFlags.T_MEMBER) {
- completions.add(
- new CCompletionProposal(
- fname,
- region.getOffset(),
- region.getLength(),
- //fname.length() + 1,
- getTagImage(kind),
- proto.equals("") ? (fname + "()") : proto,
- //null,
- //null));
- 3));
+ if (tags[i].getKind() != TagFlags.T_MEMBER) {
+ completions.add(new CCompletionProposal(fname, region.getOffset(), region.getLength(),
+ //fname.length() + 1,
+ getTagImage(kind), proto.equals("") ? (fname + "()") : proto,
+ //null,
+ //null));
+ 3));
}
}
}
}
-
+
/**
* Evaluate the actual proposals for C
*/
private ICCompletionProposal[] evalProposals(IDocument document, int pos, int length) {
IRegion region;
String frag = "";
-
+
// Move back the pos by one the position is 0-based
if (pos > 0) {
pos--;
}
-
+
// First, check if we're on a space or trying to open a struct/union
if (pos > 1) {
try {
@@ -311,27 +344,26 @@ public class CCompletionProcessor implements IContentAssistProcessor {
// Based on the frag name, build a list of completion proposals
// We look in two places: the content outline and the libs
-
ArrayList completions = new ArrayList();
// Look in index manager
IProject project = null;
IEditorInput input = fEditor.getEditorInput();
- if(input instanceof IFileEditorInput) {
- project = ((IFileEditorInput)input).getFile().getProject();
+ if (input instanceof IFileEditorInput) {
+ project = ((IFileEditorInput) input).getFile().getProject();
// Bail out quickly, if the project was deleted.
if (!project.exists()) {
project = null;
}
}
- if(project != null) {
+ if (project != null) {
addProjectCompletions(project, region, frag, completions);
// Now query referenced projects
IProject referenced[];
try {
referenced = project.getReferencedProjects();
- if(referenced.length > 0) {
+ if (referenced.length > 0) {
for (int i = 0; i < referenced.length; i++) {
addProjectCompletions(referenced[i], region, frag, completions);
}
@@ -340,53 +372,46 @@ public class CCompletionProcessor implements IContentAssistProcessor {
}
}
-
-
+
IFunctionSummary[] summary;
-
+
//UserHelpFunctionInfo inf = plugin.getFunctionInfo();
summary = CCompletionContributorManager.getDefault().getMatchingFunctions(frag);
- if(summary != null) {
- for(int i = 0; i < summary.length; i++) {
+ if (summary != null) {
+ for (int i = 0; i < summary.length; i++) {
String fname = summary[i].getName();
String proto = summary[i].getPrototype();
- completions.add(
- new CCompletionProposal(
- fname + "()",
- region.getOffset(),
- region.getLength(),
- //fname.length() + 1,
- CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION),
- proto.equals("") ? (fname + "()") : proto,
- //null,
- //null));
- 2));
+ completions.add(new CCompletionProposal(fname + "()", region.getOffset(), region.getLength(),
+ //fname.length() + 1,
+ CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION), proto.equals("") ? (fname + "()") : proto,
+ //null,
+ //null));
+ 2));
}
}
return (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]);
}
-
+
private Image getTagImage(int kind) {
switch (kind) {
- case TagFlags.T_PROTOTYPE:
+ case TagFlags.T_PROTOTYPE :
return CPluginImages.get(CPluginImages.IMG_OBJS_DECLARATION);
- case TagFlags.T_CLASS:
+ case TagFlags.T_CLASS :
return CPluginImages.get(CPluginImages.IMG_OBJS_CLASS);
- case TagFlags.T_ENUM:
- case TagFlags.T_VARIABLE:
- case TagFlags.T_MEMBER:
+ case TagFlags.T_ENUM :
+ case TagFlags.T_VARIABLE :
+ case TagFlags.T_MEMBER :
return CPluginImages.get(CPluginImages.IMG_OBJS_FIELD);
- case TagFlags.T_FUNCTION:
+ case TagFlags.T_FUNCTION :
return CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION);
- case TagFlags.T_STRUCT:
+ case TagFlags.T_STRUCT :
return CPluginImages.get(CPluginImages.IMG_OBJS_STRUCT);
- case TagFlags.T_UNION:
+ case TagFlags.T_UNION :
return CPluginImages.get(CPluginImages.IMG_OBJS_UNION);
- case TagFlags.T_MACRO:
+ case TagFlags.T_MACRO :
return CPluginImages.get(CPluginImages.IMG_OBJS_MACRO);
}
return CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION);
}
-
-}
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedDamagerRepairer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedDamagerRepairer.java
deleted file mode 100644
index 34b7e21fb0..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedDamagerRepairer.java
+++ /dev/null
@@ -1,210 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.eclipse2;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.custom.StyleRange;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.presentation.IPresentationDamager;
-import org.eclipse.jface.text.presentation.IPresentationRepairer;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.util.Assert;
-
-
-/**
- * A standard implementation of a syntax driven presentation damager
- * and presentation repairer. It uses a rule based scanner to scan
- * the document and to determine its damage and new text presentation.
- * The tokens returned by the rules the scanner is configured with
- * are supposed to return text attributes as their data.
- *
- * @see IRule
- * @see RuleBasedScanner
- */
-public class CRuleBasedDamagerRepairer implements IPresentationDamager, IPresentationRepairer {
-
- /** The document this object works on */
- protected IDocument fDocument;
- /** The scanner it uses */
- protected RuleBasedScanner fScanner;
- /** The default text attribute if non is returned as data by the current token */
- protected TextAttribute fDefaultTextAttribute;
-
- /**
- * Creates a damager/repairer that uses the given scanner and returns the given default
- * text attribute if the current token does not carry a text attribute.
- *
- * @param scanner the rule based scanner to be used
- * @param defaultTextAttribute the text attribute to be returned if non is specified by the current token,
- * may not be <code>null</code>
- *
- * @deprecated use RuleBasedDamagerRepairer(RuleBasedScanner) instead
- */
- public CRuleBasedDamagerRepairer(RuleBasedScanner scanner, TextAttribute defaultTextAttribute) {
-
- Assert.isNotNull(defaultTextAttribute);
-
- fScanner= scanner;
- fDefaultTextAttribute= defaultTextAttribute;
- }
-
- /**
- * Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
- * and is assumed to return only token that carry text attributes.
- *
- * @param scanner the rule based scanner to be used, may not be <code>null</code>
- */
- public CRuleBasedDamagerRepairer(RuleBasedScanner scanner) {
-
- Assert.isNotNull(scanner);
-
- fScanner= scanner;
- }
-
- /*
- * @see IPresentationDamager#setDocument
- * @see IPresentationRepairer#setDocument
- */
- public void setDocument(IDocument document) {
- fDocument= document;
- }
-
-
- //---- IPresentationDamager
-
- /**
- * Returns the end offset of the line that contains the specified offset or
- * if the offset is inside a line delimiter, the end offset of the next line.
- *
- * @param offset the offset whose line end offset must be computed
- * @return the line end offset for the given offset
- * @exception BadLocationException if offset is invalid in the current document
- */
- protected int endOfLineOf(int offset) throws BadLocationException {
-
- IRegion info= fDocument.getLineInformationOfOffset(offset);
- if (offset <= info.getOffset() + info.getLength())
- return info.getOffset() + info.getLength();
-
- int line= fDocument.getLineOfOffset(offset);
- try {
- info= fDocument.getLineInformation(line + 1);
- return info.getOffset() + info.getLength();
- } catch (BadLocationException x) {
- return fDocument.getLength();
- }
- }
-
- /*
- * @see IPresentationDamager#getDamageRegion
- */
- public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) {
-
- if (!documentPartitioningChanged) {
- try {
-
- IRegion info= fDocument.getLineInformationOfOffset(e.getOffset());
- int start= Math.max(partition.getOffset(), info.getOffset());
-
- int end= e.getOffset() + (e.getText() == null ? e.getLength() : e.getText().length());
-
- if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
- // optimize the case of the same line
- end= info.getOffset() + info.getLength();
- } else
- end= endOfLineOf(end);
-
- end= Math.min(partition.getOffset() + partition.getLength(), end);
- return new Region(start, end - start);
-
- } catch (BadLocationException x) {
- }
- }
-
- return partition;
- }
-
- //---- IPresentationRepairer
-
- /*
- * @see IPresentationRepairer#createPresentation
- */
- public void createPresentation(TextPresentation presentation, ITypedRegion region) {
-
- if (fScanner == null) {
- // will be removed if deprecated constructor will be removed
- addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextAttribute);
- return;
- }
-
- int lastStart= region.getOffset();
- int length= 0;
- IToken lastToken= Token.UNDEFINED;
- TextAttribute lastAttribute= getTokenTextAttribute(lastToken);
-
- fScanner.setRange(fDocument, lastStart, region.getLength());
-
- while (true) {
- IToken token= fScanner.nextToken();
- if (token.isEOF())
- break;
-
- TextAttribute attribute= getTokenTextAttribute(token);
- if (lastAttribute != null && lastAttribute.equals(attribute)) {
- length += fScanner.getTokenLength();
- } else {
- addRange(presentation, lastStart, length, lastAttribute);
- lastToken= token;
- lastAttribute= attribute;
- lastStart= fScanner.getTokenOffset();
- length= fScanner.getTokenLength();
- }
- }
-
- addRange(presentation, lastStart, length, lastAttribute);
- }
-
- /**
- * Returns a text attribute encoded in the given token. If the token's
- * data is not <code>null</code> and a text attribute it is assumed that
- * it is the encoded text attribute. It returns the default text attribute
- * if there is no encoded text attribute found.
- *
- * @param token the token whose text attribute is to be determined
- * @return the token's text attribute
- */
- protected TextAttribute getTokenTextAttribute(IToken token) {
- Object data= token.getData();
- if (data instanceof TextAttribute)
- return (TextAttribute) data;
- return fDefaultTextAttribute;
- }
-
- /**
- * Adds style information to the given text presentation.
- *
- * @param presentation the text presentation to be extended
- * @param offset the offset of the range to be styled
- * @param length the length of the range to be styled
- * @param attr the attribute describing the style of the range to be styled
- */
- protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) {
- if (attr != null)
- presentation.addStyleRange(new StyleRange(offset, length, attr.getForeground(), attr.getBackground(), attr.getStyle()));
- }
-}
-
-
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedPartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedPartitioner.java
deleted file mode 100644
index 4f5e767261..0000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/eclipse2/CRuleBasedPartitioner.java
+++ /dev/null
@@ -1,501 +0,0 @@
-package org.eclipse.cdt.internal.ui.text.eclipse2;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.text.TypedRegion;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.jface.util.Assert;
-
-
-
-/**
- * A standard implementation of a syntax driven document partitioner.
- * It uses a rule based scanner to scan the document and to determine
- * the document's partitioning. The tokens returned by the rules the
- * scanner is configured with are supposed to return the partition type
- * as their data. The partitoner remembers the document's partitions
- * in the document itself rather than maintaining its own data structure.
- *
- * @see IRule
- * @see RuleBasedScanner
- */
-public class CRuleBasedPartitioner implements IDocumentPartitioner, IDocumentPartitionerExtension {
-
- /** The position category this partitioner uses to store the document's partitioning information */
- public final static String CONTENT_TYPES_CATEGORY= "__content_types_category"; //$NON-NLS-1$
-
-
- /** The partitioner's scanner */
- protected RuleBasedScanner fScanner;
- /** The legal content types of this partitioner */
- protected String[] fLegalContentTypes;
- /** The partitioner's document */
- protected IDocument fDocument;
- /** The document length before a document change occured */
- protected int fPreviousDocumentLength;
- /** The position updater used to for the default updating of partitions */
- protected DefaultPositionUpdater fPositionUpdater= new DefaultPositionUpdater(CONTENT_TYPES_CATEGORY);
- /** The offset at which the first changed partition starts */
- protected int fStartOffset;
- /** The offset at which the last changed partition ends */
- protected int fEndOffset;
- /**The offset at which a partition has been deleted */
- protected int fDeleteOffset;
-
-
- /**
- * Creates a new partitioner that uses the given scanner and may return
- * partitions of the given legal content types.
- *
- * @param scanner the scanner this partitioner is supposed to use
- * @param legalContentTypes the legal content types of this partitioner
- */
- public CRuleBasedPartitioner(RuleBasedScanner scanner, String[] legalContentTypes) {
- fScanner= scanner;
- fLegalContentTypes= legalContentTypes;
- }
-
- /*
- * @see IDocumentPartitioner#connect
- */
- public void connect(IDocument document) {
- Assert.isNotNull(document);
- Assert.isTrue(!document.containsPositionCategory(CONTENT_TYPES_CATEGORY));
-
- fDocument= document;
- fDocument.addPositionCategory(CONTENT_TYPES_CATEGORY);
-
- initialize();
- }
-
- /**
- * Performs the initial partitioning of the partitioner's document.
- */
- protected void initialize() {
-
- fScanner.setRange(fDocument, 0, fDocument.getLength());
-
- try {
- IToken token= fScanner.nextToken();
- while (!token.isEOF()) {
-
- String contentType= getTokenContentType(token);
-
- if (isSupportedContentType(contentType)) {
- TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType);
- fDocument.addPosition(CONTENT_TYPES_CATEGORY, p);
- }
-
- token= fScanner.nextToken();
- }
- } catch (BadLocationException x) {
- // cannot happen as offsets come from scanner
- } catch (BadPositionCategoryException x) {
- // cannot happen if document has been connected before
- }
- }
-
- /*
- * @see IDocumentPartitioner#disconnect
- */
- public void disconnect() {
-
- Assert.isTrue(fDocument.containsPositionCategory(CONTENT_TYPES_CATEGORY));
-
- try {
- fDocument.removePositionCategory(CONTENT_TYPES_CATEGORY);
- } catch (BadPositionCategoryException x) {
- // can not happen because of Assert
- }
- }
-
- /*
- * @see IDocumentPartitioner#documentAboutToBeChanged
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
-
- Assert.isTrue(e.getDocument() == fDocument);
-
- fPreviousDocumentLength= e.getDocument().getLength();
- fStartOffset= -1;
- fEndOffset= -1;
- fDeleteOffset= -1;
- }
-
- /*
- * @see IDocumentPartitioner#documentChanged
- */
- public boolean documentChanged(DocumentEvent e) {
- IRegion region= documentChanged2(e);
- return (region != null);
- }
-
- private void rememberRegion(int offset, int length) {
- // remember start offset
- if (fStartOffset == -1)
- fStartOffset= offset;
- else if (offset < fStartOffset)
- fStartOffset= offset;
-
- // remember end offset
- int endOffset= offset + length;
- if (fEndOffset == -1)
- fEndOffset= endOffset;
- else if (endOffset > fEndOffset)
- fEndOffset= endOffset;
- }
-
- private void rememberDeletedOffset(int offset) {
- fDeleteOffset= offset;
- }
-
- private IRegion createRegion() {
- if (fDeleteOffset == -1) {
- if (fStartOffset == -1 || fEndOffset == -1)
- return null;
- return new Region(fStartOffset, fEndOffset - fStartOffset);
- } else if (fStartOffset == -1 || fEndOffset == -1) {
- return new Region(fDeleteOffset, 0);
- } else {
- int offset= Math.min(fDeleteOffset, fStartOffset);
- int endOffset= Math.max(fDeleteOffset, fEndOffset);
- return new Region(offset, endOffset - offset);
- }
- }
-
- /*
- * @see IDocumentPartitionerExtension#documentChanged2(DocumentEvent)
- */
- public IRegion documentChanged2(DocumentEvent e) {
-
- try {
-
- IDocument d= e.getDocument();
- Position[] category= d.getPositions(CONTENT_TYPES_CATEGORY);
- int first= 0;
- int reparseStart= 0;
- int originalSize= category.length;
-
- if (originalSize > 0) {
-
- /*
- * determine character position at which the scanner starts:
- * first position behind the last non-default partition the actual position is not involved with
- */
-
- first= d.computeIndexInCategory(CONTENT_TYPES_CATEGORY, e.getOffset());
-
- Position p= null;
- do {
- --first;
- if (first < 0)
- break;
-
- p= category[first];
-
- } while (p.overlapsWith(e.getOffset(), e.getLength()) ||
- (e.getOffset() == fPreviousDocumentLength &&
- (p.getOffset() + p.getLength() == fPreviousDocumentLength)));
-
- fPositionUpdater.update(e);
- for (int i= 0; i < category.length; i++) {
- p= category[i];
- if (p.isDeleted) {
- rememberDeletedOffset(e.getOffset());
- break;
- }
- }
- category= d.getPositions(CONTENT_TYPES_CATEGORY);
-
- if (first >= 0) {
- p= category[first];
- reparseStart= p.getOffset() + p.getLength();
- }
-
- ++first;
- }
-
- fScanner.setRange(d, reparseStart, d.getLength());
-
- int lastScannedPosition= reparseStart;
- IToken token= fScanner.nextToken();
-
- while (!token.isEOF()) {
-
-
- String contentType= getTokenContentType(token);
-
- if (!isSupportedContentType(contentType)) {
- token= fScanner.nextToken();
- continue;
- }
-
- int start= fScanner.getTokenOffset();
- int length= fScanner.getTokenLength();
-
- lastScannedPosition= start + length - 1;
-
- // remove all affected positions
- while (first < category.length) {
- TypedPosition p= (TypedPosition) category[first];
- if (lastScannedPosition >= p.offset + p.length ||
- (p.overlapsWith(start, length) &&
- (!d.containsPosition(CONTENT_TYPES_CATEGORY, start, length) ||
- !contentType.equals(p.getType())))) {
-
- rememberRegion(p.offset, p.length);
- d.removePosition(CONTENT_TYPES_CATEGORY, p);
- ++ first;
-
- } else
- break;
- }
-
- // if position already exists we are done
- if (d.containsPosition(CONTENT_TYPES_CATEGORY, start, length))
- return createRegion();
-
- // insert the new type position
- try {
- d.addPosition(CONTENT_TYPES_CATEGORY, new TypedPosition(start, length, contentType));
- rememberRegion(start, length);
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- token= fScanner.nextToken();
- }
-
-
- // remove all positions behind lastScannedPosition since there aren't any further types
- TypedPosition p;
- first= d.computeIndexInCategory(CONTENT_TYPES_CATEGORY, lastScannedPosition);
- while (first < category.length) {
- p= (TypedPosition) category[first++];
- d.removePosition(CONTENT_TYPES_CATEGORY, p);
- rememberRegion(p.offset, p.length);
- }
-
- } catch (BadPositionCategoryException x) {
- // should never happen on connected documents
- } catch (BadLocationException x) {
- }
-
- return createRegion();
- }
-
-
- /**
- * Returns the position in the partitoner's position category which is
- * close to the given offset. This is, the position has either an offset which
- * is the same as the given offset or an offset which is smaller than the given
- * offset. This method profits from the knowledge that a partitioning is
- * a ordered set of disjoint position.
- *
- * @param offset the offset for which to search the closest position
- * @return the closest position in the partitioner's category
- */
- protected TypedPosition findClosestPosition(int offset) {
-
- try {
-
- int index= fDocument.computeIndexInCategory(CONTENT_TYPES_CATEGORY, offset);
- Position[] category= fDocument.getPositions(CONTENT_TYPES_CATEGORY);
-
- if (category.length == 0)
- return null;
-
- if (index < category.length) {
- if (offset == category[index].offset)
- return (TypedPosition) category[index];
- }
-
- if (index > 0)
- index--;
-
- return (TypedPosition) category[index];
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return null;
- }
-
-
- /*
- * @see IDocumentPartitioner#getContentType
- */
- public String getContentType(int offset) {
-
- TypedPosition p= findClosestPosition(offset);
- if (p != null && p.includes(offset))
- return p.getType();
-
- return IDocument.DEFAULT_CONTENT_TYPE;
- }
-
- /*
- * @see IDocumentPartitioner#getPartition
- */
- public ITypedRegion getPartition(int offset) {
-
- try {
-
- Position[] category = fDocument.getPositions(CONTENT_TYPES_CATEGORY);
-
- if (category == null || category.length == 0)
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
-
- int index= fDocument.computeIndexInCategory(CONTENT_TYPES_CATEGORY, offset);
-
- if (index < category.length) {
-
- TypedPosition next= (TypedPosition) category[index];
-
- if (offset == next.offset)
- return new TypedRegion(next.getOffset(), next.getLength(), next.getType());
-
- if (index == 0)
- return new TypedRegion(0, next.offset, IDocument.DEFAULT_CONTENT_TYPE);
-
- TypedPosition previous= (TypedPosition) category[index - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, next.getOffset() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- TypedPosition previous= (TypedPosition) category[category.length - 1];
- if (previous.includes(offset))
- return new TypedRegion(previous.getOffset(), previous.getLength(), previous.getType());
-
- int endOffset= previous.getOffset() + previous.getLength();
- return new TypedRegion(endOffset, fDocument.getLength() - endOffset, IDocument.DEFAULT_CONTENT_TYPE);
-
- } catch (BadPositionCategoryException x) {
- } catch (BadLocationException x) {
- }
-
- return new TypedRegion(0, fDocument.getLength(), IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- /*
- * @see IDocumentPartitioner#computePartitioning
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
-
- List list= new ArrayList();
-
- try {
-
- int endOffset= offset + length;
-
- Position[] category= fDocument.getPositions(CONTENT_TYPES_CATEGORY);
-
- TypedPosition previous= null, current= null;
- int start, end, gapOffset;
- Position gap= null;
-
- for (int i= 0; i < category.length; i++) {
-
- current= (TypedPosition) category[i];
-
- gapOffset= (previous != null) ? previous.getOffset() + previous.getLength() : 0;
- gap= new Position(gapOffset, current.getOffset() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, gap.getOffset() + gap.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
-
- if (current.overlapsWith(offset, length)) {
- start= Math.max(offset, current.getOffset());
- end= Math.min(endOffset, current.getOffset() + current.getLength());
- list.add(new TypedRegion(start, end - start, current.getType()));
- }
-
- previous= current;
- }
-
- if (previous != null) {
- gapOffset= previous.getOffset() + previous.getLength();
- gap= new Position(gapOffset, fDocument.getLength() - gapOffset);
- if (gap.getLength() > 0 && gap.overlapsWith(offset, length)) {
- start= Math.max(offset, gapOffset);
- end= Math.min(endOffset, fDocument.getLength());
- list.add(new TypedRegion(start, end - start, IDocument.DEFAULT_CONTENT_TYPE));
- }
- }
-
- if (list.isEmpty())
- list.add(new TypedRegion(offset, length, IDocument.DEFAULT_CONTENT_TYPE));
-
- } catch (BadPositionCategoryException x) {
- }
-
- TypedRegion[] result= new TypedRegion[list.size()];
- list.toArray(result);
- return result;
- }
-
- /*
- * @see IDocumentPartitioner#getLegalContentTypes
- */
- public String[] getLegalContentTypes() {
- return fLegalContentTypes;
- }
-
- /**
- * Returns whether the given type is one of the legal content types.
- *
- * @param contentType the content type to check
- * @return <code>true</code> if the content type is a legal content type
- */
- protected boolean isSupportedContentType(String contentType) {
- if (contentType != null) {
- for (int i= 0; i < fLegalContentTypes.length; i++) {
- if (fLegalContentTypes[i].equals(contentType))
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Returns a content type encoded in the given token. If the token's
- * data is not <code>null</code> and a string it is assumed that
- * it is the encoded content type.
- *
- * @param token the token whose content type is to be determined
- * @return the token's content type
- */
- protected String getTokenContentType(IToken token) {
- Object data= token.getData();
- if (data instanceof String)
- return (String) data;
- return null;
- }
-}
-
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
index 999183ccc0..e788f30027 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
@@ -5,12 +5,10 @@ package org.eclipse.cdt.internal.ui.util;
* All Rights Reserved.
*/
-import java.util.List;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java
index 6b3fedf03b..7b45d645b2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java
@@ -124,11 +124,12 @@ public abstract class ConversionWizard
*
* @see org.eclipse.cdt.ui.wizards.CProjectWizard#doRun(IProgressMonitor)
*/
- protected void doRun(IProgressMonitor monitor) {
+ protected void doRun(IProgressMonitor monitor) throws CoreException {
try{
mainPage.doRun(monitor, getProjectID());
} catch (CoreException ce){
CCorePlugin.log(ce);
+ throw ce;
} finally{
doRunEpilogue(monitor);
monitor.isCanceled();
@@ -138,9 +139,7 @@ public abstract class ConversionWizard
* Return the type of project that it is being converted to
* The default if a make project
*/
- public String getProjectID() {
- return CCorePlugin.PLUGIN_ID + ".make";//$NON-NLS-1$
- }
+ public abstract String getProjectID();
/**
* Method addPages allows subclasses to add as many pages as they need. Overwrite
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java
index b36f22bae4..e5a9ca1ea5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertToStdMakeConversionWizard.java
@@ -5,6 +5,7 @@ package org.eclipse.cdt.ui.wizards.conversion;
* All Rights Reserved.
*/
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.ui.CUIPlugin;
/**
@@ -85,4 +86,8 @@ public class ConvertToStdMakeConversionWizard extends ConversionWizard {
addPage(mainPage);
}
+
+ public String getProjectID() {
+ return CCorePlugin.PLUGIN_ID + ".make";//$NON-NLS-1$
+ }
}

Back to the top