mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
improve diagnostics
This commit is contained in:
parent
307bcca6a5
commit
45d5fd9bc9
3 changed files with 34 additions and 10 deletions
|
@ -298,6 +298,14 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
return nameList.get(idx);
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
|
||||
public void dump() {
|
||||
for(int i=0; i<size(); i++) {
|
||||
IASTName name= getName(i);
|
||||
String parent= name.getParent() != null ? name.getParent().getRawSignature() : "";
|
||||
System.out.println(i+": #"+name.getRawSignature()+"# "+parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertInstances( CPPNameCollector collector, IBinding binding, int num ) throws Exception {
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.internal.core.index.CIndex;
|
|||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -36,7 +37,15 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
|
|||
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
indent.append(step);
|
||||
System.out.println(indent+""+node);
|
||||
StringBuilder sb= new StringBuilder();
|
||||
sb.append(indent);
|
||||
sb.append(node);
|
||||
if(node instanceof PDOMBinding) {
|
||||
sb.append(" ");
|
||||
PDOMBinding binding= (PDOMBinding) node;
|
||||
sb.append(" "+binding.getRecord());
|
||||
}
|
||||
System.out.println(sb);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.lang.reflect.Modifier;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -37,6 +36,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.ILogListener;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
public class BaseTestCase extends TestCase {
|
||||
|
@ -117,7 +117,7 @@ public class BaseTestCase extends TestCase {
|
|||
|
||||
@Override
|
||||
public void runBare() throws Throwable {
|
||||
final List statusLog= Collections.synchronizedList(new ArrayList());
|
||||
final List<IStatus> statusLog= Collections.synchronizedList(new ArrayList());
|
||||
ILogListener logListener= new ILogListener() {
|
||||
public void logging(IStatus status, String plugin) {
|
||||
if(!status.isOK() && status.getSeverity() != IStatus.INFO) {
|
||||
|
@ -143,13 +143,20 @@ public class BaseTestCase extends TestCase {
|
|||
msg.append("non-OK status objects differs from actual ("+statusLog.size()+").\n");
|
||||
Throwable cause= null;
|
||||
if(!statusLog.isEmpty()) {
|
||||
for(Iterator i= statusLog.iterator(); i.hasNext(); ) {
|
||||
IStatus status= (IStatus) i.next();
|
||||
if(cause==null) {
|
||||
cause= status.getException();
|
||||
for(IStatus status : statusLog) {
|
||||
IStatus[] ss= {status};
|
||||
ss= status instanceof MultiStatus ? ((MultiStatus)status).getChildren() : ss;
|
||||
for(IStatus s : ss) {
|
||||
msg.append("\t"+s.getMessage()+" ");
|
||||
|
||||
Throwable t= s.getException();
|
||||
cause= (cause==null) ? t : cause;
|
||||
if(t != null) {
|
||||
msg.append(t.getMessage()!=null ? t.getMessage() : t.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
msg.append("\n");
|
||||
}
|
||||
Throwable t= status.getException();
|
||||
msg.append("\t"+status.getMessage()+" "+(t!=null?t.getMessage():"")+"\n");
|
||||
}
|
||||
}
|
||||
AssertionFailedError afe= new AssertionFailedError(msg.toString());
|
||||
|
|
Loading…
Add table
Reference in a new issue