mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46: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) {
|
private static int version(int major, int minor) {
|
||||||
return major << 16 + 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 MINOR_VERSION = 0; // minor versions must be compatible
|
||||||
|
|
||||||
public static final int CURRENT_VERSION= version(MAJOR_VERSION, MINOR_VERSION);
|
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
|
* 70.0 - cleaned up templates, fixes bug 236197
|
||||||
* 71.0 - proper support for anonymous unions, bug 206450
|
* 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;
|
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.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
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.ICProject;
|
||||||
import org.eclipse.cdt.core.model.LanguageManager;
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
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.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
@ -89,7 +89,7 @@ public class TeamPDOMExportOperation implements IWorkspaceRunnable {
|
||||||
checkMonitor(monitor);
|
checkMonitor(monitor);
|
||||||
|
|
||||||
// create index
|
// create index
|
||||||
IIndexLocationConverter converter= new ResourceContainerRelativeLocationConverter(ResourcesPlugin.getWorkspace().getRoot());
|
IIndexLocationConverter converter= new PDOMProjectIndexLocationConverter(fProject.getProject(), true);
|
||||||
pdomManager.exportProjectPDOM(fProject, tmpPDOM, converter);
|
pdomManager.exportProjectPDOM(fProject, tmpPDOM, converter);
|
||||||
checkMonitor(monitor);
|
checkMonitor(monitor);
|
||||||
monitor.worked(5);
|
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.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
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
|
* The standard location converter used by the per-project PDOM
|
||||||
*/
|
*/
|
||||||
public class PDOMProjectIndexLocationConverter implements IIndexLocationConverter {
|
public class PDOMProjectIndexLocationConverter implements IIndexLocationConverter {
|
||||||
IWorkspaceRoot root;
|
|
||||||
private static final String EXTERNAL = "<EXT>"; //$NON-NLS-1$
|
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) {
|
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)
|
/* (non-Javadoc)
|
||||||
|
@ -47,10 +56,14 @@ public class PDOMProjectIndexLocationConverter implements IIndexLocationConverte
|
||||||
} catch(URISyntaxException use) {
|
} catch(URISyntaxException use) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fullPath= raw;
|
if (raw.startsWith(WS)) {
|
||||||
final IPath path= new Path(raw);
|
fullPath= raw.substring(WS.length());
|
||||||
|
} else {
|
||||||
|
fullPath= fFullPathPrefix+raw;
|
||||||
|
}
|
||||||
|
final IPath path= new Path(fullPath);
|
||||||
if (path.segmentCount() > 1) {
|
if (path.segmentCount() > 1) {
|
||||||
IResource member= root.getFile(path);
|
IResource member= fRoot.getFile(path);
|
||||||
uri = member.getLocationURI();
|
uri = member.getLocationURI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,12 +74,17 @@ public class PDOMProjectIndexLocationConverter implements IIndexLocationConverte
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter#toRaw(java.net.URI)
|
* @see org.eclipse.cdt.internal.core.pdom.dom.IIndexLocationConverter#toRaw(java.net.URI)
|
||||||
*/
|
*/
|
||||||
public String toInternalFormat(IIndexFileLocation location) {
|
public String toInternalFormat(IIndexFileLocation location) {
|
||||||
String result;
|
String fullPath= location.getFullPath();
|
||||||
if(location.getFullPath()!=null) {
|
if(fullPath!=null) {
|
||||||
result = new Path(location.getFullPath()).toString();
|
if (fullPath.startsWith(fFullPathPrefix)) {
|
||||||
} else {
|
return fullPath.substring(fFullPathPrefix.length());
|
||||||
result = EXTERNAL+location.getURI().toString();
|
|
||||||
}
|
}
|
||||||
return result;
|
return WS + fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fIgnoreExternal)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return EXTERNAL+location.getURI().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class EditorOpener {
|
||||||
* Opens the editor selecting the given region.
|
* Opens the editor selecting the given region.
|
||||||
*/
|
*/
|
||||||
public static void open(IWorkbenchPage page, IFile file, IRegion region, long timestamp) {
|
public static void open(IWorkbenchPage page, IFile file, IRegion region, long timestamp) {
|
||||||
|
if (file.getLocationURI() != null) {
|
||||||
IEditorPart editor= null;
|
IEditorPart editor= null;
|
||||||
if (timestamp == 0) {
|
if (timestamp == 0) {
|
||||||
timestamp= file.getLocalTimeStamp();
|
timestamp= file.getLocalTimeStamp();
|
||||||
|
@ -57,6 +58,7 @@ public class EditorOpener {
|
||||||
}
|
}
|
||||||
selectRegion(file.getFullPath(), region, timestamp, editor);
|
selectRegion(file.getFullPath(), region, timestamp, editor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void selectRegion(IPath filebufferKey, IRegion region, long timestamp, IEditorPart editor) {
|
private static void selectRegion(IPath filebufferKey, IRegion region, long timestamp, IEditorPart editor) {
|
||||||
if (editor instanceof ITextEditor) {
|
if (editor instanceof ITextEditor) {
|
||||||
|
@ -109,8 +111,10 @@ public class EditorOpener {
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
IResource r= tu.getResource();
|
IResource r= tu.getResource();
|
||||||
if (r instanceof IFile) {
|
if (r instanceof IFile) {
|
||||||
|
if (r.getLocationURI() != null) {
|
||||||
EditorOpener.open(page, (IFile) r, region, timestamp);
|
EditorOpener.open(page, (IFile) r, region, timestamp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
IPath location= tu.getPath();
|
IPath location= tu.getPath();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue