mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixes a NPE in the SpecializationFinder.
This commit is contained in:
parent
f90a097f60
commit
ff740bc273
1 changed files with 25 additions and 20 deletions
|
@ -12,7 +12,11 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
|
@ -188,22 +192,19 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SpecializationFinder implements IPDOMVisitor {
|
private class SpecializationFinder implements IPDOMVisitor {
|
||||||
private ObjectMap specMap;
|
private HashMap<IBinding,ICPPSpecialization> origToSpecialization;
|
||||||
public SpecializationFinder(IBinding[] specialized) {
|
public SpecializationFinder(IBinding[] specialized) {
|
||||||
specMap = new ObjectMap(specialized.length);
|
origToSpecialization = new HashMap<IBinding,ICPPSpecialization>(specialized.length);
|
||||||
for (int i = 0; i < specialized.length; i++) {
|
for (IBinding element : specialized) {
|
||||||
specMap.put(specialized[i], null);
|
origToSpecialization.put(element, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public boolean visit(IPDOMNode node) throws CoreException {
|
public boolean visit(IPDOMNode node) throws CoreException {
|
||||||
if (node instanceof ICPPSpecialization) {
|
if (node instanceof ICPPSpecialization) {
|
||||||
IBinding specialized = ((ICPPSpecialization)node).getSpecializedBinding();
|
final ICPPSpecialization specialization = (ICPPSpecialization) node;
|
||||||
if (specMap.containsKey(specialized)) {
|
IBinding orig = specialization.getSpecializedBinding();
|
||||||
ICPPSpecialization specialization = (ICPPSpecialization) specMap.get(node);
|
if (origToSpecialization.containsKey(orig)) {
|
||||||
if (specialization == null) {
|
origToSpecialization.put(orig, specialization);
|
||||||
specMap.remove(specialized);
|
|
||||||
specMap.put(specialized, node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -211,17 +212,21 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
|
||||||
public void leave(IPDOMNode node) throws CoreException {
|
public void leave(IPDOMNode node) throws CoreException {
|
||||||
}
|
}
|
||||||
public ICPPSpecialization[] getSpecializations() {
|
public ICPPSpecialization[] getSpecializations() {
|
||||||
ICPPSpecialization[] result = new ICPPSpecialization[specMap.size()];
|
Iterator<Map.Entry<IBinding,ICPPSpecialization>> it= origToSpecialization.entrySet().iterator();
|
||||||
for (int i = 0; i < specMap.size(); i++) {
|
while (it.hasNext()) {
|
||||||
ICPPSpecialization specialization = (ICPPSpecialization) specMap.getAt(i);
|
Entry<IBinding, ICPPSpecialization> entry= it.next();
|
||||||
if (specialization != null) {
|
if (entry.getValue() == null) {
|
||||||
result[i] = specialization;
|
ICPPSpecialization specialization= CPPTemplates.createSpecialization(
|
||||||
} else {
|
PDOMCPPClassInstance.this, entry.getKey(), getArgumentMap());
|
||||||
result[i] = CPPTemplates.createSpecialization(
|
if (specialization == null) {
|
||||||
PDOMCPPClassInstance.this, (IBinding) specMap.keyAt(i), getArgumentMap());
|
it.remove();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entry.setValue(specialization);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
}
|
||||||
|
return origToSpecialization.values().toArray(new ICPPSpecialization[origToSpecialization.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue