当前位置: 首页>>代码示例>>Java>>正文


Java CancelableDiagnostician类代码示例

本文整理汇总了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;
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:50,代码来源:AutomaticCancelationTest.java

示例2: bindCancelableDiagnostician

import org.eclipse.xtext.validation.CancelableDiagnostician; //导入依赖的package包/类
public Class<? extends CancelableDiagnostician> bindCancelableDiagnostician() {
	return XbaseDiagnostician.class;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:DefaultXbaseRuntimeModule.java

示例3: bindDiagnostician

import org.eclipse.xtext.validation.CancelableDiagnostician; //导入依赖的package包/类
@SingletonBinding
public Class<? extends Diagnostician> bindDiagnostician() {
	return CancelableDiagnostician.class;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:5,代码来源:DefaultRuntimeModule.java


注:本文中的org.eclipse.xtext.validation.CancelableDiagnostician类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。