diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog
index b1db9e5aeda..7722ba4b1d0 100644
--- a/core/org.eclipse.cdt.core/ChangeLog
+++ b/core/org.eclipse.cdt.core/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-27 Hoda Amer
+ Fixed [Bug 53074] The CView to update with each reconcile
+ Added the ability for CView to update based on the translation unit working copy
+ if one exists.
+
2004-02-27 Alain Magloire
Performance improvement in the IBinaryParser and
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ElementChangedEvent.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ElementChangedEvent.java
index 767d909cdd8..9f8a01f66ea 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ElementChangedEvent.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ElementChangedEvent.java
@@ -15,16 +15,74 @@ import java.util.EventObject;
* @see ICElementDelta
*/
public class ElementChangedEvent extends EventObject {
+ /**
+ * Event type constant (bit mask) indicating an after-the-fact
+ * report of creations, deletions, and modifications
+ * to one or more C element(s) expressed as a hierarchical
+ * C element delta as returned by getDelta()
.
+ *
+ * Note: this notification occurs during the corresponding POST_CHANGE
+ * resource change notification, and contains a full delta accounting for
+ * any CModel operation and/or resource change.
+ *
+ * @see ICElementDelta
+ * @see org.eclipse.core.resources.IResourceChangeEvent
+ * @see #getDelta()
+ * @since 2.0
+ */
public static final int POST_CHANGE = 1;
+ /**
+ * Event type constant (bit mask) indicating an after-the-fact
+ * report of creations, deletions, and modifications
+ * to one or more C element(s) expressed as a hierarchical
+ * C element delta as returned by getDelta
.
+ *
+ * Note: this notification occurs during the corresponding PRE_AUTO_BUILD
+ * resource change notification. The delta, which is notified here, only contains
+ * information relative to the previous CModel operations (in other words,
+ * it ignores the possible resources which have changed outside C operations).
+ * In particular, it is possible that the CModel be inconsistent with respect to
+ * resources, which got modified outside CModel operations (it will only be
+ * fully consistent once the POST_CHANGE notification has occurred).
+ *
+ * @see ICElementDelta
+ * @see org.eclipse.core.resources.IResourceChangeEvent
+ * @see #getDelta()
+ * @since 2.0
+ * @deprecated - no longer used, such deltas are now notified during POST_CHANGE
+ */
public static final int PRE_AUTO_BUILD = 2;
+ /**
+ * Event type constant (bit mask) indicating an after-the-fact
+ * report of creations, deletions, and modifications
+ * to one or more C element(s) expressed as a hierarchical
+ * C element delta as returned by getDelta
.
+ *
+ * Note: this notification occurs as a result of a working copy reconcile
+ * operation.
+ *
+ * @see ICElementDelta
+ * @see org.eclipse.core.resources.IResourceChangeEvent
+ * @see #getDelta()
+ * @since 2.0
+ */
public static final int POST_RECONCILE = 4;
+ /*
+ * Event type indicating the nature of this event.
+ * It can be a combination either:
+ * - POST_CHANGE
+ * - PRE_AUTO_BUILD
+ * - POST_RECONCILE
+ */
+ private int type;
/**
* Creates an new element changed event (based on a ICElementDelta
).
*
* @param delta the C element delta.
*/
- public ElementChangedEvent(ICElementDelta delta) {
+ public ElementChangedEvent(ICElementDelta delta, int type) {
super(delta);
+ this.type = type;
}
/**
* Returns the delta describing the change.
@@ -33,4 +91,16 @@ public class ElementChangedEvent extends EventObject {
public ICElementDelta getDelta() {
return (ICElementDelta) source;
}
+ /**
+ * Returns the type of event being reported.
+ *
+ * @return one of the event type constants
+ * @see #POST_CHANGE
+ * @see #PRE_AUTO_BUILD
+ * @see #POST_RECONCILE
+ * @since 2.0
+ */
+ public int getType() {
+ return this.type;
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
index 615e23f2eab..05cf2dc653f 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java
@@ -5,7 +5,9 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.ICProject;
@@ -14,7 +16,6 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.cdt.core.CCorePlugin;
public class BinaryRunner {
IProject project;
@@ -92,7 +93,7 @@ public class BinaryRunner {
cdelta.added(children[i]);
}
factory.registerCModelDelta(cdelta);
- factory.fire();
+ factory.fire(ElementChangedEvent.POST_CHANGE);
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
index 18202218c6c..70ef3597abb 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java
@@ -439,7 +439,7 @@ public class CModelManager implements IResourceChangeListener {
CElementDelta delta = new CElementDelta(getCModel());
delta.binaryParserChanged(celement);
registerCModelDelta(delta);
- fire();
+ fire(ElementChangedEvent.POST_CHANGE);
}
}
}
@@ -705,7 +705,7 @@ public class CModelManager implements IResourceChangeListener {
registerCModelDelta(translatedDeltas[i]);
}
}
- fire();
+ fire(ElementChangedEvent.POST_CHANGE);
}
} catch (Exception e) {
e.printStackTrace();
@@ -719,24 +719,15 @@ public class CModelManager implements IResourceChangeListener {
* Fire C Model deltas, flushing them after the fact.
* If the firing mode has been turned off, this has no effect.
*/
- public synchronized void fire() {
+ public synchronized void fire(int eventType) {
if (fFire) {
mergeDeltas();
try {
Iterator iterator = fCModelDeltas.iterator();
while (iterator.hasNext()) {
ICElementDelta delta= (ICElementDelta) iterator.next();
-
// Refresh internal scopes
-
- ElementChangedEvent event= new ElementChangedEvent(delta);
- // Clone the listeners since they could remove themselves when told about the event
- // (eg. a type hierarchy becomes invalid (and thus it removes itself) when the type is removed
- ArrayList listeners= (ArrayList) fElementChangedListeners.clone();
- for (int i= 0; i < listeners.size(); i++) {
- IElementChangedListener listener= (IElementChangedListener) listeners.get(i);
- listener.elementChanged(event);
- }
+ fire(delta, eventType);
}
} finally {
// empty the queue
@@ -745,6 +736,17 @@ public class CModelManager implements IResourceChangeListener {
}
}
+ public synchronized void fire(ICElementDelta delta, int eventType) {
+ ElementChangedEvent event= new ElementChangedEvent(delta, eventType);
+ // Clone the listeners since they could remove themselves when told about the event
+ // (eg. a type hierarchy becomes invalid (and thus it removes itself) when the type is removed
+ ArrayList listeners= (ArrayList) fElementChangedListeners.clone();
+ for (int i= 0; i < listeners.size(); i++) {
+ IElementChangedListener listener= (IElementChangedListener) listeners.get(i);
+ listener.elementChanged(event);
+ }
+ }
+
/**
* Flushes all deltas without firing them.
*/
@@ -814,7 +816,7 @@ public class CModelManager implements IResourceChangeListener {
// fire only if there were no awaiting deltas (if there were, they would come from a resource modifying operation)
// and the operation has not modified any resource
if (!hadAwaitingDeltas && !operation.hasModifiedResource()) {
- fire();
+ fire(ElementChangedEvent.POST_CHANGE);
} // else deltas are fired while processing the resource delta
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java
index d111a4ce210..1719cd75b19 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java
@@ -6,27 +6,27 @@ package org.eclipse.cdt.internal.core.model;
*/
import java.io.InputStream;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
/**
* Defines behavior common to all C Model operations
@@ -495,7 +495,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
// Fire if we change somethings
if (!hasModifiedResource()) {
CModelManager manager= CModelManager.getDefault();
- manager.fire();
+ manager.fire(ElementChangedEvent.POST_CHANGE);
}
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
index 0dc24796344..8d9ce47bc00 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
@@ -21,6 +21,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICModelStatus;
@@ -248,7 +249,7 @@ public class PathEntryManager {
//affectedProject.setRawPathEntries(affectedProject.getRawPathEntries(), progressMonitor);
}
if (shouldFire) {
- mgr.fire();
+ mgr.fire(ElementChangedEvent.POST_CHANGE);
}
}
}, monitor);
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
index 3c0104703cb..f90e4db60dd 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
@@ -293,13 +293,11 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
*/
public boolean reconcile(boolean forceProblemDetection, IProgressMonitor monitor)
throws CModelException {
-
- boolean somethingChanged = false;
if (this.useCount == 0) throw newNotPresentException(); //was destroyed
if (monitor != null){
- if (monitor.isCanceled()) return somethingChanged;
+ if (monitor.isCanceled()) return false;
monitor.beginTask("element.reconciling", 10); //$NON-NLS-1$
}
@@ -314,14 +312,13 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
// update the element infos with the content of the working copy
this.makeConsistent(monitor);
deltaBuilder.buildDeltas();
- somethingChanged = true;
}
if (monitor != null) monitor.worked(2);
// force problem detection? - if structure was consistent
if (forceProblemDetection && wasConsistent){
- if (monitor != null && monitor.isCanceled()) return somethingChanged;
+ if (monitor != null && monitor.isCanceled()) return (!wasConsistent);
//IProblemRequestor problemRequestor = this.getProblemRequestor();
//if (problemRequestor != null && problemRequestor.isActive()){
@@ -332,15 +329,17 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
}
// fire the deltas
- //if (deltaBuilder != null){
- // if ((deltaBuilder.delta != null) && (deltaBuilder.delta.getAffectedChildren().length > 0)) {
- // CModelManager.getDefault().fire(deltaBuilder.delta, ElementChangedEvent.POST_RECONCILE);
- // }
- //}
+ if (deltaBuilder != null){
+ if ((deltaBuilder.delta != null) && (deltaBuilder.delta.getAffectedChildren().length > 0)) {
+ CModelManager.getDefault().fire(deltaBuilder.delta, ElementChangedEvent.POST_RECONCILE);
+ }
+ }
} finally {
if (monitor != null) monitor.done();
}
- return somethingChanged;
+
+ // An indication if something has changed
+ return (!wasConsistent);
}
/**
* @see org.eclipse.cdt.core.model.IWorkingCopy#restore()
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java
index 2a849770541..15876474a4a 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CConventions.java
@@ -32,6 +32,36 @@ public class CConventions {
private final static char fgDot= '.';
private final static char fgColon= ':';
+ private static boolean isValidIdentifier(String name) {
+ if (name == null) {
+ return false;
+ }
+ String trimmed = name.trim();
+ if ((!name.equals(trimmed)) || (name.indexOf(" ") != -1) ){
+ return false;
+ }
+
+ int index = name.lastIndexOf(scopeResolutionOperator);
+ char[] scannedID;
+ if (index != -1) {
+ return false;
+ }
+ scannedID = name.toCharArray();
+
+ if (scannedID != null) {
+ IStatus status = ResourcesPlugin.getWorkspace().validateName(new String(scannedID), IResource.FILE);
+ if (!status.isOK()) {
+ return false;
+ }
+ if (CharOperation.contains('$', scannedID)) {
+ return false;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/**
* Validate the given CPP class name, either simple or qualified.
* For example, "A::B::C"
, or "C"
.
@@ -134,4 +164,56 @@ public class CConventions {
}
return CModelStatus.VERIFIED_OK;
}
+ /**
+ * Validate the given field name.
+ *
+ * Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
+ * For example, "x"
.
+ *
+ * @param name the name of a field
+ * @return a status object with code IStatus.OK
if
+ * the given name is valid as a field name, otherwise a status
+ * object indicating what is wrong with the name
+ */
+ public static IStatus validateFieldName(String name) {
+ return validateIdentifier(name);
+ }
+
+ /**
+ * Validate the given C identifier.
+ * The identifier must not have the same spelling as a C keyword,
+ * boolean literal ("true"
, "false"
), or null literal ("null"
).
+ * See section 3.8 of the C Language Specification, Second Edition (JLS2).
+ * A valid identifier can act as a simple type name, method name or field name.
+ *
+ * @param id the C identifier
+ * @return a status object with code IStatus.OK
if
+ * the given identifier is a valid C identifier, otherwise a status
+ * object indicating what is wrong with the identifier
+ */
+ public static IStatus validateIdentifier(String id) {
+ if (isValidIdentifier(id)) {
+ return CModelStatus.VERIFIED_OK;
+ } else {
+ return new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier", id), null); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Validate the given method name.
+ * The special names "<init>" and "<clinit>" are not valid.
+ *
+ * The syntax for a method name is defined by Identifier
+ * of MethodDeclarator (JLS2 8.4). For example "println".
+ *
+ * @param name the name of a method
+ * @return a status object with code IStatus.OK
if
+ * the given name is valid as a method name, otherwise a status
+ * object indicating what is wrong with the name
+ */
+ public static IStatus validateMethodName(String name) {
+
+ return validateIdentifier(name);
+ }
+
}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index 70c70a34f3a..bd0e54a6e6e 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-27 Hoda Amer
+ Fixed [Bug 53074] The CView to update with each reconcile
+ Added the ability for CView to update based on the translation unit working copy
+ if one exists.
+
2004-02-26 Andrew Niefer
externalized strings for all packages
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
index 546de621487..687b92ef2e8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
@@ -21,6 +21,8 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ILibraryReference;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -58,7 +60,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
fProvideMembers= provideMembers;
- //fProvideWorkingCopy= provideWorkingCopy;
+ fProvideWorkingCopy= provideWorkingCopy;
}
/**
@@ -82,7 +84,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
* a working copy of a compilation unit
*/
public void setProvideWorkingCopy(boolean b) {
- //fProvideWorkingCopy= b;
+ fProvideWorkingCopy= b;
}
/**
@@ -124,9 +126,20 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
return getCProjectResources((ICProject)celement);
} else if (celement instanceof ICContainer) {
return getCResources((ICContainer)celement);
- } else if (celement.getElementType() == ICElement.C_UNIT) {
+ } else if (celement instanceof ITranslationUnit) {
+ // if we want to get the chidren of a translation unit
if (fProvideMembers) {
- return ((IParent)element).getChildren();
+ // if we want to use the working copy of it
+ if(fProvideWorkingCopy){
+ // if it is not already a working copy
+ if(!(celement instanceof IWorkingCopy)){
+ // if it has a valid working copy
+ IWorkingCopy copy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy((ITranslationUnit)celement);
+ if(copy != null)
+ return ((IParent)copy).getChildren();
+ }
+ }
+ return ((IParent)celement).getChildren();
}
} else if (celement instanceof IParent) {
return (Object[])((IParent)celement).getChildren();
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 5deb464d496..be8cd4f5a71 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
@@ -8,7 +8,12 @@ package org.eclipse.cdt.internal.ui.editor;
import java.util.ArrayList;
import java.util.Iterator;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.IElementChangedListener;
+import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.model.WorkingCopy;
import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy;
@@ -37,12 +42,14 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.part.IPage;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.texteditor.IDocumentProvider;
@@ -95,16 +102,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
* Called by the editor to signal that the content has updated.
*/
public void contentUpdated() {
- if (fInput != null) {
- try {
- //fInput.update();
- fInput.reconcile();
- } catch (CoreException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- fInput= null;
- return;
- }
-
+ if (fInput != null) {
final TreeViewer treeViewer= getTreeViewer();
if (treeViewer != null && !treeViewer.getControl().isDisposed()) {
treeViewer.getControl().getDisplay().asyncExec(new Runnable() {
@@ -168,7 +166,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
treeViewer = new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
treeViewer.addSelectionChangedListener(this);
- //treeViewer.setContentProvider(new CModelContentProvider());
treeViewer.setContentProvider(new CElementContentProvider(true, true));
treeViewer.setLabelProvider(new StandardCElementLabelProvider());
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
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 ba24d1d5248..13a2b50c4de 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
@@ -68,6 +68,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
@@ -103,7 +104,7 @@ import org.eclipse.ui.views.tasklist.TaskList;
/**
* C specific text editor.
*/
-public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource {
+public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource , IReconcilingParticipant{
/** The outline page */
protected CContentOutlinePage fOutlinePage;
@@ -959,4 +960,13 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
if (statusLine != null)
statusLine.setMessage(true, msg, null);
}
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant#reconciled()
+ */
+ public void reconciled(boolean somethingHasChanged) {
+ if(somethingHasChanged)
+ fOutlinePage.contentUpdated();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IReconcilingParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IReconcilingParticipant.java
new file mode 100644
index 00000000000..46be9cc94bb
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IReconcilingParticipant.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+
+
+
+/**
+ * Interface of an object participating in reconciling.
+ */
+public interface IReconcilingParticipant {
+
+ /**
+ * Called after reconciling has been finished.
+ */
+ void reconciled(boolean SomethingHasChanged);
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
index d5be08fbb99..d179f69dcb7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
@@ -12,9 +12,13 @@
package org.eclipse.cdt.internal.ui.editor;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.ui.IWorkingCopyManagerExtension;
@@ -42,6 +46,7 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
public WorkingCopyManager(CDocumentProvider provider) {
Assert.isNotNull(provider);
fDocumentProvider= provider;
+ fMap = new HashMap();
}
/*
@@ -81,9 +86,30 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
*/
public IWorkingCopy getWorkingCopy(IEditorInput input) {
IWorkingCopy unit= fMap == null ? null : (IWorkingCopy) fMap.get(input);
- return unit != null ? unit : fDocumentProvider.getWorkingCopy(input);
+ if(unit != null)
+ return unit;
+ IWorkingCopy copy = fDocumentProvider.getWorkingCopy(input);
+ if(copy != null)
+ fMap.put(input, copy);
+ return copy;
+ }
+ /*
+ * @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.cdt.core.model.ITranslationUnit)
+ */
+ public IWorkingCopy getWorkingCopy(ITranslationUnit unit){
+ if((fMap == null) || (fMap.size() == 0)){
+ return null;
+ } else {
+ List copies = new ArrayList(fMap.values());
+ Iterator i = copies.iterator();
+ while (i.hasNext()){
+ IWorkingCopy copy = (IWorkingCopy)i.next();
+ if(copy.getOriginalElement().equals(unit))
+ return copy;
+ }
+ }
+ return null;
}
-
/*
* @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#setWorkingCopy(org.eclipse.ui.IEditorInput, org.eclipse.cdt.core.model.ITranslationUnit)
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
index 7a265b0ea50..eeaa587909b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
@@ -10,6 +10,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -68,19 +69,23 @@ public class CReconcilingStrategy implements IReconcilingStrategy {
}
private void reconcile() {
- boolean doUpdate = false;
+ boolean somethingHasChanged = false;
try {
ITranslationUnit tu = fManager.getWorkingCopy(fEditor.getEditorInput());
if (tu != null && tu.isWorkingCopy()) {
IWorkingCopy workingCopy = (IWorkingCopy)tu;
// reconcile
synchronized (workingCopy) {
- doUpdate = workingCopy.reconcile(true, fProgressMonitor);
+ somethingHasChanged = workingCopy.reconcile(true, fProgressMonitor);
}
}
- if(doUpdate){
- fOutliner.contentUpdated();
+
+ // update participants
+ if (fEditor instanceof IReconcilingParticipant /*&& !fProgressMonitor.isCanceled()*/) {
+ IReconcilingParticipant p= (IReconcilingParticipant) fEditor;
+ p.reconciled(somethingHasChanged);
}
+
} catch(CModelException e) {
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
index f1f342cdc37..9fd625a9f84 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
@@ -13,11 +13,11 @@ import org.eclipse.cdt.core.model.IArchive;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.model.ArchiveContainer;
import org.eclipse.cdt.internal.core.model.BinaryContainer;
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
@@ -52,8 +52,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
fViewer = (StructuredViewer)viewer;
if (oldInput == null && newInput != null) {
- if (newInput instanceof ICModel)
- CoreModel.getDefault().addElementChangedListener(this);
+ CoreModel.getDefault().addElementChangedListener(this);
} else if (oldInput != null && newInput == null) {
CoreModel.getDefault().removeElementChangedListener(this);
}
@@ -264,14 +263,20 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
});
}
- private void postRefresh(final Object root) {
+ private void postRefresh(final Object element) {
//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);
+ if (ctrl != null && !ctrl.isDisposed()){
+ fViewer.refresh(element);
+ if(element instanceof IWorkingCopy){
+ fViewer.refresh(((IWorkingCopy)element).getOriginalElement());
+ }
+
+
+ }
}
});
}
@@ -282,9 +287,14 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
public void run() {
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed())
+ if (ctrl != null && !ctrl.isDisposed()){
// fViewer.add(parent, element);
fViewer.refresh(parent);
+ if(parent instanceof IWorkingCopy){
+ fViewer.refresh(((IWorkingCopy)parent).getOriginalElement());
+ }
+
+ }
}
});
}
@@ -295,17 +305,25 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
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(internalGetParent(element));
+ if (ctrl != null && !ctrl.isDisposed()) {
+// fViewer.remove(element);
+ Object parent = internalGetParent(element);
+ fViewer.refresh(parent);
+ if(parent instanceof IWorkingCopy){
+ fViewer.refresh(((IWorkingCopy)parent).getOriginalElement());
+ }
+
+ }
+
}
});
}
private void postRunnable(final Runnable r) {
Control ctrl= fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed())
- ctrl.getDisplay().asyncExec(r);
+ if (ctrl != null && !ctrl.isDisposed()) {
+ ctrl.getDisplay().asyncExec(r);
+ }
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java
index 514c01b35e3..43d346cc4e2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.ui;
+import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IEditorInput;
@@ -66,6 +67,17 @@ public interface IWorkingCopyManager {
* copy for this translation unit
*/
IWorkingCopy getWorkingCopy(IEditorInput input);
+
+ /**
+ * Returns the working copy remembered for the given translation unit if one exists
+ * in the current list of the working copy manager
+ *
+ * @param unit : the Translation unit
+ * @return the working copy of the translation unit, or null
if the
+ * unit was not seen by the manager before.
+ *
+ */
+ IWorkingCopy getWorkingCopy(ITranslationUnit unit);
/**
* Shuts down this working copy manager. All working copies still remembered