本文整理汇总了Java中org.eclipse.xtext.xbase.lib.Exceptions类的典型用法代码示例。如果您正苦于以下问题:Java Exceptions类的具体用法?Java Exceptions怎么用?Java Exceptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Exceptions类属于org.eclipse.xtext.xbase.lib包,在下文中一共展示了Exceptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDuplicateCases_double_2
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void testDuplicateCases_double_2() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("switch x : 1.5d {");
_builder.newLine();
_builder.append("\t");
_builder.append("case 1.5d: 1");
_builder.newLine();
_builder.append("\t");
_builder.append("case 1.5d: 1");
_builder.newLine();
_builder.append("}");
_builder.newLine();
this._validationTestHelper.assertError(this.expression(_builder), XbasePackage.Literals.XNUMBER_LITERAL, IssueCodes.DUPLICATE_CASE);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例2: _privk3_main
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
protected static void _privk3_main(final StateMachineAspectStateMachineAspectProperties _self_, final StateMachine _self) {
try {
while ((!StateMachineAspect.unprocessedString(_self).isEmpty())) {
StateAspect.step(StateMachineAspect.currentState(_self), StateMachineAspect.unprocessedString(_self));
}
} catch (final Throwable _t) {
if (_t instanceof Exception) {
final Exception nt = (Exception)_t;
String _message = nt.getMessage();
String _plus = ("Stopped due to " + _message);
InputOutput.<String>println(_plus);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
String _unprocessedString = StateMachineAspect.unprocessedString(_self);
String _plus_1 = ("unprocessed string: " + _unprocessedString);
InputOutput.<String>println(_plus_1);
String _consummedString = StateMachineAspect.consummedString(_self);
String _plus_2 = ("processed string: " + _consummedString);
InputOutput.<String>println(_plus_2);
String _producedString = StateMachineAspect.producedString(_self);
String _plus_3 = ("produced string: " + _producedString);
InputOutput.<String>println(_plus_3);
}
示例3: _privk3_step
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
protected static void _privk3_step(final StateAspectStateAspectProperties _self_, final State _self, final String inputString) {
try {
final Function1<Transition, Boolean> _function = (Transition t) -> {
return Boolean.valueOf(inputString.startsWith(t.getInput()));
};
final Iterable<Transition> validTransitions = IterableExtensions.<Transition>filter(_self.getOutgoingTransitions(), _function);
boolean _isEmpty = IterableExtensions.isEmpty(validTransitions);
if (_isEmpty) {
throw new Exception("No Transition");
}
int _size = IterableExtensions.size(validTransitions);
boolean _greaterThan = (_size > 1);
if (_greaterThan) {
throw new Exception("Non Determinism");
}
TransitionAspect.fire(((Transition[])Conversions.unwrapArray(validTransitions, Transition.class))[0]);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例4: checkFecha
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Check
public void checkFecha(final Restaurante restaurante) {
try {
SimpleDateFormat formateadorFecha = new SimpleDateFormat("dd-MM-yyyy");
Date fechaDada = formateadorFecha.parse(restaurante.getFecha());
Calendar fechaActual = Calendar.getInstance();
Date _time = fechaActual.getTime();
boolean _greaterThan = (fechaDada.compareTo(_time) > 0);
if (_greaterThan) {
this.error("La fecha tiene que ser igual o menor que la actual",
RestaurantePackage.Literals.RESTAURANTE__FECHA, RestauranteValidator.FECHA_INVALIDA);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例5: testUnreachableCatchClause_4
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void testUnreachableCatchClause_4() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("try {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("} catch (java.io.FileNotFoundException e) {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("} catch (java.io.IOException e) {");
_builder.newLine();
_builder.newLine();
_builder.append("} catch (Exception e) {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("}");
_builder.newLine();
this._validationTestHelper.assertNoErrors(this.expression(_builder));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例6: testUnloadAndGetContents
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void testUnloadAndGetContents() throws IOException {
try {
this.with(OptionalEmptyTestLanguageStandaloneSetup.class);
Bug451668Test.TestResource r = this.<Bug451668Test.TestResource>get(Bug451668Test.TestResource.class);
r.setURI(URI.createURI("foo.dummy"));
StringInputStream _stringInputStream = new StringInputStream("");
r.load(_stringInputStream, null);
Assert.assertTrue(r.isLoaded());
final int callsBeforeUnload = r.contentsCalls;
r.unload();
Assert.assertEquals(callsBeforeUnload, r.contentsCalls);
Assert.assertFalse(r.isLoaded());
Assert.assertNull(r.getParseResult());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例7: getBooleanConstantOrNull
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
public BooleanResult getBooleanConstantOrNull(final XExpression it) {
try {
final EvaluationResult evaluationResult = this.doEvaluate(it, this.newEvaluationContext());
Object _rawValue = evaluationResult.getRawValue();
if ((_rawValue instanceof Boolean)) {
Object _rawValue_1 = evaluationResult.getRawValue();
boolean _isCompileTimeConstant = evaluationResult.isCompileTimeConstant();
return new BooleanResult(((Boolean) _rawValue_1), _isCompileTimeConstant);
}
return null;
} catch (final Throwable _t) {
if (_t instanceof ConstantExpressionEvaluationException) {
return null;
} else if (_t instanceof IllegalArgumentException) {
return null;
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
示例8: testSetLiteralAssignedToCollectionBug498779
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void testSetLiteralAssignedToCollectionBug498779() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("val java.util.Collection<String> set = #{\"\"}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
this._validationTestHelper.assertNoErrors(this.expression(_builder));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例9: testIncompleteCasesOnEnum_9
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void testIncompleteCasesOnEnum_9() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("switch Object x : org.eclipse.xtext.xbase.tests.validation.Color.RED {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
this._validationTestHelper.assertNoIssue(this.expression(_builder), XbasePackage.Literals.XMEMBER_FEATURE_CALL, IssueCodes.INCOMPLETE_CASES_ON_ENUM);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例10: getDiagnostics
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
protected Map<String, List<Diagnostic>> getDiagnostics() {
try {
final Function1<CancelIndicator, HashMap<String, List<Diagnostic>>> _function = (CancelIndicator it) -> {
final HashMap<String, List<Diagnostic>> result = CollectionLiterals.<String, List<Diagnostic>>newHashMap();
final Function1<Pair<String, Object>, Object> _function_1 = (Pair<String, Object> it_1) -> {
return it_1.getValue();
};
Iterable<PublishDiagnosticsParams> _filter = Iterables.<PublishDiagnosticsParams>filter(ListExtensions.<Pair<String, Object>, Object>map(this.notifications, _function_1), PublishDiagnosticsParams.class);
for (final PublishDiagnosticsParams diagnostic : _filter) {
result.put(diagnostic.getUri(), diagnostic.getDiagnostics());
}
return result;
};
return this.languageServer.getRequestManager().<HashMap<String, List<Diagnostic>>>runRead(_function).get();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例11: load
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Override
public void load(final Map<?, ?> options) throws IOException {
if (((((!this.isLoaded) && (!this.isLoading)) && (this.resourceStorageFacade != null)) && this.resourceStorageFacade.shouldLoadFromStorage(this))) {
boolean _isDebugEnabled = StorageAwareResource.LOG.isDebugEnabled();
if (_isDebugEnabled) {
URI _uRI = this.getURI();
String _plus = ("Loading " + _uRI);
String _plus_1 = (_plus + " from storage.");
StorageAwareResource.LOG.debug(_plus_1);
}
try {
final ResourceStorageLoadable in = this.resourceStorageFacade.getOrCreateResourceStorageLoadable(this);
this.loadFromStorage(in);
return;
} catch (final Throwable _t) {
if (_t instanceof IOException) {
this.contents.clear();
this.eAdapters.clear();
this.unload();
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
super.load(options);
}
示例12: testFormatterIntegrationWithSerializer
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void testFormatterIntegrationWithSerializer() {
try {
final Resource resource = this.factory.createResource(URI.createURI("dummy.ext"));
new ResourceSetImpl().getResources().add(resource);
final IDList model = FormattertestlanguageFactory.eINSTANCE.createIDList();
EList<String> _ids = model.getIds();
_ids.add("foo");
EList<EObject> _contents = resource.getContents();
_contents.add(model);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedOutputStream _bufferedOutputStream = new BufferedOutputStream(out);
resource.save(_bufferedOutputStream, Collections.<Object, Object>emptyMap());
Assert.assertEquals("idlist foo", out.toString());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例13: testXVariableDeclarationCall
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void testXVariableDeclarationCall() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("val foo = 1");
_builder.newLine();
_builder.append("\t");
_builder.append("val bar = foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XExpression _expression = this.expression(_builder);
final XBlockExpression blockExpression = ((XBlockExpression) _expression);
XExpression _get = blockExpression.getExpressions().get(1);
final XVariableDeclaration variableDeclaration = ((XVariableDeclaration) _get);
this.evaluatesTo(variableDeclaration, Integer.valueOf(1));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例14: regionForRuleCallToEObjectParserRule
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void regionForRuleCallToEObjectParserRule() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("6 (child (foo))");
final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
try {
finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getMixedRule());
Assert.fail();
} catch (final Throwable _t) {
if (_t instanceof IllegalStateException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
try {
finder.ruleCallsTo(this._regionAccessTestLanguageGrammarAccess.getMixedRule());
Assert.fail();
} catch (final Throwable _t_1) {
if (_t_1 instanceof IllegalStateException) {
} else {
throw Exceptions.sneakyThrow(_t_1);
}
}
}
示例15: testUnreachableCase
import org.eclipse.xtext.xbase.lib.Exceptions; //导入依赖的package包/类
@Test
public void testUnreachableCase() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("switch x : new Exception {");
_builder.newLine();
_builder.append("\t");
_builder.append("Exception: 1");
_builder.newLine();
_builder.append("\t");
_builder.append("java.io.IOException: 2");
_builder.newLine();
_builder.append("\t");
_builder.append("java.io.FileNotFoundException: 3");
_builder.newLine();
_builder.append("}");
_builder.newLine();
this._validationTestHelper.assertError(this.expression(_builder), TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE, IssueCodes.UNREACHABLE_CASE);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}