mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Store files of project with project-relative paths, bug 239472.
This commit is contained in:
parent
58dced96be
commit
ae80725f3f
4 changed files with 50 additions and 27 deletions
|
@ -104,7 +104,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
private static int version(int major, int minor) {
|
||||
return major << 16 + minor;
|
||||
}
|
||||
public static final int MAJOR_VERSION = 70;
|
||||
public static final int MAJOR_VERSION = 72;
|
||||
public static final int MINOR_VERSION = 0; // minor versions must be compatible
|
||||
|
||||
public static final int CURRENT_VERSION= version(MAJOR_VERSION, MINOR_VERSION);
|
||||
|
@ -178,6 +178,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
*
|
||||
* 70.0 - cleaned up templates, fixes bug 236197
|
||||
* 71.0 - proper support for anonymous unions, bug 206450
|
||||
* 72.0 - store project-relative paths for resources that belong to the project, bug 239472
|
||||
*/
|
||||
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
|
|
|
@ -29,10 +29,10 @@ import java.util.zip.ZipOutputStream;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||
import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMProjectIndexLocationConverter;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
|
@ -89,7 +89,7 @@ public class TeamPDOMExportOperation implements IWorkspaceRunnable {
|
|||
checkMonitor(monitor);
|
||||
|
||||
// create index
|
||||
IIndexLocationConverter converter= new ResourceContainerRelativeLocationConverter(ResourcesPlugin.getWorkspace().getRoot());
|
||||
IIndexLocationConverter converter= new PDOMProjectIndexLocationConverter(fProject.getProject(), true);
|
||||
pdomManager.exportProjectPDOM(fProject, tmpPDOM, converter);
|
||||
checkMonitor(monitor);
|
||||
monitor.worked(5);
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.core.index.IndexFileLocation;
|
|||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
|
@ -28,11 +27,21 @@ import org.eclipse.core.runtime.Path;
|
|||
* The standard location converter used by the per-project PDOM
|
||||
*/
|
||||
public class PDOMProjectIndexLocationConverter implements IIndexLocationConverter {
|
||||
IWorkspaceRoot root;
|
||||
private static final String EXTERNAL = "<EXT>"; //$NON-NLS-1$
|
||||
private static final String WS = "<WS>"; //$NON-NLS-1$
|
||||
|
||||
final private IWorkspaceRoot fRoot;
|
||||
final private String fFullPathPrefix;
|
||||
final private boolean fIgnoreExternal;
|
||||
|
||||
public PDOMProjectIndexLocationConverter(IProject project) {
|
||||
this.root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
this(project, false);
|
||||
}
|
||||
|
||||
public PDOMProjectIndexLocationConverter(IProject project, boolean ignoreWSExternal) {
|
||||
fRoot= (IWorkspaceRoot) project.getParent();
|
||||
fFullPathPrefix= project.getFullPath().toString() + IPath.SEPARATOR;
|
||||
fIgnoreExternal= ignoreWSExternal;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -47,13 +56,17 @@ public class PDOMProjectIndexLocationConverter implements IIndexLocationConverte
|
|||
} catch(URISyntaxException use) {
|
||||
}
|
||||
} else {
|
||||
fullPath= raw;
|
||||
final IPath path= new Path(raw);
|
||||
if (raw.startsWith(WS)) {
|
||||
fullPath= raw.substring(WS.length());
|
||||
} else {
|
||||
fullPath= fFullPathPrefix+raw;
|
||||
}
|
||||
final IPath path= new Path(fullPath);
|
||||
if (path.segmentCount() > 1) {
|
||||
IResource member= root.getFile(path);
|
||||
IResource member= fRoot.getFile(path);
|
||||
uri = member.getLocationURI();
|
||||
}
|
||||
}
|
||||
}
|
||||
return uri == null ? null : new IndexFileLocation(uri, fullPath);
|
||||
}
|
||||
|
||||
|
@ -61,12 +74,17 @@ public class PDOMProjectIndexLocationConverter implements IIndexLocationConverte
|
|||
* @see org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter#toRaw(java.net.URI)
|
||||
*/
|
||||
public String toInternalFormat(IIndexFileLocation location) {
|
||||
String result;
|
||||
if(location.getFullPath()!=null) {
|
||||
result = new Path(location.getFullPath()).toString();
|
||||
} else {
|
||||
result = EXTERNAL+location.getURI().toString();
|
||||
String fullPath= location.getFullPath();
|
||||
if(fullPath!=null) {
|
||||
if (fullPath.startsWith(fFullPathPrefix)) {
|
||||
return fullPath.substring(fFullPathPrefix.length());
|
||||
}
|
||||
return WS + fullPath;
|
||||
}
|
||||
return result;
|
||||
|
||||
if (fIgnoreExternal)
|
||||
return null;
|
||||
|
||||
return EXTERNAL+location.getURI().toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,16 +46,18 @@ public class EditorOpener {
|
|||
* Opens the editor selecting the given region.
|
||||
*/
|
||||
public static void open(IWorkbenchPage page, IFile file, IRegion region, long timestamp) {
|
||||
IEditorPart editor= null;
|
||||
if (timestamp == 0) {
|
||||
timestamp= file.getLocalTimeStamp();
|
||||
}
|
||||
try {
|
||||
editor= IDE.openEditor(page, file, false);
|
||||
} catch (PartInitException e) {
|
||||
CUIPlugin.log(e);
|
||||
}
|
||||
selectRegion(file.getFullPath(), region, timestamp, editor);
|
||||
if (file.getLocationURI() != null) {
|
||||
IEditorPart editor= null;
|
||||
if (timestamp == 0) {
|
||||
timestamp= file.getLocalTimeStamp();
|
||||
}
|
||||
try {
|
||||
editor= IDE.openEditor(page, file, false);
|
||||
} catch (PartInitException e) {
|
||||
CUIPlugin.log(e);
|
||||
}
|
||||
selectRegion(file.getFullPath(), region, timestamp, editor);
|
||||
}
|
||||
}
|
||||
|
||||
private static void selectRegion(IPath filebufferKey, IRegion region, long timestamp, IEditorPart editor) {
|
||||
|
@ -109,7 +111,9 @@ public class EditorOpener {
|
|||
if (tu != null) {
|
||||
IResource r= tu.getResource();
|
||||
if (r instanceof IFile) {
|
||||
EditorOpener.open(page, (IFile) r, region, timestamp);
|
||||
if (r.getLocationURI() != null) {
|
||||
EditorOpener.open(page, (IFile) r, region, timestamp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
IPath location= tu.getPath();
|
||||
|
|
Loading…
Add table
Reference in a new issue