org.eclipse.xtext.xbase.lib.Procedures.Procedure0 Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.lib.Procedures.Procedure0.
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: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void renamePrimaryTopLevelType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {}"); _builder.newLine(); this.testHelper.createFile("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("/mypackage/Bar.java", "Bar", "Bar2"); }; this.assertThereAreDeltas(_function, "mypackage.Bar", "mypackage.Bar2"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #2
Source File: N4MethodDeclarationImpl.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public LocalArgumentsVariable getLocalArgumentsVariable() { LocalArgumentsVariable __lok = this.get_lok(); boolean _tripleEquals = (__lok == null); if (_tripleEquals) { final LocalArgumentsVariable newLok = N4JSFactory.eINSTANCE.createLocalArgumentsVariable(); newLok.setName("arguments"); final Procedure0 _function = new Procedure0() { public void apply() { N4MethodDeclarationImpl.this.set_lok(newLok); } }; EcoreUtilN4.doWithDeliver(false, _function, this); } return this.get_lok(); }
Example #3
Source File: N4FieldAccessorImpl.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public LocalArgumentsVariable getLocalArgumentsVariable() { LocalArgumentsVariable __lok = this.get_lok(); boolean _tripleEquals = (__lok == null); if (_tripleEquals) { final LocalArgumentsVariable newLok = N4JSFactory.eINSTANCE.createLocalArgumentsVariable(); newLok.setName("arguments"); final Procedure0 _function = new Procedure0() { public void apply() { N4FieldAccessorImpl.this.set_lok(newLok); } }; EcoreUtilN4.doWithDeliver(false, _function, this); } return this.get_lok(); }
Example #4
Source File: TypeResourceUnloaderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddParam() throws BadLocationException, JavaModelException, InterruptedException { waitForEvent(new Procedure0() { @Override public void apply() { int idx = document.get().lastIndexOf("("); assertNull("event is null before the document was modified", event); try { document.replace(idx + 1, 0, "int foobar"); } catch (BadLocationException e) { fail(e.getMessage()); } } }); assertNotNull(event); assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty()); assertEquals("" + event.getDeltas(), 3, event.getDeltas().size()); Collection<String> allNames = getNames(event.getDeltas()); assertOriginalValues(allNames); assertEquals("" + allNames, 3, allNames.size()); }
Example #5
Source File: FunctionDeclarationImpl.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public LocalArgumentsVariable getLocalArgumentsVariable() { LocalArgumentsVariable __lok = this.get_lok(); boolean _tripleEquals = (__lok == null); if (_tripleEquals) { final LocalArgumentsVariable newLok = N4JSFactory.eINSTANCE.createLocalArgumentsVariable(); newLok.setName("arguments"); final Procedure0 _function = new Procedure0() { public void apply() { FunctionDeclarationImpl.this.set_lok(newLok); } }; EcoreUtilN4.doWithDeliver(false, _function, this); } return this.get_lok(); }
Example #6
Source File: PropertyMethodDeclarationImpl.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public LocalArgumentsVariable getLocalArgumentsVariable() { LocalArgumentsVariable __lok = this.get_lok(); boolean _tripleEquals = (__lok == null); if (_tripleEquals) { final LocalArgumentsVariable newLok = N4JSFactory.eINSTANCE.createLocalArgumentsVariable(); newLok.setName("arguments"); final Procedure0 _function = new Procedure0() { public void apply() { PropertyMethodDeclarationImpl.this.set_lok(newLok); } }; EcoreUtilN4.doWithDeliver(false, _function, this); } return this.get_lok(); }
Example #7
Source File: TypeResourceUnloaderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testCloseEditorAndDiscardWorkingCopy() throws InterruptedException { waitForEvent(new Procedure0() { @Override public void apply() { try { compilationUnit.discardWorkingCopy(); ((ITextEditor) editor).close(false); } catch (JavaModelException e) { throw new RuntimeException(e); } } }, false); assertNull(event); }
Example #8
Source File: FunctionDeclarationImpl.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public MigrationContextVariable getMigrationContextVariable() { MigrationContextVariable __migrationContext = this.get_migrationContext(); boolean _tripleEquals = (__migrationContext == null); if (_tripleEquals) { final MigrationContextVariable newMigrationContext = N4JSFactory.eINSTANCE.createMigrationContextVariable(); newMigrationContext.setName("context"); final Procedure0 _function = new Procedure0() { public void apply() { FunctionDeclarationImpl.this.set_migrationContext(newMigrationContext); } }; EcoreUtilN4.doWithDeliver(false, _function, this); } return this.get_migrationContext(); }
Example #9
Source File: TypeResourceUnloaderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testRenameMethod() throws BadLocationException, JavaModelException, InterruptedException { waitForEvent(new Procedure0() { @Override public void apply() { int idx = document.get().lastIndexOf("method("); assertNull("event is null before the document was modified", event); try { document.replace(idx + "method".length(), 0, "2"); } catch (BadLocationException e) { fail(e.getMessage()); } } }); assertNotNull(event); assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty()); assertEquals("" + event.getDeltas(), 3, event.getDeltas().size()); Collection<String> allNames = getNames(event.getDeltas()); assertOriginalValues(allNames); assertEquals("" + allNames, 3, allNames.size()); }
Example #10
Source File: TypeResourceUnloaderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testRenameInnerMethod() throws BadLocationException, JavaModelException, InterruptedException { waitForEvent(new Procedure0() { @Override public void apply() { int idx = document.get().indexOf("method("); assertNull("event is null before the document was modified", event); try { document.replace(idx + "method".length(), 0, "2"); } catch (BadLocationException e) { fail(e.getMessage()); } } }); assertNotNull(event); assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty()); assertEquals("" + event.getDeltas(), 3, event.getDeltas().size()); Collection<String> allNames = getNames(event.getDeltas()); assertOriginalValues(allNames); assertEquals("" + allNames, 3, allNames.size()); }
Example #11
Source File: TypeResourceUnloaderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testRemoveNestedClass() throws BadLocationException, JavaModelException, InterruptedException { waitForEvent(new Procedure0() { @Override public void apply() { int idx = document.get().indexOf("public abstract class Inner"); assertNull("event is null before the document was modified", event); try { int closing = document.get().substring(idx).indexOf("\t}"); document.replace(idx, closing + 2, ""); } catch (BadLocationException e) { fail(e.getMessage()); } } }); assertNotNull(event); assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty()); assertEquals("" + event.getDeltas(), 3, event.getDeltas().size()); assertNull(event.getDeltas().get(2).getNew()); assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(0).getUri().toString()); assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(1).getUri().toString()); assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(2).getUri().toString()); }
Example #12
Source File: TypeResourceUnloaderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddNestedClass() throws BadLocationException, JavaModelException, InterruptedException { waitForEvent(new Procedure0() { @Override public void apply() { int idx = document.get().indexOf("public abstract class Inner"); assertNull("event is null before the document was modified", event); try { int closing = document.get().substring(idx).indexOf("\t}"); document.replace(idx + closing, 0, " public abstract class InnerSibling {} "); } catch (BadLocationException e) { fail(e.getMessage()); } } }); assertNotNull(event); assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty()); assertEquals("" + event.getDeltas(), 4, event.getDeltas().size()); assertNull(event.getDeltas().get(3).getOld()); assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(0).getUri().toString()); assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(1).getUri().toString()); assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(2).getUri().toString()); assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(3).getUri().toString()); }
Example #13
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void addTypeParameter() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.testHelper.createFile("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("/mypackage/Bar.java", "Bar", "Bar<T>"); }; this.assertThereAreDeltas(_function, "mypackage.Bar"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #14
Source File: XtendEditorChangingClasspathTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddXtendLibWithDirtyEditor() { try { final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject"); final IFile file = IResourcesSetupUtil.createFile("testProject/src/Foo.xtend", "class Foo {}"); IResourcesSetupUtil.waitForBuild(); final XtextEditor editor = this.workbenchTestHelper.openEditor(file); final Procedure0 _function = () -> { this.changeContent(editor, "{}", "{ def foo () {} }"); }; this.waitForChangeEvent(_function); this.assertAddLibsToClasspath(project); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #15
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void removePrimaryTopLevelType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {}"); _builder.newLine(); this.testHelper.createFile("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("/mypackage/Bar.java", "public class Bar {}", ""); }; this.assertThereAreDeltas(_function, "mypackage.Bar"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #16
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void addSecondaryTopLevelType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("// secondary top level type"); _builder.newLine(); this.testHelper.createFile("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("/mypackage/Bar.java", "// secondary top level type", "class Foo {}"); }; this.assertThereAreDeltas(_function, "mypackage.Foo"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #17
Source File: MutableAssert.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public static <T extends Throwable> T assertThrowable(final Class<T> clazz, final Procedure0 codeToTest) { Object _xblockexpression = null; { try { codeToTest.apply(); } catch (final Throwable _t) { if (_t instanceof Throwable) { final Throwable e = (Throwable)_t; Assert.assertEquals(e.getMessage(), clazz, e.getClass()); return ((T) e); } else { throw Exceptions.sneakyThrow(_t); } } StringConcatenation _builder = new StringConcatenation(); _builder.append("an instance of the "); String _name = clazz.getName(); _builder.append(_name); _builder.append(" class had to be thrown"); Assert.fail(_builder.toString()); _xblockexpression = null; } return ((T)_xblockexpression); }
Example #18
Source File: WorkspaceFoldersTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected void withBuild(final Procedure0 lambda) { try { final CompletableFuture<Void> future = new CompletableFuture<Void>(); final ILanguageServerAccess.IBuildListener _function = new ILanguageServerAccess.IBuildListener() { @Override public void afterBuild(final List<IResourceDescription.Delta> it) { WorkspaceFoldersTest.this.workspaceManager.removeBuildListener(this); future.complete(null); } }; this.workspaceManager.addBuildListener(_function); lambda.apply(); future.get(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #19
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void removeSecondaryTopLevelType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {}"); _builder.newLine(); this.testHelper.createFile("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("/mypackage/Bar.java", "class Foo {}", ""); }; this.assertThereAreDeltas(_function, "mypackage.Foo"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #20
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void renameSecondaryTopLevelType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("class Bar2 {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.testHelper.createFile("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("/mypackage/Bar.java", "Bar2", "Bar3"); }; this.assertThereAreDeltas(_function, "mypackage.Bar2", "mypackage.Bar3"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #21
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void addSecondaryTopLevelTypeWithinDefaultPackage() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("public class Bar {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("// secondary top level type"); _builder.newLine(); this.testHelper.createFile("Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("Bar.java", "// secondary top level type", "class Foo {}"); }; this.assertThereAreDeltas(_function, "Foo"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #22
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void removeSecondaryTopLevelTypeWithinDefaultPackage() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("public class Bar {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {}"); _builder.newLine(); this.testHelper.createFile("Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("Bar.java", "class Foo {}", ""); }; this.assertThereAreDeltas(_function, "Foo"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #23
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void renameSecondaryTopLevelTypeWithinDefaultPackage() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("public class Bar {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("class Bar2 {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.testHelper.createFile("Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("Bar.java", "Bar2", "Bar3"); }; this.assertThereAreDeltas(_function, "Bar2", "Bar3"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #24
Source File: MutableAssert.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public static void assertValidJavaIdentifier(final String name, final Procedure1<? super String> codeToTest) { StringConcatenation _builder = new StringConcatenation(); _builder.append(name); _builder.append(" has to be a valid java identifier"); final String message = _builder.toString(); final Procedure0 _function = () -> { codeToTest.apply(null); }; MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, message, _function); final Procedure0 _function_1 = () -> { codeToTest.apply(" "); }; MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, message, _function_1); final Procedure0 _function_2 = () -> { codeToTest.apply("456"); }; MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, message, _function_2); codeToTest.apply("foo"); }
Example #25
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void makeFieldPublic() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.newLine(); _builder.append("\t"); _builder.append("private String bar;"); _builder.newLine(); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.testHelper.createFile("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("/mypackage/Bar.java", "private String bar;", "public String bar;"); }; this.assertThereAreDeltas(_function, "mypackage.Bar"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #26
Source File: AbstractSingleEditorQueuedBuildTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void makePrivateFieldStatic() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.newLine(); _builder.append("\t"); _builder.append("private String bar;"); _builder.newLine(); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.testHelper.createFile("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.save("/mypackage/Bar.java", "private String bar;", "private static String bar;"); }; this.assertThereAreDeltas(_function, "mypackage.Bar"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #27
Source File: ProblemSupportImpl.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public void validationPhaseStarted() { try { final Consumer<Procedure0> _function = (Procedure0 it) -> { it.apply(); }; this.delayedTasks.forEach(_function); } catch (final Throwable _t) { if (_t instanceof Throwable) { final Throwable t = (Throwable)_t; this.compilationUnit.handleProcessingError(Collections.<XtendFile>singleton(this.compilationUnit.getXtendFile()), this.compilationUnit.getXtendFile().eResource(), t); } else { throw Exceptions.sneakyThrow(_t); } } finally { this.delayedTasks.clear(); } }
Example #28
Source File: TypesChangingQueuedBuildDataTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void createPrimaryType2() { final Procedure0 _function = () -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.create("/mypackage/Bar.java", _builder.toString()); }; this.assertThereAreDeltas(_function, "mypackage.Bar"); }
Example #29
Source File: TypesChangingQueuedBuildDataTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void deletePrimaryType2() { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.create("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.delete("/mypackage/Bar.java"); }; this.assertThereAreDeltas(_function, "mypackage.Bar"); }
Example #30
Source File: TypesChangingQueuedBuildDataTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void deletePrimaryAndSecondaryType2() { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypackage;"); _builder.newLine(); _builder.newLine(); _builder.append("public class Bar {"); _builder.newLine(); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.create("/mypackage/Bar.java", _builder.toString()); final Procedure0 _function = () -> { this.delete("/mypackage/Bar.java"); }; this.assertThereAreDeltas(_function, "mypackage.Bar", "mypackage.Foo"); }