1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

2005-02-10 Alain Magloire

Second of 79596
	* model/org/eclipse/cdt/core/model/IPathEntryContainerExtension.java
	* model/org/eclipse/cdt/core/model/IPathEntryContainerExtensionListener.java
	* model/org/eclipse/cdt/core/model/PathEntryContainerChanged.java
	* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
This commit is contained in:
Alain Magloire 2005-02-11 00:48:11 +00:00
parent 6b3069ebc5
commit d6b9097bd5
5 changed files with 158 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2005-02-10 Alain Magloire
Second of 79596
* model/org/eclipse/cdt/core/model/IPathEntryContainerExtension.java
* model/org/eclipse/cdt/core/model/IPathEntryContainerExtensionListener.java
* model/org/eclipse/cdt/core/model/PathEntryContainerChanged.java
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
2005-02-10 Alain Magloire 2005-02-10 Alain Magloire
Part of the fix for 79596 Part of the fix for 79596
* model/org/eclipse/cdt/core/model/CoreModel.java * model/org/eclipse/cdt/core/model/CoreModel.java

View file

@ -37,4 +37,16 @@ public interface IPathEntryContainerExtension extends IPathEntryContainer {
* @see IPathEntry * @see IPathEntry
*/ */
IMacroEntry[] getMacroEntries(IPath path); IMacroEntry[] getMacroEntries(IPath path);
/**
*
* @param listener
*/
void addContainerListener(IPathEntryContainerExtensionListener listener);
/**
*
* @param listener
*/
void removeContainerListener(IPathEntryContainerExtensionListener listener);
} }

View file

@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.model;
/**
*/
public interface IPathEntryContainerExtensionListener {
void pathEntryContainerChanged(PathEntryContainerChanged[] events);
}

View file

@ -0,0 +1,71 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.model;
import java.util.EventObject;
import org.eclipse.core.runtime.IPath;
/**
*/
public class PathEntryContainerChanged extends EventObject {
/**
*
*/
public static final int INCLUDE_CHANGED = 1;
/**
*
*/
public static final int MACRO_CHANGED = 2;
/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = 3257565105200705590L;
int fType;
/**
* @param source
*/
public PathEntryContainerChanged(IPath source, int type) {
super(source);
fType = type;
}
/**
* Returns the affected path;
* @return path
*/
public IPath getPath() {
return (IPath)getSource();
}
/**
* whether or not the change affected the include paths
* @return
*/
public boolean isIncludeChange() {
return fType == INCLUDE_CHANGED;
}
/**
* Whether or not the chage affected the macro entries
* @return
*/
public boolean isMacroChange() {
return fType == MACRO_CHANGED;
}
}

View file

@ -37,14 +37,17 @@ import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.core.model.IIncludeEntry; import org.eclipse.cdt.core.model.IIncludeEntry;
import org.eclipse.cdt.core.model.ILibraryEntry; import org.eclipse.cdt.core.model.ILibraryEntry;
import org.eclipse.cdt.core.model.IMacroEntry; import org.eclipse.cdt.core.model.IMacroEntry;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.core.model.IOutputEntry; import org.eclipse.cdt.core.model.IOutputEntry;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainer; import org.eclipse.cdt.core.model.IPathEntryContainer;
import org.eclipse.cdt.core.model.IPathEntryContainerExtension; import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
import org.eclipse.cdt.core.model.IPathEntryContainerExtensionListener;
import org.eclipse.cdt.core.model.IProjectEntry; import org.eclipse.cdt.core.model.IProjectEntry;
import org.eclipse.cdt.core.model.ISourceEntry; import org.eclipse.cdt.core.model.ISourceEntry;
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.core.model.IWorkingCopy;
import org.eclipse.cdt.core.model.PathEntryContainerChanged;
import org.eclipse.cdt.core.model.PathEntryContainerInitializer; import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
import org.eclipse.cdt.core.resources.IPathEntryStore; import org.eclipse.cdt.core.resources.IPathEntryStore;
import org.eclipse.cdt.core.resources.IPathEntryStoreListener; import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
@ -74,7 +77,7 @@ import org.eclipse.core.runtime.jobs.Job;
* @author alain * @author alain
* *
*/ */
public class PathEntryManager implements IPathEntryStoreListener, IElementChangedListener { public class PathEntryManager implements IPathEntryStoreListener, IElementChangedListener, IPathEntryContainerExtensionListener {
// PathEntry extension // PathEntry extension
public final static String PATHENTRY_STORE_ID = "PathEntryStore"; //$NON-NLS-1$ public final static String PATHENTRY_STORE_ID = "PathEntryStore"; //$NON-NLS-1$
@ -861,6 +864,12 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
oldContainer.notifyAll(); oldContainer.notifyAll();
} }
} }
if (oldContainer instanceof IPathEntryContainerExtension) {
((IPathEntryContainerExtension)oldContainer).removeContainerListener(this);
}
if (container instanceof IPathEntryContainerExtension) {
((IPathEntryContainerExtension)container).addContainerListener(this);
}
} }
private synchronized void containerRemove(ICProject cproject) { private synchronized void containerRemove(ICProject cproject) {
@ -1404,6 +1413,45 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
return false; return false;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IPathEntryContainerExtensionListener#pathEntryContainerChanged(org.eclipse.cdt.core.model.PathEntryContainerChanged[])
*/
public void pathEntryContainerChanged(PathEntryContainerChanged[] events) {
ArrayList list = new ArrayList(events.length);
for (int i = 0; i < events.length; ++i) {
PathEntryContainerChanged event = events[i];
ICElement celement = CoreModel.getDefault().create(event.getPath());
if (celement != null) {
if (celement instanceof IOpenable) {
try {
((IOpenable)celement).close();
} catch (CModelException e) {
// ignore.
}
}
int flag =0;
if (event.isIncludeChange()) {
flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
} else if (event.isMacroChange()) {
flag = ICElementDelta.F_CHANGED_PATHENTRY_MACRO;
}
CElementDelta delta = new CElementDelta(celement.getCModel());
delta.changed(celement, flag);
list.add(delta);
}
}
if (list.size() > 0) {
ICElementDelta[] deltas = new ICElementDelta[list.size()];
list.toArray(deltas);
CModelManager manager = CModelManager.getDefault();
for (int i = 0; i < deltas.length; i++) {
manager.registerCModelDelta(deltas[i]);
}
manager.fire(ElementChangedEvent.POST_CHANGE);
}
}
protected IPathEntry cloneEntry(IPath rpath, IPathEntry entry) { protected IPathEntry cloneEntry(IPath rpath, IPathEntry entry) {
// get the path // get the path