protected void _toJavaExpression(XSetLiteral literal, ITreeAppendable b) { LightweightTypeReference literalType = batchTypeResolver.resolveTypes(literal).getActualType(literal); if (literalType == null) { b.append("error - couldn't compute type for literal : "+literal); return; } if (literalType.isType(Map.class)) { LightweightTypeReference keyType = literalType.getTypeArguments().get(0); LightweightTypeReference valueType = literalType.getTypeArguments().get(1); b.append(Collections.class) .append(".<").append(keyType).append(", ").append(valueType) .append(">unmodifiableMap("); b.append(CollectionLiterals.class).append(".<").append(keyType).append(", ").append(valueType).append(">newHashMap("); Iterator<XExpression> elements = literal.getElements().iterator(); while(elements.hasNext()) { XExpression element = elements.next(); internalToJavaExpression(element, b); if (elements.hasNext()) { b.append(", "); } } b.append("))"); } else { appendImmutableCollectionExpression(literal, b, "unmodifiableSet", CollectionLiterals.class, "newHashSet"); } }
public void generateJavaDoc(final EObject it, final ITreeAppendable appendable, final GeneratorConfig config) { final DocumentationAdapter adapter = IterableExtensions.<DocumentationAdapter>head(Iterables.<DocumentationAdapter>filter(it.eAdapters(), DocumentationAdapter.class)); String _documentation = null; if (adapter!=null) { _documentation=adapter.getDocumentation(); } boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_documentation); boolean _not = (!_isNullOrEmpty); if (_not) { final Set<EObject> sourceElements = this.getSourceElements(it); if (((sourceElements.size() == 1) && (this.documentationProvider instanceof IEObjectDocumentationProviderExtension))) { final List<INode> documentationNodes = ((IEObjectDocumentationProviderExtension) this.documentationProvider).getDocumentationNodes(IterableExtensions.<EObject>head(sourceElements)); this.addJavaDocImports(it, appendable, documentationNodes); this.generateDocumentation(adapter.getDocumentation(), documentationNodes, appendable, config); } else { this.generateDocumentation(adapter.getDocumentation(), CollectionLiterals.<INode>emptyList(), appendable, config); } } }
protected List<ILeafNode> findNextHiddenLeafs(final INode node) { ArrayList<ILeafNode> _xblockexpression = null; { final ArrayList<ILeafNode> result = CollectionLiterals.<ILeafNode>newArrayList(); final NodeIterator ni = new NodeIterator(node); while (ni.hasNext()) { { final INode next = ni.next(); if ((next instanceof ILeafNode)) { boolean _isHidden = ((ILeafNode)next).isHidden(); if (_isHidden) { result.add(((ILeafNode)next)); } else { return result; } } } } _xblockexpression = result; } return _xblockexpression; }
public List<? extends SymbolInformation> getSymbols(final IResourceDescription resourceDescription, final String query, final IReferenceFinder.IResourceAccess resourceAccess, final CancelIndicator cancelIndicator) { final LinkedList<SymbolInformation> symbols = CollectionLiterals.<SymbolInformation>newLinkedList(); Iterable<IEObjectDescription> _exportedObjects = resourceDescription.getExportedObjects(); for (final IEObjectDescription description : _exportedObjects) { { this.operationCanceledManager.checkCanceled(cancelIndicator); boolean _filter = this.filter(description, query); if (_filter) { final Procedure1<SymbolInformation> _function = (SymbolInformation symbol) -> { symbols.add(symbol); }; this.createSymbol(description, resourceAccess, _function); } } } return symbols; }
@Test public void withNull() { final List<? extends DocumentHighlight> input = this.sort(CollectionLiterals.<DocumentHighlight>newArrayList(null, this.newHighlight(DocumentHighlightKind.Text, this.newRange(1, 1, 1, 1)), this.newHighlight(DocumentHighlightKind.Write, this.newRange(1, 1, 1, 1)), this.newHighlight(DocumentHighlightKind.Read, this.newRange(1, 1, 1, 1)))); Assert.assertEquals(1, input.get(0).getRange().getStart().getLine()); Assert.assertEquals(1, input.get(0).getRange().getStart().getCharacter()); Assert.assertEquals(1, input.get(0).getRange().getEnd().getLine()); Assert.assertEquals(1, input.get(0).getRange().getEnd().getCharacter()); Assert.assertEquals(DocumentHighlightKind.Text, input.get(0).getKind()); Assert.assertEquals(1, input.get(1).getRange().getStart().getLine()); Assert.assertEquals(1, input.get(1).getRange().getStart().getCharacter()); Assert.assertEquals(1, input.get(1).getRange().getEnd().getLine()); Assert.assertEquals(1, input.get(1).getRange().getEnd().getCharacter()); Assert.assertEquals(DocumentHighlightKind.Read, input.get(1).getKind()); Assert.assertEquals(1, input.get(2).getRange().getStart().getLine()); Assert.assertEquals(1, input.get(2).getRange().getStart().getCharacter()); Assert.assertEquals(1, input.get(2).getRange().getEnd().getLine()); Assert.assertEquals(1, input.get(2).getRange().getEnd().getCharacter()); Assert.assertEquals(DocumentHighlightKind.Write, input.get(2).getKind()); Assert.assertNull(IterableExtensions.last(input)); }
@Override public CompletableFuture<List<? extends Location>> references(final ReferenceParams params) { final Function1<CancelIndicator, List<? extends Location>> _function = (CancelIndicator cancelIndicator) -> { final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri()); final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri); DocumentSymbolService _get = null; if (resourceServiceProvider!=null) { _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class); } final DocumentSymbolService documentSymbolService = _get; if ((documentSymbolService == null)) { return CollectionLiterals.<Location>emptyList(); } final Function2<Document, XtextResource, List<? extends Location>> _function_1 = (Document document, XtextResource resource) -> { return documentSymbolService.getReferences(document, resource, params, this.resourceAccess, this.workspaceManager.getIndex(), cancelIndicator); }; return this.workspaceManager.<List<? extends Location>>doRead(uri, _function_1); }; return this.requestManager.<List<? extends Location>>runRead(_function); }
@Test public void test1() { try { this.with(ReferenceGrammarTestLanguageStandaloneSetup.class); final String model = "kind (Hugo 13)"; final ParserRule kindRule = this.<ReferenceGrammarTestLanguageGrammarAccess>get(ReferenceGrammarTestLanguageGrammarAccess.class).getKindRule(); final XtextResource resource = this.createResource(); resource.setEntryPoint(kindRule); StringInputStream _stringInputStream = new StringInputStream(model); resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap()); Assert.assertTrue(resource.getErrors().isEmpty()); Assert.assertEquals(kindRule, NodeModelUtils.getEntryParserRule(resource.getParseResult().getRootNode())); final String originalNodeModel = NodeModelUtils.compactDump(resource.getParseResult().getRootNode(), false); resource.update(0, model.length(), ((" " + model) + " ")); final String reparsedNodeModel = NodeModelUtils.compactDump(resource.getParseResult().getRootNode(), false); Assert.assertEquals(originalNodeModel, reparsedNodeModel); final ParserRule erwachsenerRule = this.<ReferenceGrammarTestLanguageGrammarAccess>get(ReferenceGrammarTestLanguageGrammarAccess.class).getErwachsenerRule(); resource.setEntryPoint(erwachsenerRule); resource.update(0, model.length(), "erwachsener (Peter 30)"); Assert.assertEquals(erwachsenerRule, NodeModelUtils.getEntryParserRule(resource.getParseResult().getRootNode())); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
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; }
@Override public CompletableFuture<List<? extends TextEdit>> rangeFormatting(final DocumentRangeFormattingParams params) { final Function1<CancelIndicator, List<? extends TextEdit>> _function = (CancelIndicator cancelIndicator) -> { final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri()); final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri); FormattingService _get = null; if (resourceServiceProvider!=null) { _get=resourceServiceProvider.<FormattingService>get(FormattingService.class); } final FormattingService formatterService = _get; if ((formatterService == null)) { return CollectionLiterals.<TextEdit>emptyList(); } final Function2<Document, XtextResource, List<? extends TextEdit>> _function_1 = (Document document, XtextResource resource) -> { return formatterService.format(document, resource, params, cancelIndicator); }; return this.workspaceManager.<List<? extends TextEdit>>doRead(uri, _function_1); }; return this.requestManager.<List<? extends TextEdit>>runRead(_function); }
@Override public Set<ExternalDependency> getExternalDependencies() { final LinkedHashSet<ExternalDependency> deps = CollectionLiterals.<ExternalDependency>newLinkedHashSet(); Set<ExternalDependency> _externalDependencies = super.getExternalDependencies(); Iterables.<ExternalDependency>addAll(deps, _externalDependencies); ExternalDependency _externalDependency = new ExternalDependency(); final Procedure1<ExternalDependency> _function = (ExternalDependency it) -> { ExternalDependency.P2Coordinates _p2 = it.getP2(); _p2.setBundleId("org.junit"); ExternalDependency.P2Coordinates _p2_1 = it.getP2(); _p2_1.setVersion("4.12.0"); ExternalDependency.MavenCoordinates _maven = it.getMaven(); _maven.setGroupId("junit"); ExternalDependency.MavenCoordinates _maven_1 = it.getMaven(); _maven_1.setArtifactId("junit"); ExternalDependency.MavenCoordinates _maven_2 = it.getMaven(); _maven_2.setVersion("4.12"); ExternalDependency.MavenCoordinates _maven_3 = it.getMaven(); _maven_3.setScope(Scope.TESTCOMPILE); }; ExternalDependency _doubleArrow = ObjectExtensions.<ExternalDependency>operator_doubleArrow(_externalDependency, _function); deps.add(_doubleArrow); return deps; }
public List<? extends SymbolInformation> getSymbols(final String query, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) { final LinkedList<SymbolInformation> result = CollectionLiterals.<SymbolInformation>newLinkedList(); Iterable<IResourceDescription> _allResourceDescriptions = indexData.getAllResourceDescriptions(); for (final IResourceDescription resourceDescription : _allResourceDescriptions) { { this.operationCanceledManager.checkCanceled(cancelIndicator); final IResourceServiceProvider resourceServiceProvider = this._registry.getResourceServiceProvider(resourceDescription.getURI()); DocumentSymbolService _get = null; if (resourceServiceProvider!=null) { _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class); } final DocumentSymbolService documentSymbolService = _get; if ((documentSymbolService != null)) { List<? extends SymbolInformation> _symbols = documentSymbolService.getSymbols(resourceDescription, query, resourceAccess, cancelIndicator); Iterables.<SymbolInformation>addAll(result, _symbols); } } } return result; }
@Override public Set<String> getSourceFolders() { LinkedHashSet<String> _xblockexpression = null; { final LinkedHashSet<String> sourceFolders = CollectionLiterals.<String>newLinkedHashSet(); Set<String> _sourceFolders = super.getSourceFolders(); Iterables.<String>addAll(sourceFolders, _sourceFolders); boolean _isInlined = this.getTestProject().isInlined(); if (_isInlined) { Set<String> _sourceFolders_1 = this.getTestProject().getSourceFolders(); Iterables.<String>addAll(sourceFolders, _sourceFolders_1); } _xblockexpression = sourceFolders; } return _xblockexpression; }
@Test public void testClasspathScanning() { try { final File bootstrapJar = new File("./somelib/sample.jar"); URL _uRL = bootstrapJar.toURI().toURL(); final URLClassLoader classloader = new URLClassLoader(new URL[] { _uRL }); final Iterable<ITypeDescriptor> utilPackage = this.scanner.getDescriptors(classloader, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("sample"))); final Function1<ITypeDescriptor, Boolean> _function = (ITypeDescriptor it) -> { String _name = it.getName(); return Boolean.valueOf(Objects.equal(_name, "sample.Sample")); }; Assert.assertTrue(IterableExtensions.<ITypeDescriptor>exists(utilPackage, _function)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
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; }
protected List<? extends Location> definition(final CancelIndicator cancelIndicator, final TextDocumentPositionParams params) { final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri()); final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri); DocumentSymbolService _get = null; if (resourceServiceProvider!=null) { _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class); } final DocumentSymbolService documentSymbolService = _get; if ((documentSymbolService == null)) { return CollectionLiterals.<Location>emptyList(); } final Function2<Document, XtextResource, List<? extends Location>> _function = (Document document, XtextResource resource) -> { return documentSymbolService.getDefinitions(document, resource, params, this.resourceAccess, cancelIndicator); }; return this.workspaceManager.<List<? extends Location>>doRead(uri, _function); }
@Override public List<? extends Command> getCodeActions(final Document document, final XtextResource resource, final CodeActionParams params, final CancelIndicator indicator) { final ArrayList<Command> commands = CollectionLiterals.<Command>newArrayList(); List<Diagnostic> _diagnostics = params.getContext().getDiagnostics(); for (final Diagnostic d : _diagnostics) { String _code = d.getCode(); if (_code != null) { switch (_code) { case TestLanguageValidator.INVALID_NAME: Command _fixInvalidName = this.fixInvalidName(d, document, resource, params); commands.add(_fixInvalidName); break; case TestLanguageValidator.UNSORTED_MEMBERS: Command _fixUnsortedMembers = this.fixUnsortedMembers(d, document, resource, params); commands.add(_fixUnsortedMembers); break; } } } return commands; }
public void callRoutine1(final Female person, final FamilyRegister familyRegister, final Member member, @Extension final RoutinesFacade _routinesFacade) { EList<Family> collectionFamilies = familyRegister.getFamilies(); int _size = collectionFamilies.size(); final List<String> familiesNames = new ArrayList<String>(_size); for (final Family f : collectionFamilies) { familiesNames.add(f.getLastName()); } final String selectMsg = "Please select the family to which the person belongs."; final int selected = this.userInteracting.selectFromMessage(UserInteractionType.MODAL, selectMsg, ((String[])Conversions.unwrapArray(familiesNames, String.class))); final Family selectedFamily = collectionFamilies.get(selected); selectedFamily.setLastName(person.getFullName().split(" ")[1]); List<String> collectionRoles = new ArrayList<String>(); Iterables.<String>addAll(collectionRoles, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("Mother", "Daughter"))); final String selectMsgRoles = "Please select whether the person is a mother or a daughter."; final List<String> _converted_collectionRoles = (List<String>)collectionRoles; final int selectedRole = this.userInteracting.selectFromMessage(UserInteractionType.MODAL, selectMsgRoles, ((String[])Conversions.unwrapArray(_converted_collectionRoles, String.class))); if ((selectedRole == 0)) { selectedFamily.setMother(member); } else { selectedFamily.getDaughters().add(member); } _routinesFacade.addCorr(person, selectedFamily); }
@Test public void testSimpleFullBuild() { final Procedure1<BuildRequest> _function = (BuildRequest it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("entity B {}"); _builder.newLine(); _builder.append("\t"); _builder.append("entity A { foo.B myReference }"); _builder.newLine(); _builder.append("}"); _builder.newLine(); URI _minus = this.operator_minus( "src/MyFile.indextestlanguage", _builder.toString()); it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus))); }; final BuildRequest buildRequest = this.newBuildRequest(_function); this.build(buildRequest); Assert.assertTrue(this.issues.toString(), this.issues.isEmpty()); Assert.assertEquals(2, this.generated.size()); Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt")); Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt")); }
protected List<ITextReplacement> format2(final XtextResource resource, final ITextRegion selection, final ITypedPreferenceValues preferences) { final FormatterRequest request = this.formatterRequestProvider.get(); request.setAllowIdentityEdits(false); request.setFormatUndefinedHiddenRegionsOnly(false); if ((selection != null)) { request.setRegions(Collections.<ITextRegion>unmodifiableList(CollectionLiterals.<ITextRegion>newArrayList(selection))); } if ((preferences != null)) { request.setPreferences(preferences); } final ITextRegionAccess regionAccess = this.regionBuilder.forNodeModel(resource).create(); request.setTextRegionAccess(regionAccess); final IFormatter2 formatter2 = this.formatter2Provider.get(); final List<ITextReplacement> replacements = formatter2.format(request); return replacements; }
@Before public void before() { try { final Path tmpPath = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value()); StringConcatenation _builder = new StringConcatenation(); _builder.append("tempFolder_"); UUID _randomUUID = UUID.randomUUID(); _builder.append(_randomUUID); final Path output = Files.createTempDirectory(tmpPath, _builder.toString()); final Path resource = Files.createFile(output.resolve(URIBasedFileSystemAccessTest.EXISTING_RESOURCE_NAME)); resource.toFile().deleteOnExit(); output.toFile().deleteOnExit(); final OutputConfiguration config = IterableExtensions.<OutputConfiguration>head(this.configProvider.getOutputConfigurations()); config.setOutputDirectory(output.toString()); Pair<String, OutputConfiguration> _mappedTo = Pair.<String, OutputConfiguration>of(IFileSystemAccess.DEFAULT_OUTPUT, config); this.fsa.setOutputConfigurations(Collections.<String, OutputConfiguration>unmodifiableMap(CollectionLiterals.<String, OutputConfiguration>newHashMap(_mappedTo))); this.fsa.setConverter(this.uriConverter); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testFormattingClosedFile() { final Procedure1<FormattingConfiguration> _function = (FormattingConfiguration it) -> { StringConcatenation _builder = new StringConcatenation(); _builder.append("type Foo{int bar} type Bar{Foo foo}"); Pair<String, String> _mappedTo = Pair.<String, String>of("foo.testlang", _builder.toString()); it.setFilesInScope(Collections.<String, CharSequence>unmodifiableMap(CollectionLiterals.<String, CharSequence>newHashMap(_mappedTo))); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("type Foo{"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("int bar"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); _builder_1.append("type Bar{"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("Foo foo"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); it.setExpectedText(_builder_1.toString()); }; this.testFormatting(_function); }
@Override public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(final TextDocumentPositionParams params) { final Function1<CancelIndicator, List<? extends DocumentHighlight>> _function = (CancelIndicator cancelIndicator) -> { final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri()); final IResourceServiceProvider serviceProvider = this.languagesRegistry.getResourceServiceProvider(uri); IDocumentHighlightService _get = null; if (serviceProvider!=null) { _get=serviceProvider.<IDocumentHighlightService>get(IDocumentHighlightService.class); } final IDocumentHighlightService service = _get; if ((service == null)) { return CollectionLiterals.<DocumentHighlight>emptyList(); } final Function2<Document, XtextResource, List<? extends DocumentHighlight>> _function_1 = (Document doc, XtextResource resource) -> { return service.getDocumentHighlights(doc, resource, params, cancelIndicator); }; return this.workspaceManager.<List<? extends DocumentHighlight>>doRead(uri, _function_1); }; return this.requestManager.<List<? extends DocumentHighlight>>runRead(_function); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Iterable<? extends TClassifier> getSuperClassifiers() { final List<TClassifier> result = CollectionLiterals.<TClassifier>newArrayList(); final Object _superClassifierRefs = this.getSuperClassifierRefs(); for (final Object superClassifierRef : ((Iterable<?>) _superClassifierRefs)) { if ((superClassifierRef != null)) { final Type declType = ((TypeRef) superClassifierRef).getDeclaredType(); if ((declType instanceof TClassifier)) { result.add(((TClassifier)declType)); } } } return result; }
protected Result<TypeArgument> applyRuleSubstTypeVariablesInComposedTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ComposedTypeRef typeRef) throws RuleFailedException { ComposedTypeRef result = null; // output parameter boolean haveReplacement = false; final ArrayList<TypeRef> substTypeRefs = CollectionLiterals.<TypeRef>newArrayList(); EList<TypeRef> _typeRefs = typeRef.getTypeRefs(); for (final TypeRef currTypeRef : _typeRefs) { /* G |- currTypeRef ~> var TypeRef substTypeRef */ TypeRef substTypeRef = null; Result<TypeArgument> result_1 = substTypeVariablesInternal(G, _trace_, currTypeRef); checkAssignableTo(result_1.getFirst(), TypeRef.class); substTypeRef = (TypeRef) result_1.getFirst(); boolean _add = substTypeRefs.add(substTypeRef); /* substTypeRefs.add(substTypeRef) */ if (!_add) { sneakyThrowRuleFailedException("substTypeRefs.add(substTypeRef)"); } haveReplacement = (haveReplacement || (substTypeRef != currTypeRef)); } if (haveReplacement) { result = TypeUtils.<ComposedTypeRef>copy(typeRef); result.getTypeRefs().clear(); /* result.typeRefs.addAll(TypeUtils.copyAll(substTypeRefs)) */ if (!result.getTypeRefs().addAll(TypeUtils.<TypeRef>copyAll(substTypeRefs))) { sneakyThrowRuleFailedException("result.typeRefs.addAll(TypeUtils.copyAll(substTypeRefs))"); } } else { result = typeRef; } return new Result<TypeArgument>(result); }
@Before public void setUp() { try { WorkspaceConfig _workspaceConfig = new WorkspaceConfig(); this.workspaceConfig = _workspaceConfig; ProjectConfig _projectConfig = new ProjectConfig("foo", this.workspaceConfig); this.fooProject = _projectConfig; ProjectConfig _projectConfig_1 = new ProjectConfig("bar", this.workspaceConfig); this.barProject = _projectConfig_1; final XtextResourceSet rs0 = this.resourceSetProvider.get(); this.fooURI = IterableExtensions.<SourceFolder>head(this.fooProject.getSourceFolders()).getPath().trimSegments(1).appendSegment("foo.livecontainertestlanguage"); this.barURI = IterableExtensions.<SourceFolder>head(this.barProject.getSourceFolders()).getPath().trimSegments(1).appendSegment("bar.livecontainertestlanguage"); ResourceDescriptionsData _createResourceDescriptionData = this.createResourceDescriptionData(this._parseHelper.parse("foo", this.fooURI, rs0).eResource()); Pair<String, ResourceDescriptionsData> _mappedTo = Pair.<String, ResourceDescriptionsData>of("foo", _createResourceDescriptionData); ResourceDescriptionsData _createResourceDescriptionData_1 = this.createResourceDescriptionData(this._parseHelper.parse("bar", this.barURI, rs0).eResource()); Pair<String, ResourceDescriptionsData> _mappedTo_1 = Pair.<String, ResourceDescriptionsData>of("bar", _createResourceDescriptionData_1); final Map<String, ResourceDescriptionsData> chunks = Collections.<String, ResourceDescriptionsData>unmodifiableMap(CollectionLiterals.<String, ResourceDescriptionsData>newHashMap(_mappedTo, _mappedTo_1)); this.rs1 = this.resourceSetProvider.get(); new ChunkedResourceDescriptions(chunks, this.rs1); ProjectConfigAdapter.install(this.rs1, this.fooProject); this.liveShadowedChunkedResourceDescriptions = this.provider.get(); this.liveShadowedChunkedResourceDescriptions.setContext(this.rs1); LiveShadowedChunkedContainer _liveShadowedChunkedContainer = new LiveShadowedChunkedContainer(this.liveShadowedChunkedResourceDescriptions, "foo"); this.fooContainer = _liveShadowedChunkedContainer; LiveShadowedChunkedContainer _liveShadowedChunkedContainer_1 = new LiveShadowedChunkedContainer(this.liveShadowedChunkedResourceDescriptions, "bar"); this.barContainer = _liveShadowedChunkedContainer_1; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
public Set<ISyntacticSequencerPDAProvider.ISynTransition> getAllAmbiguousTransitions() { final Set<ISyntacticSequencerPDAProvider.ISynTransition> result = CollectionLiterals.<ISyntacticSequencerPDAProvider.ISynTransition>newLinkedHashSet(); List<ISyntacticSequencerPDAProvider.ISynAbsorberState> _allPDAs = this.getAllPDAs(); for (final ISyntacticSequencerPDAProvider.ISynAbsorberState start : _allPDAs) { this.collectAllAmbiguousTransitions(start, result, CollectionLiterals.<Object>newHashSet()); } return result; }
private void saveResource(final Resource resource) { try { final HashMap<String, Object> saveOptions = CollectionLiterals.<String, Object>newHashMap(); saveOptions.put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.AbsoluteCrossBundleAware() { @Override public URI deresolve(final URI uri) { boolean _isPlatform = uri.isPlatform(); boolean _not = (!_isPlatform); if (_not) { Set<Map.Entry<String, URI>> _entrySet = EcorePlugin.getPlatformResourceMap().entrySet(); for (final Map.Entry<String, URI> entry : _entrySet) { { String _key = entry.getKey(); String _plus = ("platform:/resource/" + _key); String _plus_1 = (_plus + "/"); final URI newPrefix = URI.createURI(_plus_1); final URI uri2 = uri.replacePrefix(entry.getValue(), newPrefix); if ((uri2 != null)) { return super.deresolve(uri2); } } } } return super.deresolve(uri); } }); saveOptions.put(Resource.OPTION_LINE_DELIMITER, this.codeConfig.getLineDelimiter()); resource.save(saveOptions); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public Iterable<? extends AbstractFile> getFiles() { ArrayList<AbstractFile> _xblockexpression = null; { final ArrayList<AbstractFile> files = CollectionLiterals.<AbstractFile>newArrayList(); Iterable<? extends AbstractFile> _files = super.getFiles(); Iterables.<AbstractFile>addAll(files, _files); PlainTextFile _file = this.file(Outlet.ROOT, "feature.xml", this.featureXml()); files.add(_file); _xblockexpression = files; } return _xblockexpression; }
public Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> surround(final INode node, final Procedure1<? super FormattingDataInit> before, final Procedure1<? super FormattingDataInit> after) { final Function1<FormattableDocument, Iterable<FormattingData>> _function = (FormattableDocument doc) -> { ArrayList<FormattingData> _xblockexpression = null; { final ArrayList<FormattingData> result = CollectionLiterals.<FormattingData>newArrayList(); if ((node != null)) { Iterable<FormattingData> _elvis = null; Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData = this.newFormattingData(this._hiddenLeafAccess.getHiddenLeafsBefore(node), before); Iterable<FormattingData> _apply = null; if (_newFormattingData!=null) { _apply=_newFormattingData.apply(doc); } if (_apply != null) { _elvis = _apply; } else { List<FormattingData> _emptyList = CollectionLiterals.<FormattingData>emptyList(); _elvis = _emptyList; } Iterables.<FormattingData>addAll(result, _elvis); Iterable<FormattingData> _elvis_1 = null; Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData_1 = this.newFormattingData(this._hiddenLeafAccess.getHiddenLeafsAfter(node), after); Iterable<FormattingData> _apply_1 = null; if (_newFormattingData_1!=null) { _apply_1=_newFormattingData_1.apply(doc); } if (_apply_1 != null) { _elvis_1 = _apply_1; } else { List<FormattingData> _emptyList_1 = CollectionLiterals.<FormattingData>emptyList(); _elvis_1 = _emptyList_1; } Iterables.<FormattingData>addAll(result, _elvis_1); } _xblockexpression = result; } return _xblockexpression; }; return _function; }
@Test @Deprecated public void testGuessTypeRef() { final TypeReference ref = TypeReference.guessTypeRef("java.util.Map.Entry"); Assert.assertEquals("java.util", ref.getPackageName()); Assert.assertEquals("Entry", ref.getSimpleName()); Assert.assertEquals(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("Map", "Entry")), ref.getSimpleNames()); }
public Object evaluate(final XExpression it, final boolean validationMode) { Object _xblockexpression = null; { HashSet<XExpression> _newHashSet = CollectionLiterals.<XExpression>newHashSet(); final SwitchConstantExpressionsInterpreter.SwitchContext ctx = new SwitchConstantExpressionsInterpreter.SwitchContext(null, null, null, _newHashSet); ctx.validationMode = validationMode; _xblockexpression = this.evaluate(it, ctx); } return _xblockexpression; }
public Iterable<JvmFeature> getAllFeatures(final Resource resource, final JvmDeclaredType importedType, final boolean static_, final boolean extension, final String memberName) { Iterable<JvmFeature> _xblockexpression = null; { if (((!static_) || (importedType == null))) { return CollectionLiterals.<JvmFeature>emptyList(); } final IVisibilityHelper visibilityHelper = this.getVisibilityHelper(resource); final IResolvedFeatures resolvedFeatures = this._provider.getResolvedFeatures(importedType); final Function1<JvmFeature, Boolean> _function = (JvmFeature feature) -> { return Boolean.valueOf((feature.isStatic() && visibilityHelper.isVisible(feature))); }; _xblockexpression = IterableExtensions.<JvmFeature>filter(resolvedFeatures.getAllFeatures(memberName), _function); } return _xblockexpression; }
@Test public void testResourcesAreClearedWithDeliverFalse_01() { final XtextResourceSet rs = this.createEmptyResourceSet(); Assert.assertEquals(0, rs.getURIResourceMap().size()); final XtextResource resource = new XtextResource(); resource.setURI(URI.createFileURI(new File("foo").getAbsolutePath())); EList<Resource> _resources = rs.getResources(); ArrayList<Resource> _newArrayList = CollectionLiterals.<Resource>newArrayList(resource); Iterables.<Resource>addAll(_resources, _newArrayList); Assert.assertEquals(1, rs.getURIResourceMap().size()); rs.eSetDeliver(false); rs.getResources().clear(); Assert.assertTrue(resource.eAdapters().isEmpty()); Assert.assertEquals(0, rs.getURIResourceMap().size()); }
private static Set<String> computeFqFeatureNamesFromSuperGrammars(final Grammar grammar) { Set<String> _xblockexpression = null; { final HashSet<Grammar> superGrammars = CollectionLiterals.<Grammar>newHashSet(); ContentAssistFragmentExtensions.computeAllSuperGrammars(grammar, superGrammars); final Function1<Grammar, Iterable<String>> _function = (Grammar it) -> { return ContentAssistFragmentExtensions.computeFqFeatureNames(it); }; _xblockexpression = IterableExtensions.<String>toSet(Iterables.<String>concat(IterableExtensions.<Grammar, Iterable<String>>map(superGrammars, _function))); } return _xblockexpression; }
public void hasNoImplicitReturns(final XExpression expression) { final ArrayList<XExpression> returns = CollectionLiterals.<XExpression>newArrayList(); final ImplicitReturnFinder.Acceptor _function = (XExpression it) -> { returns.add(it); }; this.finder.findImplicitReturns(expression, _function); StringConcatenation _builder = new StringConcatenation(); _builder.append("Expected "); _builder.append(expression); _builder.append(" to have no implicit returns, but it had "); _builder.append(returns); Assert.assertTrue(_builder.toString(), returns.isEmpty()); }
@Override public List<? extends SubProjectConfig> getEnabledProjects() { ArrayList<SubProjectConfig> _xblockexpression = null; { final ArrayList<SubProjectConfig> enabledProjects = CollectionLiterals.<SubProjectConfig>newArrayList(); final Function1<SubProjectConfig, Boolean> _function = (SubProjectConfig it) -> { return Boolean.valueOf(it.isEnabled()); }; Iterable<? extends SubProjectConfig> _filter = IterableExtensions.filter(this.getAllProjects(), _function); Iterables.<SubProjectConfig>addAll(enabledProjects, _filter); _xblockexpression = enabledProjects; } return _xblockexpression; }
@Override public WorkspaceEdit rename(final WorkspaceManager workspaceManager, final RenameParams renameParams, final CancelIndicator cancelIndicator) { WorkspaceEdit _xblockexpression = null; { final URI uri = this._uriExtensions.toUri(renameParams.getTextDocument().getUri()); final ServerRefactoringIssueAcceptor issueAcceptor = this.issueProvider.get(); final Function2<Document, XtextResource, WorkspaceEdit> _function = (Document document, XtextResource resource) -> { final ProjectManager projectManager = workspaceManager.getProjectManager(uri); final XtextResourceSet resourceSet = projectManager.createNewResourceSet(projectManager.getIndexState().getResourceDescriptions()); resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.LIVE_SCOPE, Boolean.valueOf(true)); final int offset = document.getOffSet(renameParams.getPosition()); final WorkspaceEdit workspaceEdit = new WorkspaceEdit(); final Resource xtextResource = resourceSet.getResource(resource.getURI(), true); if ((xtextResource instanceof XtextResource)) { final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(((XtextResource)xtextResource), offset); if (((element == null) || element.eIsProxy())) { StringConcatenation _builder = new StringConcatenation(); _builder.append("No element found at position line:"); int _line = renameParams.getPosition().getLine(); _builder.append(_line); _builder.append(" column:"); int _character = renameParams.getPosition().getCharacter(); _builder.append(_character); issueAcceptor.add(RefactoringIssueAcceptor.Severity.FATAL, _builder.toString()); } else { String _newName = renameParams.getNewName(); URI _uRI = EcoreUtil.getURI(element); final RenameChange change = new RenameChange(_newName, _uRI); final IChangeSerializer changeSerializer = this.changeSerializerProvider.get(); final RenameContext context = new RenameContext(Collections.<RenameChange>unmodifiableList(CollectionLiterals.<RenameChange>newArrayList(change)), resourceSet, changeSerializer, issueAcceptor); this.renameStrategy.applyRename(context); final ChangeConverter changeConverter = this.converterFactory.create(workspaceManager, workspaceEdit); changeSerializer.applyModifications(changeConverter); } } else { issueAcceptor.add(RefactoringIssueAcceptor.Severity.FATAL, "Loaded resource is not an XtextResource", resource.getURI()); } return workspaceEdit; }; _xblockexpression = workspaceManager.<WorkspaceEdit>doRead(uri, _function); } return _xblockexpression; }
@Test public void withNull() { Position _position = new Position(2, 2); Position _position_1 = new Position(1, 1); final List<? extends Position> input = this.sort(CollectionLiterals.<Position>newArrayList(_position, null, _position_1)); Assert.assertEquals(1, input.get(0).getLine()); Assert.assertEquals(1, input.get(0).getCharacter()); Assert.assertEquals(2, input.get(1).getLine()); Assert.assertEquals(2, input.get(1).getCharacter()); Assert.assertNull(IterableExtensions.last(input)); }
@Override public void generate() { this.addRuntimeGuiceBindings(); this.addEclipsePluginGuiceBindings(); ManifestAccess _manifest = this.getProjectConfig().getEclipsePlugin().getManifest(); boolean _tripleNotEquals = (_manifest != null); if (_tripleNotEquals) { this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles().addAll( Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext.builder", "org.eclipse.xtext.ui"))); } }
@Test public void testResourceDescriptionsAreCorrect() { try { final Resource resource = this.newResource("return s.toUpperCase"); final boolean initialized = (this._reflectExtensions.<Boolean>get(resource, "fullyInitialized")).booleanValue(); Assert.assertFalse(initialized); final IResourceDescription desc = this.manager.getResourceDescription(resource); final ArrayList<Iterable<IEObjectDescription>> list = CollectionLiterals.<Iterable<IEObjectDescription>>newArrayList(desc.getExportedObjects()); Assert.assertEquals(1, list.size()); Assert.assertFalse((this._reflectExtensions.<Boolean>get(resource, "fullyInitialized")).booleanValue()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }