mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
report the IProblemBinding ID constant name on failure
This commit is contained in:
parent
e3ae583f4f
commit
7a78073d7d
1 changed files with 27 additions and 2 deletions
|
@ -8,10 +8,12 @@
|
|||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -456,11 +458,34 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
|
||||
public IBinding assertNonProblem(String section, int len) {
|
||||
IBinding binding= binding(section, len);
|
||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||
!(binding instanceof IProblemBinding));
|
||||
if(binding instanceof IProblemBinding) {
|
||||
IProblemBinding problem= (IProblemBinding) binding;
|
||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")");
|
||||
}
|
||||
if(binding == null) {
|
||||
fail("Null binding resolved for name: " + section.substring(0, len));
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
||||
private String renderProblemID(int i) {
|
||||
try {
|
||||
for(Field field : IProblemBinding.class.getDeclaredFields()) {
|
||||
if(field.getName().startsWith("SEMANTIC_")) {
|
||||
if(field.getType() == int.class) {
|
||||
Integer ci= (Integer) field.get(null);
|
||||
if(ci.intValue() == i) {
|
||||
return field.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(IllegalAccessException iae) {
|
||||
throw new RuntimeException(iae);
|
||||
}
|
||||
return "Unknown problem ID";
|
||||
}
|
||||
|
||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
||||
IBinding binding= binding(section, len);
|
||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||
|
|
Loading…
Add table
Reference in a new issue