# HG changeset patch # User Vladimir Kvashin # Date 1342646100 -14400 # Node ID 74fd7f6f2bac823f147f99db1d33124e178c9ece # Parent cd13abeb21a6d4ab2f8bbcc0d21cabd19d074ec8 fixing #215291 - Code model cache should be relocatable diff --git a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/LibProjectImpl.java b/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/LibProjectImpl.java --- a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/LibProjectImpl.java +++ b/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/LibProjectImpl.java @@ -49,6 +49,7 @@ import org.netbeans.modules.cnd.api.model.CsmProject; import org.netbeans.modules.cnd.api.model.CsmUID; import org.netbeans.modules.cnd.api.project.NativeFileItem; +import org.netbeans.modules.cnd.apt.utils.APTSerializeUtils; import org.netbeans.modules.cnd.modelimpl.debug.DiagnosticExceptoins; import org.netbeans.modules.cnd.utils.cache.FilePathCache; import org.netbeans.modules.cnd.modelimpl.debug.TraceFlags; @@ -198,12 +199,12 @@ public void write(RepositoryDataOutput aStream) throws IOException { super.write(aStream); assert this.includePath != null; - PersistentUtils.writeUTF(includePath, aStream); + APTSerializeUtils.writeFileNameIndex(includePath, aStream, getUnitId()); } public LibProjectImpl(RepositoryDataInput aStream) throws IOException { super(aStream); - this.includePath = PersistentUtils.readUTF(aStream, FilePathCache.getManager()); + this.includePath = APTSerializeUtils.readFileNameIndex(aStream, FilePathCache.getManager(), getUnitId()); assert this.includePath != null; setPlatformProject(this.includePath); } diff --git a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/ProjectBase.java b/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/ProjectBase.java --- a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/ProjectBase.java +++ b/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/csm/core/ProjectBase.java @@ -100,6 +100,7 @@ import org.netbeans.modules.cnd.apt.support.IncludeDirEntry; import org.netbeans.modules.cnd.apt.support.PostIncludeData; import org.netbeans.modules.cnd.apt.support.StartEntry; +import org.netbeans.modules.cnd.apt.utils.APTSerializeUtils; import org.netbeans.modules.cnd.apt.utils.APTUtils; import org.netbeans.modules.cnd.debug.DebugUtils; import org.netbeans.modules.cnd.modelimpl.cache.impl.WeakContainer; @@ -167,7 +168,9 @@ protected ProjectBase(ModelImpl model, FileSystem fs, Object platformProject, String name) { namespaces = new ConcurrentHashMap>(); this.uniqueName = getUniqueName(fs, platformProject); - RepositoryUtils.openUnit(createProjectKey(fs, platformProject)); + Key key = createProjectKey(fs, platformProject); + RepositoryUtils.openUnit(key); + unitId = key.getUnitId(); setStatus(Status.Initial); this.name = ProjectNameCache.getManager().getString(name); this.fileSystem = fs; @@ -3362,6 +3365,7 @@ private final AtomicBoolean disposing = new AtomicBoolean(false); private final ReadWriteLock disposeLock = new ReentrantReadWriteLock(); private final CharSequence uniqueName; + private final int unitId; private final Map> namespaces; private final Key classifierStorageKey; @@ -3399,11 +3403,12 @@ @Override public void write(RepositoryDataOutput aStream) throws IOException { assert aStream != null; + aStream.writeInt(unitId); PersistentUtils.writeFileSystem(fileSystem, aStream); UIDObjectFactory aFactory = UIDObjectFactory.getDefaultFactory(); assert aFactory != null; assert this.name != null; - PersistentUtils.writeUTF(name, aStream); + APTSerializeUtils.writeFileNameIndex(name, aStream, unitId); //PersistentUtils.writeUTF(RepositoryUtils.getUnitName(getUID()), aStream); aFactory.writeUID(this.globalNamespaceUID, aStream); aFactory.writeStringToUIDMap(this.namespaces, aStream, false); @@ -3414,12 +3419,12 @@ ProjectComponent.writeKey(classifierStorageKey, aStream); this.includedFileContainer.write(aStream); - PersistentUtils.writeUTF(this.uniqueName, aStream); + APTSerializeUtils.writeFileNameIndex(this.uniqueName, aStream, unitId); aStream.writeBoolean(hasFileSystemProblems); } protected ProjectBase(RepositoryDataInput aStream) throws IOException { - + unitId = aStream.readInt(); fileSystem = PersistentUtils.readFileSystem(aStream); sysAPTData = APTSystemStorage.getInstance(); userPathStorage = new APTIncludePathStorage(); @@ -3430,7 +3435,7 @@ UIDObjectFactory aFactory = UIDObjectFactory.getDefaultFactory(); assert aFactory != null : "default UID factory can not be bull"; - this.name = PersistentUtils.readUTF(aStream, ProjectNameCache.getManager()); + this.name = APTSerializeUtils.readFileNameIndex(aStream, ProjectNameCache.getManager(), unitId); assert this.name != null : "project name can not be null"; //CharSequence unitName = PersistentUtils.readUTF(aStream, DefaultCache.getManager()); @@ -3464,7 +3469,7 @@ includedFileContainer = new IncludedFileContainer(this, aStream); - uniqueName = PersistentUtils.readUTF(aStream, ProjectNameCache.getManager()); + uniqueName = APTSerializeUtils.readFileNameIndex(aStream, ProjectNameCache.getManager(), unitId); assert uniqueName != null : "uniqueName can not be null"; this.model = (ModelImpl) CsmModelAccessor.getModel(); @@ -3473,6 +3478,10 @@ this.hasFileSystemProblems = aStream.readBoolean(); } + protected int getUnitId() { + return unitId; + } + private final WeakContainer weakDeclarationContainer; private DeclarationContainerProject getDeclarationsSorage() { DeclarationContainerProject dc = weakDeclarationContainer.getContainer(); diff --git a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/repository/RepositoryUtils.java b/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/repository/RepositoryUtils.java --- a/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/repository/RepositoryUtils.java +++ b/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/repository/RepositoryUtils.java @@ -78,7 +78,7 @@ /** * the version of the persistency mechanism */ - private static int CURRENT_VERSION_OF_PERSISTENCY = 132; + private static int CURRENT_VERSION_OF_PERSISTENCY = 133; // /** temporary flag, to be removed as soon as relocatable repository is achieved */ // public static final boolean RELOCATABLE = true;