mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-21 07:05:58 +02:00
The CView to update with each reconcile : [Bug 53074]
This commit is contained in:
parent
f0ac94629e
commit
e7dfb880a4
17 changed files with 352 additions and 81 deletions
|
@ -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
|
2004-02-27 Alain Magloire
|
||||||
|
|
||||||
Performance improvement in the IBinaryParser and
|
Performance improvement in the IBinaryParser and
|
||||||
|
|
|
@ -15,16 +15,74 @@ import java.util.EventObject;
|
||||||
* @see ICElementDelta
|
* @see ICElementDelta
|
||||||
*/
|
*/
|
||||||
public class ElementChangedEvent extends EventObject {
|
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 <code>getDelta()</code>.
|
||||||
|
*
|
||||||
|
* 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;
|
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 <code>getDelta</code>.
|
||||||
|
*
|
||||||
|
* 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;
|
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 <code>getDelta</code>.
|
||||||
|
*
|
||||||
|
* 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;
|
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 <code>ICElementDelta</code>).
|
* Creates an new element changed event (based on a <code>ICElementDelta</code>).
|
||||||
*
|
*
|
||||||
* @param delta the C element delta.
|
* @param delta the C element delta.
|
||||||
*/
|
*/
|
||||||
public ElementChangedEvent(ICElementDelta delta) {
|
public ElementChangedEvent(ICElementDelta delta, int type) {
|
||||||
super(delta);
|
super(delta);
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the delta describing the change.
|
* Returns the delta describing the change.
|
||||||
|
@ -33,4 +91,16 @@ public class ElementChangedEvent extends EventObject {
|
||||||
public ICElementDelta getDelta() {
|
public ICElementDelta getDelta() {
|
||||||
return (ICElementDelta) source;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
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.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
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.IResource;
|
||||||
import org.eclipse.core.resources.IResourceVisitor;
|
import org.eclipse.core.resources.IResourceVisitor;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
|
|
||||||
public class BinaryRunner {
|
public class BinaryRunner {
|
||||||
IProject project;
|
IProject project;
|
||||||
|
@ -92,7 +93,7 @@ public class BinaryRunner {
|
||||||
cdelta.added(children[i]);
|
cdelta.added(children[i]);
|
||||||
}
|
}
|
||||||
factory.registerCModelDelta(cdelta);
|
factory.registerCModelDelta(cdelta);
|
||||||
factory.fire();
|
factory.fire(ElementChangedEvent.POST_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -439,7 +439,7 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
CElementDelta delta = new CElementDelta(getCModel());
|
CElementDelta delta = new CElementDelta(getCModel());
|
||||||
delta.binaryParserChanged(celement);
|
delta.binaryParserChanged(celement);
|
||||||
registerCModelDelta(delta);
|
registerCModelDelta(delta);
|
||||||
fire();
|
fire(ElementChangedEvent.POST_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,7 +705,7 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
registerCModelDelta(translatedDeltas[i]);
|
registerCModelDelta(translatedDeltas[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fire();
|
fire(ElementChangedEvent.POST_CHANGE);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -719,17 +719,25 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
* Fire C Model deltas, flushing them after the fact.
|
* Fire C Model deltas, flushing them after the fact.
|
||||||
* If the firing mode has been turned off, this has no effect.
|
* If the firing mode has been turned off, this has no effect.
|
||||||
*/
|
*/
|
||||||
public synchronized void fire() {
|
public synchronized void fire(int eventType) {
|
||||||
if (fFire) {
|
if (fFire) {
|
||||||
mergeDeltas();
|
mergeDeltas();
|
||||||
try {
|
try {
|
||||||
Iterator iterator = fCModelDeltas.iterator();
|
Iterator iterator = fCModelDeltas.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ICElementDelta delta= (ICElementDelta) iterator.next();
|
ICElementDelta delta= (ICElementDelta) iterator.next();
|
||||||
|
|
||||||
// Refresh internal scopes
|
// Refresh internal scopes
|
||||||
|
fire(delta, eventType);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// empty the queue
|
||||||
|
this.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ElementChangedEvent event= new ElementChangedEvent(delta);
|
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
|
// 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
|
// (eg. a type hierarchy becomes invalid (and thus it removes itself) when the type is removed
|
||||||
ArrayList listeners= (ArrayList) fElementChangedListeners.clone();
|
ArrayList listeners= (ArrayList) fElementChangedListeners.clone();
|
||||||
|
@ -738,12 +746,6 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
listener.elementChanged(event);
|
listener.elementChanged(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
// empty the queue
|
|
||||||
this.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flushes all deltas without firing them.
|
* 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)
|
// 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
|
// and the operation has not modified any resource
|
||||||
if (!hadAwaitingDeltas && !operation.hasModifiedResource()) {
|
if (!hadAwaitingDeltas && !operation.hasModifiedResource()) {
|
||||||
fire();
|
fire(ElementChangedEvent.POST_CHANGE);
|
||||||
} // else deltas are fired while processing the resource delta
|
} // else deltas are fired while processing the resource delta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,27 +6,27 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
*/
|
*/
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
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.ICElement;
|
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.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatus;
|
import org.eclipse.cdt.core.model.ICModelStatus;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
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
|
* Defines behavior common to all C Model operations
|
||||||
|
@ -495,7 +495,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
||||||
// Fire if we change somethings
|
// Fire if we change somethings
|
||||||
if (!hasModifiedResource()) {
|
if (!hasModifiedResource()) {
|
||||||
CModelManager manager= CModelManager.getDefault();
|
CModelManager manager= CModelManager.getDefault();
|
||||||
manager.fire();
|
manager.fire(ElementChangedEvent.POST_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
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.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatus;
|
import org.eclipse.cdt.core.model.ICModelStatus;
|
||||||
|
@ -248,7 +249,7 @@ public class PathEntryManager {
|
||||||
//affectedProject.setRawPathEntries(affectedProject.getRawPathEntries(), progressMonitor);
|
//affectedProject.setRawPathEntries(affectedProject.getRawPathEntries(), progressMonitor);
|
||||||
}
|
}
|
||||||
if (shouldFire) {
|
if (shouldFire) {
|
||||||
mgr.fire();
|
mgr.fire(ElementChangedEvent.POST_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, monitor);
|
}, monitor);
|
||||||
|
|
|
@ -294,12 +294,10 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
public boolean reconcile(boolean forceProblemDetection, IProgressMonitor monitor)
|
public boolean reconcile(boolean forceProblemDetection, IProgressMonitor monitor)
|
||||||
throws CModelException {
|
throws CModelException {
|
||||||
|
|
||||||
boolean somethingChanged = false;
|
|
||||||
|
|
||||||
if (this.useCount == 0) throw newNotPresentException(); //was destroyed
|
if (this.useCount == 0) throw newNotPresentException(); //was destroyed
|
||||||
|
|
||||||
if (monitor != null){
|
if (monitor != null){
|
||||||
if (monitor.isCanceled()) return somethingChanged;
|
if (monitor.isCanceled()) return false;
|
||||||
monitor.beginTask("element.reconciling", 10); //$NON-NLS-1$
|
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
|
// update the element infos with the content of the working copy
|
||||||
this.makeConsistent(monitor);
|
this.makeConsistent(monitor);
|
||||||
deltaBuilder.buildDeltas();
|
deltaBuilder.buildDeltas();
|
||||||
somethingChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor != null) monitor.worked(2);
|
if (monitor != null) monitor.worked(2);
|
||||||
|
|
||||||
// force problem detection? - if structure was consistent
|
// force problem detection? - if structure was consistent
|
||||||
if (forceProblemDetection && wasConsistent){
|
if (forceProblemDetection && wasConsistent){
|
||||||
if (monitor != null && monitor.isCanceled()) return somethingChanged;
|
if (monitor != null && monitor.isCanceled()) return (!wasConsistent);
|
||||||
|
|
||||||
//IProblemRequestor problemRequestor = this.getProblemRequestor();
|
//IProblemRequestor problemRequestor = this.getProblemRequestor();
|
||||||
//if (problemRequestor != null && problemRequestor.isActive()){
|
//if (problemRequestor != null && problemRequestor.isActive()){
|
||||||
|
@ -332,15 +329,17 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fire the deltas
|
// fire the deltas
|
||||||
//if (deltaBuilder != null){
|
if (deltaBuilder != null){
|
||||||
// if ((deltaBuilder.delta != null) && (deltaBuilder.delta.getAffectedChildren().length > 0)) {
|
if ((deltaBuilder.delta != null) && (deltaBuilder.delta.getAffectedChildren().length > 0)) {
|
||||||
// CModelManager.getDefault().fire(deltaBuilder.delta, ElementChangedEvent.POST_RECONCILE);
|
CModelManager.getDefault().fire(deltaBuilder.delta, ElementChangedEvent.POST_RECONCILE);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (monitor != null) monitor.done();
|
if (monitor != null) monitor.done();
|
||||||
}
|
}
|
||||||
return somethingChanged;
|
|
||||||
|
// An indication if something has changed
|
||||||
|
return (!wasConsistent);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#restore()
|
* @see org.eclipse.cdt.core.model.IWorkingCopy#restore()
|
||||||
|
|
|
@ -32,6 +32,36 @@ public class CConventions {
|
||||||
private final static char fgDot= '.';
|
private final static char fgDot= '.';
|
||||||
private final static char fgColon= ':';
|
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.
|
* Validate the given CPP class name, either simple or qualified.
|
||||||
* For example, <code>"A::B::C"</code>, or <code>"C"</code>.
|
* For example, <code>"A::B::C"</code>, or <code>"C"</code>.
|
||||||
|
@ -134,4 +164,56 @@ public class CConventions {
|
||||||
}
|
}
|
||||||
return CModelStatus.VERIFIED_OK;
|
return CModelStatus.VERIFIED_OK;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Validate the given field name.
|
||||||
|
* <p>
|
||||||
|
* Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
|
||||||
|
* For example, <code>"x"</code>.
|
||||||
|
*
|
||||||
|
* @param name the name of a field
|
||||||
|
* @return a status object with code <code>IStatus.OK</code> 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 (<code>"true"</code>, <code>"false"</code>), or null literal (<code>"null"</code>).
|
||||||
|
* See section 3.8 of the <em>C Language Specification, Second Edition</em> (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 <code>IStatus.OK</code> 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.
|
||||||
|
* <p>
|
||||||
|
* 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 <code>IStatus.OK</code> 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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
|
2004-02-26 Andrew Niefer
|
||||||
externalized strings for all packages
|
externalized strings for all packages
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
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.IContainer;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -58,7 +60,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
|
|
||||||
public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
|
public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
|
||||||
fProvideMembers= provideMembers;
|
fProvideMembers= provideMembers;
|
||||||
//fProvideWorkingCopy= provideWorkingCopy;
|
fProvideWorkingCopy= provideWorkingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +84,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
* a working copy of a compilation unit
|
* a working copy of a compilation unit
|
||||||
*/
|
*/
|
||||||
public void setProvideWorkingCopy(boolean b) {
|
public void setProvideWorkingCopy(boolean b) {
|
||||||
//fProvideWorkingCopy= b;
|
fProvideWorkingCopy= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,9 +126,20 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
return getCProjectResources((ICProject)celement);
|
return getCProjectResources((ICProject)celement);
|
||||||
} else if (celement instanceof ICContainer) {
|
} else if (celement instanceof ICContainer) {
|
||||||
return getCResources((ICContainer)celement);
|
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) {
|
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) {
|
} else if (celement instanceof IParent) {
|
||||||
return (Object[])((IParent)celement).getChildren();
|
return (Object[])((IParent)celement).getChildren();
|
||||||
|
|
|
@ -8,7 +8,12 @@ package org.eclipse.cdt.internal.ui.editor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
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.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.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.model.WorkingCopy;
|
import org.eclipse.cdt.internal.core.model.WorkingCopy;
|
||||||
import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy;
|
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.SWT;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Menu;
|
import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IFileEditorInput;
|
import org.eclipse.ui.IFileEditorInput;
|
||||||
import org.eclipse.ui.IStorageEditorInput;
|
import org.eclipse.ui.IStorageEditorInput;
|
||||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||||
|
import org.eclipse.ui.part.IPage;
|
||||||
import org.eclipse.ui.part.IPageSite;
|
import org.eclipse.ui.part.IPageSite;
|
||||||
import org.eclipse.ui.part.Page;
|
import org.eclipse.ui.part.Page;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
|
@ -96,15 +103,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
*/
|
*/
|
||||||
public void contentUpdated() {
|
public void contentUpdated() {
|
||||||
if (fInput != null) {
|
if (fInput != null) {
|
||||||
try {
|
|
||||||
//fInput.update();
|
|
||||||
fInput.reconcile();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CUIPlugin.getDefault().log(e.getStatus());
|
|
||||||
fInput= null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final TreeViewer treeViewer= getTreeViewer();
|
final TreeViewer treeViewer= getTreeViewer();
|
||||||
if (treeViewer != null && !treeViewer.getControl().isDisposed()) {
|
if (treeViewer != null && !treeViewer.getControl().isDisposed()) {
|
||||||
treeViewer.getControl().getDisplay().asyncExec(new Runnable() {
|
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 = new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||||
treeViewer.addSelectionChangedListener(this);
|
treeViewer.addSelectionChangedListener(this);
|
||||||
|
|
||||||
//treeViewer.setContentProvider(new CModelContentProvider());
|
|
||||||
treeViewer.setContentProvider(new CElementContentProvider(true, true));
|
treeViewer.setContentProvider(new CElementContentProvider(true, true));
|
||||||
treeViewer.setLabelProvider(new StandardCElementLabelProvider());
|
treeViewer.setLabelProvider(new StandardCElementLabelProvider());
|
||||||
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
|
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
|
||||||
|
|
|
@ -68,6 +68,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.IEditorActionBarContributor;
|
import org.eclipse.ui.IEditorActionBarContributor;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IFileEditorInput;
|
import org.eclipse.ui.IFileEditorInput;
|
||||||
|
@ -103,7 +104,7 @@ import org.eclipse.ui.views.tasklist.TaskList;
|
||||||
/**
|
/**
|
||||||
* C specific text editor.
|
* C specific text editor.
|
||||||
*/
|
*/
|
||||||
public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource {
|
public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource , IReconcilingParticipant{
|
||||||
|
|
||||||
/** The outline page */
|
/** The outline page */
|
||||||
protected CContentOutlinePage fOutlinePage;
|
protected CContentOutlinePage fOutlinePage;
|
||||||
|
@ -959,4 +960,13 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
||||||
if (statusLine != null)
|
if (statusLine != null)
|
||||||
statusLine.setMessage(true, msg, 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -12,9 +12,13 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManagerExtension;
|
import org.eclipse.cdt.ui.IWorkingCopyManagerExtension;
|
||||||
|
@ -42,6 +46,7 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
|
||||||
public WorkingCopyManager(CDocumentProvider provider) {
|
public WorkingCopyManager(CDocumentProvider provider) {
|
||||||
Assert.isNotNull(provider);
|
Assert.isNotNull(provider);
|
||||||
fDocumentProvider= provider;
|
fDocumentProvider= provider;
|
||||||
|
fMap = new HashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -81,9 +86,30 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
|
||||||
*/
|
*/
|
||||||
public IWorkingCopy getWorkingCopy(IEditorInput input) {
|
public IWorkingCopy getWorkingCopy(IEditorInput input) {
|
||||||
IWorkingCopy unit= fMap == null ? null : (IWorkingCopy) fMap.get(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)
|
* @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#setWorkingCopy(org.eclipse.ui.IEditorInput, org.eclipse.cdt.core.model.ITranslationUnit)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
|
import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
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.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -68,19 +69,23 @@ public class CReconcilingStrategy implements IReconcilingStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reconcile() {
|
private void reconcile() {
|
||||||
boolean doUpdate = false;
|
boolean somethingHasChanged = false;
|
||||||
try {
|
try {
|
||||||
ITranslationUnit tu = fManager.getWorkingCopy(fEditor.getEditorInput());
|
ITranslationUnit tu = fManager.getWorkingCopy(fEditor.getEditorInput());
|
||||||
if (tu != null && tu.isWorkingCopy()) {
|
if (tu != null && tu.isWorkingCopy()) {
|
||||||
IWorkingCopy workingCopy = (IWorkingCopy)tu;
|
IWorkingCopy workingCopy = (IWorkingCopy)tu;
|
||||||
// reconcile
|
// reconcile
|
||||||
synchronized (workingCopy) {
|
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) {
|
} catch(CModelException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ import org.eclipse.cdt.core.model.IArchive;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
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.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
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.ArchiveContainer;
|
||||||
import org.eclipse.cdt.internal.core.model.BinaryContainer;
|
import org.eclipse.cdt.internal.core.model.BinaryContainer;
|
||||||
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
||||||
|
@ -52,7 +52,6 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
fViewer = (StructuredViewer)viewer;
|
fViewer = (StructuredViewer)viewer;
|
||||||
|
|
||||||
if (oldInput == null && newInput != null) {
|
if (oldInput == null && newInput != null) {
|
||||||
if (newInput instanceof ICModel)
|
|
||||||
CoreModel.getDefault().addElementChangedListener(this);
|
CoreModel.getDefault().addElementChangedListener(this);
|
||||||
} else if (oldInput != null && newInput == null) {
|
} else if (oldInput != null && newInput == null) {
|
||||||
CoreModel.getDefault().removeElementChangedListener(this);
|
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);
|
//System.out.println("UI refresh:" + root);
|
||||||
postRunnable(new Runnable() {
|
postRunnable(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl= fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed())
|
if (ctrl != null && !ctrl.isDisposed()){
|
||||||
fViewer.refresh(root);
|
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() {
|
public void run() {
|
||||||
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl= fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed())
|
if (ctrl != null && !ctrl.isDisposed()){
|
||||||
// fViewer.add(parent, element);
|
// fViewer.add(parent, element);
|
||||||
fViewer.refresh(parent);
|
fViewer.refresh(parent);
|
||||||
|
if(parent instanceof IWorkingCopy){
|
||||||
|
fViewer.refresh(((IWorkingCopy)parent).getOriginalElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -295,18 +305,26 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
public void run() {
|
public void run() {
|
||||||
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl= fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed())
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
// fViewer.remove(element);
|
// fViewer.remove(element);
|
||||||
fViewer.refresh(internalGetParent(element));
|
Object parent = internalGetParent(element);
|
||||||
|
fViewer.refresh(parent);
|
||||||
|
if(parent instanceof IWorkingCopy){
|
||||||
|
fViewer.refresh(((IWorkingCopy)parent).getOriginalElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postRunnable(final Runnable r) {
|
private void postRunnable(final Runnable r) {
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl= fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed())
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
ctrl.getDisplay().asyncExec(r);
|
ctrl.getDisplay().asyncExec(r);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The workbench has changed. Process the delta and issue updates to the viewer,
|
* The workbench has changed. Process the delta and issue updates to the viewer,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui;
|
package org.eclipse.cdt.ui;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
|
@ -67,6 +68,17 @@ public interface IWorkingCopyManager {
|
||||||
*/
|
*/
|
||||||
IWorkingCopy getWorkingCopy(IEditorInput input);
|
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 <code>null</code> 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
|
* Shuts down this working copy manager. All working copies still remembered
|
||||||
* by this manager are destroyed.
|
* by this manager are destroyed.
|
||||||
|
|
Loading…
Add table
Reference in a new issue