public static List<Ddl2Bean.Klass> map(final Table table) { Column[] _columns = table.getColumns(); final Function1<Column, Ddl2Bean.Klass> _function = (Column column) -> { Ddl2Bean.Klass _xblockexpression = null; { String _type = column.getType(); String type = Ddl2Bean.fieldType(_type); String columnName = column.getName(); String _name = column.getName(); String[] _split = _name.split("_"); final Function1<String, String> _function_1 = (String it) -> { return StringExtensions.toFirstUpper(it); }; List<String> _map = ListExtensions.<String, String>map(((List<String>)Conversions.doWrapArray(_split)), _function_1); String _join = IterableExtensions.join(_map); String name = StringExtensions.toFirstLower(_join); String comment = column.getDescription(); _xblockexpression = new Ddl2Bean.Klass(type, name, columnName, comment); } return _xblockexpression; }; return ListExtensions.<Column, Ddl2Bean.Klass>map(((List<Column>)Conversions.doWrapArray(_columns)), _function); }
protected Result<TypeRef> applyRuleUpperBoundUnionTypeExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final UnionTypeExpression U) throws RuleFailedException { TypeRef T = null; // output parameter final Function1<TypeRef, TypeRef> _function = (TypeRef it) -> { TypeRef _xblockexpression = null; { TypeRef E = null; /* G|~ it /\ E */ Result<TypeRef> result = upperBoundInternal(G, _trace_, it); checkAssignableTo(result.getFirst(), TypeRef.class); E = (TypeRef) result.getFirst(); _xblockexpression = E; } return _xblockexpression; }; T = TypeUtils.createNonSimplifiedUnionType( ListExtensions.<TypeRef, TypeRef>map(U.getTypeRefs(), _function)); TypeUtils.copyTypeModifiers(T, U); return new Result<TypeRef>(T); }
protected Result<TypeRef> applyRuleUpperBoundIntersectionTypeExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final IntersectionTypeExpression I) throws RuleFailedException { TypeRef T = null; // output parameter final Function1<TypeRef, TypeRef> _function = (TypeRef it) -> { TypeRef _xblockexpression = null; { TypeRef E = null; /* G|~ it /\ E */ Result<TypeRef> result = upperBoundInternal(G, _trace_, it); checkAssignableTo(result.getFirst(), TypeRef.class); E = (TypeRef) result.getFirst(); _xblockexpression = E; } return _xblockexpression; }; T = TypeUtils.createNonSimplifiedIntersectionType( ListExtensions.<TypeRef, TypeRef>map(I.getTypeRefs(), _function)); TypeUtils.copyTypeModifiers(T, I); return new Result<TypeRef>(T); }
protected Result<TypeRef> applyRuleLowerBoundUnionTypeExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final UnionTypeExpression U) throws RuleFailedException { TypeRef T = null; // output parameter final Function1<TypeRef, TypeRef> _function = (TypeRef it) -> { TypeRef _xblockexpression = null; { TypeRef E = null; /* G|~ it \/ E */ Result<TypeRef> result = lowerBoundInternal(G, _trace_, it); checkAssignableTo(result.getFirst(), TypeRef.class); E = (TypeRef) result.getFirst(); _xblockexpression = E; } return _xblockexpression; }; T = TypeUtils.createNonSimplifiedUnionType( ListExtensions.<TypeRef, TypeRef>map(U.getTypeRefs(), _function)); TypeUtils.copyTypeModifiers(T, U); return new Result<TypeRef>(T); }
protected Result<TypeRef> applyRuleLowerBoundIntersectionTypeExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final IntersectionTypeExpression I) throws RuleFailedException { TypeRef T = null; // output parameter final Function1<TypeRef, TypeRef> _function = (TypeRef it) -> { TypeRef _xblockexpression = null; { TypeRef E = null; /* G|~ it \/ E */ Result<TypeRef> result = lowerBoundInternal(G, _trace_, it); checkAssignableTo(result.getFirst(), TypeRef.class); E = (TypeRef) result.getFirst(); _xblockexpression = E; } return _xblockexpression; }; T = TypeUtils.createNonSimplifiedIntersectionType( ListExtensions.<TypeRef, TypeRef>map(I.getTypeRefs(), _function)); TypeUtils.copyTypeModifiers(T, I); return new Result<TypeRef>(T); }
@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); } }
protected List<Class<?>> getExtensionClasses() { return Lists.<Class<?>> newArrayList( ArrayExtensions.class, BigDecimalExtensions.class, BigIntegerExtensions.class, BooleanExtensions.class, ByteExtensions.class, CharacterExtensions.class, CollectionExtensions.class, ComparableExtensions.class, DoubleExtensions.class, FloatExtensions.class, FunctionExtensions.class, IntegerExtensions.class, IterableExtensions.class, IteratorExtensions.class, ListExtensions.class, LongExtensions.class, MapExtensions.class, ObjectExtensions.class, ProcedureExtensions.class, ShortExtensions.class, StringExtensions.class); }
@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); }
public static List<URI> getURIs(final EStructuralFeature.Setting setting) { List<URI> _switchResult = null; Object _get = setting.get(false); final Object it = _get; boolean _matched = false; if (it instanceof EObject) { _matched=true; _switchResult = CollectionLiterals.<URI>newImmutableList(EcoreUtil.getURI(((EObject)it))); } if (!_matched) { if (it instanceof List) { _matched=true; final Function1<EObject, URI> _function = (EObject it_1) -> { return EcoreUtil.getURI(it_1); }; _switchResult = ListExtensions.<EObject, URI>map(((List<EObject>)it), _function); } } return _switchResult; }
public List<String> getPossibleGetterNames(final FieldDeclaration it) { final ArrayList<String> names = CollectionLiterals.<String>newArrayList(); if ((((this.isBooleanType(this.orObject(it.getType())) && it.getSimpleName().startsWith("is")) && (it.getSimpleName().length() > 2)) && Character.isUpperCase(it.getSimpleName().charAt(2)))) { String _simpleName = it.getSimpleName(); names.add(_simpleName); } List<String> _xifexpression = null; boolean _isBooleanType = this.isBooleanType(this.orObject(it.getType())); if (_isBooleanType) { _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("is", "get")); } else { _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("get")); } final Function1<String, String> _function = new Function1<String, String>() { @Override public String apply(final String prefix) { String _firstUpper = StringExtensions.toFirstUpper(it.getSimpleName()); return (prefix + _firstUpper); } }; names.addAll(ListExtensions.<String, String>map(_xifexpression, _function)); return names; }
protected Iterable<IGeneratorNode> leafsBackwards(final IGeneratorNode it) { Iterable<IGeneratorNode> _switchResult = null; boolean _matched = false; if (it instanceof CompositeGeneratorNode) { _matched=true; final Function1<IGeneratorNode, Iterable<IGeneratorNode>> _function = (IGeneratorNode it_1) -> { return this.leafsBackwards(it_1); }; final Function2<Iterable<IGeneratorNode>, Iterable<IGeneratorNode>, Iterable<IGeneratorNode>> _function_1 = (Iterable<IGeneratorNode> p1, Iterable<IGeneratorNode> p2) -> { return Iterables.<IGeneratorNode>concat(p1, p2); }; _switchResult = IterableExtensions.<Iterable<IGeneratorNode>>reduce(ListExtensions.<IGeneratorNode, Iterable<IGeneratorNode>>map(ListExtensions.<IGeneratorNode>reverseView(((CompositeGeneratorNode)it).getChildren()), _function), _function_1); } if (!_matched) { _switchResult = Collections.<IGeneratorNode>unmodifiableList(CollectionLiterals.<IGeneratorNode>newArrayList(it)); } return _switchResult; }
@Override public void appendImmediate(final Object object, final String indentation) { final ArrayList<IGeneratorNode> removed = Lists.<IGeneratorNode>newArrayList(); for (int i = (this.currentParent.getChildren().size() - 1); (i >= 0); i--) { { final IGeneratorNode node = this.currentParent.getChildren().get(i); if (((node instanceof TextNode) && (!TemplateNode.hasContent(((TextNode) node).getText())))) { IGeneratorNode _remove = this.currentParent.getChildren().remove(i); removed.add(_remove); } else { if ((node instanceof NewLineNode)) { IGeneratorNode _remove_1 = this.currentParent.getChildren().remove(i); removed.add(_remove_1); } else { this.append(object, indentation); final Consumer<IGeneratorNode> _function = (IGeneratorNode it) -> { this.append(it, indentation); }; ListExtensions.<IGeneratorNode>reverse(removed).forEach(_function); return; } } } } this.append(object, indentation); }
private void setHiddenTokens(final Grammar copy, final Grammar orig, final Map<RuleWithParameterValues, AbstractRule> origToCopy) { if ((orig == null)) { copy.setDefinesHiddenTokens(true); } else { boolean _isDefinesHiddenTokens = orig.isDefinesHiddenTokens(); boolean _not = (!_isDefinesHiddenTokens); if (_not) { this.setHiddenTokens(copy, IterableExtensions.<Grammar>head(orig.getUsedGrammars()), origToCopy); } else { copy.setDefinesHiddenTokens(true); EList<AbstractRule> _hiddenTokens = copy.getHiddenTokens(); final Function1<AbstractRule, AbstractRule> _function = (AbstractRule hidden) -> { RuleWithParameterValues _ruleWithParameterValues = new RuleWithParameterValues(hidden); return origToCopy.get(_ruleWithParameterValues); }; List<AbstractRule> _map = ListExtensions.<AbstractRule, AbstractRule>map(orig.getHiddenTokens(), _function); Iterables.<AbstractRule>addAll(_hiddenTokens, _map); } } }
public List<String> initialHiddenTokens(final Grammar it) { List<String> _xblockexpression = null; { boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens(); if (_isDefinesHiddenTokens) { final Function1<AbstractRule, String> _function = (AbstractRule it_1) -> { return this.ruleName(it_1); }; return IterableExtensions.<String>toList(ListExtensions.<AbstractRule, String>map(it.getHiddenTokens(), _function)); } int _size = it.getUsedGrammars().size(); boolean _equals = (_size == 1); if (_equals) { return this.initialHiddenTokens(IterableExtensions.<Grammar>head(it.getUsedGrammars())); } _xblockexpression = CollectionLiterals.<String>emptyList(); } return _xblockexpression; }
public Set<String> getFQFeatureNamesToExclude(final Grammar g) { Set<String> _xifexpression = null; Grammar _nonTerminalsSuperGrammar = GrammarUtil2.getNonTerminalsSuperGrammar(g); boolean _tripleNotEquals = (_nonTerminalsSuperGrammar != null); if (_tripleNotEquals) { Sets.SetView<String> _xblockexpression = null; { final Set<String> thisGrammarFqFeatureNames = IterableExtensions.<String>toSet(this.computeFQFeatureNames(g)); final Function1<Grammar, Iterable<String>> _function = (Grammar it) -> { return this.computeFQFeatureNames(it); }; final Set<String> superGrammarsFqFeatureNames = IterableExtensions.<String>toSet(Iterables.<String>concat(ListExtensions.<Grammar, Iterable<String>>map(GrammarUtil.allUsedGrammars(g), _function))); _xblockexpression = Sets.<String>intersection(thisGrammarFqFeatureNames, superGrammarsFqFeatureNames); } _xifexpression = _xblockexpression; } else { _xifexpression = CollectionLiterals.<String>emptySet(); } return _xifexpression; }
public List<EqualAmbiguousTransitions> getAllAmbiguousTransitionsBySyntax() { if ((this.ambiguousTransitions != null)) { return this.ambiguousTransitions; } final Map<GrammarAlias.AbstractElementAlias, EqualAmbiguousTransitions> result = CollectionLiterals.<GrammarAlias.AbstractElementAlias, EqualAmbiguousTransitions>newHashMap(); Set<ISyntacticSequencerPDAProvider.ISynTransition> _allAmbiguousTransitions = this.getAllAmbiguousTransitions(); for (final ISyntacticSequencerPDAProvider.ISynTransition transition : _allAmbiguousTransitions) { List<GrammarAlias.AbstractElementAlias> _ambiguousSyntaxes = transition.getAmbiguousSyntaxes(); for (final GrammarAlias.AbstractElementAlias syntax : _ambiguousSyntaxes) { { EqualAmbiguousTransitions list = result.get(syntax); if ((list == null)) { String _elementAliasToIdentifier = this.elementAliasToIdentifier(syntax); EqualAmbiguousTransitions _equalAmbiguousTransitions = new EqualAmbiguousTransitions(_elementAliasToIdentifier, syntax); list = _equalAmbiguousTransitions; result.put(syntax, list); } list.getTransitions().add(transition); } } } this.ambiguousTransitions = CollectionLiterals.<EqualAmbiguousTransitions>newArrayList(((EqualAmbiguousTransitions[])Conversions.unwrapArray(result.values(), EqualAmbiguousTransitions.class))); ListExtensions.<EqualAmbiguousTransitions>sortInplace(this.ambiguousTransitions); return this.ambiguousTransitions; }
protected void testFormatting(final Procedure1<? super FormattingConfiguration> configurator) { try { @Extension final FormattingConfiguration configuration = new FormattingConfiguration(); configuration.setFilePath(("MyModel." + this.fileExtension)); configurator.apply(configuration); final FileInfo fileInfo = this.initializeContext(configuration); DocumentFormattingParams _documentFormattingParams = new DocumentFormattingParams(); final Procedure1<DocumentFormattingParams> _function = (DocumentFormattingParams it) -> { String _uri = fileInfo.getUri(); TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(_uri); it.setTextDocument(_textDocumentIdentifier); }; DocumentFormattingParams _doubleArrow = ObjectExtensions.<DocumentFormattingParams>operator_doubleArrow(_documentFormattingParams, _function); final CompletableFuture<List<? extends TextEdit>> changes = this.languageServer.formatting(_doubleArrow); String _contents = fileInfo.getContents(); final Document result = new Document(1, _contents).applyChanges(ListExtensions.<TextEdit>reverse(CollectionLiterals.<TextEdit>newArrayList(((TextEdit[])Conversions.unwrapArray(changes.get(), TextEdit.class))))); this.assertEquals(configuration.getExpectedText(), result.getContents()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected void testRangeFormatting(final Procedure1<? super RangeFormattingConfiguration> configurator) { try { @Extension final RangeFormattingConfiguration configuration = new RangeFormattingConfiguration(); configuration.setFilePath(("MyModel." + this.fileExtension)); configurator.apply(configuration); final FileInfo fileInfo = this.initializeContext(configuration); DocumentRangeFormattingParams _documentRangeFormattingParams = new DocumentRangeFormattingParams(); final Procedure1<DocumentRangeFormattingParams> _function = (DocumentRangeFormattingParams it) -> { String _uri = fileInfo.getUri(); TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(_uri); it.setTextDocument(_textDocumentIdentifier); it.setRange(configuration.getRange()); }; DocumentRangeFormattingParams _doubleArrow = ObjectExtensions.<DocumentRangeFormattingParams>operator_doubleArrow(_documentRangeFormattingParams, _function); final CompletableFuture<List<? extends TextEdit>> changes = this.languageServer.rangeFormatting(_doubleArrow); String _contents = fileInfo.getContents(); final Document result = new Document(1, _contents).applyChanges(ListExtensions.<TextEdit>reverse(CollectionLiterals.<TextEdit>newArrayList(((TextEdit[])Conversions.unwrapArray(changes.get(), TextEdit.class))))); this.assertEquals(configuration.getExpectedText(), result.getContents()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
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); } }
private TreeSet<CliWizardIntegrationTest.GeneratedFile> toFileSet(final File root) { TreeSet<CliWizardIntegrationTest.GeneratedFile> _xblockexpression = null; { final ArrayList<File> allFiles = CollectionLiterals.<File>newArrayList(); this.collectAllFiles(root, allFiles); final Function1<File, CliWizardIntegrationTest.GeneratedFile> _function = (File it) -> { CliWizardIntegrationTest.GeneratedFile _xblockexpression_1 = null; { final String relativePath = it.getPath().replace(root.getPath(), ""); _xblockexpression_1 = this.toGeneratedFile(it, relativePath); } return _xblockexpression_1; }; final List<CliWizardIntegrationTest.GeneratedFile> generatedFiles = ListExtensions.<File, CliWizardIntegrationTest.GeneratedFile>map(allFiles, _function); final Comparator<CliWizardIntegrationTest.GeneratedFile> _function_1 = (CliWizardIntegrationTest.GeneratedFile $0, CliWizardIntegrationTest.GeneratedFile $1) -> { return ($0.relativePath.compareTo($1.relativePath)); }; final Comparator<CliWizardIntegrationTest.GeneratedFile> sortByPath = _function_1; _xblockexpression = CollectionLiterals.<CliWizardIntegrationTest.GeneratedFile>newTreeSet(sortByPath, ((CliWizardIntegrationTest.GeneratedFile[])Conversions.unwrapArray(generatedFiles, CliWizardIntegrationTest.GeneratedFile.class))); } return _xblockexpression; }
@Override public boolean update(final IUpdateContext context) { PictogramElement _pictogramElement = context.getPictogramElement(); final ContainerShape containerShape = ((ContainerShape) _pictogramElement); String businessName = null; final Object bo = this.getBusinessObjectForPictogramElement(containerShape); if ((bo instanceof State)) { String _name = ((State)bo).getName(); businessName = _name; } EList<Shape> _children = containerShape.getChildren(); final Function1<Shape, GraphicsAlgorithm> _function = new Function1<Shape, GraphicsAlgorithm>() { @Override public GraphicsAlgorithm apply(final Shape it) { return it.getGraphicsAlgorithm(); } }; List<GraphicsAlgorithm> _map = ListExtensions.<Shape, GraphicsAlgorithm>map(_children, _function); Iterable<Text> _filter = Iterables.<Text>filter(_map, Text.class); Text _head = IterableExtensions.<Text>head(_filter); if (_head!=null) { _head.setValue(businessName); } return false; }
public static String pingying(final String fullName) { String _xblockexpression = null; { final HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat(); format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); char[] _charArray = fullName.toCharArray(); final Function1<Character, String> _function = (Character it) -> { try { String[] _hanyuPinyinStringArray = PinyinHelper.toHanyuPinyinStringArray((it).charValue(), format); String _get = null; if (_hanyuPinyinStringArray!=null) { _get=_hanyuPinyinStringArray[0]; } return _get; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; List<String> _map = ListExtensions.<Character, String>map(((List<Character>)Conversions.doWrapArray(_charArray)), _function); Iterable<String> _filterNull = IterableExtensions.<String>filterNull(_map); String _join = IterableExtensions.join(_filterNull); _xblockexpression = _join.replace(":", ""); } return _xblockexpression; }
public static int wordSimilarity(final String first, final String second) { int _xblockexpression = (int) 0; { boolean _equalsIgnoreCase = first.equalsIgnoreCase(second); if (_equalsIgnoreCase) { return 1; } char[] _charArray = first.toCharArray(); final Function1<Character, Character> _function = (Character it) -> { return it; }; final List<Character> firstChars = ListExtensions.<Character, Character>map(((List<Character>)Conversions.doWrapArray(_charArray)), _function); int orginSize = firstChars.size(); char[] _charArray_1 = second.toCharArray(); firstChars.retainAll(((Collection<?>)Conversions.doWrapArray(_charArray_1))); int newSize = firstChars.size(); _xblockexpression = (newSize / orginSize); } return _xblockexpression; }
public static List<ModuleGeneratedDoc> byFileTypes(final String[] fileTypes) { final Function1<String, ModuleGeneratedDoc> _function = (String it) -> { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("cn.tung.fabricator.back.clazz."); _builder.append(it, ""); Class<?> _forName = Class.forName(_builder.toString()); Object _newInstance = _forName.newInstance(); return ((ModuleGeneratedDoc) _newInstance); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; List<ModuleGeneratedDoc> _map = ListExtensions.<String, ModuleGeneratedDoc>map(((List<String>)Conversions.doWrapArray(fileTypes)), _function); Iterable<ModuleGeneratedDoc> _filterNull = IterableExtensions.<ModuleGeneratedDoc>filterNull(_map); return CollectionLiterals.<ModuleGeneratedDoc>newArrayList(((ModuleGeneratedDoc[])Conversions.unwrapArray(_filterNull, ModuleGeneratedDoc.class))); }
public static List<ModuleGeneratedDoc> byOtherFileTypes(final String[] fileTypes) { final Function1<String, ModuleGeneratedDoc> _function = (String it) -> { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("cn.tung.fabricator.back.other."); _builder.append(it, ""); Class<?> _forName = Class.forName(_builder.toString()); Object _newInstance = _forName.newInstance(); return ((ModuleGeneratedDoc) _newInstance); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; List<ModuleGeneratedDoc> _map = ListExtensions.<String, ModuleGeneratedDoc>map(((List<String>)Conversions.doWrapArray(fileTypes)), _function); Iterable<ModuleGeneratedDoc> _filterNull = IterableExtensions.<ModuleGeneratedDoc>filterNull(_map); return CollectionLiterals.<ModuleGeneratedDoc>newArrayList(((ModuleGeneratedDoc[])Conversions.unwrapArray(_filterNull, ModuleGeneratedDoc.class))); }
public static List<ModuleGeneratedDoc> byPageFileTypes(final String[] fileTypes) { final Function1<String, ModuleGeneratedDoc> _function = (String it) -> { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("cn.tung.fabricator.back.page."); _builder.append(it, ""); Class<?> _forName = Class.forName(_builder.toString()); Object _newInstance = _forName.newInstance(); return ((ModuleGeneratedDoc) _newInstance); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; List<ModuleGeneratedDoc> _map = ListExtensions.<String, ModuleGeneratedDoc>map(((List<String>)Conversions.doWrapArray(fileTypes)), _function); Iterable<ModuleGeneratedDoc> _filterNull = IterableExtensions.<ModuleGeneratedDoc>filterNull(_map); return CollectionLiterals.<ModuleGeneratedDoc>newArrayList(((ModuleGeneratedDoc[])Conversions.unwrapArray(_filterNull, ModuleGeneratedDoc.class))); }
public static String klassType(final Table table) { String _xblockexpression = null; { String _name = table.getName(); String _substring = _name.substring(2); String[] _split = _substring.split("_"); final Function1<String, String> _function = (String it) -> { return StringExtensions.toFirstUpper(it); }; List<String> _map = ListExtensions.<String, String>map(((List<String>)Conversions.doWrapArray(_split)), _function); String name = IterableExtensions.join(_map); boolean _equals = Objects.equal(name, "Enum"); if (_equals) { name = "EnumCode"; } _xblockexpression = name; } return _xblockexpression; }
public static List<Ddl2Rest.Klass> map(final Table table) { Column[] _columns = table.getColumns(); final Function1<Column, Ddl2Rest.Klass> _function = (Column column) -> { Ddl2Rest.Klass _xblockexpression = null; { String _type = column.getType(); String type = Ddl2Rest.fieldType(_type); String columnName = column.getName(); String _name = column.getName(); String[] _split = _name.split("_"); final Function1<String, String> _function_1 = (String it) -> { return StringExtensions.toFirstUpper(it); }; List<String> _map = ListExtensions.<String, String>map(((List<String>)Conversions.doWrapArray(_split)), _function_1); String _join = IterableExtensions.join(_map); String name = StringExtensions.toFirstLower(_join); String comment = column.getDescription(); _xblockexpression = new Ddl2Rest.Klass(type, name, columnName, comment); } return _xblockexpression; }; return ListExtensions.<Column, Ddl2Rest.Klass>map(((List<Column>)Conversions.doWrapArray(_columns)), _function); }
protected static Expression _foldConstants(final ConstantOrFunctionCallExp cofce) { final ConstantOrFunctionCallExp result = RigidBodiesFactory.eINSTANCE.createConstantOrFunctionCallExp(); String _label = cofce.getLabel(); result.setLabel(_label); EList<Expression> _param = result.getParam(); EList<Expression> _param_1 = cofce.getParam(); final Function1<Expression, Expression> _function = new Function1<Expression, Expression>() { @Override public Expression apply(final Expression p) { return ExpressionHelper.foldConstants(p); } }; List<Expression> _map = ListExtensions.<Expression, Expression>map(_param_1, _function); _param.addAll(_map); return result; }
public List<String> getPossibleGetterNames(final FieldDeclaration it) { List<String> _xifexpression = null; final TypeReference _type = it.getType(); final TypeReference _orObject = this.orObject(_type); final boolean _isBooleanType = this.isBooleanType(_orObject); if (_isBooleanType) { _xifexpression = Collections.<String> unmodifiableList(CollectionLiterals.<String> newArrayList("is", "get")); } else { _xifexpression = Collections.<String> unmodifiableList(CollectionLiterals.<String> newArrayList("get")); } final Function1<String, String> _function = new Function1<String, String>() { @Override public String apply(final String prefix) { final String _simpleName = it.getSimpleName(); final String _firstUpper = StringExtensions.toFirstUpper(_simpleName); return (prefix + _firstUpper); } }; return ListExtensions.<String, String> map(_xifexpression, _function); }
protected HDLDirectGeneration _toHDL(final PSHDLLang.PsDirectGenerationContext context, final boolean isStatement) { HDLDirectGeneration gen = new HDLDirectGeneration().setGeneratorContent(""); gen = gen.setInclude((context.isInclude != null)); IHDLObject _hDL = this.toHDL(context.psInterface(), false); gen = gen.setHIf(((HDLInterface) _hDL)); IHDLObject _hDL_1 = this.toHDL(context.psVariable(), false); gen = gen.setVar(((HDLVariable) _hDL_1)); gen = gen.setGeneratorID(context.RULE_ID().getText()); PSHDLLang.PsPassedArgumentsContext _psPassedArguments = context.psPassedArguments(); boolean _tripleNotEquals = (_psPassedArguments != null); if (_tripleNotEquals) { final Function1<PSHDLLang.PsArgumentContext, HDLArgument> _function = (PSHDLLang.PsArgumentContext it) -> { IHDLObject _hDL_2 = this.toHDL(it, isStatement); return ((HDLArgument) _hDL_2); }; gen = gen.setArguments(ListExtensions.<PSHDLLang.PsArgumentContext, HDLArgument>map(context.psPassedArguments().psArgument(), _function)); } TerminalNode _RULE_GENERATOR_CONTENT = context.RULE_GENERATOR_CONTENT(); boolean _tripleNotEquals_1 = (_RULE_GENERATOR_CONTENT != null); if (_tripleNotEquals_1) { gen = gen.setGeneratorContent(context.RULE_GENERATOR_CONTENT().getText()); } return this.<HDLDirectGeneration>attachContext(gen, context); }
protected IHDLObject _toHDL(final PSHDLLang.PsInstantiationContext context, final boolean isStatement) { HDLInstantiation res = null; PSHDLLang.PsDirectGenerationContext _psDirectGeneration = context.psDirectGeneration(); boolean _tripleNotEquals = (_psDirectGeneration != null); if (_tripleNotEquals) { IHDLObject _hDL = this.toHDL(context.psDirectGeneration(), true); res = ((HDLInstantiation) _hDL); } PSHDLLang.PsInterfaceInstantiationContext _psInterfaceInstantiation = context.psInterfaceInstantiation(); boolean _tripleNotEquals_1 = (_psInterfaceInstantiation != null); if (_tripleNotEquals_1) { IHDLObject _hDL_1 = this.toHDL(context.psInterfaceInstantiation(), true); res = ((HDLInstantiation) _hDL_1); } if ((res != null)) { final Function1<PSHDLLang.PsAnnotationContext, HDLAnnotation> _function = (PSHDLLang.PsAnnotationContext it) -> { IHDLObject _hDL_2 = this.toHDL(it, false); return ((HDLAnnotation) _hDL_2); }; res = res.setAnnotations(ListExtensions.<PSHDLLang.PsAnnotationContext, HDLAnnotation>map(context.psAnnotation(), _function)); return this.<HDLInstantiation>attachContext(res, context); } Class<? extends PSHDLLang.PsInstantiationContext> _class = context.getClass(); String _plus = ("Not implemented type:" + _class); throw new IllegalArgumentException(_plus); }
protected HDLFunctionParameter _toHDL(final PSHDLLang.PsFuncRecturnTypeContext context, final boolean isStatement) { IHDLObject _hDL = this.toHDL(context.psFuncParamType(), isStatement); HDLFunctionParameter res = ((HDLFunctionParameter) _hDL); res = res.setRw(HDLFunctionParameter.RWType.RETURN); final Function1<PSHDLLang.PsFuncOptArrayContext, HDLExpression> _function = (PSHDLLang.PsFuncOptArrayContext it) -> { HDLExpression _xifexpression = null; PSHDLLang.PsExpressionContext _psExpression = it.psExpression(); boolean _tripleNotEquals = (_psExpression != null); if (_tripleNotEquals) { IHDLObject _hDL_1 = this.toHDL(it.psExpression(), false); _xifexpression = ((HDLExpression) _hDL_1); } else { _xifexpression = HDLFunctionParameter.EMPTY_ARR(); } return _xifexpression; }; res = res.setDim( ListExtensions.<PSHDLLang.PsFuncOptArrayContext, HDLExpression>map(context.dims, _function)); return res; }
protected HDLFunctionParameter _toHDL(final PSHDLLang.PsFuncSpecContext context, final boolean isStatement) { IHDLObject _hDL = this.toHDL(context.psFuncParamWithRW(), false); HDLFunctionParameter res = ((HDLFunctionParameter) _hDL); res = res.setName(new HDLVariable().setName(context.RULE_ID().getText())); final Function1<PSHDLLang.PsFuncOptArrayContext, HDLExpression> _function = (PSHDLLang.PsFuncOptArrayContext it) -> { HDLExpression _xifexpression = null; PSHDLLang.PsExpressionContext _psExpression = it.psExpression(); boolean _tripleNotEquals = (_psExpression != null); if (_tripleNotEquals) { IHDLObject _hDL_1 = this.toHDL(it.psExpression(), false); _xifexpression = ((HDLExpression) _hDL_1); } else { _xifexpression = HDLFunctionParameter.EMPTY_ARR(); } return _xifexpression; }; res = res.setDim( ListExtensions.<PSHDLLang.PsFuncOptArrayContext, HDLExpression>map(context.dims, _function)); return res; }
protected HDLReference _toHDL(final PSHDLLang.PsVariableRefContext context, final boolean isStatement) { if ((context.isClk != null)) { return this.<HDLVariableRef>attachContext(HDLRegisterConfig.defaultClk(true).asHDLRef(), context); } if ((context.isRst != null)) { return this.<HDLVariableRef>attachContext(HDLRegisterConfig.defaultRst(true).asHDLRef(), context); } HDLUnresolvedFragment current = null; List<PSHDLLang.PsRefPartContext> _reverseView = ListExtensions.<PSHDLLang.PsRefPartContext>reverseView(context.psRefPart()); for (final PSHDLLang.PsRefPartContext sub : _reverseView) { { IHDLObject _hDL = this.toHDL(sub, false); HDLUnresolvedFragment frag = ((HDLUnresolvedFragment) _hDL); if ((current != null)) { frag = frag.setSub(current); } current = frag; } } if ((current != null)) { current = current.setIsStatement(isStatement); return this.<HDLUnresolvedFragment>attachContext(current, context); } return null; }
private TValueSpecification _resolveValueSpecification(final Attribute specification, final TAspect to) { EList<AbstractMessageView> _messageViews = to.getMessageViews(); AbstractMessageView _get = _messageViews.get(0); final TAbstractMessageView tAbstractMessageView = ((TAbstractMessageView) _get); EList<TLifeline> _lifelines = tAbstractMessageView.getLifelines(); final Function1<TLifeline,EList<TTemporaryProperty>> _function = new Function1<TLifeline,EList<TTemporaryProperty>>() { public EList<TTemporaryProperty> apply(final TLifeline it) { return it.getLocalProperties(); } }; List<EList<TTemporaryProperty>> _map = ListExtensions.<TLifeline, EList<TTemporaryProperty>>map(_lifelines, _function); Iterable<TTemporaryProperty> _flatten = Iterables.<TTemporaryProperty>concat(_map); Iterable<TLocalAttribute> _filter = Iterables.<TLocalAttribute>filter(_flatten, TLocalAttribute.class); final Function1<TLocalAttribute,Boolean> _function_1 = new Function1<TLocalAttribute,Boolean>() { public Boolean apply(final TLocalAttribute la) { String _name = la.getName(); String _name_1 = specification.getName(); return Boolean.valueOf(Objects.equal(_name, _name_1)); } }; final TLocalAttribute res = IterableExtensions.<TLocalAttribute>findFirst(_filter, _function_1); return res; }
private TMessageAssignableFeature _getAssignToFrom(final Attribute feature, final TAspect to, final TClass clazz) { EList<AbstractMessageView> _messageViews = to.getMessageViews(); AbstractMessageView _get = _messageViews.get(0); final TAbstractMessageView mv = ((TAbstractMessageView) _get); EList<TLifeline> _lifelines = mv.getLifelines(); final Function1<TLifeline,EList<TTemporaryProperty>> _function = new Function1<TLifeline,EList<TTemporaryProperty>>() { public EList<TTemporaryProperty> apply(final TLifeline it) { return it.getLocalProperties(); } }; List<EList<TTemporaryProperty>> _map = ListExtensions.<TLifeline, EList<TTemporaryProperty>>map(_lifelines, _function); Iterable<TTemporaryProperty> _flatten = Iterables.<TTemporaryProperty>concat(_map); Iterable<TLocalAttribute> _filter = Iterables.<TLocalAttribute>filter(_flatten, TLocalAttribute.class); final Function1<TLocalAttribute,Boolean> _function_1 = new Function1<TLocalAttribute,Boolean>() { public Boolean apply(final TLocalAttribute la) { String _name = la.getName(); String _name_1 = feature.getName(); return Boolean.valueOf(Objects.equal(_name, _name_1)); } }; final TLocalAttribute res = IterableExtensions.<TLocalAttribute>findFirst(_filter, _function_1); return res; }
public Iterable<TTemporaryProperty> getGetTAttributesFromLifelines(final Aspect aspect) { EList<AbstractMessageView> _messageViews = aspect.getMessageViews(); AbstractMessageView _head = IterableExtensions.<AbstractMessageView>head(_messageViews); final TAbstractMessageView tAbstractMessageView = ((TAbstractMessageView) _head); boolean _notEquals = (!Objects.equal(tAbstractMessageView, null)); if (_notEquals) { EList<TLifeline> _lifelines = tAbstractMessageView.getLifelines(); final Function1<TLifeline,EList<TTemporaryProperty>> _function = new Function1<TLifeline,EList<TTemporaryProperty>>() { public EList<TTemporaryProperty> apply(final TLifeline it) { return it.getLocalProperties(); } }; List<EList<TTemporaryProperty>> _map = ListExtensions.<TLifeline, EList<TTemporaryProperty>>map(_lifelines, _function); return Iterables.<TTemporaryProperty>concat(_map); } return null; }
protected static StringBuilder privgenerateCode(final Programme _self, final ContextNCX ctx) { StringBuilder _xblockexpression = null; { StringBuilder _header = ctx.getHeader(); _header.append("#include \"NXCDefs.h\"\n\ntask main(){\n"); StringBuilder _stringBuilder = new StringBuilder("while(1){\n"); EList<Expr> _programme = _self.getProgramme(); final Function1<Expr,StringBuilder> _function = new Function1<Expr,StringBuilder>() { public StringBuilder apply(final Expr it) { StringBuilder _generateCode = NXCCodeGenerator.generateCode(it, ctx); return _generateCode; } }; List<StringBuilder> _map = ListExtensions.<Expr, StringBuilder>map(_programme, _function); String _join = IterableExtensions.join(_map); StringBuilder _append = _stringBuilder.append(_join); StringBuilder _append_1 = _append.append("}\n}\n"); _xblockexpression = (_append_1); } return _xblockexpression; }
public String argsTypesAsStrings(final SJMemberSelection sel) { EList<SJExpression> _args = sel.getArgs(); final Function1<SJExpression, String> _function = new Function1<SJExpression, String>() { @Override public String apply(final SJExpression it) { SJClass _typeFor = SmallJavaTypeProvider.this.typeFor(it); String _name = null; if (_typeFor!=null) { _name=_typeFor.getName(); } return _name; } }; List<String> _map = ListExtensions.<SJExpression, String>map(_args, _function); String _join = IterableExtensions.join(_map, ", "); String _plus = ("(" + _join); return (_plus + ")"); }