Przeglądaj źródła

recursive message checks of run status with children

tags/Root_ajdt_support
wisberg 20 lat temu
rodzic
commit
60b3a70a85

+ 20
- 0
testing/src/org/aspectj/testing/run/IRunStatus.java Wyświetl plik

@@ -105,6 +105,26 @@ public interface IRunStatus extends IMessageHolder {
*/
void completeAbruptly();
//------------------- process messages
/**
* Detect whether a message of a given kind has been handled.
* @param kind the IMessage.Kind of the message to detect
* @param orGreater if true, then also accept any message of a greater kind
* @param includeChildren if true, then also search in any child IRunStatus
* @return true if any such message is detected
*/
boolean hasAnyMessage(IMessage.Kind kind, boolean orGreater, boolean includeChildren);

/**
* Get all messages or those of a specific kind, optionally in children as well
* Pass null to get all kinds.
* @param kind the IMessage.Kind expected, or null for all messages
* @param orGreater if true, also get any greater than the target kind
* as determined by IMessage.Kind.COMPARATOR
* @param includeChildren if true, then also search in any child IRunStatus
* @return IMessage[] of messages of the right kind, or IMessage.NONE
*/
IMessage[] getMessages(IMessage.Kind kind, boolean orGreater, boolean includeChildren);
/**
* Call this any time to signal any messages.
* (In particular, the IRun caller may use this to register messages

+ 38
- 0
testing/src/org/aspectj/testing/run/RunStatus.java Wyświetl plik

@@ -15,13 +15,16 @@
package org.aspectj.testing.run;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHolder;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.testing.util.BridgeUtil;
import org.aspectj.util.LangUtil;

/**
* Default implementation of {@link IRunStatus}.
@@ -227,6 +230,41 @@ public class RunStatus implements IRunStatus {
public boolean runResult() {
return validator.runPassed(this);
}
public boolean hasAnyMessage(IMessage.Kind kind, boolean orGreater, boolean includeChildren) {
if (messageHolder.hasAnyMessage(kind, orGreater)) {
return true;
}
if (includeChildren) {
IRunStatus[] kids = getChildren();
for (int i = 0; i < kids.length; i++) {
if (kids[i].hasAnyMessage(kind, orGreater, true)) {
return true;
}
}
}
return false;
}

public IMessage[] getMessages(IMessage.Kind kind, boolean orGreater, boolean includeChildren) {
IMessage[] result = getMessages(kind, orGreater);
if (!includeChildren) {
return result;
}
ArrayList sink = new ArrayList();
if (!LangUtil.isEmpty(result)) {
sink.addAll(Arrays.asList(result));
}

IRunStatus[] kids = getChildren();
for (int i = 0; i < kids.length; i++) {
result = kids[i].getMessages(kind, orGreater, includeChildren);
if (!LangUtil.isEmpty(result)) {
sink.addAll(Arrays.asList(result));
}
}
return (IMessage[]) sink.toArray(new IMessage[0]);
}

//------------------- process messages
/**

Ładowanie…
Anuluj
Zapisz