mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 356057: Updating unnamed enumerations.
This commit is contained in:
parent
881fc3304b
commit
ad4729d954
11 changed files with 228 additions and 134 deletions
|
@ -117,6 +117,15 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()));
|
||||
}
|
||||
|
||||
private void updateHeader() throws Exception {
|
||||
// Append variable comment to the end of the file to change its contents.
|
||||
// Indexer would not reindex the file if its contents remain the same.
|
||||
IProject project= fHeader.getProject();
|
||||
fHeader= TestSourceReader.createFile(project, "header.h",
|
||||
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, fHeader, INDEXER_WAIT_TIME);
|
||||
}
|
||||
|
||||
private void setupFile(int totalFileVersions, boolean cpp) throws Exception {
|
||||
if (fContents == null) {
|
||||
fContents= getContentsForTest(totalFileVersions);
|
||||
|
@ -135,7 +144,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_WAIT_TIME);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
fIndex= null;
|
||||
|
@ -1339,4 +1348,89 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
// typedef enum {
|
||||
// AE_ON = 0
|
||||
// } Adaptiv_T;
|
||||
// struct mystruct {
|
||||
// Adaptiv_T eAdapt;
|
||||
// };
|
||||
|
||||
// int main() {
|
||||
// mystruct ms;
|
||||
// ms.eAdapt = AE_ON;
|
||||
// }
|
||||
|
||||
// // insert line
|
||||
// typedef enum {
|
||||
// AE_ON = 0
|
||||
// } Adaptiv_T;
|
||||
// struct mystruct {
|
||||
// Adaptiv_T eAdapt;
|
||||
// };
|
||||
public void testAnonymousEnum_Bug356057cpp() throws Exception {
|
||||
setupHeader(3, true);
|
||||
setupFile(3, true);
|
||||
String name1;
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
|
||||
assertNotNull(e);
|
||||
name1= e.getOwner().getName();
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
updateHeader();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
|
||||
assertNotNull(e);
|
||||
assertFalse(name1.equals(e.getOwner().getName()));
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
// typedef enum {
|
||||
// AE_ON = 0
|
||||
// } Adaptiv_T;
|
||||
// struct mystruct {
|
||||
// Adaptiv_T eAdapt;
|
||||
// };
|
||||
|
||||
// int main() {
|
||||
// mystruct ms;
|
||||
// ms.eAdapt = AE_ON;
|
||||
// }
|
||||
|
||||
// // insert line
|
||||
// typedef enum {
|
||||
// AE_ON = 0
|
||||
// } Adaptiv_T;
|
||||
// struct mystruct {
|
||||
// Adaptiv_T eAdapt;
|
||||
// };
|
||||
public void testAnonymousEnum_Bug356057c() throws Exception {
|
||||
setupHeader(3, false);
|
||||
setupFile(3, false);
|
||||
String name1;
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
|
||||
assertNotNull(e);
|
||||
name1= e.getOwner().getName();
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
updateHeader();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
|
||||
assertNotNull(e);
|
||||
assertFalse(name1.equals(e.getOwner().getName()));
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ package org.eclipse.cdt.internal.core.index;
|
|||
* Constants used by IIndexFragment implementations for identifying persisted binding types
|
||||
*/
|
||||
public interface IIndexBindingConstants {
|
||||
int MACRO_DEFINITION = 4;
|
||||
int MACRO_CONTAINER = 5;
|
||||
int LAST_CONSTANT= MACRO_CONTAINER;
|
||||
int ENUMERATOR= 3;
|
||||
int MACRO_DEFINITION = 4;
|
||||
int MACRO_CONTAINER = 5;
|
||||
int LAST_CONSTANT= MACRO_CONTAINER;
|
||||
}
|
||||
|
|
|
@ -14,12 +14,13 @@ package org.eclipse.cdt.internal.core.index;
|
|||
* Constants used by IIndexFragment implementations for identifying persisted binding types
|
||||
*/
|
||||
public interface IIndexCBindingConstants {
|
||||
int CVARIABLE = IIndexBindingConstants.LAST_CONSTANT + 1;
|
||||
int CFUNCTION = IIndexBindingConstants.LAST_CONSTANT + 2;
|
||||
int CSTRUCTURE = IIndexBindingConstants.LAST_CONSTANT + 3;
|
||||
int CFIELD = IIndexBindingConstants.LAST_CONSTANT + 4;
|
||||
int CENUMERATION = IIndexBindingConstants.LAST_CONSTANT + 5;
|
||||
int CENUMERATOR = IIndexBindingConstants.LAST_CONSTANT + 6;
|
||||
int CTYPEDEF = IIndexBindingConstants.LAST_CONSTANT + 7;
|
||||
int CPARAMETER = IIndexBindingConstants.LAST_CONSTANT + 8;
|
||||
int CENUMERATOR = IIndexBindingConstants.ENUMERATOR;
|
||||
|
||||
int CVARIABLE = IIndexBindingConstants.LAST_CONSTANT + 1;
|
||||
int CFUNCTION = IIndexBindingConstants.LAST_CONSTANT + 2;
|
||||
int CSTRUCTURE = IIndexBindingConstants.LAST_CONSTANT + 3;
|
||||
int CFIELD = IIndexBindingConstants.LAST_CONSTANT + 4;
|
||||
int CENUMERATION = IIndexBindingConstants.LAST_CONSTANT + 5;
|
||||
int CTYPEDEF = IIndexBindingConstants.LAST_CONSTANT + 7;
|
||||
int CPARAMETER = IIndexBindingConstants.LAST_CONSTANT + 8;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ package org.eclipse.cdt.internal.core.index;
|
|||
* Constants used by IIndexFragment implementations for identifying persisted binding types.
|
||||
*/
|
||||
public interface IIndexCPPBindingConstants {
|
||||
int CPPENUMERATOR = IIndexBindingConstants.ENUMERATOR;
|
||||
|
||||
int CPPVARIABLE = IIndexBindingConstants.LAST_CONSTANT + 1;
|
||||
int CPPFUNCTION = IIndexBindingConstants.LAST_CONSTANT + 2;
|
||||
int CPPCLASSTYPE = IIndexBindingConstants.LAST_CONSTANT + 3;
|
||||
|
@ -24,7 +26,6 @@ public interface IIndexCPPBindingConstants {
|
|||
int CPPNAMESPACEALIAS = IIndexBindingConstants.LAST_CONSTANT + 7;
|
||||
int CPPPARAMETER = IIndexBindingConstants.LAST_CONSTANT + 9;
|
||||
int CPPENUMERATION = IIndexBindingConstants.LAST_CONSTANT + 10;
|
||||
int CPPENUMERATOR = IIndexBindingConstants.LAST_CONSTANT + 11;
|
||||
int CPPTYPEDEF = IIndexBindingConstants.LAST_CONSTANT + 12;
|
||||
int CPP_CONSTRUCTOR= IIndexBindingConstants.LAST_CONSTANT + 14;
|
||||
int CPP_FUNCTION_TEMPLATE= IIndexBindingConstants.LAST_CONSTANT + 16;
|
||||
|
|
|
@ -196,7 +196,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* 96.0 - storing pack expansions in the template parameter map, bug 294730.
|
||||
* 97.0 - storing file contents hash in PDOMFile, bug 302083.
|
||||
* #98.0# - strongly typed enums, bug 305975. <<CDT 7.0.0>>
|
||||
* 99.0 - correct marshalling of basic types, bug 319186.
|
||||
* #99.0# - correct marshalling of basic types, bug 319186. <<CDT 7.0.1>>
|
||||
*
|
||||
* CDT 8.0 development (versions not supported on the 7.0.x branch)
|
||||
* 110.0 - update index on encoding change, bug 317435.
|
||||
|
@ -204,12 +204,15 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* 111.1 - defaulted and deleted functions, bug 305978
|
||||
* 112.0 - inline namespaces, bug 305980
|
||||
* 113.0 - Changed marshaling of values, bug 327878
|
||||
* 114.0 - Partial specializations for class template specializations, bug 332884.
|
||||
* 115.0 - Corrected signatures for function templates, bug 335062.
|
||||
* #114.0# - Partial specializations for class template specializations, bug 332884.
|
||||
* - Corrected signatures for function templates, bug 335062. <<CDT 8.0>>
|
||||
*
|
||||
* CDT 8.1 development (versions not supported on teh 8.0.x branch)
|
||||
* 120.0 - Enumerators in global index, bug 356235
|
||||
*/
|
||||
private static final int MIN_SUPPORTED_VERSION= version(114, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(114, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(114, 0);
|
||||
private static final int MIN_SUPPORTED_VERSION= version(120, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(120, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(120, 0);
|
||||
|
||||
private static int version(int major, int minor) {
|
||||
return (major << 16) + minor;
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom;
|
|||
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||
|
@ -44,6 +45,11 @@ public class FindBinding {
|
|||
if (t1 == t2) {
|
||||
t1 = PDOMNode.getNodeType(database, record1);
|
||||
t2 = PDOMNode.getNodeType(database, record2);
|
||||
if (t1 == t2 && t1 == IIndexBindingConstants.ENUMERATOR) {
|
||||
// Allow to insert multiple enumerators into the global index.
|
||||
t1= record1;
|
||||
t2= record2;
|
||||
}
|
||||
}
|
||||
cmp= t1 < t2 ? -1 : (t1 > t2 ? 1 : 0);
|
||||
}
|
||||
|
@ -164,7 +170,6 @@ public class FindBinding {
|
|||
|
||||
public static PDOMBinding findBinding(IPDOMNode node, final PDOMLinkage linkage, final char[] name, final int[] constants,
|
||||
long localToFileRec) throws CoreException {
|
||||
// mstodo faster searches
|
||||
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(linkage, name, constants, localToFileRec);
|
||||
try {
|
||||
node.accept(visitor);
|
||||
|
|
|
@ -11,20 +11,28 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -33,12 +41,10 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* Enumerations in the database.
|
||||
*/
|
||||
class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
|
||||
|
||||
private static final int FIRST_ENUMERATOR = PDOMBinding.RECORD_SIZE + 0;
|
||||
private static final int OFFSET_MIN_VALUE= FIRST_ENUMERATOR + Database.PTR_SIZE;
|
||||
class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType, IPDOMMemberOwner {
|
||||
private static final int OFFSET_ENUMERATOR_LIST = PDOMBinding.RECORD_SIZE;
|
||||
private static final int OFFSET_MIN_VALUE= OFFSET_ENUMERATOR_LIST + Database.PTR_SIZE;
|
||||
private static final int OFFSET_MAX_VALUE= OFFSET_MIN_VALUE + 8;
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = OFFSET_MAX_VALUE + 8;
|
||||
|
||||
|
@ -80,35 +86,71 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
|
|||
return IIndexCBindingConstants.CENUMERATION;
|
||||
}
|
||||
|
||||
public IEnumerator[] getEnumerators() throws DOMException {
|
||||
public IEnumerator[] getEnumerators() {
|
||||
List<PDOMCEnumerator> result = getCachedEnumerators(true);
|
||||
return result.toArray(new IEnumerator[result.size()]);
|
||||
}
|
||||
|
||||
private List<PDOMCEnumerator> getCachedEnumerators(boolean create) {
|
||||
final Long key= record;
|
||||
final PDOM pdom = getPDOM();
|
||||
@SuppressWarnings("unchecked")
|
||||
Reference<List<PDOMCEnumerator>> cached= (Reference<List<PDOMCEnumerator>>) pdom.getCachedResult(key);
|
||||
List<PDOMCEnumerator> result= cached == null ? null : cached.get();
|
||||
|
||||
if (result == null && create) {
|
||||
// there is no cache, build it:
|
||||
result= loadEnumerators();
|
||||
pdom.putCachedResult(key, new SoftReference<List<PDOMCEnumerator>>(result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<PDOMCEnumerator> loadEnumerators() {
|
||||
final ArrayList<PDOMCEnumerator> result= new ArrayList<PDOMCEnumerator>();
|
||||
try {
|
||||
ArrayList<PDOMCEnumerator> enums = new ArrayList<PDOMCEnumerator>();
|
||||
for (PDOMCEnumerator enumerator = getFirstEnumerator();
|
||||
enumerator != null;
|
||||
enumerator = enumerator.getNextEnumerator()) {
|
||||
enums.add(enumerator);
|
||||
}
|
||||
|
||||
// Reverse the list since they are last in first out
|
||||
Collections.reverse(enums);
|
||||
return enums.toArray(new IEnumerator[enums.size()]);
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
||||
list.accept(new IPDOMVisitor() {
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof PDOMCEnumerator) {
|
||||
result.add((PDOMCEnumerator) node);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void leave(IPDOMNode node) {}
|
||||
});
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new IEnumerator[0];
|
||||
}
|
||||
result.trimToSize();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||
for (PDOMCEnumerator enumerator : getCachedEnumerators(true)) {
|
||||
visitor.visit(enumerator);
|
||||
visitor.leave(enumerator);
|
||||
}
|
||||
}
|
||||
|
||||
private PDOMCEnumerator getFirstEnumerator() throws CoreException {
|
||||
long value = getDB().getRecPtr(record + FIRST_ENUMERATOR);
|
||||
return value != 0 ? new PDOMCEnumerator(getLinkage(), value) : null;
|
||||
@Override
|
||||
public void addChild(PDOMNode node) throws CoreException {
|
||||
if (node instanceof PDOMCEnumerator) {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
|
||||
list.addMember(node);
|
||||
List<PDOMCEnumerator> cache = getCachedEnumerators(false);
|
||||
if (cache != null)
|
||||
cache.add((PDOMCEnumerator) node);
|
||||
}
|
||||
}
|
||||
|
||||
public void addEnumerator(PDOMCEnumerator enumerator) throws CoreException {
|
||||
PDOMCEnumerator first = getFirstEnumerator();
|
||||
enumerator.setNextEnumerator(first);
|
||||
getDB().putRecPtr(record + FIRST_ENUMERATOR, enumerator.getRecord());
|
||||
|
||||
@Override
|
||||
public boolean mayHaveChildren() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long getMinValue() {
|
||||
if (fMinValue != null) {
|
||||
return fMinValue.longValue();
|
||||
|
@ -149,18 +191,20 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
|
|||
|
||||
if (type instanceof IEnumeration) {
|
||||
IEnumeration etype= (IEnumeration) type;
|
||||
etype= (IEnumeration) PDOMASTAdapter.getAdapterForAnonymousASTBinding(etype);
|
||||
try {
|
||||
return getDBName().equals(etype.getNameCharArray());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
char[] nchars = etype.getNameCharArray();
|
||||
if (nchars.length == 0) {
|
||||
nchars= ASTTypeUtil.createNameForAnonymous(etype);
|
||||
}
|
||||
if (nchars == null || !CharArrayUtils.equals(nchars, getNameCharArray()))
|
||||
return false;
|
||||
|
||||
return SemanticUtil.isSameOwner(getOwner(), etype.getOwner());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
throw new IllegalArgumentException("Enums must not be cloned"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,22 +29,17 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* Binding for c enumerator in the index.
|
||||
*/
|
||||
class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
|
||||
|
||||
private static final int ENUMERATION = PDOMBinding.RECORD_SIZE + 0;
|
||||
private static final int NEXT_ENUMERATOR = PDOMBinding.RECORD_SIZE + 4;
|
||||
private static final int VALUE= PDOMBinding.RECORD_SIZE + 8;
|
||||
private static final int VALUE= PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 12;
|
||||
protected static final int RECORD_SIZE = VALUE + 4;
|
||||
|
||||
public PDOMCEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator, PDOMCEnumeration enumeration)
|
||||
public PDOMCEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator)
|
||||
throws CoreException {
|
||||
super(linkage, parent, enumerator.getNameCharArray());
|
||||
|
||||
final Database db = getDB();
|
||||
db.putRecPtr(record + ENUMERATION, enumeration.getRecord());
|
||||
storeValue(db, enumerator);
|
||||
enumeration.addEnumerator(this);
|
||||
}
|
||||
|
||||
public PDOMCEnumerator(PDOMLinkage linkage, long record) {
|
||||
|
@ -75,35 +70,13 @@ class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
|
|||
storeValue(getDB(), (IEnumerator) newBinding);
|
||||
}
|
||||
|
||||
|
||||
public PDOMCEnumerator getNextEnumerator() throws CoreException {
|
||||
long value = getDB().getRecPtr(record + NEXT_ENUMERATOR);
|
||||
return value != 0 ? new PDOMCEnumerator(getLinkage(), value) : null;
|
||||
}
|
||||
|
||||
public void setNextEnumerator(PDOMCEnumerator enumerator) throws CoreException {
|
||||
long value = enumerator != null ? enumerator.getRecord() : 0;
|
||||
getDB().putRecPtr(record + NEXT_ENUMERATOR, value);
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
return getEnumeration();
|
||||
}
|
||||
|
||||
private PDOMCEnumeration getEnumeration() {
|
||||
try {
|
||||
return new PDOMCEnumeration(getLinkage(), getDB().getRecPtr(record + ENUMERATION));
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
IIndexFragmentBinding owner = getOwner();
|
||||
if (owner instanceof IType)
|
||||
return (IType) owner;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragmentBinding getOwner() {
|
||||
return getEnumeration();
|
||||
}
|
||||
|
||||
public IValue getValue() {
|
||||
try {
|
||||
int val= getDB().getInt(record + VALUE);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
|
@ -110,6 +109,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
|||
private PDOMBinding createBinding(PDOMNode parent, IBinding binding, long localToFile) throws CoreException {
|
||||
PDOMBinding pdomBinding= null;
|
||||
|
||||
PDOMNode insertIntoIndex= null;
|
||||
if (binding instanceof IField) { // must be before IVariable
|
||||
if (parent instanceof IPDOMMemberOwner)
|
||||
pdomBinding = new PDOMCField(this, (IPDOMMemberOwner)parent, (IField) binding);
|
||||
|
@ -124,15 +124,11 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
|||
} else if (binding instanceof IEnumeration) {
|
||||
pdomBinding = new PDOMCEnumeration(this, parent, (IEnumeration) binding);
|
||||
} else if (binding instanceof IEnumerator) {
|
||||
try {
|
||||
IType enumeration= ((IEnumerator)binding).getType();
|
||||
if (enumeration instanceof IEnumeration) {
|
||||
PDOMBinding pdomEnumeration = adaptBinding((IEnumeration) enumeration);
|
||||
if (pdomEnumeration instanceof PDOMCEnumeration)
|
||||
pdomBinding = new PDOMCEnumerator(this, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
assert parent instanceof IEnumeration;
|
||||
pdomBinding = new PDOMCEnumerator(this, parent, (IEnumerator) binding);
|
||||
insertIntoIndex= parent.getParentNode();
|
||||
if (insertIntoIndex == null) {
|
||||
insertIntoIndex= this;
|
||||
}
|
||||
} else if (binding instanceof ITypedef) {
|
||||
pdomBinding = new PDOMCTypedef(this, parent, (ITypedef)binding);
|
||||
|
@ -141,7 +137,12 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
|||
if (pdomBinding != null) {
|
||||
pdomBinding.setLocalToFileRec(localToFile);
|
||||
parent.addChild(pdomBinding);
|
||||
insertIntoNestedBindingsIndex(pdomBinding);
|
||||
if (insertIntoIndex != null) {
|
||||
insertIntoIndex.addChild(pdomBinding);
|
||||
}
|
||||
if (parent != this && insertIntoIndex != this) {
|
||||
insertIntoNestedBindingsIndex(pdomBinding);
|
||||
}
|
||||
}
|
||||
return pdomBinding;
|
||||
}
|
||||
|
@ -214,10 +215,6 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
|||
}
|
||||
|
||||
IBinding owner= binding.getOwner();
|
||||
// For plain c the enumeration type is not the parent of the enumeration item.
|
||||
if (owner instanceof IEnumeration) {
|
||||
owner= owner.getOwner();
|
||||
}
|
||||
if (owner == null) {
|
||||
return this;
|
||||
}
|
||||
|
@ -263,23 +260,11 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
|||
if (parent == null) {
|
||||
parent= getAdaptedParent(binding);
|
||||
}
|
||||
PDOMNode inheritFileLocal= parent;
|
||||
if (binding instanceof IEnumerator) {
|
||||
try {
|
||||
IType enumeration= ((IEnumerator)binding).getType();
|
||||
if (enumeration instanceof IEnumeration) {
|
||||
inheritFileLocal= adaptBinding((IEnumeration) enumeration);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (parent == this) {
|
||||
final int[] bindingTypes = new int[] {getBindingType(binding)};
|
||||
final char[] nameChars = binding.getNameCharArray();
|
||||
PDOMBinding nonLocal= FindBinding.findBinding(getIndex(), this, nameChars, bindingTypes, 0);
|
||||
long localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
|
||||
long localToFileRec= getLocalToFileRec(parent, binding, nonLocal);
|
||||
if (localToFileRec == 0)
|
||||
return nonLocal;
|
||||
localToFileHolder[0]= localToFileRec;
|
||||
|
@ -289,7 +274,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
|||
final int[] bindingTypes = new int[] {getBindingType(binding)};
|
||||
final char[] nameChars = binding.getNameCharArray();
|
||||
PDOMBinding nonLocal= FindBinding.findBinding(parent, this, nameChars, bindingTypes, 0);
|
||||
long localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
|
||||
long localToFileRec= getLocalToFileRec(parent, binding, nonLocal);
|
||||
if (localToFileRec == 0)
|
||||
return nonLocal;
|
||||
localToFileHolder[0]= localToFileRec;
|
||||
|
|
|
@ -104,7 +104,6 @@ public class CPPFindBinding extends FindBinding {
|
|||
|
||||
public static PDOMBinding findBinding(PDOMNode node, PDOMLinkage linkage, char[] name, int constant,
|
||||
int sigHash, long localToFileRec) throws CoreException {
|
||||
// mstodo faster searches
|
||||
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(linkage, name, constant, sigHash,
|
||||
localToFileRec);
|
||||
try {
|
||||
|
|
|
@ -638,21 +638,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
if (parent == null) {
|
||||
parent= adaptOrAddParent(false, binding);
|
||||
}
|
||||
PDOMNode inheritFileLocal= parent;
|
||||
if (binding instanceof IEnumerator) {
|
||||
try {
|
||||
IType enumeration= ((IEnumerator) binding).getType();
|
||||
if (enumeration instanceof IEnumeration) {
|
||||
inheritFileLocal= adaptBinding((IEnumeration) enumeration);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (parent == this) {
|
||||
PDOMBinding glob= CPPFindBinding.findBinding(getIndex(), this, binding, 0);
|
||||
final long loc= getLocalToFileRec(inheritFileLocal, binding, glob);
|
||||
final long loc= getLocalToFileRec(parent, binding, glob);
|
||||
if (loc == 0)
|
||||
return glob;
|
||||
fileLocalRecHolder[0]= loc;
|
||||
|
@ -661,7 +649,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
if (parent instanceof PDOMCPPNamespace) {
|
||||
final BTree btree = ((PDOMCPPNamespace) parent).getIndex();
|
||||
PDOMBinding glob= CPPFindBinding.findBinding(btree, this, binding, 0);
|
||||
final long loc= getLocalToFileRec(inheritFileLocal, binding, glob);
|
||||
final long loc= getLocalToFileRec(parent, binding, glob);
|
||||
if (loc == 0)
|
||||
return glob;
|
||||
fileLocalRecHolder[0]= loc;
|
||||
|
@ -673,7 +661,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
}
|
||||
if (parent instanceof IPDOMMemberOwner) {
|
||||
PDOMBinding glob= CPPFindBinding.findBinding(parent, this, binding, 0);
|
||||
final long loc= getLocalToFileRec(inheritFileLocal, binding, glob);
|
||||
final long loc= getLocalToFileRec(parent, binding, glob);
|
||||
if (loc == 0)
|
||||
return glob;
|
||||
fileLocalRecHolder[0]= loc;
|
||||
|
|
Loading…
Add table
Reference in a new issue