本文整理汇总了Java中org.eclipse.xtext.validation.CancelableDiagnostician类的典型用法代码示例。如果您正苦于以下问题:Java CancelableDiagnostician类的具体用法?Java CancelableDiagnostician怎么用?Java CancelableDiagnostician使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CancelableDiagnostician类属于org.eclipse.xtext.validation包,在下文中一共展示了CancelableDiagnostician类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCancelIndicatorGetsInvokedAutomatically
import org.eclipse.xtext.validation.CancelableDiagnostician; //导入依赖的package包/类
@Test
public void testCancelIndicatorGetsInvokedAutomatically() throws Exception {
String program = " class X { \n\t a: any; \n\t a: any; } } ";
Script s;
try {
s = ph.parse(program);
N4ClassDeclaration clazz = (N4ClassDeclaration) s.getScriptElements().get(0);
Map<Object, Object> context = new HashMap<>();
context.put(CancelableDiagnostician.CANCEL_INDICATOR, new TraceLeavingCancelIndicator());
// the cancel indicator in use sets a flag in case its isCanceled() was queried
assertTrue(!(wasChecked.get()));
DiagnosticChain chain = new BasicDiagnostic();
try {
v.validate(clazz, chain, context);
fail("expected OperationCanceledException or OperationCanceledError was not thrown");
} catch (Throwable th) {
assertTrue(
"wrong kind of throwable; expected: OperationCanceledException or OperationCanceledError, actual: "
+ th.getClass().getSimpleName(),
operationCanceledManager.isOperationCanceledException(th));
}
assertTrue(wasChecked.get());
// now validate with a cancel indicator that never cancels,
// upon which validation methods run and errors are recorded.
context.put(CancelableDiagnostician.CANCEL_INDICATOR, CancelIndicator.NullImpl);
final boolean isValid02 = v.validate(clazz, chain, context);
assertTrue(!isValid02);
// validate again (this time with the default cancel indicator, which never cancels),
// check expected errors one by one.
String[] expectedErrorMsgs = {
"The field a (line 2) duplicates field a (line 3).",
"The field a (line 3) duplicates field a (line 2)."
};
for (String expectedErrorMsg : expectedErrorMsgs) {
vth.assertError(s, N4JSPackage.Literals.N4_MEMBER_DECLARATION, IssueCodes.CLF_DUP_MEMBER,
expectedErrorMsg);
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
示例2: bindCancelableDiagnostician
import org.eclipse.xtext.validation.CancelableDiagnostician; //导入依赖的package包/类
public Class<? extends CancelableDiagnostician> bindCancelableDiagnostician() {
return XbaseDiagnostician.class;
}
示例3: bindDiagnostician
import org.eclipse.xtext.validation.CancelableDiagnostician; //导入依赖的package包/类
@SingletonBinding
public Class<? extends Diagnostician> bindDiagnostician() {
return CancelableDiagnostician.class;
}