mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 310837: Updating header from referenced project.
This commit is contained in:
parent
7ea9474e1b
commit
8158ebaadb
3 changed files with 27 additions and 7 deletions
|
@ -17,6 +17,7 @@ import java.net.URI;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.core.filesystem.URIUtil;
|
import org.eclipse.core.filesystem.URIUtil;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,4 +37,10 @@ public class ExternalTranslationUnit extends TranslationUnit {
|
||||||
super(parent, uri, contentTypeID);
|
super(parent, uri, contentTypeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A file included from a different project can still belong to a (non-CDT) project
|
||||||
|
*/
|
||||||
|
public void setResource(IFile file) {
|
||||||
|
resource= file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,11 @@ import org.eclipse.cdt.core.model.CoreModel;
|
||||||
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.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -98,23 +102,32 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (haveProject && (fUpdateOptions & IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT) != 0) {
|
if (haveProject && (fUpdateOptions & IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT) != 0) {
|
||||||
|
final String projectPrefix= project.getProject().getFullPath().toString() + IPath.SEPARATOR;
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(project);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(project);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexFile[] files= index.getAllFiles();
|
IIndexFile[] files= index.getAllFiles();
|
||||||
for (IIndexFile indexFile : files) {
|
for (IIndexFile indexFile : files) {
|
||||||
IIndexFileLocation floc= indexFile.getLocation();
|
IIndexFileLocation floc= indexFile.getLocation();
|
||||||
if (floc.getFullPath() == null) {
|
final String fullPath = floc.getFullPath();
|
||||||
IPath path= IndexLocationFactory.getPath(floc);
|
if (fullPath == null || !fullPath.startsWith(projectPrefix)) {
|
||||||
|
IPath path= IndexLocationFactory.getAbsolutePath(floc);
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
ITranslationUnit tu= CoreModel.getDefault().createTranslationUnitFrom(project, path);
|
ITranslationUnit tu= CoreModel.getDefault().createTranslationUnitFrom(project, path);
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
|
if (fullPath != null) {
|
||||||
|
if (tu instanceof ExternalTranslationUnit) {
|
||||||
|
IResource file= ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath);
|
||||||
|
if (file instanceof IFile) {
|
||||||
|
((ExternalTranslationUnit) tu).setResource((IFile) file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
set.add(tu);
|
set.add(tu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,15 +42,13 @@ import org.eclipse.core.runtime.content.IContentType;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
/**
|
|
||||||
* mstodo
|
|
||||||
*/
|
|
||||||
private static final AbstractLanguage[] NO_LANGUAGE = new AbstractLanguage[0];
|
private static final AbstractLanguage[] NO_LANGUAGE = new AbstractLanguage[0];
|
||||||
private final ICProject fCProject;
|
private final ICProject fCProject;
|
||||||
private final HashMap<String, IIndexFileLocation> fIflCache;
|
private final HashMap<String, IIndexFileLocation> fIflCache;
|
||||||
private final FileExistsCache fExistsCache;
|
private final FileExistsCache fExistsCache;
|
||||||
private AbstractLanguage fLangC;
|
private AbstractLanguage fLangC;
|
||||||
private AbstractLanguage fLangCpp;
|
private AbstractLanguage fLangCpp;
|
||||||
|
private String fProjectPrefix;
|
||||||
|
|
||||||
public ProjectIndexerInputAdapter(ICProject cproject) {
|
public ProjectIndexerInputAdapter(ICProject cproject) {
|
||||||
this(cproject, true);
|
this(cproject, true);
|
||||||
|
@ -58,6 +56,7 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
|
|
||||||
public ProjectIndexerInputAdapter(ICProject cproject, boolean useCache) {
|
public ProjectIndexerInputAdapter(ICProject cproject, boolean useCache) {
|
||||||
fCProject= cproject;
|
fCProject= cproject;
|
||||||
|
fProjectPrefix= cproject.getProject().getFullPath().toString() + IPath.SEPARATOR;
|
||||||
if (useCache) {
|
if (useCache) {
|
||||||
fIflCache= new HashMap<String, IIndexFileLocation>();
|
fIflCache= new HashMap<String, IIndexFileLocation>();
|
||||||
fExistsCache= new FileExistsCache();
|
fExistsCache= new FileExistsCache();
|
||||||
|
@ -226,7 +225,8 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBePartOfSDK(IIndexFileLocation ifl) {
|
public boolean canBePartOfSDK(IIndexFileLocation ifl) {
|
||||||
return ifl.getFullPath() == null;
|
final String fullPath = ifl.getFullPath();
|
||||||
|
return fullPath == null || !fullPath.startsWith(fProjectPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue