Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2009-07-28 10:19:06 -0400
committerMarkus Schorn2009-07-28 10:19:06 -0400
commit09b12baea67e7eaa06f7907ec82d7e751d699314 (patch)
treefae580cfbdf64e4ea0cc15d6c3497d7064d7f978 /core
parentfe7b9b95c27fb3b4681ae99c60a73a23434a209c (diff)
downloadorg.eclipse.cdt-09b12baea67e7eaa06f7907ec82d7e751d699314.tar.gz
org.eclipse.cdt-09b12baea67e7eaa06f7907ec82d7e751d699314.tar.xz
org.eclipse.cdt-09b12baea67e7eaa06f7907ec82d7e751d699314.zip
Corrects deleting parameters in index, related to bug 284686.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java27
3 files changed, 11 insertions, 36 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java
index 62415d0358..4810f34bbb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java
@@ -17,7 +17,6 @@ package org.eclipse.cdt.internal.core.pdom.dom;
import java.util.Arrays;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@@ -123,7 +122,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
public IIndexFragmentBinding getParentBinding() throws CoreException {
PDOMNode parent= getParentNode();
- if (parent instanceof IIndexBinding) {
+ if (parent instanceof IIndexFragmentBinding) {
return (IIndexFragmentBinding) parent;
}
return null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
index 23a3780a20..d6042ad524 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
@@ -76,18 +76,17 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
Database db = getDB();
try {
+ IParameter[] params= function.getParameters();
+ IType[] paramTypes= IType.EMPTY_TYPE_ARRAY;
IFunctionType ft= function.getType();
if (ft != null) {
PDOMNode typeNode = getLinkage().addType(this, ft);
if (typeNode != null) {
db.putRecPtr(record + FUNCTION_TYPE, typeNode.getRecord());
+ paramTypes= ((IFunctionType) typeNode).getParameterTypes();
}
}
- ft= getType();
- IParameter[] params= function.getParameters();
- IType[] paramTypes= ft.getParameterTypes();
-
ICPPFunction sFunc= (ICPPFunction) ((ICPPSpecialization)function).getSpecializedBinding();
IParameter[] sParams= sFunc.getParameters();
IType[] sParamTypes= sFunc.getType().getParameterTypes();
@@ -95,11 +94,13 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
final int length= Math.min(sParams.length, params.length);
db.putInt(record + NUM_PARAMS, length);
for (int i=0; i<length; ++i) {
+ final PDOMNode stype= linkage.addType(this, i<sParamTypes.length ? sParamTypes[i] : null);
+ final long stypeRec= stype == null ? 0 : stype.getRecord();
+ PDOMCPPParameter sParam = new PDOMCPPParameter(getLinkage(), this, sParams[i], stypeRec);
+
long typeRecord= i<paramTypes.length && paramTypes[i]!=null ? ((PDOMNode)paramTypes[i]).getRecord() : 0;
- //TODO shouldn't need to make new parameter (find old one)
- final IType type= i<sParamTypes.length ? sParamTypes[i] : null;
- PDOMCPPParameter sParam = new PDOMCPPParameter(getLinkage(), this, sParams[i], type);
- setFirstParameter(new PDOMCPPParameterSpecialization(getLinkage(), this, (ICPPParameter) params[i], sParam, typeRecord));
+ final ICPPParameter param = (ICPPParameter) params[i];
+ setFirstParameter(new PDOMCPPParameterSpecialization(getLinkage(), this, param, sParam, typeRecord));
}
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(function));
} catch (DOMException e) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
index 1819529198..bfb84c392a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java
@@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.index.IIndexFile;
-import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexScope;
@@ -77,30 +76,6 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
super(linkage, record);
}
- public PDOMCPPParameter(PDOMLinkage linkage, PDOMNode parent, IParameter param, IType type)
- throws CoreException {
- super(linkage, parent, param.getNameCharArray());
-
- Database db = getDB();
-
- db.putRecPtr(record + NEXT_PARAM, 0);
- byte flags= encodeFlags(param);
- db.putByte(record + FLAGS, flags);
-
- try {
- if (type == null)
- type= param.getType();
- if (type != null) {
- PDOMNode typeNode = getLinkage().addType(this, type);
- db.putRecPtr(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
- }
- byte annotations = PDOMCPPAnnotation.encodeAnnotation(param);
- db.putByte(record + ANNOTATIONS, annotations);
- } catch (DOMException e) {
- throw new CoreException(Util.createStatus(e));
- }
- }
-
public PDOMCPPParameter(PDOMLinkage linkage, PDOMNode parent, IParameter param, long typeRecord)
throws CoreException {
super(linkage, parent, param.getNameCharArray());
@@ -265,7 +240,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
@Override
public void delete(PDOMLinkage linkage) throws CoreException {
- linkage.deleteType(getType(), record);
+ // the parameter reuses the type from the function type, so do not delete it.
PDOMCPPParameter next= getNextParameter();
if (next != null) {
next.delete(linkage);

Back to the top