mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 20:35:38 +02:00
Move the get/set PathEntryStore to the CoreModel
so we can sync the access
This commit is contained in:
parent
14c5c93240
commit
db634def0a
5 changed files with 61 additions and 50 deletions
|
@ -734,6 +734,27 @@ public class CoreModel {
|
|||
return pathEntryManager.getPathEntryContainerInitializer(containerID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the IPathEntryStore of the project.
|
||||
*
|
||||
* @param project
|
||||
* @return
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static IPathEntryStore getPathEntryStore(IProject project) throws CoreException {
|
||||
return pathEntryManager.getPathEntryStore(project, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set in the map the store, but not persisted.
|
||||
*
|
||||
* @param project
|
||||
* @param store
|
||||
*/
|
||||
public static void setPathEntryStore(IProject project, IPathEntryStore store) {
|
||||
pathEntryManager.setPathEntryStore(project, store);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a given path entries for a project, using the following rules:
|
||||
* <ul>
|
||||
|
@ -783,14 +804,6 @@ public class CoreModel {
|
|||
return pathEntryManager.validatePathEntry(cProject, entry, checkSourceAttachment, recurseInContainers);
|
||||
}
|
||||
|
||||
public static IPathEntryStore getPathEntryStore(IProject project) throws CoreException {
|
||||
return CCorePlugin.getDefault().getPathEntryStore(project);
|
||||
}
|
||||
|
||||
public static void setPathEntryStore(IProject project, IPathEntryStore store) {
|
||||
pathEntryManager.setPathEntryStore(project, store);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the singleton.
|
||||
*/
|
||||
|
|
|
@ -18,6 +18,8 @@ import java.util.HashMap;
|
|||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
|
@ -68,6 +70,10 @@ import org.eclipse.core.runtime.jobs.Job;
|
|||
*/
|
||||
public class PathEntryManager implements IPathEntryStoreListener, IElementChangedListener {
|
||||
|
||||
// PathEntry extension
|
||||
public final static String PATHENTRY_STORE_ID = "PathEntryStore"; //$NON-NLS-1$
|
||||
public final static String PATHENTRY_STORE_UNIQ_ID = CCorePlugin.PLUGIN_ID + "." + PATHENTRY_STORE_ID; //$NON-NLS-1$
|
||||
|
||||
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "PathEntryContainerInitializer"; //$NON-NLS-1$
|
||||
/**
|
||||
* An empty array of strings indicating that a project doesn't have any prerequesite projects.
|
||||
|
@ -949,16 +955,45 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
}
|
||||
}
|
||||
|
||||
private synchronized IPathEntryStore getPathEntryStore(IProject project, boolean create) throws CoreException {
|
||||
public synchronized IPathEntryStore getPathEntryStore(IProject project, boolean create) throws CoreException {
|
||||
IPathEntryStore store = (IPathEntryStore)storeMap.get(project);
|
||||
if (store == null && create == true) {
|
||||
store = CCorePlugin.getDefault().getPathEntryStore(project);
|
||||
store = createPathEntryStore(project);
|
||||
storeMap.put(project, store);
|
||||
store.addPathEntryStoreListener(this);
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
public IPathEntryStore createPathEntryStore(IProject project) throws CoreException {
|
||||
IPathEntryStore store = null;
|
||||
if (project != null) {
|
||||
try {
|
||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
||||
if (cdesc != null) {
|
||||
ICExtensionReference[] cextensions = cdesc.get(PATHENTRY_STORE_UNIQ_ID, true);
|
||||
if (cextensions.length > 0) {
|
||||
for (int i = 0; i < cextensions.length; i++) {
|
||||
try {
|
||||
store = (IPathEntryStore) cextensions[i].createExtension();
|
||||
break;
|
||||
} catch (ClassCastException e) {
|
||||
//
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// ignore since we fall back to a default....
|
||||
}
|
||||
}
|
||||
if (store == null) {
|
||||
store = new DefaultPathEntryStore(project);
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryChangedEvent)
|
||||
*/
|
||||
|
|
|
@ -24,14 +24,12 @@ import org.eclipse.cdt.core.model.CoreModel;
|
|||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.resources.IConsole;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
||||
import org.eclipse.cdt.core.resources.ScannerProvider;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.CDTLogWriter;
|
||||
import org.eclipse.cdt.internal.core.CDescriptorManager;
|
||||
import org.eclipse.cdt.internal.core.model.BufferManager;
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.cdt.internal.core.model.DefaultPathEntryStore;
|
||||
import org.eclipse.cdt.internal.core.model.DeltaProcessor;
|
||||
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
||||
import org.eclipse.cdt.internal.core.model.Util;
|
||||
|
@ -77,9 +75,6 @@ public class CCorePlugin extends Plugin {
|
|||
|
||||
public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
|
||||
|
||||
// PathEntry extension
|
||||
public final static String PATHENTRY_STORE_ID = "PathEntryStore"; //$NON-NLS-1$
|
||||
public final static String PATHENTRY_STORE_UNIQ_ID = PLUGIN_ID + "." + PATHENTRY_STORE_ID; //$NON-NLS-1$
|
||||
// default store for pathentry
|
||||
public final static String DEFAULT_PATHENTRY_STORE_ID = PLUGIN_ID + ".cdtPathEntryStore"; //$NON-NLS-1$
|
||||
|
||||
|
@ -594,37 +589,6 @@ public class CCorePlugin extends Plugin {
|
|||
return parser;
|
||||
}
|
||||
|
||||
public IPathEntryStore getPathEntryStore(IProject project) throws CoreException {
|
||||
IPathEntryStore store = null;
|
||||
if (project != null) {
|
||||
try {
|
||||
ICDescriptor cdesc = getCProjectDescription(project);
|
||||
ICExtensionReference[] cextensions = cdesc.get(PATHENTRY_STORE_UNIQ_ID, true);
|
||||
if (cextensions.length > 0) {
|
||||
for (int i = 0; i < cextensions.length; i++) {
|
||||
try {
|
||||
store = (IPathEntryStore) cextensions[i].createExtension();
|
||||
break;
|
||||
} catch (ClassCastException e) {
|
||||
//
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// ignore since we fall back to a default....
|
||||
}
|
||||
}
|
||||
if (store == null) {
|
||||
store = getDefaultPathEntryStore(project);
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
public IPathEntryStore getDefaultPathEntryStore(IProject project) throws CoreException {
|
||||
return new DefaultPathEntryStore(project);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file type object corresponding to the provided
|
||||
* file name.
|
||||
|
|
|
@ -10,7 +10,6 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
|||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
@ -66,7 +65,7 @@ public class CPathPropertyPage extends PropertyPage implements IStatusChangeList
|
|||
result = createForClosedProject(parent);
|
||||
} else {
|
||||
try {
|
||||
fStore = CCorePlugin.getDefault().getPathEntryStore(getProject());
|
||||
fStore = CoreModel.getPathEntryStore(getProject());
|
||||
fStore.addPathEntryStoreListener(this);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
|||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStore;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
|
||||
|
@ -59,7 +59,7 @@ public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatus
|
|||
result = createForClosedProject(parent);
|
||||
} else {
|
||||
try {
|
||||
fStore = CCorePlugin.getDefault().getPathEntryStore(getProject());
|
||||
fStore = CoreModel.getPathEntryStore(getProject());
|
||||
fStore.addPathEntryStoreListener(this);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue