@Override public void resolvesIdentifiablesTo(final String expression, final String... types) { try { final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::"); final XExpression xExpression = this.expression(expressionWithQualifiedNames, false); final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(xExpression); final List<JvmIdentifiableElement> identifiables = this.findIdentifiables(xExpression); Assert.assertFalse(identifiables.isEmpty()); Assert.assertEquals(((List<String>)Conversions.doWrapArray(types)).size(), identifiables.size()); final Procedure2<JvmIdentifiableElement, Integer> _function = (JvmIdentifiableElement identifiable, Integer index) -> { final LightweightTypeReference type = resolvedTypes.getActualType(identifiable); Assert.assertNotNull(type); StringConcatenation _builder = new StringConcatenation(); _builder.append("failed for identifiable at "); _builder.append(index); Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName()); }; IterableExtensions.<JvmIdentifiableElement>forEach(identifiables, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public void resolvesConstructorCallsTo(final String expression, final String... types) { final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::"); final List<XConstructorCall> featureCalls = this.findConstructorCalls(expressionWithQualifiedNames); Assert.assertFalse(featureCalls.isEmpty()); Assert.assertEquals(((List<String>)Conversions.doWrapArray(types)).size(), featureCalls.size()); final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(IterableExtensions.<XConstructorCall>head(featureCalls)); final Procedure2<XConstructorCall, Integer> _function = (XConstructorCall featureCall, Integer index) -> { final LightweightTypeReference type = resolvedTypes.getActualType(featureCall); StringConcatenation _builder = new StringConcatenation(); _builder.append("failed for constructor call at "); _builder.append(index); Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName()); }; IterableExtensions.<XConstructorCall>forEach(featureCalls, _function); }
@Override public void resolvesFeatureCallsTo(final String expression, final String... types) { final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::"); final List<XAbstractFeatureCall> featureCalls = this.findFeatureCalls(expressionWithQualifiedNames); final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(IterableExtensions.<XAbstractFeatureCall>head(featureCalls)); final Iterable<XAbstractFeatureCall> actualFeatureCalls = this.filterTypeLiteralsAndPackageFragments(featureCalls); Assert.assertFalse(IterableExtensions.isEmpty(actualFeatureCalls)); Assert.assertEquals(("" + actualFeatureCalls), ((List<String>)Conversions.doWrapArray(types)).size(), IterableExtensions.size(actualFeatureCalls)); final Procedure2<XAbstractFeatureCall, Integer> _function = (XAbstractFeatureCall featureCall, Integer index) -> { final LightweightTypeReference type = resolvedTypes.getActualType(featureCall); StringConcatenation _builder = new StringConcatenation(); _builder.append("failed for feature call at "); _builder.append(index); Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName()); }; IterableExtensions.<XAbstractFeatureCall>forEach(actualFeatureCalls, _function); }
@Override public void withEquivalents(final List<Object> references, final String... types) { final Procedure2<Object, Integer> _function = (Object reference, Integer index) -> { final Callable<Object> _function_1 = () -> { Assert.assertTrue((reference instanceof FunctionTypeReference)); return null; }; this.collector.<Object>checkSucceeds(_function_1); final Callable<Object> _function_2 = () -> { Assert.assertEquals(types[(index).intValue()], this.getEquivalent(((FunctionTypeReference) reference))); return null; }; this.collector.<Object>checkSucceeds(_function_2); }; IterableExtensions.<Object>forEach(references, _function); }
@Override protected void hasTypeArguments(final XExpression expression, final String... typeArguments) { final List<LightweightTypeReference> actualTypeArguments = this.resolvedTypes.getActualTypeArguments(expression); Assert.assertEquals(((List<String>)Conversions.doWrapArray(typeArguments)).size(), actualTypeArguments.size()); final Procedure2<String, Integer> _function = (String typeArgument, Integer i) -> { StringConcatenation _builder = new StringConcatenation(); String _join = IterableExtensions.join(((Iterable<?>)Conversions.doWrapArray(typeArguments)), ", "); _builder.append(_join); _builder.append(" vs "); final Function1<LightweightTypeReference, String> _function_1 = (LightweightTypeReference it) -> { return it.getSimpleName(); }; String _join_1 = IterableExtensions.join(ListExtensions.<LightweightTypeReference, String>map(actualTypeArguments, _function_1), ", "); _builder.append(_join_1); Assert.assertEquals(_builder.toString(), typeArgument, actualTypeArguments.get((i).intValue()).getSimpleName()); }; IterableExtensions.<String>forEach(((Iterable<String>)Conversions.doWrapArray(typeArguments)), _function); }
@Before public void setup() { ServerModule _serverModule = new ServerModule(); final Injector injector = Guice.createInjector(Modules2.mixin(_serverModule, new AbstractModule() { @Override protected void configure() { this.<IWorkspaceConfigFactory>bind(IWorkspaceConfigFactory.class).to(MultiProjectWorkspaceConfigFactory.class); } })); injector.injectMembers(this); final File workspaceRoot = this.getRoot("test-data"); File _file = new File(workspaceRoot, "test-project0"); this.project0 = _file; File _file_1 = new File(workspaceRoot, "test-project1"); this.project1 = _file_1; this.project0.mkdir(); this.project1.mkdir(); final Procedure2<URI, Iterable<Issue>> _function = (URI $0, Iterable<Issue> $1) -> { this.diagnostics.put($0, IterableExtensions.<Issue>toList($1)); }; this.workspaceManager.initialize(URI.createFileURI(workspaceRoot.getAbsolutePath()), _function, null); }
@Before public void setup() { try { ServerModule _serverModule = new ServerModule(); final Injector injector = Guice.createInjector(_serverModule); injector.injectMembers(this); File _file = new File("./test-data/test-project"); this.root = _file; boolean _mkdirs = this.root.mkdirs(); boolean _not = (!_mkdirs); if (_not) { Files.cleanFolder(this.root, null, true, false); } this.root.deleteOnExit(); final Procedure2<URI, Iterable<Issue>> _function = (URI $0, Iterable<Issue> $1) -> { this.diagnostics.put($0, IterableExtensions.<Issue>toList($1)); }; this.workspaceManger.initialize(this.uriExtensions.withEmptyAuthority(URI.createFileURI(this.root.getAbsolutePath())), _function, null); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public Collection<IHierarchyNode> buildChildren(final IHierarchyNode parent, final IProgressMonitor monitor) { boolean _mayHaveChildren = parent.mayHaveChildren(); boolean _not = (!_mayHaveChildren); if (_not) { return CollectionLiterals.<IHierarchyNode>emptyList(); } final LinkedHashMap<URI, IHierarchyNode> children = CollectionLiterals.<URI, IHierarchyNode>newLinkedHashMap(); final Procedure2<IEObjectDescription, IReferenceDescription> _function = (IEObjectDescription declaration, IReferenceDescription reference) -> { final IHierarchyNode childNode = this.createChild(children, declaration, parent); if ((childNode != null)) { final IHierarchyNodeReference nodeReference = this.createNodeReference(reference); if ((nodeReference != null)) { Collection<IHierarchyNodeReference> _references = childNode.getReferences(); _references.add(nodeReference); } } }; this.findDeclarations(parent, monitor, _function); return children.values(); }
protected void findTargetDeclarations(final URI sourceDeclarationURI, final IProgressMonitor monitor, final Procedure2<? super IEObjectDescription, ? super IReferenceDescription> acceptor) { final IUnitOfWork<Object, EObject> _function = (EObject sourceDeclaration) -> { Object _xblockexpression = null; { IResourceServiceProvider.Registry _resourceServiceProviderRegistry = this.getResourceServiceProviderRegistry(); final IAcceptor<IReferenceDescription> _function_1 = (IReferenceDescription reference) -> { boolean _filterReference = this.filterReference(reference); if (_filterReference) { IEObjectDescription _findTargetDeclaration = null; if (reference!=null) { _findTargetDeclaration=this.findTargetDeclaration(reference); } final IEObjectDescription targetDeclaration = _findTargetDeclaration; acceptor.apply(targetDeclaration, reference); } }; ReferenceAcceptor _referenceAcceptor = new ReferenceAcceptor(_resourceServiceProviderRegistry, _function_1); this.getReferenceFinder().findAllReferences(sourceDeclaration, _referenceAcceptor, monitor); _xblockexpression = null; } return _xblockexpression; }; this.<Object>readOnly(sourceDeclarationURI, _function); }
protected void findSourceDeclarations(final URI targetDeclarationURI, final IProgressMonitor monitor, final Procedure2<? super IEObjectDescription, ? super IReferenceDescription> acceptor) { final TargetURIs targetURIs = this.collectTargetURIs(targetDeclarationURI); IResourceServiceProvider.Registry _resourceServiceProviderRegistry = this.getResourceServiceProviderRegistry(); final IAcceptor<IReferenceDescription> _function = (IReferenceDescription reference) -> { boolean _filterReference = this.filterReference(reference); if (_filterReference) { IEObjectDescription _findSourceDeclaration = null; if (reference!=null) { _findSourceDeclaration=this.findSourceDeclaration(reference); } final IEObjectDescription sourceDeclaration = _findSourceDeclaration; acceptor.apply(sourceDeclaration, reference); } }; ReferenceAcceptor _referenceAcceptor = new ReferenceAcceptor(_resourceServiceProviderRegistry, _function); this.getReferenceFinder().findAllReferences(targetURIs, this.getResourceAccess(), this.getIndexData(), _referenceAcceptor, monitor); }
private void _checkIsValidLocking(final AdditiveLockedJointType aljt, final JointTypeExpression exp) { LockedJointTypeExpression _left = aljt.getLeft(); JointTypeExpression _get = JointTypeHelper.get(exp, 0); this.checkIsValidLocking(_left, _get); EList<LockedJointTypeExpression> _right = aljt.getRight(); final Procedure2<LockedJointTypeExpression, Integer> _function = new Procedure2<LockedJointTypeExpression, Integer>() { @Override public void apply(final LockedJointTypeExpression e, final Integer idx) { final JointTypeExpression jt = JointTypeHelper.get(exp, ((idx).intValue() + 1)); boolean _notEquals = (!Objects.equal(jt, null)); if (_notEquals) { RigidBodiesValidator.this.checkIsValidLocking(e, jt); } else { RigidBodiesValidator.this.error("No matching element in original joint type", e, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, RigidBodiesValidator.LOCKED_TYPE_NO_MATCH); } } }; IterableExtensions.<LockedJointTypeExpression>forEach(_right, _function); }
public Slider addSlider(final int min, final int max, final float x, final float y) { Slider _xblockexpression = null; { final Slider slider = this.addSliderWithoutLabel(min, max, x, y); final Label label = this.addLabel((x + 150), (y + 5), ("" + Integer.valueOf(min))); final Procedure2<ChangeListener.ChangeEvent, Actor> _function = new Procedure2<ChangeListener.ChangeEvent, Actor>() { @Override public void apply(final ChangeListener.ChangeEvent $0, final Actor $1) { float _value = slider.getValue(); int _intValue = Float.valueOf(_value).intValue(); String _plus = ("" + Integer.valueOf(_intValue)); label.setText(_plus); } }; MyChangeListener _myChangeListener = new MyChangeListener(_function); slider.addListener(_myChangeListener); _xblockexpression = slider; } return _xblockexpression; }
private CellData[][] fillCells(final Board<ServerPlayer, ServerCell, ServerLinks> board) { int _xSize = board.getXSize(); int _ySize = board.getYSize(); final CellData[][] cellUpdates = new CellData[_xSize][_ySize]; int _xSize_1 = board.getXSize(); int _ySize_1 = board.getYSize(); final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { final ServerCell originalCell = board.getCellAt((x).intValue(), (y).intValue()); CellData[] _get = cellUpdates[(x).intValue()]; CellData _buildCell = InitGameSender.this.buildCell(originalCell); _get[(y).intValue()] = _buildCell; } }; FieldLoop.visitAllFields(_xSize_1, _ySize_1, _function); return cellUpdates; }
public static void fillBoard(final ServerBoardImpl board, final IntPoint size, final CheckModelElement checker, final Function2<Integer, Integer, Integer> heightFunction) { final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { final int id = IDGenerator.generateId(); final IntPoint boardCoordinate = IntPoint.from((x).intValue(), (y).intValue()); final int height = (heightFunction.apply(x, y)).intValue(); final CellTypes cellType = CellTypes.PLAIN; final ServerCellImpl cell = new ServerCellImpl(id, boardCoordinate, height, cellType, checker); cell.setBattle(false); cell.setStrength(0); cell.<Player>setOwner(null); board.setCellAt(cell); } }; FieldLoop.visitAllFields(size.x, size.y, _function); }
private CellUpdateData[][] fillCells(final Board<ClientPlayer, ClientCell, ClientLinks> board) { int _xSize = board.getXSize(); int _ySize = board.getYSize(); final CellUpdateData[][] cellUpdates = new CellUpdateData[_xSize][_ySize]; int _xSize_1 = board.getXSize(); int _ySize_1 = board.getYSize(); final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { final ClientCell originalCell = board.getCellAt((x).intValue(), (y).intValue()); CellUpdateData _xifexpression = null; boolean _isVisible = originalCell.isVisible(); if (_isVisible) { _xifexpression = GameSender.this.buildCell(originalCell); } else { _xifexpression = null; } final CellUpdateData cell = _xifexpression; CellUpdateData[] _get = cellUpdates[(x).intValue()]; _get[(y).intValue()] = cell; } }; FieldLoop.visitAllFields(_xSize_1, _ySize_1, _function); return cellUpdates; }
@Override public void run() { int _xSize = this.board.getXSize(); int _ySize = this.board.getYSize(); final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { ServerCell _cellAt = XBattleDistribute.this.board.getCellAt((x).intValue(), (y).intValue()); _cellAt.setBattle(false); } }; FieldLoop.visitAllFields(_xSize, _ySize, _function); final ArrayList<ServerCell> cells = this.shuffleCells(); this.resetFight(cells); for (final ServerCell cell : cells) { { LogicHelper.updateCellGrowth(cell, this.configuration); this.updateCellFights(cell); this.updateCellMovement(cell); } } }
protected void _assertEqualLinkingData(final IClosureCandidate left, final IClosureCandidate right) { Assert.assertEquals("type", left.getParameters().size(), right.getParameters().size()); final Procedure2<JvmFormalParameter, Integer> _function = (JvmFormalParameter leftParam, Integer idx) -> { final JvmFormalParameter rightParam = right.getParameters().get((idx).intValue()); Assert.assertEquals(leftParam.getName(), rightParam.getName()); EStructuralFeature _eContainingFeature = leftParam.eContainingFeature(); boolean _notEquals = (!Objects.equal(_eContainingFeature, XbasePackage.Literals.XCLOSURE__DECLARED_FORMAL_PARAMETERS)); if (_notEquals) { Assert.assertEquals(leftParam.getParameterType().getIdentifier(), rightParam.getParameterType().getIdentifier()); } }; IterableExtensions.<JvmFormalParameter>forEach(left.getParameters(), _function); }
public void withEquivalents(final List<Object> references, final String... types) { final Procedure2<Object, Integer> _function = (Object reference, Integer index) -> { final Callable<Object> _function_1 = () -> { Assert.assertTrue((reference instanceof FunctionTypeReference)); return null; }; this.collector.<Object>checkSucceeds(_function_1); final Callable<Object> _function_2 = () -> { Assert.assertEquals(types[(index).intValue()], this.getEquivalent(((FunctionTypeReference) reference))); return null; }; this.collector.<Object>checkSucceeds(_function_2); }; IterableExtensions.<Object>forEach(references, _function); }
public void resolvesStringLiteralsTo(final String expression, final String... types) { final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::"); final List<XStringLiteral> featureCalls = this.findLiterals(expressionWithQualifiedNames); Assert.assertFalse(featureCalls.isEmpty()); Assert.assertEquals(((List<String>)Conversions.doWrapArray(types)).size(), featureCalls.size()); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(IterableExtensions.<XStringLiteral>head(featureCalls)); final Procedure2<XStringLiteral, Integer> _function = (XStringLiteral featureCall, Integer index) -> { final LightweightTypeReference type = resolvedTypes.getActualType(featureCall); StringConcatenation _builder = new StringConcatenation(); _builder.append("failed for literal at "); _builder.append(index); Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName()); }; IterableExtensions.<XStringLiteral>forEach(featureCalls, _function); }
@Test public void testAppendForEachSafely() { XExpression _validatedExpression = this.validatedExpression("{ val x=42 val y=42 }"); final XBlockExpression e = ((XBlockExpression) _validatedExpression); final TreeAppendable app = this.createTreeAppendable(e); Assert.assertFalse(this._errorSafeExtensions.hasErrors(e.getExpressions().get(0))); Assert.assertFalse(this._errorSafeExtensions.hasErrors(e.getExpressions().get(1))); final Procedure2<XExpression, ITreeAppendable> _function = (XExpression it, ITreeAppendable app2) -> { app2.append(this.getText(it)); }; this._errorSafeExtensions.<XExpression>forEachSafely(app, e.getExpressions(), this.getLoopInitializer(), _function); Assert.assertEquals("(val x=42:val y=42)", app.getContent()); }
@Test public void testAppendForEachSafely_0() { XExpression _validatedExpression = this.validatedExpression("{ error val x=42 val y=42 }"); final XBlockExpression e = ((XBlockExpression) _validatedExpression); final TreeAppendable app = this.createTreeAppendable(e); Assert.assertTrue(this._errorSafeExtensions.hasErrors(e.getExpressions().get(0))); Assert.assertFalse(this._errorSafeExtensions.hasErrors(e.getExpressions().get(1))); Assert.assertFalse(this._errorSafeExtensions.hasErrors(e.getExpressions().get(2))); final Procedure2<XExpression, ITreeAppendable> _function = (XExpression it, ITreeAppendable app2) -> { app2.append(this.getText(it)); }; this._errorSafeExtensions.<XExpression>forEachSafely(app, e.getExpressions(), this.getLoopInitializer(), _function); Assert.assertEquals("(/* error */val x=42:val y=42)", app.getContent()); }
@Test public void testAppendForEachSafely_1() { XExpression _validatedExpression = this.validatedExpression("{ val x=42 error val y=42 }"); final XBlockExpression e = ((XBlockExpression) _validatedExpression); final TreeAppendable app = this.createTreeAppendable(e); Assert.assertFalse(this._errorSafeExtensions.hasErrors(e.getExpressions().get(0))); Assert.assertTrue(this._errorSafeExtensions.hasErrors(e.getExpressions().get(1))); Assert.assertFalse(this._errorSafeExtensions.hasErrors(e.getExpressions().get(2))); final Procedure2<XExpression, ITreeAppendable> _function = (XExpression it, ITreeAppendable app2) -> { app2.append(this.getText(it)); }; this._errorSafeExtensions.<XExpression>forEachSafely(app, e.getExpressions(), this.getLoopInitializer(), _function); Assert.assertEquals("(val x=42/* :error */:val y=42)", app.getContent()); }
@Test public void testAppendForEachSafely_2() { XExpression _validatedExpression = this.validatedExpression("{ val x=42 val y=42 error }"); final XBlockExpression e = ((XBlockExpression) _validatedExpression); final TreeAppendable app = this.createTreeAppendable(e); Assert.assertFalse(this._errorSafeExtensions.hasErrors(e.getExpressions().get(0))); Assert.assertFalse(this._errorSafeExtensions.hasErrors(e.getExpressions().get(1))); Assert.assertTrue(this._errorSafeExtensions.hasErrors(e.getExpressions().get(2))); final Procedure2<XExpression, ITreeAppendable> _function = (XExpression it, ITreeAppendable app2) -> { app2.append(this.getText(it)); }; this._errorSafeExtensions.<XExpression>forEachSafely(app, e.getExpressions(), this.getLoopInitializer(), _function); Assert.assertEquals("(val x=42:val y=42/* :error */)", app.getContent()); }
@Test public void testAppendForEachSafely_3() { XExpression _validatedExpression = this.validatedExpression("{ error }"); final XBlockExpression e = ((XBlockExpression) _validatedExpression); final TreeAppendable app = this.createTreeAppendable(e); Assert.assertTrue(this._errorSafeExtensions.hasErrors(e.getExpressions().get(0))); final Procedure2<XExpression, ITreeAppendable> _function = (XExpression it, ITreeAppendable app2) -> { app2.append(this.getText(it)); }; this._errorSafeExtensions.<XExpression>forEachSafely(app, e.getExpressions(), this.getLoopInitializer(), _function); Assert.assertEquals("/* (error) */", app.getContent()); }
@Test public void testAppendForEachSafely_4() { XExpression _validatedExpression = this.validatedExpression("{ error1 error2 }"); final XBlockExpression e = ((XBlockExpression) _validatedExpression); final TreeAppendable app = this.createTreeAppendable(e); Assert.assertTrue(this._errorSafeExtensions.hasErrors(e.getExpressions().get(0))); Assert.assertTrue(this._errorSafeExtensions.hasErrors(e.getExpressions().get(1))); final Procedure2<XExpression, ITreeAppendable> _function = (XExpression it, ITreeAppendable app2) -> { app2.append(this.getText(it)); }; this._errorSafeExtensions.<XExpression>forEachSafely(app, e.getExpressions(), this.getLoopInitializer(), _function); Assert.assertEquals("/* (error1:error2) */", app.getContent()); }
/** * Curries a procedure that takes two arguments. * * @param procedure * the original procedure. May not be <code>null</code>. * @param argument * the fixed first argument of {@code procedure}. * @return a procedure that takes one argument. Never <code>null</code>. */ @Pure public static <P1, P2> Procedure1<P2> curry(final Procedure2<? super P1, ? super P2> procedure, final P1 argument) { if (procedure == null) throw new NullPointerException("procedure"); return new Procedure1<P2>() { @Override public void apply(P2 p) { procedure.apply(argument, p); } }; }
/** * Curries a procedure that takes three arguments. * * @param procedure * the original procedure. May not be <code>null</code>. * @param argument * the fixed first argument of {@code procedure}. * @return a procedure that takes two arguments. Never <code>null</code>. */ @Pure public static <P1, P2, P3> Procedure2<P2, P3> curry(final Procedure3<? super P1, ? super P2, ? super P3> procedure, final P1 argument) { if (procedure == null) throw new NullPointerException("procedure"); return new Procedure2<P2, P3>() { @Override public void apply(P2 p2, P3 p3) { procedure.apply(argument, p2, p3); } }; }
/** * Applies {@code procedure} for each element of the given iterator. * The procedure takes the element and a loop counter. If the counter would overflow, {@link Integer#MAX_VALUE} * is returned for all subsequent elements. The first element is at index zero. * * @param iterator * the iterator. May not be <code>null</code>. * @param procedure * the procedure. May not be <code>null</code>. */ public static <T> void forEach(Iterator<T> iterator, Procedure2<? super T, ? super Integer> procedure) { if (procedure == null) throw new NullPointerException("procedure"); int i = 0; while(iterator.hasNext()) { procedure.apply(iterator.next(), i); if (i != Integer.MAX_VALUE) i++; } }
public void initialize(final ProjectDescription description, final IProjectConfig projectConfig, final Procedure2<? super URI, ? super Iterable<Issue>> acceptor, final IExternalContentSupport.IExternalContentProvider openedDocumentsContentProvider, final Provider<Map<String, ResourceDescriptionsData>> indexProvider, final CancelIndicator cancelIndicator) { this.projectDescription = description; this.projectConfig = projectConfig; this.baseDir = projectConfig.getPath(); this.issueAcceptor = acceptor; this.openedDocumentsContentProvider = openedDocumentsContentProvider; this.indexProvider = indexProvider; }
public CompletionList createCompletionList(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final CancelIndicator cancelIndicator) { try { final CompletionList result = new CompletionList(); result.setIsIncomplete(true); final IdeContentProposalAcceptor acceptor = this.proposalAcceptorProvider.get(); final int caretOffset = document.getOffSet(params.getPosition()); final Position caretPosition = params.getPosition(); final TextRegion position = new TextRegion(caretOffset, 0); try { this.createProposals(document.getContents(), position, caretOffset, resource, acceptor); } catch (final Throwable _t) { if (_t instanceof Throwable) { final Throwable t = (Throwable)_t; boolean _isOperationCanceledException = this.operationCanceledManager.isOperationCanceledException(t); boolean _not = (!_isOperationCanceledException); if (_not) { throw t; } } else { throw Exceptions.sneakyThrow(_t); } } final Procedure2<ContentAssistEntry, Integer> _function = (ContentAssistEntry it, Integer idx) -> { final CompletionItem item = this.toCompletionItem(it, caretOffset, caretPosition, document); item.setSortText(Strings.padStart(Integer.toString((idx).intValue()), 5, '0')); List<CompletionItem> _items = result.getItems(); _items.add(item); }; IterableExtensions.<ContentAssistEntry>forEach(acceptor.getEntries(), _function); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected void findDeclarations(final IHierarchyNode parent, final IProgressMonitor monitor, final Procedure2<? super IEObjectDescription, ? super IReferenceDescription> acceptor) { final ICallHierarchyBuilder.CallHierarchyType hierarchyType = this.hierarchyType; if (hierarchyType != null) { switch (hierarchyType) { case CALLEE: this.findTargetDeclarations(parent.getElement().getEObjectURI(), monitor, acceptor); break; default: this.findSourceDeclarations(parent.getElement().getEObjectURI(), monitor, acceptor); break; } } else { this.findSourceDeclarations(parent.getElement().getEObjectURI(), monitor, acceptor); } }
private void updateBoard(final Board<ClientPlayer, ClientCell, ClientLinks> board, final CellData[][] cellUpdates) { int _xSize = board.getXSize(); int _ySize = board.getYSize(); final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { CellData[] _get = cellUpdates[(x).intValue()]; CellData _get_1 = _get[(y).intValue()]; InitBoardCommandProcessor.this.createCell(board, (x).intValue(), (y).intValue(), _get_1); } }; FieldLoop.visitAllFields(_xSize, _ySize, _function); }
private void updateBoard(final Board<ClientPlayer, ClientCell, ClientLinks> board, final CellUpdateData[][] cellUpdates) { int _xSize = board.getXSize(); int _ySize = board.getYSize(); final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { ClientCell _cellAt = board.getCellAt((x).intValue(), (y).intValue()); CellUpdateData[] _get = cellUpdates[(x).intValue()]; CellUpdateData _get_1 = _get[(y).intValue()]; BoardUpdateCommandProcessor.this.updateCell(_cellAt, _get_1); } }; FieldLoop.visitAllFields(_xSize, _ySize, _function); }
public void drawHexField() { int _width = Gdx.graphics.getWidth(); int _height = Gdx.graphics.getHeight(); Gdx.gl.glViewport(0, 0, _width, _height); final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { BackgroundRender.this.renderHex((x).intValue(), (y).intValue()); } }; FieldLoop.visitAllFields(16, 16, _function); }
public static void visitAllFields(final int xsize, final int ysize, final Procedure2<Integer, Integer> delegate) { for (int y = 0; y < ysize; y++) { for (int x = 0; x < xsize; x++) { delegate.apply(x, y); } } }
private ArrayList<ServerCell> shuffleCells() { ArrayList<ServerCell> _xblockexpression = null; { final ArrayList<ServerCell> cells = CollectionLiterals.<ServerCell>newArrayList(); int _xSize = this.board.getXSize(); int _ySize = this.board.getYSize(); final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { ServerCell _cellAt = XBattleDistribute.this.board.getCellAt((x).intValue(), (y).intValue()); cells.add(_cellAt); } }; FieldLoop.visitAllFields(_xSize, _ySize, _function); for (int i = 0; (i < cells.size()); i++) { { int _size = cells.size(); final int swapPos = this.rand.nextInt(_size); final ServerCell old = cells.get(i); ServerCell _get = cells.get(swapPos); cells.set(i, _get); cells.set(swapPos, old); } } _xblockexpression = cells; } return _xblockexpression; }
public void testTotalStrength(final int expectedStrength, final ServerGameImpl game) { final LongHolder strength = new LongHolder(); final Procedure2<Integer, Integer> _function = new Procedure2<Integer, Integer>() { @Override public void apply(final Integer x, final Integer y) { Board<ServerPlayer, ServerCell, ServerLinks> _board = game.getBoard(); ServerCell _cellAt = _board.getCellAt((x).intValue(), (y).intValue()); int _strength = _cellAt.getStrength(); strength.add(_strength); } }; FieldLoop.visitAllFields(SimpleGameLogicTest.XSIZE, SimpleGameLogicTest.YSIZE, _function); Assert.assertEquals(expectedStrength, ((int) strength.value)); }
/** * Runs some code safely. * Never throws an Exception. * @return return true; on success. */ public static <E1, E2> boolean attempt(final Procedure2<E1, E2> code, final E1 p1, final E2 p2) { try { code.apply(p1, p2); return true; } catch (final Throwable t) { LOG.log(Level.SEVERE, t.getMessage(), t); return false; } }
@Check public void checkCharacterAttributes(final de.unidue.ecg.characterScript.characterScript.Character c) { Template _template = c.getTemplate(); boolean _equals = Objects.equal(_template, null); if (_equals) { EList<Property> _properties = c.getProperties(); final Procedure2<Property,Integer> _function = new Procedure2<Property,Integer>() { public void apply(final Property it, final Integer i) { boolean _matched = false; if (!_matched) { if (it instanceof CustomProperty) { _matched=true; CustomAttributeName _customAttributeRef = ((CustomProperty)it).getCustomAttributeRef(); EObject _eContainer = _customAttributeRef.eContainer(); EObject _eContainer_1 = _eContainer.eContainer(); if ((_eContainer_1 instanceof Template)) { CustomAttributeName _customAttributeRef_1 = ((CustomProperty)it).getCustomAttributeRef(); EObject _eContainer_2 = _customAttributeRef_1.eContainer(); EObject _eContainer_3 = _eContainer_2.eContainer(); final Template template = ((Template) _eContainer_3); CustomAttributeName _customAttributeRef_2 = ((CustomProperty)it).getCustomAttributeRef(); String _name = null; if (_customAttributeRef_2!=null) { _name=_customAttributeRef_2.getName(); } String _plus = ("The property " + _name); String _plus_1 = (_plus + " is defined in the template "); String _name_1 = template.getName(); String _plus_2 = (_plus_1 + _name_1); String _plus_3 = (_plus_2 + ". In order to use it, explicitly refer to this template."); CharacterScriptValidator.this.error(_plus_3, CharacterScriptPackage.Literals.CHARACTER__PROPERTIES, (i).intValue(), CharacterScriptValidator.INVALID_ATTRIBUTE); } } } } }; IterableExtensions.<Property>forEach(_properties, _function); } }
@Check public void checkTemplateAccordance(final de.unidue.ecg.characterScript.characterScript.Character c) { Template _template = c.getTemplate(); boolean _notEquals = (!Objects.equal(_template, null)); if (_notEquals) { final Template template = c.getTemplate(); final EList<CustomAttribute> allowedCustoms = template.getCustoms(); EList<Property> _properties = c.getProperties(); final Procedure2<Property,Integer> _function = new Procedure2<Property,Integer>() { public void apply(final Property it, final Integer i) { boolean _matched = false; if (!_matched) { if (it instanceof CustomProperty) { boolean _isValidCustom = CharacterScriptValidator.this.isValidCustom(((CustomProperty)it), allowedCustoms); boolean _not = (!_isValidCustom); if (_not) { _matched=true; String _name = template.getName(); String _plus = ("The used template " + _name); String _plus_1 = (_plus + " does not provide this property"); CharacterScriptValidator.this.error(_plus_1, CharacterScriptPackage.Literals.CHARACTER__PROPERTIES, (i).intValue(), CharacterScriptValidator.INVALID_PROPERTY); } } } } }; IterableExtensions.<Property>forEach(_properties, _function); } }