org.eclipse.xtext.xbase.lib.Exceptions Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.lib.Exceptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Java8ValidationTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testRedeclaredMethodFromObject() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("interface A {"); _builder.newLine(); _builder.append("\t"); _builder.append("override String toString()"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("class C implements A {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this.file(_builder.toString())); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #2
Source File: ConstantExpressionsInterpreterTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void evaluatesWithException(final String expression, final Procedure1<? super ConstantExpressionEvaluationException> exceptionAssertions) { try { final XtendFunction function = this.function((("def void testFoo() { " + expression) + " }")); XExpression _expression = function.getExpression(); final XExpression expr = IterableExtensions.<XExpression>head(((XBlockExpression) _expression).getExpressions()); try { this.interpreter.evaluate(expr, null); Assert.fail("exception expected"); } catch (final Throwable _t) { if (_t instanceof ConstantExpressionEvaluationException) { final ConstantExpressionEvaluationException e = (ConstantExpressionEvaluationException)_t; exceptionAssertions.apply(e); } else { throw Exceptions.sneakyThrow(_t); } } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #3
Source File: ConstantExpressionsInterpreterTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAnnotationValues() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("@test.Annotation([email protected](\'foo\'))"); _builder.newLine(); _builder.append("class C { "); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile file = this.file(_builder.toString()); final XAnnotationElementValuePair pair = IterableExtensions.<XAnnotationElementValuePair>head(IterableExtensions.<XAnnotation>head(IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()).getAnnotations()).getElementValuePairs()); Object _evaluate = this.interpreter.evaluate(pair.getValue(), pair.getElement().getReturnType()); final XAnnotation anno = ((XAnnotation) _evaluate); Assert.assertEquals("test.Annotation2", anno.getAnnotationType().getIdentifier()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #4
Source File: RequestManagerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test(timeout = 1000) public void testRunReadLogException() { final Runnable _function = () -> { final Function1<CancelIndicator, Object> _function_1 = (CancelIndicator it) -> { throw new RuntimeException(); }; final CompletableFuture<Object> future = this.requestManager.<Object>runRead(_function_1); try { future.join(); } catch (final Throwable _t) { if (_t instanceof Exception) { } else { throw Exceptions.sneakyThrow(_t); } } }; final LoggingTester.LogCapture logResult = LoggingTester.captureLogging(Level.ALL, ReadRequest.class, _function); logResult.assertLogEntry("Error during request:"); }
Example #5
Source File: XbaseValidationTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); } }
Example #6
Source File: LambdaValidationTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testIncompatibleParameterType_01() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("class C {"); _builder.newLine(); _builder.append("\t"); _builder.append("val I<Integer> f = [String k| 1]"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("interface I<T> {"); _builder.newLine(); _builder.append("\t"); _builder.append("def T m(int u);"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.file(_builder.toString()), XbasePackage.Literals.XCLOSURE, IssueCodes.INCOMPATIBLE_TYPES, "Type mismatch: cannot convert from (String)=>int to I<Integer>"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #7
Source File: ValidationTests.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testExplicitGetterReplacesTheGeneratedOne() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("entity E {"); _builder.newLine(); _builder.append("\t"); _builder.append("name : String"); _builder.newLine(); _builder.append("\t"); _builder.append("op getName() {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("return name"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this._parseHelper.parse(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #8
Source File: JavaFileConverterTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public JavaConverter.ConversionResult converToXtend(final String unitName, final String javaCode) { try { final JavaConverter j2x = this.javaConverter.get(); JavaConverter.ConversionResult result = j2x.toXtend(unitName, javaCode); int _size = IterableExtensions.size(result.getProblems()); boolean _equals = (_size == 0); if (_equals) { try { this.file(result.getXtendCode(), true); } catch (final Throwable _t) { if (_t instanceof AssertionError) { result = j2x.useRobustSyntax().toXtend(unitName, javaCode); } else { throw Exceptions.sneakyThrow(_t); } } } return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #9
Source File: ValidationTests.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testDuplicatedOperationWithDifferentSignatureIsAllowed() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("entity E {"); _builder.newLine(); _builder.append("\t"); _builder.append("op m(int i) {}"); _builder.newLine(); _builder.append("\t"); _builder.append("op m() {}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoErrors(this._parseHelper.parse(_builder)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #10
Source File: CliProjectsCreatorMain.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public static void main(final String[] args) { CliProjectsCreatorMain bean = new CliProjectsCreatorMain(); CliProjectsCreator projectsCreator = new CliProjectsCreator(); CmdLineParser parser = new CmdLineParser(bean); try { parser.parseArgument(args); final WizardConfiguration config = bean.createProjectConfig(); projectsCreator.setLineDelimiter(config.getLineDelimiter()); projectsCreator.createProjects(config); LOG.info(String.format("Created projects for language %s in %s", config.getLanguage().getName(), config.getRootLocation())); } catch (final Throwable _t) { if (_t instanceof CmdLineException) { final CmdLineException e = (CmdLineException) _t; System.err.println(e.getMessage()); parser.printUsage(System.err); } else { throw Exceptions.sneakyThrow(_t); } } }
Example #11
Source File: LiveShadowedChunkedContainerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testDeleteElement() { try { this._parseHelper.parse("foo", this.fooURI, this.rs1).eResource().getContents().clear(); final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> { return it.getQualifiedName().toString(); }; Assert.assertEquals("", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(this.fooContainer.getExportedObjects(), _function), ",")); Assert.assertEquals(1, IterableExtensions.size(this.fooContainer.getResourceDescriptions())); Assert.assertEquals(1, this.fooContainer.getResourceDescriptionCount()); Assert.assertEquals(0, IterableExtensions.size(this.fooContainer.getExportedObjects())); Assert.assertEquals(1, IterableExtensions.size(this.barContainer.getResourceDescriptions())); Assert.assertEquals(1, this.barContainer.getResourceDescriptionCount()); this.assertGlobalDescriptionsAreUnaffected(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #12
Source File: ValidationTests.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testImportUnused_1() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("import java.util.List"); _builder.newLine(); _builder.append("entity X {"); _builder.newLine(); _builder.append("\t"); _builder.append("sb: java.util.List<String>"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertWarning(this._parseHelper.parse(_builder), XtypePackage.Literals.XIMPORT_DECLARATION, IssueCodes.IMPORT_UNUSED); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #13
Source File: OldDataCompilerTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testSuperClassWithTypeParameters() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("@Data class Foo<T> {"); _builder.newLine(); _builder.append("\t"); _builder.append("T foo"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("@Data class Bar extends Foo<String> {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> { Assert.assertTrue(it.getGeneratedCode("Bar").contains("public Bar(final String foo) {")); }; this.compilationTestHelper.compile(_builder, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #14
Source File: ConstantExpressionsInterpreter.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected Object _internalEvaluate(final XNumberLiteral it, final Context ctx) { try { Number _xblockexpression = null; { Class<? extends Number> _xifexpression = null; JvmTypeReference _expectedType = ctx.getExpectedType(); boolean _tripleEquals = (_expectedType == null); if (_tripleEquals) { _xifexpression = this.numberLiterals.getJavaType(it); } else { Class<?> _javaType = this.getJavaType(ctx.getExpectedType().getType(), ctx.getClassFinder()); _xifexpression = ((Class<? extends Number>) _javaType); } final Class<? extends Number> type = _xifexpression; _xblockexpression = this.numberLiterals.numberValue(it, type); } return _xblockexpression; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #15
Source File: AbstractOverloadedStaticMethodTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void linksTo(final String invocation, final String method) { try { final XtendFile file = this.file(this.inMethodBody(invocation), false); XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()); final XtendClass c = ((XtendClass) _head); XtendMember _head_1 = IterableExtensions.<XtendMember>head(c.getMembers()); final XtendFunction m = ((XtendFunction) _head_1); XExpression _expression = m.getExpression(); final XBlockExpression body = ((XBlockExpression) _expression); XExpression _last = IterableExtensions.<XExpression>last(body.getExpressions()); final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last); JvmIdentifiableElement _feature = featureCall.getFeature(); final JvmOperation operation = ((JvmOperation) _feature); final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, file); final ParameterizedTypeReference declaration = owner.newParameterizedTypeReference(operation.getDeclaringType()); final BottomResolvedOperation resolved = new BottomResolvedOperation(operation, declaration, this.overrideTester); Assert.assertEquals(method, resolved.getSimpleSignature()); Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty()); Assert.assertNull(featureCall.getImplicitReceiver()); Assert.assertNull(featureCall.getImplicitFirstArgument()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #16
Source File: XtendUIValidationTests.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testForbiddenArrayTypeUsage() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("class Foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("def bar(org.eclipse.xtend.core.tests.restricted.RestrictedClass[] x) {}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile xtendFile = this.testHelper.xtendFile("Clazz.xtend", _builder.toString()); XtendMember _head = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers()); final XtendFunction function = ((XtendFunction) _head); this.helper.assertError(function.getParameters().get(0), TypesPackage.Literals.JVM_TYPE_REFERENCE, org.eclipse.xtext.xbase.validation.IssueCodes.FORBIDDEN_REFERENCE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #17
Source File: XbaseValidationTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testDuplicateCases_int() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch x : 1 {"); _builder.newLine(); _builder.append("\t"); _builder.append("case 1: 1"); _builder.newLine(); _builder.append("\t"); _builder.append("case 1: 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); } }
Example #18
Source File: InMemoryJavaCompiler.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public NameEnvironmentAnswer findType(final char[][] compoundTypeName) { try { final Function1<char[], String> _function = (char[] it) -> { return String.valueOf(it); }; String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/"); final String fileName = (_join + ".class"); boolean _containsKey = this.cache.containsKey(fileName); if (_containsKey) { return this.cache.get(fileName); } final URL url = this.classLoader.getResource(fileName); if ((url == null)) { this.cache.put(fileName, null); return null; } final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName); final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null); this.cache.put(fileName, result); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #19
Source File: LiveShadowedAllContainerStateTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testEmptyProject() { try { final IProject project = IResourcesSetupUtil.createProject("MyProject"); IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID); final ResourceSet rs = this.liveScopeResourceSetProvider.get(project); StringConcatenation _builder = new StringConcatenation(); _builder.append("container MyProject isEmpty=true {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final String expected = _builder.toString(); Assert.assertEquals(expected, this.formatContainers(rs)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #20
Source File: JvmTypesBuilderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testAnnotationDefaultValue() { try { final XAnnotationsFactory f = XAnnotationsFactory.eINSTANCE; final XExpression e = this.expression("\'Foo\'"); final XAnnotation anno = f.createXAnnotation(); JvmType _findDeclaredType = this.references.findDeclaredType(Named.class, e); anno.setAnnotationType(((JvmAnnotationType) _findDeclaredType)); anno.setValue(e); final JvmGenericType type = this.typesFactory.createJvmGenericType(); this._jvmTypesBuilder.addAnnotation(type, anno); Assert.assertEquals(anno.getAnnotationType(), IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getAnnotation()); JvmAnnotationValue _head = IterableExtensions.<JvmAnnotationValue>head(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues()); EObject _head_1 = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue) _head).getValues()); Assert.assertTrue((_head_1 instanceof XStringLiteral)); Assert.assertNull(IterableExtensions.<JvmAnnotationValue>head(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues()).getOperation()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #21
Source File: EqualsHashCodeCompilerTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testSuperClassWithoutEquals() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("import org.eclipse.xtend.lib.annotations.EqualsHashCode"); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("@EqualsHashCode class Bar extends Foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("String bar = \"Foo\""); _builder.newLine(); _builder.append("}"); _builder.newLine(); final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> { Assert.assertFalse(it.getGeneratedCode("Bar"), it.getGeneratedCode("Bar").contains("super.equals")); Assert.assertFalse(it.getGeneratedCode("Bar").contains("super.hashCode")); }; this.compilationTestHelper.compile(_builder, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #22
Source File: XbaseValidationTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testRedundantCases_05() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch i : 1 {"); _builder.newLine(); _builder.append("\t"); _builder.append("case 1,"); _builder.newLine(); _builder.append("\t"); _builder.append("case 2: 1"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertNoIssue(this.expression(_builder), XbasePackage.Literals.XCASE_PART, IssueCodes.REDUNDANT_CASE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #23
Source File: XbaseValidationTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testUnreachableCase_8() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch new java.util.ArrayList<String> {"); _builder.newLine(); _builder.append("\t"); _builder.append("java.util.List: \"list of integers\""); _builder.newLine(); _builder.append("\t"); _builder.append("java.util.List<String>: \"list of strings\""); _builder.newLine(); _builder.append("\t"); _builder.append("default: \"something else\""); _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); } }
Example #24
Source File: IResourcesSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public static boolean setAutobuild(boolean enable) { IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); boolean oldValue = description.isAutoBuilding(); if (oldValue != enable) { description.setAutoBuilding(enable); try { ResourcesPlugin.getWorkspace().setDescription(description); } catch (CoreException e) { Exceptions.sneakyThrow(e); } } return oldValue; }
Example #25
Source File: AbstractFSSynchronizationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void testDeleteDeletedDerivedResource(IContainer output) { try { File outputDirectory = output.getLocation().toFile(); int expectedSize = 0; if (outputDirectory.exists()) { expectedSize = outputDirectory.list().length; } IFile sourceFile = createFile(project.getFile(("src/Foo" + F_EXT)).getFullPath(), "object Foo"); build(); Assert.assertNotEquals(expectedSize, outputDirectory.list().length); IFile file = output.getFile(new Path("Foo.txt")); file.refreshLocal(0, null); Assert.assertTrue(isSynchronized(file)); new WorkspaceJob("file.delete") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { Assert.assertTrue(file.getLocation().toFile().delete()); Assert.assertFalse(isSynchronized(file)); return Status.OK_STATUS; } }.run(monitor()); sourceFile.delete(false, monitor()); build(); Assert.assertEquals(expectedSize, outputDirectory.list().length); } catch (CoreException e) { throw Exceptions.sneakyThrow(e); } }
Example #26
Source File: ReorderedVarArgFeatureCallArgumentsTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected IFeatureCallArguments toArguments(final String signature, final String invocation, final boolean receiver) { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("def void m("); _builder.append(signature); _builder.append(") {"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("m("); _builder.append(invocation, "\t"); _builder.append(")"); _builder.newLineIfNotEmpty(); _builder.append("}"); _builder.newLine(); final String functionString = _builder.toString(); final XtendFunction function = this.function(functionString); XExpression _expression = function.getExpression(); final XBlockExpression body = ((XBlockExpression) _expression); XExpression _head = IterableExtensions.<XExpression>head(body.getExpressions()); final XFeatureCall featureCall = ((XFeatureCall) _head); final EList<XExpression> arguments = featureCall.getFeatureCallArguments(); final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function); final IFeatureCallArguments result = this.factory.createVarArgArguments(arguments, operation.getParameters(), receiver, this.getOwner()); Class<? extends IFeatureCallArguments> _class = result.getClass(); boolean _equals = Objects.equal(_class, ReorderedVarArgFeatureCallArguments.class); Assert.assertTrue(_equals); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #27
Source File: UIResourceChangeRegistry.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void forgetBuildState() { final Function1<IProject, Boolean> _function = (IProject it) -> { try { return Boolean.valueOf(((it.isAccessible() && it.hasNature(XtextProjectHelper.NATURE_ID)) && it.hasNature(JavaCore.NATURE_ID))); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; final Iterable<IProject> projects = IterableExtensions.<IProject>filter(((Iterable<IProject>)Conversions.doWrapArray(this.workspace.getRoot().getProjects())), _function); this.scheduler.scheduleBuildIfNecessary(projects, IBuildFlag.FORGET_BUILD_STATE_ONLY); }
Example #28
Source File: ContentAssistTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testImportCompletion() { try { this.newBuilder().append("import java.util.Da").assertText("java.util.Date"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #29
Source File: ValidationBug464563Test.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmField_05() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.newLine(); _builder.append("\t"); _builder.append("Unknown<?> myField"); _builder.newLine(); _builder.newLine(); _builder.append("\t"); _builder.append("def void bar() {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("myField = notify"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile file = this._parseHelper.parse(_builder); this._validationTestHelper.assertError(file, XbasePackage.Literals.XASSIGNMENT, IssueCodes.REFER_INVALID_TYPES, "The field Foo.myField refers to the missing type Unknown"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #30
Source File: XbaseValidationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testRangeLiteralInForLoopBug440006_03() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("for (Number i : #[1..2]) {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.expression(_builder), XbasePackage.Literals.XBINARY_OPERATION, IssueCodes.INCOMPATIBLE_TYPES); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }