protected String getTabName() { String _xifexpression = null; boolean _needsSave = this.root.getNeedsSave(); if (_needsSave) { _xifexpression = "*"; } else { _xifexpression = ""; } final String prefix = _xifexpression; String _fileName = this.root.getFileName(); String[] _split = null; if (_fileName != null) { String _quote = Pattern.quote(File.separator); _split = _fileName.split(_quote); } String _last = null; if (((Iterable<String>) Conversions.doWrapArray(_split)) != null) { _last = IterableExtensions.<String>last(((Iterable<String>) Conversions.doWrapArray(_split))); } final String fileName = _last; boolean _equals = Objects.equal(fileName, null); if (_equals) { return (prefix + "Untitled"); } final int dotPos = fileName.lastIndexOf("."); if ((dotPos >= 0)) { String _substring = fileName.substring(0, dotPos); return (prefix + _substring); } else { return (prefix + fileName); } }
@Override public WorkspaceConfig get() { SimpleWorkspaceConfig _xblockexpression = null; { ProjectManager _instance = ProjectManager.getInstance(); Project[] _openProjects = _instance.getOpenProjects(); final Project project = IterableExtensions.<Project>head( ((Iterable<Project>) Conversions.doWrapArray(_openProjects))); String _basePath = project.getBasePath(); final SimpleWorkspaceConfig result = new SimpleWorkspaceConfig(_basePath); ModuleManager _instance_1 = ModuleManager.getInstance(project); Module[] _modules = _instance_1.getModules(); final Procedure1<Module> _function = new Procedure1<Module>() { @Override public void apply(final Module m) { IdeaModuleConfig _ideaModuleConfig = new IdeaModuleConfig(m, IdeaWorkspaceConfigProvider.this.outputConfigurations); result.addProjectConfig(_ideaModuleConfig); } }; IterableExtensions.<Module>forEach( ((Iterable<Module>) Conversions.doWrapArray(_modules)), _function); _xblockexpression = result; } return _xblockexpression; }
private IJavaProject xtendProject(final String name, final IJavaProject... upstreamProjects) { try { final IJavaProject result = JavaProjectSetupUtil.createJavaProject(name); IProject _project = result.getProject(); IResourcesSetupUtil.addNature(_project, XtextProjectHelper.NATURE_ID); this.xtendLibs.addLibsToClasspath(result, null); final Procedure1<IJavaProject> _function = new Procedure1<IJavaProject>() { @Override public void apply(final IJavaProject it) { try { IPath _path = it.getPath(); IClasspathEntry _newProjectEntry = JavaCore.newProjectEntry(_path, true); JavaProjectSetupUtil.addToClasspath(result, _newProjectEntry); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } } }; IterableExtensions.<IJavaProject>forEach( ((Iterable<IJavaProject>) Conversions.doWrapArray(upstreamProjects)), _function); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
public String simpleName(final ModuleAST module) { String _name = module.getName(); String[] _split = _name.split("\\."); String _last = IterableExtensions.<String>last(((Iterable<String>) Conversions.doWrapArray(_split))); return StringExtensions.toFirstLower(_last); }
public String getLanguageNameAbbreviation() { String[] packageNames = this.languageName.split("\\."); final String[] _converted_packageNames = (String[]) packageNames; String _last = IterableExtensions.<String>last( ((Iterable<String>) Conversions.doWrapArray(_converted_packageNames))); return Strings.toFirstUpper(_last); }
public void checkEntityProgram(final String contents, final int expectedErrors) { try { String _plus = (this.TEST_PROJECT + "/src/test.entities"); final IFile file = IResourcesSetupUtil.createFile(_plus, contents); IResourcesSetupUtil.waitForAutoBuild(); IMarker[] _findMarkers = file.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE); int _size = ((List<IMarker>) Conversions.doWrapArray(_findMarkers)).size(); Assert.assertEquals(expectedErrors, _size); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected Object _execute(final ExitState exitState) { Object _xblockexpression = null; { ExecutionState[] _stateConfiguration = this.executionContext.getStateConfiguration(); ExecutionState _state = exitState.getState(); StateVector _stateVector = _state.getStateVector(); int _offset = _stateVector.getOffset(); ((List<ExecutionState>) Conversions.doWrapArray(_stateConfiguration)).set(_offset, null); _xblockexpression = (null); } return _xblockexpression; }
public void runCycle() throws ExecutionException { { this.externalExecutionContext.flush(); this.nextSVIdx = 0; this.execute(this.brc); ExecutionState[] _stateConfiguration = this.executionContext.getStateConfiguration(); int _size = ((List<ExecutionState>) Conversions.doWrapArray(_stateConfiguration)).size(); boolean _operator_lessThan = ComparableExtensions.<Integer>operator_lessThan( ((Integer) this.nextSVIdx), ((Integer) _size)); Boolean _xwhileexpression = _operator_lessThan; while (_xwhileexpression) { { ExecutionState[] _stateConfiguration_1 = this.executionContext.getStateConfiguration(); ExecutionState _get = ((List<ExecutionState>) Conversions.doWrapArray(_stateConfiguration_1)) .get(this.nextSVIdx); ExecutionState state = _get; boolean _operator_notEquals = ObjectExtensions.operator_notEquals(state, null); if (_operator_notEquals) { Sequence _reactSequence = state.getReactSequence(); this.execute(_reactSequence); } int _operator_plus = IntegerExtensions.operator_plus(((Integer) this.nextSVIdx), ((Integer) 1)); this.nextSVIdx = _operator_plus; } ExecutionState[] _stateConfiguration_2 = this.executionContext.getStateConfiguration(); int _size_1 = ((List<ExecutionState>) Conversions.doWrapArray(_stateConfiguration_2)).size(); boolean _operator_lessThan_1 = ComparableExtensions.<Integer>operator_lessThan( ((Integer) this.nextSVIdx), ((Integer) _size_1)); _xwhileexpression = _operator_lessThan_1; } this.executionContext.resetRaisedEvents(); this.execute(this.erc); } }
public void addExportedPackage( final IJavaProject pluginProject, final String... exportedPackages) { try { IProject _project = pluginProject.getProject(); final IFile manifestFile = _project.getFile("META-INF/MANIFEST.MF"); final InputStream manifestContent = manifestFile.getContents(); Manifest _xtrycatchfinallyexpression = null; try { _xtrycatchfinallyexpression = new Manifest(manifestContent); } finally { manifestContent.close(); } final Manifest manifest = _xtrycatchfinallyexpression; final Attributes attrs = manifest.getMainAttributes(); boolean _containsKey = attrs.containsKey("Export-Package"); if (_containsKey) { Object _get = attrs.get("Export-Package"); String _plus = (_get + ","); String _join = IterableExtensions.join(((Iterable<?>) Conversions.doWrapArray(exportedPackages)), ","); String _plus_1 = (_plus + _join); attrs.putValue("Export-Package", _plus_1); } else { String _join_1 = IterableExtensions.join(((Iterable<?>) Conversions.doWrapArray(exportedPackages)), ","); attrs.putValue("Export-Package", _join_1); } final ByteArrayOutputStream out = new ByteArrayOutputStream(); manifest.write(out); byte[] _byteArray = out.toByteArray(); final ByteArrayInputStream in = new ByteArrayInputStream(_byteArray); BufferedInputStream _bufferedInputStream = new BufferedInputStream(in); manifestFile.setContents(_bufferedInputStream, true, true, null); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testEnumeration() { try { final XExpression expression = this.expression("null", false); final Procedure1<JvmEnumerationType> _function = new Procedure1<JvmEnumerationType>() { public void apply(final JvmEnumerationType it) { EList<JvmMember> _members = it.getMembers(); JvmEnumerationLiteral _enumerationLiteral = JvmModelGeneratorTest.this.builder.toEnumerationLiteral(expression, "BAR"); JvmModelGeneratorTest.this.builder.<JvmEnumerationLiteral>operator_add( _members, _enumerationLiteral); EList<JvmMember> _members_1 = it.getMembers(); JvmEnumerationLiteral _enumerationLiteral_1 = JvmModelGeneratorTest.this.builder.toEnumerationLiteral(expression, "BAZ"); JvmModelGeneratorTest.this.builder.<JvmEnumerationLiteral>operator_add( _members_1, _enumerationLiteral_1); } }; final JvmEnumerationType enumeration = this.builder.toEnumerationType(expression, "my.test.Foo", _function); Resource _eResource = expression.eResource(); final Class<? extends Object> compiled = this.compile(_eResource, enumeration); final Method valuesMethod = compiled.getMethod("values"); Object _invoke = valuesMethod.invoke(null); final Object[] values = ((Object[]) _invoke); Object _get = ((List<Object>) Conversions.doWrapArray(values)).get(0); String _string = _get.toString(); Assert.assertEquals("BAR", _string); Object _get_1 = ((List<Object>) Conversions.doWrapArray(values)).get(1); String _string_1 = _get_1.toString(); Assert.assertEquals("BAZ", _string_1); } catch (Exception _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testCompileTestData() { this.batchCompiler.compile(); File _file = new File((FeatureBatchCompilerTest.OUTPUT_DIRECTORY + "/test")); final FilenameFilter _function = new FilenameFilter() { public boolean accept(final File dir, final String name) { boolean _endsWith = name.endsWith(".java"); return _endsWith; } }; String[] _list = _file.list(_function); int _size = ((List<String>) Conversions.doWrapArray(_list)).size(); Assert.assertEquals(3, _size); }
protected String root(final EObject xtendClass) { final XtendFile specFile = EcoreUtil2.<XtendFile>getContainerOfType(xtendClass, XtendFile.class); final String packageName = specFile.getPackage(); boolean _equals = Objects.equal(packageName, null); if (_equals) { return ""; } final String[] fragments = packageName.split("\\."); final Function1<String, String> _function = new Function1<String, String>() { public String apply(final String s) { return "../"; } }; final List<String> path = ListExtensions.<String, String>map( ((List<String>) Conversions.doWrapArray(fragments)), _function); return IterableExtensions.join(path, ""); }
public TypeReference( final String packageName, final String className, final List<TypeReference> arguments) { if ((packageName == null)) { throw new IllegalArgumentException(("Invalid package name: " + packageName)); } if ((className == null)) { throw new IllegalArgumentException(("Invalid class name: " + className)); } this.packageName = packageName; String[] _split = className.split("\\."); this.simpleNames = ((List<String>) Conversions.doWrapArray(_split)); List<TypeReference> _elvis = null; if (arguments != null) { _elvis = arguments; } else { List<TypeReference> _emptyList = Collections.<TypeReference>emptyList(); _elvis = _emptyList; } this.typeArguments = _elvis; }
@Override public IResource getResource() { boolean _equals = Objects.equal(this.file, null); if (_equals) { IWorkspace _workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot _root = _workspace.getRoot(); IPath _path = this.getPath(); final List<IFile> possibleFiles = (List<IFile>) Conversions.doWrapArray(_root.findFilesForLocation(_path)); int _size = possibleFiles.size(); boolean _equals_1 = (_size == 1); if (_equals_1) { IFile _head = IterableExtensions.<IFile>head(possibleFiles); this.file = _head; } ErlLogger _instance = ErlLogger.getInstance(); IPath _path_1 = this.getPath(); _instance.warn("not able to find file %s", _path_1); } return this.file; }
protected void createParserBasedProposals( final CompletionParameters parameters, final CompletionResultSet result) { Editor _editor = parameters.getEditor(); int _offset = parameters.getOffset(); final TokenSet tokenSet = this._tokenSetProvider.getTokenSet(((EditorEx) _editor), _offset); boolean _supportParserBasedProposals = this.supportParserBasedProposals(tokenSet); boolean _not = (!_supportParserBasedProposals); if (_not) { return; } final ContentAssistContextFactory delegate = this.getParserBasedDelegate(); boolean _equals = Objects.equal(delegate, null); if (_equals) { return; } String _text = this.getText(parameters); TextRegion _selection = this.getSelection(parameters); int _offset_1 = parameters.getOffset(); XtextResource _resource = this.getResource(parameters); final ContentAssistContext[] contexts = delegate.create(_text, _selection, _offset_1, _resource); final Procedure1<ContentAssistContext> _function = new Procedure1<ContentAssistContext>() { @Override public void apply(final ContentAssistContext c) { ImmutableList<AbstractElement> _firstSetGrammarElements = c.getFirstSetGrammarElements(); final Procedure1<AbstractElement> _function = new Procedure1<AbstractElement>() { @Override public void apply(final AbstractElement e) { AbstractCompletionContributor.this.createProposal(e, c, parameters, result); } }; IterableExtensions.<AbstractElement>forEach(_firstSetGrammarElements, _function); } }; IterableExtensions.<ContentAssistContext>forEach( ((Iterable<ContentAssistContext>) Conversions.doWrapArray(contexts)), _function); }
protected Object _execute(final StateSwitch stateSwitch) throws ExecutionException { Object _xblockexpression = null; { ExecutionRegion _historyRegion = stateSwitch.getHistoryRegion(); final ExecutionRegion historyRegion = _historyRegion; boolean _operator_notEquals = ObjectExtensions.operator_notEquals(historyRegion, null); if (_operator_notEquals) { { ExecutionState _historyStateConfiguration = this.executionContext.getHistoryStateConfiguration(historyRegion); final ExecutionState historyState = _historyStateConfiguration; EList<StateCase> _cases = stateSwitch.getCases(); for (final StateCase stateCase : _cases) { ExecutionState _state = stateCase.getState(); boolean _operator_equals = ObjectExtensions.operator_equals(historyState, _state); if (_operator_equals) { Step _step = stateCase.getStep(); this.execute(_step); } } } } else { EList<StateCase> _cases_1 = stateSwitch.getCases(); for (final StateCase stateCase_1 : _cases_1) { ExecutionState[] _stateConfiguration = this.executionContext.getStateConfiguration(); ExecutionState _state_1 = stateCase_1.getState(); boolean _contains = ((List<ExecutionState>) Conversions.doWrapArray(_stateConfiguration)) .contains(_state_1); if (_contains) { Step _step_1 = stateCase_1.getStep(); this.execute(_step_1); } } } _xblockexpression = (null); } return _xblockexpression; }
@Test public void testAnnotation_1() { try { final XExpression expression = this.expression("42", false); final Procedure1<JvmAnnotationType> _function = new Procedure1<JvmAnnotationType>() { public void apply(final JvmAnnotationType it) { EList<JvmMember> _members = it.getMembers(); JvmTypeReference _typeForName = JvmModelGeneratorTest.this.references.getTypeForName(int.class, expression); final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { public void apply(final JvmOperation it) { JvmModelGeneratorTest.this.builder.setBody(it, expression); } }; JvmOperation _method = JvmModelGeneratorTest.this.builder.toMethod( expression, "theTruth", _typeForName, _function); JvmModelGeneratorTest.this.builder.<JvmOperation>operator_add(_members, _method); } }; final JvmAnnotationType clazz = this.builder.toAnnotationType(expression, "my.test.Foo", _function); Resource _eResource = expression.eResource(); final Class<? extends Object> compiledClass = this.compile(_eResource, clazz); boolean _isAnnotation = compiledClass.isAnnotation(); Assert.assertTrue(_isAnnotation); Method[] _methods = compiledClass.getMethods(); final Method method = IterableExtensions.<Method>head(((Iterable<Method>) Conversions.doWrapArray(_methods))); String _name = method.getName(); Assert.assertEquals("theTruth", _name); Object _defaultValue = method.getDefaultValue(); Assert.assertEquals(Integer.valueOf(42), _defaultValue); } catch (Exception _e) { throw Exceptions.sneakyThrow(_e); } }
protected String surroundWithDiv(final String html, final String... divClasses) { StringConcatenation _builder = new StringConcatenation(); _builder.append("<div"); { int _length = divClasses.length; boolean _greaterThan = (_length > 0); if (_greaterThan) { _builder.append(" class=\""); String _join = IterableExtensions.join(((Iterable<?>) Conversions.doWrapArray(divClasses)), " "); _builder.append(_join, ""); _builder.append("\""); } } _builder.append(">"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append(html, "\t"); _builder.newLineIfNotEmpty(); _builder.append("</div>"); _builder.newLine(); return _builder.toString(); }
public void testLibNotAddedTwice() { this.libraryAdder.apply(this.myModule); this.libraryAdder.apply(this.myModule); ModuleRootManager _instance = ModuleRootManager.getInstance(this.myModule); OrderEntry[] _orderEntries = _instance.getOrderEntries(); final Function1<OrderEntry, Boolean> _function = new Function1<OrderEntry, Boolean>() { @Override public Boolean apply(final OrderEntry it) { String _presentableName = it.getPresentableName(); return Boolean.valueOf( _presentableName.startsWith(XtendLibraryDescription.XTEND_LIBRARY_NAME)); } }; final Iterable<OrderEntry> xtendlibs = IterableExtensions.<OrderEntry>filter( ((Iterable<OrderEntry>) Conversions.doWrapArray(_orderEntries)), _function); int _size = IterableExtensions.size(xtendlibs); TestCase.assertEquals("Xtend libraries in module", 1, _size); StringConcatenation _builder = new StringConcatenation(); _builder.append("class Foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("def static void main(String... args) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("println(\"Foo\")"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.configureByText(_builder.toString()); this.myFixture.checkHighlighting(); }
@Override public CharSequence getFileContents(final SerializerGenFileNames.GenFileName filename) { String _xblockexpression = null; { String _packageName = filename.getPackageName(); String _fileHeader = this._naming.fileHeader(); final JavaFile file = new JavaFile(_packageName, _fileHeader); file.imported(org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer.class); file.imported(RuleCall.class); file.imported(INode.class); file.imported(ISyntacticSequencerPDAProvider.ISynTransition.class); file.imported(Inject.class); file.imported(IGrammarAccess.class); file.imported(EObject.class); file.imported(List.class); file.imported(GrammarAlias.AbstractElementAlias.class); String _annotationImports = this._naming.annotationImports(); boolean _notEquals = (!Objects.equal(_annotationImports, null)); if (_notEquals) { String _annotationImports_1 = this._naming.annotationImports(); String[] _split = _annotationImports_1.split("(import)|;"); final Function1<String, String> _function = new Function1<String, String>() { @Override public String apply(final String it) { return it.trim(); } }; List<String> _map = ListExtensions.<String, String>map( ((List<String>) Conversions.doWrapArray(_split)), _function); final Function1<String, Boolean> _function_1 = new Function1<String, Boolean>() { @Override public Boolean apply(final String it) { boolean _isEmpty = it.isEmpty(); return Boolean.valueOf((!_isEmpty)); } }; Iterable<String> _filter = IterableExtensions.<String>filter(_map, _function_1); final Procedure1<String> _function_2 = new Procedure1<String>() { @Override public void apply(final String it) { file.imported(it); } }; IterableExtensions.<String>forEach(_filter, _function_2); } String _xifexpression = null; boolean _isAbstract = filename.isAbstract(); if (_isAbstract) { _xifexpression = "abstract "; } else { _xifexpression = ""; } final String _abstract = _xifexpression; StringConcatenation _builder = new StringConcatenation(); String _classAnnotations = this._naming.classAnnotations(); _builder.append(_classAnnotations, ""); _builder.append("@SuppressWarnings(\"all\")"); _builder.newLineIfNotEmpty(); _builder.append("public "); _builder.append(_abstract, ""); _builder.append("class "); String _simpleName = filename.getSimpleName(); _builder.append(_simpleName, ""); _builder.append(" extends AbstractSyntacticSequencer {"); _builder.newLineIfNotEmpty(); _builder.newLine(); _builder.append("\t"); _builder.append("protected "); String _gaFQName = this.grammarAccess.gaFQName(this.grammar); String _imported = file.imported(_gaFQName); _builder.append(_imported, "\t"); _builder.append(" grammarAccess;"); _builder.newLineIfNotEmpty(); { List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax = this.util.getAllAmbiguousTransitionsBySyntax(); for (final EqualAmbiguousTransitions group : _allAmbiguousTransitionsBySyntax) { _builder.append("\t"); _builder.append("protected "); String _imported_1 = file.imported( "org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias"); _builder.append(_imported_1, "\t"); _builder.append(" match_"); String _identifyer = group.getIdentifyer(); _builder.append(_identifyer, "\t"); _builder.append(";"); _builder.newLineIfNotEmpty(); } } _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("@Inject"); _builder.newLine(); _builder.append("\t"); _builder.append("protected void init(IGrammarAccess access) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("grammarAccess = ("); String _gaFQName_1 = this.grammarAccess.gaFQName(this.grammar); String _imported_2 = file.imported(_gaFQName_1); _builder.append(_imported_2, "\t\t"); _builder.append(") access;"); _builder.newLineIfNotEmpty(); { List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_1 = this.util.getAllAmbiguousTransitionsBySyntax(); for (final EqualAmbiguousTransitions group_1 : _allAmbiguousTransitionsBySyntax_1) { _builder.append("\t\t"); _builder.append("match_"); String _identifyer_1 = group_1.getIdentifyer(); _builder.append(_identifyer_1, "\t\t"); _builder.append(" = "); GrammarAlias.AbstractElementAlias _elementAlias = group_1.getElementAlias(); String _elementAliasToConstructor = this.util.elementAliasToConstructor(_elementAlias, file); _builder.append(_elementAliasToConstructor, "\t\t"); _builder.append(";"); _builder.newLineIfNotEmpty(); } } _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); CharSequence _genGetUnassignedRuleCallTokens = this.genGetUnassignedRuleCallTokens(file); _builder.append(_genGetUnassignedRuleCallTokens, "\t"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.newLine(); { List<AbstractRule> _unassignedCalledTokenRules = this.unassignedCalledTokenRules(); boolean _hasElements = false; for (final AbstractRule rule : _unassignedCalledTokenRules) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate("\n", "\t"); } _builder.append("\t"); boolean _isAbstract_1 = filename.isAbstract(); String _genGetUnassignedRuleCallToken = this.genGetUnassignedRuleCallToken(file, rule, _isAbstract_1); _builder.append(_genGetUnassignedRuleCallToken, "\t"); _builder.newLineIfNotEmpty(); } } _builder.append("\t"); _builder.newLine(); _builder.append("\t"); CharSequence _genEmitUnassignedTokens = this.genEmitUnassignedTokens(file); _builder.append(_genEmitUnassignedTokens, "\t"); _builder.newLineIfNotEmpty(); _builder.newLine(); { List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_2 = this.util.getAllAmbiguousTransitionsBySyntax(); for (final EqualAmbiguousTransitions group_2 : _allAmbiguousTransitionsBySyntax_2) { _builder.append("\t"); _builder.append("/**"); _builder.newLine(); _builder.append("\t"); _builder.append(" "); _builder.append("* Ambiguous syntax:"); _builder.newLine(); _builder.append("\t"); _builder.append(" "); _builder.append("* "); GrammarAlias.AbstractElementAlias _elementAlias_1 = group_2.getElementAlias(); String _string = _elementAlias_1.toString(); String _replace = _string.replace("\n", "\n * "); _builder.append(_replace, "\t "); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append(" "); _builder.append("*"); _builder.newLine(); _builder.append("\t"); _builder.append(" "); _builder.append("* This ambiguous syntax occurs at:"); _builder.newLine(); { List<ISyntacticSequencerPDAProvider.ISynTransition> _transitions = group_2.getTransitions(); final Function1<ISyntacticSequencerPDAProvider.ISynTransition, String> _function_3 = new Function1<ISyntacticSequencerPDAProvider.ISynTransition, String>() { @Override public String apply(final ISyntacticSequencerPDAProvider.ISynTransition it) { String _ambiguityInsideTransition = group_2.ambiguityInsideTransition(it); return _ambiguityInsideTransition.trim(); } }; List<String> _map_1 = ListExtensions.<ISyntacticSequencerPDAProvider.ISynTransition, String>map( _transitions, _function_3); Set<String> _set = IterableExtensions.<String>toSet(_map_1); List<String> _sort = IterableExtensions.<String>sort(_set); for (final String trans : _sort) { _builder.append("\t"); _builder.append(" "); _builder.append("* "); String _string_1 = trans.toString(); String _replace_1 = _string_1.replace("\n", "\n* "); _builder.append(_replace_1, "\t "); _builder.newLineIfNotEmpty(); } } _builder.append("\t"); _builder.append(" "); _builder.append("*/"); _builder.newLine(); _builder.append("\t"); _builder.append("protected void emit_"); String _identifyer_2 = group_2.getIdentifyer(); _builder.append(_identifyer_2, "\t"); _builder.append("(EObject semanticObject, "); String _imported_3 = file.imported(ISyntacticSequencerPDAProvider.ISynNavigable.class); _builder.append(_imported_3, "\t"); _builder.append(" transition, List<INode> nodes) {"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("\t"); _builder.append("acceptNodes(transition, nodes);"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); } } _builder.append("}"); _builder.newLine(); String _string_2 = _builder.toString(); file.body = _string_2; _xblockexpression = file.toString(); } return _xblockexpression; }
public static TypeReference typeRef(final String name, final TypeReference... arguments) { return new TypeReference(name, (List<TypeReference>) Conversions.doWrapArray(arguments)); }
@Test public void bug390290InnerClassMemberImport() { try { final XExpression expression = this.expression("null"); final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { public void apply(final JvmGenericType it) { final JvmGenericType innerClass = JvmModelGeneratorTest.this.builder.toClass(it, "InnerClass"); final JvmGenericType innerClassString = JvmModelGeneratorTest.this.builder.toClass(it, "String"); EList<JvmMember> _members = it.getMembers(); JvmModelGeneratorTest.this.builder.<JvmGenericType>operator_add(_members, innerClass); EList<JvmMember> _members_1 = it.getMembers(); JvmModelGeneratorTest.this.builder.<JvmGenericType>operator_add( _members_1, innerClassString); EList<JvmMember> _members_2 = it.getMembers(); JvmTypeReference _typeForName = JvmModelGeneratorTest.this.references.getTypeForName(String.class, expression); final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { public void apply(final JvmOperation fooMethod) { EList<JvmFormalParameter> _parameters = fooMethod.getParameters(); JvmParameterizedTypeReference _createTypeRef = JvmModelGeneratorTest.this.references.createTypeRef(innerClass); JvmFormalParameter _parameter = JvmModelGeneratorTest.this.builder.toParameter(it, "p1", _createTypeRef); JvmModelGeneratorTest.this.builder.<JvmFormalParameter>operator_add( _parameters, _parameter); EList<JvmFormalParameter> _parameters_1 = fooMethod.getParameters(); JvmParameterizedTypeReference _createTypeRef_1 = JvmModelGeneratorTest.this.references.createTypeRef(innerClassString); JvmFormalParameter _parameter_1 = JvmModelGeneratorTest.this.builder.toParameter( it, "p2", _createTypeRef_1); JvmModelGeneratorTest.this.builder.<JvmFormalParameter>operator_add( _parameters_1, _parameter_1); JvmModelGeneratorTest.this.builder.setBody(fooMethod, expression); } }; JvmOperation _method = JvmModelGeneratorTest.this.builder.toMethod(it, "foo", _typeForName, _function); JvmModelGeneratorTest.this.builder.<JvmOperation>operator_add(_members_2, _method); } }; final JvmGenericType clazz = this.builder.toClass(expression, "my.test.Outer", _function); Resource _eResource = expression.eResource(); _eResource.eSetDeliver(false); Resource _eResource_1 = expression.eResource(); EList<EObject> _contents = _eResource_1.getContents(); this.builder.<JvmGenericType>operator_add(_contents, clazz); Resource _eResource_2 = expression.eResource(); _eResource_2.eSetDeliver(true); InMemoryFileSystemAccess _inMemoryFileSystemAccess = new InMemoryFileSystemAccess(); final InMemoryFileSystemAccess fsa = _inMemoryFileSystemAccess; Resource _eResource_3 = expression.eResource(); this.generator.doGenerate(_eResource_3, fsa); Map<String, CharSequence> _files = fsa.getFiles(); String _identifier = clazz.getIdentifier(); String _replace = _identifier.replace(".", "/"); String _plus = (IFileSystemAccess.DEFAULT_OUTPUT + _replace); String _plus_1 = (_plus + ".java"); CharSequence _get = _files.get(_plus_1); final String code = _get.toString(); boolean _contains = code.contains("import"); Assert.assertFalse(_contains); boolean _contains_1 = code.contains("java.lang.String foo"); Assert.assertTrue(_contains_1); String _identifier_1 = clazz.getIdentifier(); final Class<? extends Object> compiledClass = this.javaCompiler.compileToClass(_identifier_1, code); Resource _eResource_4 = expression.eResource(); EList<EObject> _contents_1 = _eResource_4.getContents(); EObject _head = IterableExtensions.<EObject>head(_contents_1); this.helper.assertNoErrors(_head); Class<? extends Object>[] _declaredClasses = compiledClass.getDeclaredClasses(); int _size = ((List<Class<? extends Object>>) Conversions.doWrapArray(_declaredClasses)).size(); Assert.assertEquals(2, _size); Class<? extends Object>[] _declaredClasses_1 = compiledClass.getDeclaredClasses(); Class<? extends Object> _head_1 = IterableExtensions.<Class<? extends Object>>head( ((Iterable<Class<? extends Object>>) Conversions.doWrapArray(_declaredClasses_1))); Class<? extends Object>[] _declaredClasses_2 = compiledClass.getDeclaredClasses(); Class<? extends Object> _last = IterableExtensions.<Class<? extends Object>>last( ((Iterable<Class<? extends Object>>) Conversions.doWrapArray(_declaredClasses_2))); Method _method = compiledClass.getMethod("foo", _head_1, _last); Assert.assertNotNull(_method); } catch (Exception _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testAnnotation_2() { try { final XExpression expression = this.expression("typeof(String)", false); final Procedure1<JvmAnnotationType> _function = new Procedure1<JvmAnnotationType>() { public void apply(final JvmAnnotationType it) { EList<JvmMember> _members = it.getMembers(); JvmWildcardTypeReference _wildCard = JvmModelGeneratorTest.this.references.wildCard(); JvmTypeReference _typeForName = JvmModelGeneratorTest.this.references.getTypeForName( Class.class, expression, _wildCard); final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { public void apply(final JvmOperation it) { JvmModelGeneratorTest.this.builder.setBody(it, expression); } }; JvmOperation _method = JvmModelGeneratorTest.this.builder.toMethod( expression, "value", _typeForName, _function); JvmModelGeneratorTest.this.builder.<JvmOperation>operator_add(_members, _method); EList<JvmMember> _members_1 = it.getMembers(); JvmTypeReference _typeForName_1 = JvmModelGeneratorTest.this.references.getTypeForName(int.class, expression); final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { public void apply(final JvmOperation it) {} }; JvmOperation _method_1 = JvmModelGeneratorTest.this.builder.toMethod( expression, "otherValue", _typeForName_1, _function_1); JvmModelGeneratorTest.this.builder.<JvmOperation>operator_add(_members_1, _method_1); } }; final JvmAnnotationType clazz = this.builder.toAnnotationType(expression, "my.test.Foo", _function); Resource _eResource = expression.eResource(); final Class<? extends Object> compiledClass = this.compile(_eResource, clazz); boolean _isAnnotation = compiledClass.isAnnotation(); Assert.assertTrue(_isAnnotation); Method[] _methods = compiledClass.getMethods(); final Function1<Method, Boolean> _function_1 = new Function1<Method, Boolean>() { public Boolean apply(final Method it) { String _name = it.getName(); boolean _equals = Objects.equal(_name, "value"); return Boolean.valueOf(_equals); } }; Method _findFirst = IterableExtensions.<Method>findFirst( ((Iterable<Method>) Conversions.doWrapArray(_methods)), _function_1); Object _defaultValue = _findFirst.getDefaultValue(); Assert.assertEquals(String.class, _defaultValue); Method[] _methods_1 = compiledClass.getMethods(); final Function1<Method, Boolean> _function_2 = new Function1<Method, Boolean>() { public Boolean apply(final Method it) { String _name = it.getName(); boolean _equals = Objects.equal(_name, "otherValue"); return Boolean.valueOf(_equals); } }; Method _findFirst_1 = IterableExtensions.<Method>findFirst( ((Iterable<Method>) Conversions.doWrapArray(_methods_1)), _function_2); Object _defaultValue_1 = _findFirst_1.getDefaultValue(); Assert.assertNull(_defaultValue_1); } catch (Exception _e) { throw Exceptions.sneakyThrow(_e); } }
/** @deprecated this method is available for backwards compatibility reasons */ @Deprecated public static TypeReference guessTypeRef(final String name, final TypeReference... arguments) { return new TypeReference(name, (List<TypeReference>) Conversions.doWrapArray(arguments), false); }
public static TypeReference typeRef(final Class<?> clazz, final TypeReference... arguments) { return new TypeReference(clazz, (List<TypeReference>) Conversions.doWrapArray(arguments)); }
protected CharSequence internalToHtmlParagraph(final Object it) { CharSequence _switchResult = null; boolean matched = false; if (!matched) { if (it instanceof TextOrMarkup) { final TextOrMarkup _textOrMarkup = (TextOrMarkup) it; matched = true; EList<EObject> _contents = _textOrMarkup.getContents(); CharSequence _internalToHtmlParagraph = this.internalToHtmlParagraph(_contents); _switchResult = _internalToHtmlParagraph; } } if (!matched) { if (it instanceof List) { final List<EObject> _list = (List<EObject>) it; matched = true; final Function1<EObject, CharSequence> _function = new Function1<EObject, CharSequence>() { public CharSequence apply(final EObject it) { CharSequence _internalToHtmlParagraph = HtmlExtensions.this.internalToHtmlParagraph(it); return _internalToHtmlParagraph; } }; List<CharSequence> _map = ListExtensions.<EObject, CharSequence>map(_list, _function); String _join = IterableExtensions.join(_map); _switchResult = _join; } } if (!matched) { if (it instanceof TextPart) { final TextPart _textPart = (TextPart) it; matched = true; String _xblockexpression = null; { String _text = _textPart.getText(); String _quote = this.quote(_text); String[] _split = _quote.split("^\\s*$"); final String[] paragraphs = _split; final String[] _typeConverted_paragraphs = (String[]) paragraphs; final Function1<String, Boolean> _function = new Function1<String, Boolean>() { public Boolean apply(final String it) { boolean _isEmpty = it.isEmpty(); boolean _operator_not = BooleanExtensions.operator_not(_isEmpty); return Boolean.valueOf(_operator_not); } }; Iterable<String> _filter = IterableExtensions.<String>filter( ((Iterable<String>) Conversions.doWrapArray(_typeConverted_paragraphs)), _function); StringConcatenation _builder = new StringConcatenation(); _builder.append("</p>"); _builder.newLine(); _builder.append("<p>"); _builder.newLine(); String _join = IterableExtensions.join(_filter, _builder); _xblockexpression = (_join); } _switchResult = _xblockexpression; } } if (!matched) { if (it instanceof CodeBlock) { final CodeBlock _codeBlock = (CodeBlock) it; matched = true; CharSequence _internalToHtml = this.internalToHtml(_codeBlock, true); _switchResult = _internalToHtml; } } if (!matched) { CharSequence _html = this.toHtml(it); _switchResult = _html; } return _switchResult; }
public Library createOrGetXtendJavaLibrary( final ModifiableRootModel rootModel, final Module module) { LibraryTablesRegistrar _instance = LibraryTablesRegistrar.getInstance(); Project _project = module.getProject(); LibraryTable _libraryTable = _instance.getLibraryTable(_project); Library[] _libraries = _libraryTable.getLibraries(); LibraryTablesRegistrar _instance_1 = LibraryTablesRegistrar.getInstance(); LibraryTable _libraryTable_1 = _instance_1.getLibraryTable(); Library[] _libraries_1 = _libraryTable_1.getLibraries(); final Iterable<Library> libraryTable = Iterables.<Library>concat( ((Iterable<? extends Library>) Conversions.doWrapArray(_libraries)), ((Iterable<? extends Library>) Conversions.doWrapArray(_libraries_1))); final Function1<Library, Boolean> _function = new Function1<Library, Boolean>() { @Override public Boolean apply(final Library it) { String _name = it.getName(); boolean _startsWith = false; if (_name != null) { _startsWith = _name.startsWith(XtendLibraryDescription.XTEND_LIBRARY_NAME); } return Boolean.valueOf(_startsWith); } }; final Iterable<Library> xtendLibs = IterableExtensions.<Library>filter(libraryTable, _function); boolean _isEmpty = IterableExtensions.isEmpty(xtendLibs); boolean _not = (!_isEmpty); if (_not) { final Function1<Library, Boolean> _function_1 = new Function1<Library, Boolean>() { @Override public Boolean apply(final Library it) { String _name = it.getName(); return Boolean.valueOf( Objects.equal(_name, XtendLibraryDescription.XTEND_LIBRARY_NAME)); } }; boolean _exists = IterableExtensions.<Library>exists(xtendLibs, _function_1); if (_exists) { final Function1<Library, Boolean> _function_2 = new Function1<Library, Boolean>() { @Override public Boolean apply(final Library it) { String _name = it.getName(); return Boolean.valueOf( Objects.equal(_name, XtendLibraryDescription.XTEND_LIBRARY_NAME)); } }; return IterableExtensions.<Library>findFirst(xtendLibs, _function_2); } else { return IterableExtensions.<Library>head(xtendLibs); } } else { final NewLibraryConfiguration libDescr = this.xtendLibDescr.createLibraryDescription(); LibraryTable _moduleLibraryTable = rootModel.getModuleLibraryTable(); final LibraryTable.ModifiableModel model = _moduleLibraryTable.getModifiableModel(); String _defaultLibraryName = libDescr.getDefaultLibraryName(); final Library createdLib = model.createLibrary(_defaultLibraryName); final Library.ModifiableModel libModel = createdLib.getModifiableModel(); HashMap<OrderRootType, List<String>> _libraryRoots = this.xtendLibDescr.libraryRoots(); final Procedure2<OrderRootType, List<String>> _function_3 = new Procedure2<OrderRootType, List<String>>() { @Override public void apply(final OrderRootType type, final List<String> roots) { final Procedure1<String> _function = new Procedure1<String>() { @Override public void apply(final String it) { libModel.addRoot(it, type); } }; IterableExtensions.<String>forEach(roots, _function); } }; MapExtensions.<OrderRootType, List<String>>forEach(_libraryRoots, _function_3); libModel.commit(); model.commit(); return createdLib; } }