mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Common method to compute string for PDOM versions.
This commit is contained in:
parent
2f974e0ef5
commit
bb834c4bb7
3 changed files with 11 additions and 11 deletions
|
@ -527,7 +527,7 @@ class MockStateIndexFragmentProvider extends MockStateIndexProvider implements I
|
|||
|
||||
fragments = new IIndexFragment[MockState.states.size()];
|
||||
for(int i=0; i<MockState.states.size(); i++) {
|
||||
fragments[i] = new MockPDOM("mock.test.index."+System.identityHashCode(this)+"."+i, ""+PDOM.MAJOR_VERSION+'.'+PDOM.MINOR_VERSION);
|
||||
fragments[i] = new MockPDOM("mock.test.index."+System.identityHashCode(this)+"."+i, PDOM.versionString(PDOM.CURRENT_VERSION));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,17 +96,22 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
*/
|
||||
public static final String FRAGMENT_PROPERTY_VALUE_FORMAT_ID= "org.eclipse.cdt.internal.core.pdom.PDOM"; //$NON-NLS-1$
|
||||
|
||||
public static int version(int major, int minor) {
|
||||
private static int version(int major, int minor) {
|
||||
return major << 16 + minor;
|
||||
}
|
||||
|
||||
public static final int MAJOR_VERSION = 57;
|
||||
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 MIN_SUPPORTED_VERSION= version(MAJOR_VERSION, 0);
|
||||
public static final int MAX_SUPPORTED_VERSION= version(MAJOR_VERSION+1, 0)-1;
|
||||
|
||||
|
||||
public static String versionString(int version) {
|
||||
final int major= version >> 16;
|
||||
final int minor= version & 0xffff;
|
||||
return "" + major + '.' + minor; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* PDOM internal format history
|
||||
*
|
||||
|
@ -241,10 +246,6 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
return locationConverter;
|
||||
}
|
||||
|
||||
public boolean isCurrentVersion() throws CoreException {
|
||||
return db.getVersion() == CURRENT_VERSION;
|
||||
}
|
||||
|
||||
public boolean isSupportedVersion() throws CoreException {
|
||||
final int version = db.getVersion();
|
||||
return version >= MIN_SUPPORTED_VERSION && version <= MAX_SUPPORTED_VERSION;
|
||||
|
@ -894,8 +895,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
return FRAGMENT_PROPERTY_VALUE_FORMAT_ID;
|
||||
}
|
||||
if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(propertyName)) {
|
||||
int version= db.getVersion();
|
||||
return ""+(version >> 16) + '.' + (version & 0xffff); //$NON-NLS-1$
|
||||
return PDOM.versionString(db.getVersion());
|
||||
}
|
||||
return new DBProperties(db, PROPERTIES).getProperty(propertyName);
|
||||
}
|
||||
|
|
|
@ -1172,7 +1172,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
version= (version << 8) + (b & 0xff);
|
||||
out.write(b);
|
||||
}
|
||||
if (version < PDOM.MIN_SUPPORTED_VERSION) {
|
||||
if (version < PDOM.MIN_SUPPORTED_VERSION || version > PDOM.MAX_SUPPORTED_VERSION) {
|
||||
final IStatus status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, 0, CCorePlugin.getResourceString("PDOMManager.unsupportedVersion"), null); //$NON-NLS-1$
|
||||
throw new CoreException(status);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue