diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java new file mode 100644 index 00000000000..a2e41c70274 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2007 Symbian Software Ltd. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Ferguson (Symbian) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.index.tests; + +import java.util.regex.Pattern; + +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.index.IIndexLinkage; +import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.internal.core.index.IIndexFragment; +import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; +import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; +import org.eclipse.cdt.internal.core.index.IIndexFragmentInclude; +import org.eclipse.cdt.internal.core.index.IIndexFragmentName; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * An empty index fragment implementation + * @since 4.0.1 + */ +public class EmptyIndexFragment implements IIndexFragment { + public void acquireReadLock() throws InterruptedException {} + + public IIndexFragmentBinding adaptBinding(IBinding binding) + throws CoreException { + return null; + } + + public IIndexFragmentBinding adaptBinding(IIndexFragmentBinding proxy) + throws CoreException { + return null; + } + + public IIndexFragmentBinding findBinding(IASTName astName) throws CoreException { + return null; + } + + public IIndexFragmentBinding[] findBindings(Pattern[] patterns, + boolean isFullyQualified, IndexFilter filter, + IProgressMonitor monitor) throws CoreException { + return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; + } + + public IIndexFragmentBinding[] findBindings(char[][] names, + IndexFilter filter, IProgressMonitor monitor) throws CoreException { + return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; + } + + public IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix, + boolean filescope, IndexFilter filter, IProgressMonitor monitor) + throws CoreException { + return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; + } + + public IIndexFragmentInclude[] findIncludedBy(IIndexFragmentFile file) + throws CoreException { + return IIndexFragmentInclude.EMPTY_FRAGMENT_INCLUDES_ARRAY; + } + + public IIndexFragmentName[] findNames(IIndexFragmentBinding binding, + int flags) throws CoreException { + return IIndexFragmentName.EMPTY_NAME_ARRAY; + } + + public long getCacheHits() { + return 0; + } + + public long getCacheMisses() { + return 0; + } + + public IIndexFragmentFile getFile(IIndexFileLocation location) + throws CoreException { + return null; + } + + public long getLastWriteAccess() { + return 0; + } + + public IIndexLinkage[] getLinkages() { + return IIndexLinkage.EMPTY_INDEX_LINKAGE_ARRAY; + } + + public String getProperty(String key) throws CoreException { + if(IIndexFragment.PROPERTY_FRAGMENT_ID.equals(key)) { + return "org.eclipse.cdt.internal.core.index.EmptyIndexFragment"; //$NON-NLS-1$ + } + if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(key)) { + return "org.eclipse.cdt.internal.core.index.EmptyIndexFragmentFormat"; //$NON-NLS-1$ + } + if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(key)) { + return "0"; //$NON-NLS-1$ + } + return null; + } + + public void releaseReadLock() {} + public void resetCacheCounters() {} +} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java index 0859add59cf..8d2df68f928 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java @@ -11,10 +11,6 @@ package org.eclipse.cdt.internal.index.tests; import java.io.File; -import java.lang.reflect.Array; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -55,6 +51,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.provider.IIndexFragmentProvider; import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager; +import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOMManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; @@ -63,6 +60,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.osgi.service.resolver.VersionRange; /** * Example usage and test for IIndexProvider @@ -76,6 +74,14 @@ public class IndexProviderManagerTest extends IndexTestBase { final static Class DP5= Providers.Dummy5.class; final static Class[] DPS= new Class[] {DP4, DP2, DP1, DP3, DP5}; + /* + * Fictional compatibility ranges for testing + */ + final static VersionRange VERSION_400= new VersionRange("36"); + final static VersionRange VERSION_401= new VersionRange("[36,37]"); + final static VersionRange VERSION_405= new VersionRange("[37,39]"); + final static VersionRange VERSION_502= new VersionRange("[89,91]"); + final CCorePlugin core= CCorePlugin.getDefault(); public IndexProviderManagerTest() { @@ -86,6 +92,11 @@ public class IndexProviderManagerTest extends IndexTestBase { return suite(IndexProviderManagerTest.class); } + protected void tearDown() throws Exception { + IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager(); + ipm.reset(); ipm.startup(); + } + public void testProvider_SimpleLifeCycle_200958() throws Exception { for(int i=0; inull, if no such file exists. - * This method may only return files that are actually managed by this fragement. + * This method may only return files that are actually managed by this fragment. * @param location the IIndexFileLocation representing the location of the file - * @return the file for the location + * @return the file for the location, or null if the file is not present in the index * @throws CoreException */ IIndexFragmentFile getFile(IIndexFileLocation location) throws CoreException; @@ -167,11 +184,17 @@ public interface IIndexFragment { /** * Read the named property in this fragment. All fragments are expected to return a non-null value for - *
PROPERTY_FRAGMENT_ID
+ * * @param key a case-sensitive identifier for a property, or null * @return the value associated with the key, or null if either no such property is set, or the specified key was null * @throws CoreException * @see IIndexFragment#PROPERTY_FRAGMENT_ID + * @see IIndexFragment#PROPERTY_FRAGMENT_FORMAT_ID + * @see IIndexFragment#PROPERTY_FRAGMENT_FORMAT_VERSION */ public String getProperty(String propertyName) throws CoreException; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java index aadc4ed83eb..0a134b6dc9e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/IndexProviderManager.java @@ -13,11 +13,12 @@ package org.eclipse.cdt.internal.core.index.provider; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.provider.IIndexProvider; @@ -28,31 +29,70 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IElementChangedListener; +import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.internal.core.index.IIndexFragment; +import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; - +import org.eclipse.core.runtime.Status; +import org.eclipse.osgi.service.resolver.VersionRange; +import org.osgi.framework.Version; /** * The IndexProviderManager is responsible for maintaining the set of index * fragments contributed via the CIndex extension point. *

* It is an internal class, and is public only for testing purposes. + * @since 4.0 + */ +/* + * For bug 196338, the role of this class was extended. It now has responsibility to + * look at the pool of fragments available depending on their IDs, and select the most appropriate. + * The following rules are applied + * (i) If its not compatible, don't use it + * (ii) If multiple are compatible, pick the latest + * + * A warning is logged if a fragment is contributed which is incompatible, and for which there is + * no compatible equivalent. */ public final class IndexProviderManager implements IElementChangedListener { - public static final String READ_ONLY_PDOM_PROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$ - private IIndexFragmentProvider[] allProviders= {}; - private Map provisionMap= new HashMap(); + private static final String ELEMENT_RO_PDOMPROVIDER= "ReadOnlyPDOMProvider"; //$NON-NLS-1$ + private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$ + + private IIndexFragmentProvider[] allProviders; + private Map/**/ provisionMap; + private Set/**/ compatibleFragmentUnavailable; + private VersionRange pdomVersionRange; public IndexProviderManager() { + reset(); + } + + /** + * Note: This method should not be called by clients for purposes other than testing + */ + public void reset() { + reset(new VersionRange("["+PDOM.MIN_SUPPORTED_VERSION+','+PDOM.CURRENT_VERSION+']')); //$NON-NLS-1$ } + /** + * Note: This method should not be called by clients for purposes other than testing + * @param pdomVersionRange + */ + public void reset(VersionRange pdomVersionRange) { + this.allProviders= new IIndexFragmentProvider[0]; + this.provisionMap= new HashMap(); + this.pdomVersionRange= pdomVersionRange; + this.compatibleFragmentUnavailable= new HashSet(); + } + public void startup() { List providers = new ArrayList(); IExtensionRegistry registry = Platform.getExtensionRegistry(); @@ -63,8 +103,9 @@ public final class IndexProviderManager implements IElementChangedListener { try { IConfigurationElement[] ce = extension.getConfigurationElements(); for(int j=0; j custom IIndexFragment implementation) + * changes are coped with. + */ + } + } else { + id2fragment.put(cid, candidate); + } + } else { + if(existing==null) { + id2fragment.put(cid, null); // signifies candidate is unusable + } + } } /** - * This is only public for test purposes + * Note: This method should not be called for purposes other than testing * @param provider */ public void addIndexProvider(IIndexProvider provider) { @@ -131,6 +269,20 @@ public final class IndexProviderManager implements IElementChangedListener { allProviders = newAllProviders; } + /** + * Removes the specified provider by object identity + * Note: This method should not be called for purposes other than testing + * @param provider + */ + public void removeIndexProvider(IIndexProvider provider) { + ArrayUtil.remove(allProviders, provider); + if(allProviders[allProviders.length-1]==null) { + IIndexFragmentProvider[] newAllProviders = new IIndexFragmentProvider[allProviders.length-1]; + System.arraycopy(allProviders, 0, newAllProviders, 0, allProviders.length-1); + allProviders= newAllProviders; + } + } + private boolean providesForProject(IIndexProvider provider, IProject project) { List key = new ArrayList(); key.add(provider); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/Messages.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/Messages.java index fe1cf9091f3..f448a387f74 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/Messages.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/Messages.java @@ -15,6 +15,7 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.index.provider.messages"; //$NON-NLS-1$ public static String IndexProviderManager_0; + public static String IndexProviderManager_NoCompatibleFragmentsAvailable; public static String OfflinePDOMProviderBridge_UnsupportedUsage; public static String PDOMCache_VersionTooOld; static { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/PDOMCache.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/PDOMCache.java index 382a7a0821b..7b56eef267c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/PDOMCache.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/PDOMCache.java @@ -12,11 +12,8 @@ package org.eclipse.cdt.internal.core.index.provider; import java.io.File; -import java.text.MessageFormat; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndexLocationConverter; @@ -29,17 +26,15 @@ import org.eclipse.core.runtime.IPath; * Internal singleton map maintained for non-project PDOM objects */ class PDOMCache { - private Map/**/ path2pdom; // gives the pdom for a particular path - private Set/**/ versionMismatch; - + private Map/**/ path2pdom; // gives the PDOM for a particular path + private static PDOMCache singleton; private static Object singletonMutex = new Object(); private PDOMCache() { this.path2pdom = new HashMap(); - this.versionMismatch = new HashSet(); } - + /** * Returns the instance of the cache * @return @@ -54,48 +49,30 @@ class PDOMCache { } /** - * Returns the mapped pdom for the path specified, if such a pdom is not already known about + * Returns the mapped PDOM for the path specified, if such a pdom is not already known about * then one is created using the location converter specified. * @param path * @param converter - * @return a pdom instance or null if the pdom version was too old + * @return a PDOM instance or null if the PDOM version was too old */ public PDOM getPDOM(IPath path, IIndexLocationConverter converter) { PDOM result= null; File file = path.toFile(); - if(!versionMismatch.contains(file)) { - synchronized(path2pdom) { - if(path2pdom.containsKey(file)) { - result = (PDOM) path2pdom.get(file); + synchronized(path2pdom) { + if(path2pdom.containsKey(file)) { + result = (PDOM) path2pdom.get(file); + } + if(result==null) { + try { + result = new PDOM(file, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); + path2pdom.put(file, result); + } catch(CoreException ce) { + CCorePlugin.log(ce); } - if(result==null) { - try { - result = new PDOM(file, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); - - result.acquireReadLock(); - try { - if(!result.isSupportedVersion()) { - versionMismatch.add(file); - String msg= MessageFormat.format(Messages.PDOMCache_VersionTooOld, new Object[] {file}); - CCorePlugin.log(msg); - return null; - } else { - path2pdom.put(file, result); - } - } finally { - result.releaseReadLock(); - } - } catch(CoreException ce) { - CCorePlugin.log(ce); - } catch(InterruptedException ie) { - CCorePlugin.log(ie); - } - } - } } return result; } -} +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/messages.properties b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/messages.properties index a0e7f83d6c8..87063621795 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/messages.properties +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/provider/messages.properties @@ -11,3 +11,4 @@ IndexProviderManager_0=Ignoring unrecognized implementation of IIndexProvider contributed by {0} OfflinePDOMProviderBridge_UnsupportedUsage=Unsupported usage of IOfflinePDOMProvider PDOMCache_VersionTooOld=External index (PDOM) version is not supported: {0} +IndexProviderManager_NoCompatibleFragmentsAvailable=No compatible index fragment found for fragment id: {0} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index 47fe62dd09c..65df7b909e0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -73,47 +73,60 @@ import org.eclipse.core.runtime.Status; public class PDOM extends PlatformObject implements IIndexFragment, IPDOM { protected Database db; + /** + * Identifier for PDOM format + * @see IIndexFragment#PROPERTY_FRAGMENT_FORMAT_ID + */ + public static final String FRAGMENT_PROPERTY_VALUE_FORMAT_ID= "org.eclipse.cdt.internal.core.pdom.PDOM"; //$NON-NLS-1$ + public static final int CURRENT_VERSION = 37; public static final int MIN_SUPPORTED_VERSION= 36; public static final int MIN_VERSION_TO_WRITE_NESTED_BINDINGS_INDEX= 37; // to be removed in 4.1 - // 0 - the beginning of it all - // 1 - first change to kick off upgrades - // 2 - added file inclusions - // 3 - added macros and change string implementation - // 4 - added parameters in C++ - // 5 - added types and restructured nodes a bit - // 6 - function style macros. - // 7 - class key - // 8 - enumerators - // 9 - base classes - // 10 - typedefs, types on C++ variables - // 11 - changed how members work - // 12 - one more change for members (is-a list -> has-a list) - // 13 - CV-qualifiers, storage class specifiers, function/method annotations - // 14 - added timestamps for files (bug 149571) - // 15 - fixed offsets for pointer types and qualifier types and PDOMCPPVariable (bug 160540). - // 16 - have PDOMCPPField store type information, and PDOMCPPNamespaceAlias store what it is aliasing - // 17 - use single linked list for names in file, adds a link to enclosing definition name. - // 18 - distinction between c-unions and c-structs. - // 19 - alter representation of paths in the pdom (162172) - // 20 - add pointer to member types, array types, return types for functions - // 21 - change representation of paths in the pdom (167549) - // 22 - fix inheritance relations (167396) - // 23 - types on c-variables, return types on c-functions - // 24 - file local scopes (161216) - // 25 - change ordering of bindings (175275) - // 26 - add properties storage - // 27 - templates: classes, functions, limited nesting support, only template type parameters - // 28 - templates: class instance/specialization base classes - // 29 - includes: fixed modeling of unresolved includes (180159) - // 30 - templates: method/constructor templates, typedef specializations - // 31 - macros: added file locations - // 32 - support stand-alone function types (181936) - // 33 - templates: constructor instances - // 34 - fix for base classes represented by qualified names (183843) - // 35 - add scanner configuration hash-code (62366) - // 36 - changed chunk size back to 4K (184892) - // 37 - added index for nested bindings (189811), compatible with version 36. + + /* + * PDOM internal format history + * + * #x# = the version was used in an official release + * + * 0 - the beginning of it all + * 1 - first change to kick off upgrades + * 2 - added file inclusions + * 3 - added macros and change string implementation + * 4 - added parameters in C++ + * 5 - added types and restructured nodes a bit + * 6 - function style macros + * # 7#- class key - <> + * 8 - enumerators + * 9 - base classes + * 10 - typedefs, types on C++ variables + * #11#- changed how members work - <>, <> + * 12 - one more change for members (is-a list -> has-a list) + * 13 - CV-qualifiers, storage class specifiers, function/method annotations + * 14 - added timestamps for files (bug 149571) + * 15 - fixed offsets for pointer types and qualifier types and PDOMCPPVariable (bug 160540). + * 16 - have PDOMCPPField store type information, and PDOMCPPNamespaceAlias store what it is aliasing + * 17 - use single linked list for names in file, adds a link to enclosing definition name. + * 18 - distinction between c-unions and c-structs. + * 19 - alter representation of paths in the pdom (162172) + * 20 - add pointer to member types, array types, return types for functions + * 21 - change representation of paths in the pdom (167549) + * 22 - fix inheritance relations (167396) + * 23 - types on c-variables, return types on c-functions + * 24 - file local scopes (161216) + * 25 - change ordering of bindings (175275) + * 26 - add properties storage + * 27 - templates: classes, functions, limited nesting support, only template type parameters + * 28 - templates: class instance/specialization base classes + * 29 - includes: fixed modeling of unresolved includes (180159) + * 30 - templates: method/constructor templates, typedef specializations + * 31 - macros: added file locations + * 32 - support stand-alone function types (181936) + * 33 - templates: constructor instances + * 34 - fix for base classes represented by qualified names (183843) + * 35 - add scanner configuration hash-code (62366) + * #36#- changed chunk size back to 4K (184892) - <> + * #37#- added index for nested bindings (189811), compatible with version 36 - <> + */ public static final int LINKAGES = Database.DATA_AREA; public static final int FILE_INDEX = Database.DATA_AREA + 4; @@ -760,6 +773,12 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM { } public String getProperty(String propertyName) throws CoreException { + if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(propertyName)) { + return FRAGMENT_PROPERTY_VALUE_FORMAT_ID; + } + if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(propertyName)) { + return ""+db.getVersion(); //$NON-NLS-1$ + } return new DBProperties(db, PROPERTIES).getProperty(propertyName); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java index 158c70591d2..508bde45d3b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/WritablePDOM.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexLocationConverter; +import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.index.IWritableIndexFragment; import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation; @@ -88,11 +89,18 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment { return result; } + /* + * (non-Javadoc) + * @see org.eclipse.cdt.internal.core.index.IWritableIndexFragment#setProperty(java.lang.String, java.lang.String) + */ public void setProperty(String propertyName, String value) throws CoreException { + if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(propertyName) + || IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(propertyName)) { + throw new IllegalArgumentException("Property "+value+" may not be written to"); //$NON-NLS-1$ //$NON-NLS-2$ + } new DBProperties(db, PROPERTIES).setProperty(propertyName, value); } - /** * Use the specified location converter to update each internal representation of a file location. * The file index is rebuilt with the new representations. Individual PDOMFile records are unmoved so diff --git a/doc/org.eclipse.cdt.doc.isv/guide/dom/index/prebuiltVersioning.html b/doc/org.eclipse.cdt.doc.isv/guide/dom/index/prebuiltVersioning.html new file mode 100644 index 00000000000..dc319b7243c --- /dev/null +++ b/doc/org.eclipse.cdt.doc.isv/guide/dom/index/prebuiltVersioning.html @@ -0,0 +1,350 @@ + + + + + + + + + + +Versioning pre-built indexes + + + + + + + +

+ +

Versioning of pre-built indexes

+ +

 

+ +

In CDT 4.0.1 support for +versioning of pre-built indexes was added. This means that if you release +pre-built indexes for the same content (for example, the same SDK version), but +they were built with different versions of CDT, then a suitable version will +now be used automatically. The previous behaviour assumed only one format +version of any particular content would be provided via the CIndex +extension point.

+ +

 

+ +

It is important to distinguish +between two versions: the content version and the index format version. A +content version refers to the version of the source code being indexed +independent of how it is represented in the index e.g. SDK v1.0 and SDK v1.2. +The index format version is the version of the internal representation of the +index. This document is about coping with the latter.

+ +

 

+ +

Our versioning policy for index +formats is that they should be compatible within major (yearly) release +versions. That is if you build an index using CDT 4.0.X it should work with CDT +4.0.Y. This policy should mean that ISVs do not need to worry about index +format versioning, but this page describes how to handle it should it be +necessary (for example bugzilla 189811).Each +pre-built index carries a string ID which identifies it uniquely within a +logical index - i.e. it identifies the content (e.g MySDK v1.2). When multiple pre-built indexes are provided +with the same ID, the particular one for use is disambiguated automatically by +CDT which chooses the most recent compatible version.

+ +

Compatibility +Table

+ +

 

+ +

This table shows the +compatibility of pre-built indexes built with one version of CDT and used with +another. “Built With” is the vertical axis.

+ +

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Built With \ Use With

+
+

CDT 4.0

+
+

CDT 4.0.1

+
+

CDT Next**

+
+

 

+
+

CDT 4.0

+
+

Yes*

+
+

Yes*

+
+

No

+
+

 

+
+

CDT 4.0.1

+
+

Yes*

+
+

Yes

+
+

No

+
+

 

+
+

CDT Next**

+
+

No

+
+

No

+
+

Yes

+
+

 

+
+

 

+
+

 

+
+

 

+
+

 

+
+

 

+
+ +

 

+ +

Note that even though in the PDOM +format has its own internal versioning scheme, consumers of official CDT +releases need only be aware of compatibility constraints between these +releases.

+ +

 

+ +

* with +performance issues in very large projects. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=189811

+ +

** represents +the next major release of CDT. It +is assumed significant changes to the PDOM database will occur.

+ +

 

+ +

Example scenario

+ +

 

+ +
+
+ +

 

+ +

+ +

 

+ +

The figure above shows an example +scenario where pre-built indexes are contributed by multiple plug-ins. +The same content is contributed in multiple index format versions. The versions +selected for use by each version of CDT are highlighted in gray.

+ +

 

+ +

 

+ +

 

+ +

Versioning Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=196338

+ +

 

+ +
+ + + + diff --git a/doc/org.eclipse.cdt.doc.isv/guide/dom/index/prebuiltVersioning_files/image001.jpg b/doc/org.eclipse.cdt.doc.isv/guide/dom/index/prebuiltVersioning_files/image001.jpg new file mode 100644 index 00000000000..0acc405f981 Binary files /dev/null and b/doc/org.eclipse.cdt.doc.isv/guide/dom/index/prebuiltVersioning_files/image001.jpg differ diff --git a/doc/org.eclipse.cdt.doc.isv/topics_Guide.xml b/doc/org.eclipse.cdt.doc.isv/topics_Guide.xml index c81a1aaac09..ae30603660c 100644 --- a/doc/org.eclipse.cdt.doc.isv/topics_Guide.xml +++ b/doc/org.eclipse.cdt.doc.isv/topics_Guide.xml @@ -6,6 +6,7 @@ +