public <T extends Object, U extends Object> Iterable<T> select( final AbstractNodeMappingCall<T, U> nodeMappingCall, final U domainArgument) { boolean _equals = Objects.equal(domainArgument, null); if (_equals) { return Collections.<T>unmodifiableList(CollectionLiterals.<T>newArrayList()); } if ((nodeMappingCall instanceof NodeMappingCall<?, ?>)) { final NodeMappingCall<T, U> nodeMappingCallCasted = ((NodeMappingCall<T, U>) nodeMappingCall); Function1<? super U, ? extends T> _selector = nodeMappingCallCasted.getSelector(); final T nodeObject = ((Function1<? super Object, ? extends T>) ((Function1<? super Object, ? extends T>) _selector)) .apply(domainArgument); boolean _equals_1 = Objects.equal(nodeObject, null); if (_equals_1) { return Collections.<T>unmodifiableList(CollectionLiterals.<T>newArrayList()); } else { return Collections.<T>unmodifiableList(CollectionLiterals.<T>newArrayList(nodeObject)); } } else { if ((nodeMappingCall instanceof MultiNodeMappingCall<?, ?>)) { final MultiNodeMappingCall<T, U> nodeMappingCallCasted_1 = ((MultiNodeMappingCall<T, U>) nodeMappingCall); Function1<? super U, ? extends Iterable<? extends T>> _selector_1 = nodeMappingCallCasted_1.getSelector(); Iterable<T> _apply = ((Function1<? super Object, ? extends Iterable<T>>) ((Function1<? super Object, ? extends Iterable<T>>) _selector_1)) .apply(domainArgument); return IterableExtensions.<T>filterNull(_apply); } } return null; }
public void assertNonSmoking(final CharSequence input) throws Exception { final String string = input.toString(); final List<CommonToken> tokenList = CollectionLiterals.<CommonToken>newArrayList(); { final Lexer lexer = this.lexerProvider.get(); ANTLRStringStream _aNTLRStringStream = new ANTLRStringStream(string); lexer.setCharStream(_aNTLRStringStream); Token token = lexer.nextToken(); boolean _notEquals = (!Objects.equal(token, Token.EOF_TOKEN)); boolean _while = _notEquals; while (_while) { { tokenList.add(((CommonToken) token)); Token _nextToken = lexer.nextToken(); token = _nextToken; } boolean _notEquals_1 = (!Objects.equal(token, Token.EOF_TOKEN)); _while = _notEquals_1; } } for (final CommonToken token : tokenList) { { final int start = token.getStartIndex(); String _text = token.getText(); final int length = _text.length(); String _substring = string.substring(0, start); String _substring_1 = string.substring((start + length)); String _plus = (_substring + _substring_1); this.processFile(_plus); } } }
private void copyFields( final EObject objectWithReference, final Iterable<XtendMember> members, final Set<String> fieldNames) { boolean _not = (!(objectWithReference instanceof XtendClass)); if (_not) { return; } final XtendClass type = ((XtendClass) objectWithReference); final ArrayList<XtendField> newFields = CollectionLiterals.<XtendField>newArrayList(); Iterable<XtendField> _filter = Iterables.<XtendField>filter(members, XtendField.class); for (final XtendField field : _filter) { String _name = field.getName(); boolean _contains = fieldNames.contains(_name); boolean _not_1 = (!_contains); if (_not_1) { final XtendField copiedMember = this._expressionCopier.<XtendField>cloneWithProxies(field); SourceAdapter.adapt(copiedMember, field); newFields.add(((XtendField) copiedMember)); String _name_1 = field.getName(); fieldNames.add(_name_1); } } EList<XtendMember> _members = type.getMembers(); _members.addAll(newFields); }
@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); TestProjectDescriptor _testProject = this.getTestProject(); boolean _isInlined = _testProject.isInlined(); if (_isInlined) { TestProjectDescriptor _testProject_1 = this.getTestProject(); Iterable<? extends AbstractFile> _files_1 = _testProject_1.getFiles(); final Function1<AbstractFile, Boolean> _function = (AbstractFile fileFromTestProject) -> { final Function1<AbstractFile, Boolean> _function_1 = (AbstractFile it) -> { String _relativePath = it.getRelativePath(); String _relativePath_1 = fileFromTestProject.getRelativePath(); return Boolean.valueOf(Objects.equal(_relativePath, _relativePath_1)); }; boolean _exists = IterableExtensions.<AbstractFile>exists(files, _function_1); return Boolean.valueOf((!_exists)); }; Iterable<? extends AbstractFile> _filter = IterableExtensions.filter(_files_1, _function); Iterables.<AbstractFile>addAll(files, _filter); } _xblockexpression = files; } return _xblockexpression; }
public String subClassAlternatives(final EClass eClazz) { String _xblockexpression = null; { ArrayList<EClass> _newArrayList = CollectionLiterals.<EClass>newArrayList(eClazz); Iterable<EClass> _subClasses = Ecore2XtextExtensions.subClasses(eClazz); Iterable<EClass> list = Iterables.<EClass>concat(_newArrayList, _subClasses); final Function1<EClass, Boolean> _function = new Function1<EClass, Boolean>() { public Boolean apply(final EClass c) { boolean _needsConcreteRule = Ecore2XtextExtensions.needsConcreteRule(c); return Boolean.valueOf(_needsConcreteRule); } }; Iterable<EClass> _filter = IterableExtensions.<EClass>filter(list, _function); list = _filter; final Function1<EClass, String> _function_1 = new Function1<EClass, String>() { public String apply(final EClass it) { String _concreteRuleName = Ecore2XtextExtensions.concreteRuleName(it); return _concreteRuleName; } }; Iterable<String> _map = IterableExtensions.<EClass, String>map(list, _function_1); String _join = IterableExtensions.join(_map, " | "); _xblockexpression = (_join); } return _xblockexpression; }
public Set<ProjectDescriptor> getEnabledProjects() { ImmutableSet<ProjectDescriptor> _xblockexpression = null; { final Function1<ProjectDescriptor, Boolean> _function = new Function1<ProjectDescriptor, Boolean>() { @Override public Boolean apply(final ProjectDescriptor it) { return Boolean.valueOf(it.isEnabled()); } }; final Iterable<? extends ProjectDescriptor> productionProjects = IterableExtensions.filter( Collections.<ProjectDescriptor>unmodifiableList( CollectionLiterals.<ProjectDescriptor>newArrayList( this.runtimeProject, this.ideProject, this.uiProject, this.intellijProject, this.webProject, this.parentProject, this.targetPlatformProject)), _function); Iterable<TestedProjectDescriptor> _filter = Iterables.<TestedProjectDescriptor>filter( productionProjects, TestedProjectDescriptor.class); final Function1<TestedProjectDescriptor, TestProjectDescriptor> _function_1 = new Function1<TestedProjectDescriptor, TestProjectDescriptor>() { @Override public TestProjectDescriptor apply(final TestedProjectDescriptor it) { return it.getTestProject(); } }; Iterable<TestProjectDescriptor> _map = IterableExtensions.<TestedProjectDescriptor, TestProjectDescriptor>map( _filter, _function_1); final Function1<TestProjectDescriptor, Boolean> _function_2 = new Function1<TestProjectDescriptor, Boolean>() { @Override public Boolean apply(final TestProjectDescriptor it) { boolean _and = false; boolean _isEnabled = it.isEnabled(); if (!_isEnabled) { _and = false; } else { boolean _isSeparate = it.isSeparate(); _and = _isSeparate; } return Boolean.valueOf(_and); } }; final Iterable<TestProjectDescriptor> testProjects = IterableExtensions.<TestProjectDescriptor>filter(_map, _function_2); Iterable<ProjectDescriptor> _plus = Iterables.<ProjectDescriptor>concat(productionProjects, testProjects); _xblockexpression = ImmutableSet.<ProjectDescriptor>copyOf(_plus); } return _xblockexpression; }
public void reset() { super.reset(); HashMap<String, JavaBuilderState> _newHashMap = CollectionLiterals.<String, JavaBuilderState>newHashMap(); this.javaBuildState = _newHashMap; ArrayList<UnconfirmedStructuralChangesDelta> _newArrayList = CollectionLiterals.<UnconfirmedStructuralChangesDelta>newArrayList(); this.unconfirmedDeltas = _newArrayList; }
@Test public void testShouldLoadFromStorage() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypack"); _builder.newLine(); _builder.newLine(); _builder.append("class MyClass {"); _builder.newLine(); _builder.append("\t"); _builder.append("public def void foo() {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final IFile file = this.helper.createFile("mypack/MyClass.xtend", _builder.toString()); IResourcesSetupUtil.waitForAutoBuild(); final URI uri = this.uriMapper.getUri(file); IProject _project = file.getProject(); final ResourceSet resourceSet = this.resourceSetProvider.get(_project); SourceLevelURIsAdapter.setSourceLevelUris( resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList())); Resource _createResource = resourceSet.createResource(uri); final StorageAwareResource resource = ((StorageAwareResource) _createResource); final Procedure0 _function = new Procedure0() { @Override public void apply() { IResourceStorageFacade _resourceStorageFacade = resource.getResourceStorageFacade(); boolean _shouldLoadFromStorage = _resourceStorageFacade.shouldLoadFromStorage(resource); Assert.assertTrue(_shouldLoadFromStorage); } }; this.doWorkInJob(_function); NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor(); file.delete(true, _nullProgressMonitor); IResourcesSetupUtil.waitForAutoBuild(); final Procedure0 _function_1 = new Procedure0() { @Override public void apply() { IResourceStorageFacade _resourceStorageFacade = resource.getResourceStorageFacade(); boolean _shouldLoadFromStorage = _resourceStorageFacade.shouldLoadFromStorage(resource); Assert.assertFalse(_shouldLoadFromStorage); } }; this.doWorkInJob(_function_1); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
public <T extends Object, U extends Object> Iterable<? extends XLabel> execute( final AbstractLabelMappingCall<T, U> labelMappingCall, final U domainArgument) { final Iterable<T> labelObjects = this.<T, U>select(labelMappingCall, domainArgument); final ArrayList<XLabel> result = CollectionLiterals.<XLabel>newArrayList(); for (final T labelObject : labelObjects) { AbstractLabelMapping<T> _labelMapping = labelMappingCall.getLabelMapping(); XLabel _createLabel = this.<T>createLabel(labelObject, _labelMapping); result.add(_createLabel); } return result; }
/** @noreference */ @SuppressWarnings("all") public class CompositeGeneratorFragment implements IXtextGeneratorFragment { @Accessors(AccessorType.PROTECTED_GETTER) private final List<IXtextGeneratorFragment> fragments = CollectionLiterals.<IXtextGeneratorFragment>newArrayList(); public void addFragment(final IXtextGeneratorFragment fragment) { if ((fragment == this)) { throw new IllegalArgumentException(); } this.fragments.add(fragment); } @Override public void checkConfiguration(final Issues issues) { for (final IXtextGeneratorFragment fragment : this.fragments) { fragment.checkConfiguration(issues); } } @Override public void generate() { final CompositeGeneratorException composite = new CompositeGeneratorException(); for (final IXtextGeneratorFragment fragment : this.fragments) { try { fragment.generate(); } catch (final Throwable _t) { if (_t instanceof Exception) { final Exception e = (Exception) _t; composite.addException(e); } else { throw Exceptions.sneakyThrow(_t); } } } boolean _hasExceptions = composite.hasExceptions(); if (_hasExceptions) { throw composite; } } @Override public void initialize(final Injector injector) { for (final IXtextGeneratorFragment fragment : this.fragments) { fragment.initialize(injector); } } @Pure protected List<IXtextGeneratorFragment> getFragments() { return this.fragments; } }
public <T extends Object, U extends Object> Iterable<XNode> execute( final AbstractNodeMappingCall<T, U> nodeMappingCall, final U domainArgument, final InterpreterContext context) { final Iterable<T> nodeObjects = this.<T, U>select(nodeMappingCall, domainArgument); final ArrayList<XNode> result = CollectionLiterals.<XNode>newArrayList(); for (final T nodeObject : nodeObjects) { NodeMapping<T> _nodeMapping = nodeMappingCall.getNodeMapping(); XNode _createNode = this.<T>createNode(nodeObject, _nodeMapping, context); result.add(_createNode); } return result; }
@Override public List<TextRange> getRanges() { List<TextRange> _xblockexpression = null; { final TextRange rangeInElement = this.getRangeInElement(); final TextRange rangeToHighlightInElement = this.getRangeToHighlightInElement(); List<TextRange> _xifexpression = null; boolean _equals = Objects.equal(rangeInElement, rangeToHighlightInElement); if (_equals) { _xifexpression = Collections.<TextRange>unmodifiableList( CollectionLiterals.<TextRange>newArrayList(rangeInElement)); } else { _xifexpression = Collections.<TextRange>unmodifiableList( CollectionLiterals.<TextRange>newArrayList( rangeInElement, rangeToHighlightInElement)); } _xblockexpression = _xifexpression; } return _xblockexpression; }
public List<Integer> test() { ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList("red", "green"); final Function1<String, Integer> _function = new Function1<String, Integer>() { public Integer apply(final String it) { int _length = it.length(); return Integer.valueOf(_length); } }; List<Integer> _map = ListExtensions.<String, Integer>map(_newArrayList, _function); List<Integer> _reverseView = ListExtensions.<Integer>reverseView(_map); return _reverseView; }
public String blah(final String input) { final ArrayList<?> _cacheKey = CollectionLiterals.newArrayList(input); final String _result; synchronized (_createCache_blah) { if (_createCache_blah.containsKey(_cacheKey)) { return _createCache_blah.get(_cacheKey); } String _string = new String(); _result = _string; _createCache_blah.put(_cacheKey, _result); } _init_blah(_result, input); return _result; }
protected void doWorkInJob(final Procedure0 work) { try { final ArrayList<Throwable> throwables = CollectionLiterals.<Throwable>newArrayList(); StringConcatenation _builder = new StringConcatenation(); Class<? extends ResourceStorageTest> _class = this.getClass(); String _name = _class.getName(); _builder.append(_name, ""); _builder.append(".TestJob"); final Procedure1<Job> _function = new Procedure1<Job>() { @Override public void apply(final Job it) { ISchedulingRule _newSequence = SchedulingRuleFactory.INSTANCE.newSequence(); it.setRule(_newSequence); } }; final Job testShouldLoadFromStorageJob = ObjectExtensions.<Job>operator_doubleArrow( new Job(_builder.toString()) { @Override protected IStatus run(final IProgressMonitor monitor) { IStatus _xblockexpression = null; { try { work.apply(); } catch (final Throwable _t) { if (_t instanceof Throwable) { final Throwable t = (Throwable) _t; throwables.add(t); } else { throw Exceptions.sneakyThrow(_t); } } _xblockexpression = Status.OK_STATUS; } return _xblockexpression; } }, _function); testShouldLoadFromStorageJob.schedule(); testShouldLoadFromStorageJob.join(); final Throwable t = IterableExtensions.<Throwable>head(throwables); boolean _notEquals = (!Objects.equal(t, null)); if (_notEquals) { Throwables.propagate(t); } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public List<ReferenceType> getAllClasses(final SourcePosition source) throws NoDataException { PsiFile _file = source.getFile(); Language _language = _file.getLanguage(); boolean _notEquals = (!Objects.equal(_language, this.language)); if (_notEquals) { throw NoDataException.INSTANCE; } final Map<URI, AbstractTraceRegion> traces = this._debugProcessExtensions.getTracesForSource(this.process, source); final ArrayList<ReferenceType> allClasses = CollectionLiterals.<ReferenceType>newArrayList(); final int line = source.getLine(); Set<Map.Entry<URI, AbstractTraceRegion>> _entrySet = traces.entrySet(); for (final Map.Entry<URI, AbstractTraceRegion> uri2trace : _entrySet) { { AbstractTraceRegion _value = uri2trace.getValue(); TreeIterator<AbstractTraceRegion> _treeIterator = _value.treeIterator(); final Function1<AbstractTraceRegion, Boolean> _function = new Function1<AbstractTraceRegion, Boolean>() { @Override public Boolean apply(final AbstractTraceRegion it) { List<ILocationData> _associatedLocations = it.getAssociatedLocations(); ILocationData _head = IterableExtensions.<ILocationData>head(_associatedLocations); int _lineNumber = 0; if (_head != null) { _lineNumber = _head.getLineNumber(); } return Boolean.valueOf((_lineNumber == line)); } }; final AbstractTraceRegion region = IteratorExtensions.<AbstractTraceRegion>findFirst(_treeIterator, _function); boolean _notEquals_1 = (!Objects.equal(region, null)); if (_notEquals_1) { URI _key = uri2trace.getKey(); final PsiFile psiFile = this._debugProcessExtensions.getPsiFile(this.process, _key); PositionManagerImpl _javaPositionManger = this._debugProcessExtensions.getJavaPositionManger(this.process); int _myLineNumber = region.getMyLineNumber(); int _plus = (_myLineNumber + 1); SourcePosition _createFromLine = SourcePosition.createFromLine(psiFile, _plus); final List<ReferenceType> classes = _javaPositionManger.getAllClasses(_createFromLine); allClasses.addAll(classes); } } } return allClasses; }
protected String addIconDivs(final IImageDescription it, final String nameHtml) { String _switchResult = null; boolean _matched = false; if (it instanceof SimpleImageDescription) { _matched = true; String _imageID = ((SimpleImageDescription) it).getImageID(); String _plus = (_imageID + "-icon"); _switchResult = this.surroundWithDiv(nameHtml, _plus); } if (!_matched) { if (it instanceof AlternativeImageDescription) { _matched = true; List<String> _imageIDs = ((AlternativeImageDescription) it).getImageIDs(); final Function1<String, String> _function = new Function1<String, String>() { @Override public String apply(final String it) { return (it + "-icon"); } }; List<String> _map = ListExtensions.<String, String>map(_imageIDs, _function); _switchResult = this.surroundWithDiv( nameHtml, ((String[]) Conversions.unwrapArray(_map, String.class))); } } if (!_matched) { if (it instanceof DecoratedImageDescription) { _matched = true; List<IImageDescription> _decorators = ((DecoratedImageDescription) it).getDecorators(); IImageDescription _baseImage = ((DecoratedImageDescription) it).getBaseImage(); Iterable<IImageDescription> _plus = Iterables.<IImageDescription>concat( _decorators, Collections.<IImageDescription>unmodifiableList( CollectionLiterals.<IImageDescription>newArrayList(_baseImage))); final Function2<String, IImageDescription, String> _function = new Function2<String, IImageDescription, String>() { @Override public String apply(final String $0, final IImageDescription $1) { return HoverService.this.addIconDivs($1, $0); } }; _switchResult = IterableExtensions.<IImageDescription, String>fold(_plus, nameHtml, _function); } } return _switchResult; }
public <T extends Object, U extends Object> Iterable<XConnection> execute( final AbstractConnectionMappingCall<T, U> connectionMappingCall, final U domainArgument, final Procedure1<? super XConnection> initializer, final InterpreterContext context) { final Iterable<T> connectionObjects = this.<T, U>select(connectionMappingCall, domainArgument); final ArrayList<XConnection> result = CollectionLiterals.<XConnection>newArrayList(); for (final T connectionObject : connectionObjects) { { ConnectionMapping<T> _connectionMapping = connectionMappingCall.getConnectionMapping(); final XConnection connection = this.<T>createConnection(connectionObject, _connectionMapping, initializer, context); result.add(connection); } } return result; }
public void resolve() { boolean _equals = Objects.equal(this.resolved, null); if (_equals) { HashMap<QualifiedName, GeneratorScope.Sortable> _newHashMap = CollectionLiterals.<QualifiedName, GeneratorScope.Sortable>newHashMap(); this.resolved = _newHashMap; final ArrayList<GeneratorScope.Sortable> temp = CollectionLiterals.<GeneratorScope.Sortable>newArrayList(); Iterable<IEObjectDescription> _allElements = this.delegate.getAllElements(); for (final IEObjectDescription desc : _allElements) { GeneratorScope.Sortable _sortable = new GeneratorScope.Sortable(desc); temp.add(_sortable); } Collections.<GeneratorScope.Sortable>sort(temp); for (final GeneratorScope.Sortable desc_1 : temp) { this.resolved.put(desc_1.name, desc_1); } } }
public TypeReference(final Class<?> clazz, final List<TypeReference> arguments) { boolean _isPrimitive = clazz.isPrimitive(); if (_isPrimitive) { String _name = clazz.getName(); String _plus = ("Type is primitive: " + _name); throw new IllegalArgumentException(_plus); } boolean _isAnonymousClass = clazz.isAnonymousClass(); if (_isAnonymousClass) { String _name_1 = clazz.getName(); String _plus_1 = ("Class is anonymous: " + _name_1); throw new IllegalArgumentException(_plus_1); } boolean _isLocalClass = clazz.isLocalClass(); if (_isLocalClass) { String _name_2 = clazz.getName(); String _plus_2 = ("Class is local: " + _name_2); throw new IllegalArgumentException(_plus_2); } Package _package = clazz.getPackage(); String _name_3 = _package.getName(); this.packageName = _name_3; ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList(); this.simpleNames = _newArrayList; List<TypeReference> _elvis = null; if (arguments != null) { _elvis = arguments; } else { List<TypeReference> _emptyList = Collections.<TypeReference>emptyList(); _elvis = _emptyList; } this.typeArguments = _elvis; Class<?> c = clazz; do { { String _simpleName = c.getSimpleName(); this.simpleNames.add(0, _simpleName); Class<?> _declaringClass = c.getDeclaringClass(); c = _declaringClass; } } while ((c != null)); }
public void testResourceDescriptionsAreCorrect() throws IOException, IllegalAccessException, NoSuchFieldException { Resource _newResource = this.newResource("return s.toUpperCase"); final Resource resource = _newResource; Field _declaredField = org.eclipse.xtext.resource.DerivedStateAwareResource.class.getDeclaredField( "fullyInitialized"); final Field field = _declaredField; field.setAccessible(true); Object _get = field.get(resource); Assert.assertFalse(((Boolean) _get)); IResourceDescription _resourceDescription = this.manager.getResourceDescription(resource); final IResourceDescription desc = _resourceDescription; Iterable<IEObjectDescription> _exportedObjects = desc.getExportedObjects(); ArrayList<Iterable<IEObjectDescription>> _newArrayList = CollectionLiterals.<Iterable<IEObjectDescription>>newArrayList(_exportedObjects); final ArrayList<Iterable<IEObjectDescription>> list = _newArrayList; int _size = list.size(); Assert.assertEquals(1, _size); Object _get_1 = field.get(resource); Assert.assertFalse(((Boolean) _get_1)); }
protected List<AbstractElement> _contentsAsList(final UnorderedGroup it) { ArrayList<AbstractElement> _xblockexpression = null; { final ArrayList<AbstractElement> result = CollectionLiterals.<AbstractElement>newArrayList(it); EList<AbstractElement> _elements = it.getElements(); final Function1<AbstractElement, List<AbstractElement>> _function = new Function1<AbstractElement, List<AbstractElement>>() { @Override public List<AbstractElement> apply(final AbstractElement it) { return GrammarAccessExtensions.this.contentsAsList(it); } }; List<List<AbstractElement>> _map = ListExtensions.<AbstractElement, List<AbstractElement>>map(_elements, _function); Iterable<AbstractElement> _flatten = Iterables.<AbstractElement>concat(_map); List<AbstractElement> _list = IterableExtensions.<AbstractElement>toList(_flatten); Iterables.<AbstractElement>addAll(result, _list); _xblockexpression = result; } return _xblockexpression; }
@Override public Object[] getVariants() { ArrayList<LookupElementBuilder> _xblockexpression = null; { ProgressIndicatorProvider.checkCanceled(); ICrossReferenceDescription crossReferenceDescription = this.getCrossReferenceDescription(); boolean _equals = Objects.equal(crossReferenceDescription, null); if (_equals) { return ((Object[]) Conversions.unwrapArray(CollectionLiterals.<Object>emptyList(), Object.class)); } ArrayList<LookupElementBuilder> variants = CollectionLiterals.<LookupElementBuilder>newArrayList(); Iterable<IEObjectDescription> _variants = crossReferenceDescription.getVariants(); for (final IEObjectDescription objectDescription : _variants) { { ProgressIndicatorProvider.checkCanceled(); QualifiedName _name = objectDescription.getName(); String name = this.qualifiedNameConverter.toString(_name); BaseXtextFile _xtextFile = this.myElement.getXtextFile(); XtextResource _resource = _xtextFile.getResource(); PsiElement element = this.psiModelAssociations.getPsiElement(objectDescription, _resource); boolean _notEquals = (!Objects.equal(element, null)); if (_notEquals) { LookupElementBuilder _create = LookupElementBuilder.create(name); PsiElement _navigationElement = element.getNavigationElement(); PsiFile _containingFile = _navigationElement.getContainingFile(); String _name_1 = _containingFile.getName(); LookupElementBuilder _withTypeText = _create.withTypeText(_name_1); variants.add(_withTypeText); } } } _xblockexpression = variants; } return ((Object[]) Conversions.unwrapArray(_xblockexpression, Object.class)); }
protected List<? extends PsiElement> getGeneratedElements(final PsiElement element) { if ((element instanceof PsiNameIdentifierOwner)) { final PsiElement nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier(); if ((nameIdentifier == null)) { return Collections.<PsiElement>emptyList(); } return this.getGeneratedElements(nameIdentifier); } final ArrayList<PsiNamedElement> result = CollectionLiterals.<PsiNamedElement>newArrayList(); List<? extends PsiElement> _generatedElements = this.traceProvider.getGeneratedElements(element); for (final PsiElement generatedElement : _generatedElements) { { final PsiNamedElement parent = PsiTreeUtil.<PsiNamedElement>getParentOfType( generatedElement, PsiNamedElement.class, false); if (((!Objects.equal(parent, null)) && (!result.contains(parent)))) { result.add(parent); } } } return result; }
protected void refreshUpdateState() { XDiagram _diagram = this.root.getDiagram(); final ReconcileBehavior behavior = _diagram.<ReconcileBehavior>getBehavior(ReconcileBehavior.class); boolean _notEquals = (!Objects.equal(behavior, null)); if (_notEquals) { this.refreshDirtyState(behavior); } final ArrayList<XShape> allShapes = CollectionLiterals.<XShape>newArrayList(); XDiagram _diagram_1 = this.root.getDiagram(); ObservableList<XNode> _nodes = _diagram_1.getNodes(); Iterables.<XShape>addAll(allShapes, _nodes); XDiagram _diagram_2 = this.root.getDiagram(); ObservableList<XConnection> _connections = _diagram_2.getConnections(); Iterables.<XShape>addAll(allShapes, _connections); final Consumer<XShape> _function = (XShape it) -> { ReconcileBehavior _behavior = it.<ReconcileBehavior>getBehavior(ReconcileBehavior.class); if (_behavior != null) { this.refreshDirtyState(_behavior); } }; allShapes.forEach(_function); }
@Override public TextRange getRangeToHighlightInElement() { final ArrayList<?> _cacheKey = CollectionLiterals.newArrayList(); final TextRange _result; synchronized (_createCache_getRangeToHighlightInElement) { if (_createCache_getRangeToHighlightInElement.containsKey(_cacheKey)) { return _createCache_getRangeToHighlightInElement.get(_cacheKey); } TextRange _xblockexpression = null; { ICrossReferenceDescription _crossReferenceDescription = this.getCrossReferenceDescription(); final ITextRegion textRegion = _crossReferenceDescription.getTextRegion(); int _offset = textRegion.getOffset(); TextRange _textRange = this.myElement.getTextRange(); int _startOffset = _textRange.getStartOffset(); int startOffset = (_offset - _startOffset); TextRange _xifexpression = null; if ((startOffset < 0)) { _xifexpression = this.getRangeInElement(); } else { TextRange _xblockexpression_1 = null; { int _length = textRegion.getLength(); final int endOffset = (startOffset + _length); _xblockexpression_1 = new TextRange(startOffset, endOffset); } _xifexpression = _xblockexpression_1; } _xblockexpression = _xifexpression; } _result = _xblockexpression; _createCache_getRangeToHighlightInElement.put(_cacheKey, _result); } _init_getRangeToHighlightInElement(_result); return _result; }
/** * An attempt to avoid directly manipulating xsemantics environment map. * * @author jfernandes */ @SuppressWarnings("all") public class BoundsBasedTypeSystem implements TypeSystem { private Map<EObject, TypedNode> nodes = CollectionLiterals.<EObject, TypedNode>newHashMap(); private List<TypeBound> bounds = CollectionLiterals.<TypeBound>newArrayList(); public ValueTypedNode fixedNode(final WollokType fixedType, final EObject obj) { ValueTypedNode _valueTypedNode = new ValueTypedNode(obj, fixedType, this); final Procedure1<ValueTypedNode> _function = new Procedure1<ValueTypedNode>() { public void apply(final ValueTypedNode it) { BoundsBasedTypeSystem.this.nodes.put(obj, it); } }; return ObjectExtensions.<ValueTypedNode>operator_doubleArrow(_valueTypedNode, _function); } public TypedNode fixedNode( final WollokType fixedType, final EObject obj, final Procedure1<? super ExpectationBuilder> expectationsBuilder) { ValueTypedNode _fixedNode = this.fixedNode(fixedType, obj); return this.setupExpectations(_fixedNode, expectationsBuilder); } public TypeInferedNode inferredNode(final EObject obj) { TypeInferedNode _typeInferedNode = new TypeInferedNode(obj, this); final Procedure1<TypeInferedNode> _function = new Procedure1<TypeInferedNode>() { public void apply(final TypeInferedNode it) { BoundsBasedTypeSystem.this.nodes.put(obj, it); } }; return ObjectExtensions.<TypeInferedNode>operator_doubleArrow(_typeInferedNode, _function); } public TypedNode inferredNode( final EObject obj, final Procedure1<? super ExpectationBuilder> expectationsBuilder) { TypeInferedNode _inferredNode = this.inferredNode(obj); return this.setupExpectations(_inferredNode, expectationsBuilder); } public TypedNode setupExpectations( final TypedNode n, final Procedure1<? super ExpectationBuilder> expectationsBuilder) { TypedNode _xblockexpression = null; { ExpectationBuilder _expectationBuilder = new ExpectationBuilder(this, n); expectationsBuilder.apply(_expectationBuilder); _xblockexpression = n; } return _xblockexpression; } public TypedNode getNode(final EObject obj) { TypedNode _xblockexpression = null; { boolean _containsKey = this.nodes.containsKey(obj); boolean _not = (!_containsKey); if (_not) { this.bind(obj); } _xblockexpression = this.nodes.get(obj); } return _xblockexpression; } /** # 2 Second step. Goes through all the bindings and tries to infer types. */ public void inferTypes() { final Procedure1<TypeBound> _function = new Procedure1<TypeBound>() { public void apply(final TypeBound it) { it.inferTypes(); } }; IterableExtensions.<TypeBound>forEach(this.bounds, _function); } /** # 3 Third step. Asks each node individually for errors (type expectation violations). */ public Iterable<TypeExpectationFailedException> issues(final EObject obj) { TypedNode _node = this.getNode(obj); return _node.issues(); } /** * Returns the resolved type for the given object. This must be called after "inferTypes" step. */ public WollokType type(final EObject obj) { TypedNode _node = this.getNode(obj); return _node.getType(); } public void analyse(final EObject o) { this.bind(o); } protected void _bind(final WProgram p) { this.inferredNode(p); EList<WExpression> _elements = p.getElements(); final Procedure1<WExpression> _function = new Procedure1<WExpression>() { public void apply(final WExpression it) { BoundsBasedTypeSystem.this.bind(it); } }; IterableExtensions.<WExpression>forEach(_elements, _function); EList<WExpression> _elements_1 = p.getElements(); WExpression _last = IterableExtensions.<WExpression>last(_elements_1); this.operator_spaceship(p, _last); } protected void _bind(final WClass c) { ClassBasedWollokType _classBasedWollokType = new ClassBasedWollokType(c, null, null); this.fixedNode(_classBasedWollokType, c); Iterable<WVariableDeclaration> _variableDeclarations = WMethodContainerExtensions.variableDeclarations(c); final Procedure1<WVariableDeclaration> _function = new Procedure1<WVariableDeclaration>() { public void apply(final WVariableDeclaration it) { BoundsBasedTypeSystem.this.bind(it); } }; IterableExtensions.<WVariableDeclaration>forEach(_variableDeclarations, _function); Iterable<WMethodDeclaration> _methods = WMethodContainerExtensions.methods(c); final Procedure1<WMethodDeclaration> _function_1 = new Procedure1<WMethodDeclaration>() { public void apply(final WMethodDeclaration it) { BoundsBasedTypeSystem.this.bind(it); } }; IterableExtensions.<WMethodDeclaration>forEach(_methods, _function_1); } protected void _bind(final WBlockExpression e) { this.inferredNode(e); EList<WExpression> _expressions = e.getExpressions(); final Procedure1<WExpression> _function = new Procedure1<WExpression>() { public void apply(final WExpression it) { BoundsBasedTypeSystem.this.bind(it); } }; IterableExtensions.<WExpression>forEach(_expressions, _function); EList<WExpression> _expressions_1 = e.getExpressions(); WExpression _last = IterableExtensions.<WExpression>last(_expressions_1); this.operator_spaceship(e, _last); } protected void _bind(final WVariableDeclaration v) { final Procedure1<ExpectationBuilder> _function = new Procedure1<ExpectationBuilder>() { public void apply(@Extension final ExpectationBuilder b) { WExpression _right = v.getRight(); boolean _notEquals = (!Objects.equal(_right, null)); if (_notEquals) { WExpression _right_1 = v.getRight(); b.operator_greaterEqualsThan(v, _right_1); } } }; this.inferredNode(v, _function); } protected void _bind(final WVariableReference v) { this.inferredNode(v); WReferenciable _ref = v.getRef(); this.operator_spaceship(v, _ref); } protected void _bind(final WAssignment a) { final Procedure1<ExpectationBuilder> _function = new Procedure1<ExpectationBuilder>() { public void apply(@Extension final ExpectationBuilder b) { WVariableReference _feature = a.getFeature(); WExpression _value = a.getValue(); b.operator_greaterEqualsThan(_feature, _value); } }; this.fixedNode(WollokType.WVoid, a, _function); } protected void _bind(final WBinaryOperation op) { String _feature = op.getFeature(); final Pair<? extends List<? extends BasicType>, ? extends BasicType> opType = TypeSystemUtils.typeOfOperation(_feature); BasicType _value = opType.getValue(); final Procedure1<ExpectationBuilder> _function = new Procedure1<ExpectationBuilder>() { public void apply(@Extension final ExpectationBuilder b) { WExpression _leftOperand = op.getLeftOperand(); List<? extends BasicType> _key = opType.getKey(); BasicType _get = _key.get(0); BoundsBasedTypeSystem.this.operator_tripleLessThan(_leftOperand, _get); WExpression _rightOperand = op.getRightOperand(); List<? extends BasicType> _key_1 = opType.getKey(); BasicType _get_1 = _key_1.get(1); BoundsBasedTypeSystem.this.operator_tripleLessThan(_rightOperand, _get_1); WExpression _leftOperand_1 = op.getLeftOperand(); WExpression _rightOperand_1 = op.getRightOperand(); BoundsBasedTypeSystem.this.operator_spaceship(_leftOperand_1, _rightOperand_1); } }; this.fixedNode(_value, op, _function); } protected void _bind(final WIfExpression ef) { final Procedure1<ExpectationBuilder> _function = new Procedure1<ExpectationBuilder>() { public void apply(@Extension final ExpectationBuilder b) { WExpression _condition = ef.getCondition(); BoundsBasedTypeSystem.this.operator_tripleLessThan(_condition, WollokType.WBoolean); WExpression _then = ef.getThen(); BoundsBasedTypeSystem.this.operator_spaceship(ef, _then); WExpression _else = ef.getElse(); BoundsBasedTypeSystem.this.operator_spaceship(ef, _else); } }; this.inferredNode(ef, _function); } protected void _bind(final WMethodDeclaration m) { final Procedure1<ExpectationBuilder> _function = new Procedure1<ExpectationBuilder>() { public void apply(@Extension final ExpectationBuilder b) { boolean _isOverrides = m.isOverrides(); if (_isOverrides) { WMethodDeclaration _overridenMethod = WMethodContainerExtensions.overridenMethod(m); b.operator_greaterEqualsThan(_overridenMethod, m); } WExpression _expression = m.getExpression(); BoundsBasedTypeSystem.this.operator_spaceship(m, _expression); } }; this.inferredNode(m, _function); } protected void _bind(final WParameter p) { this.inferredNode(p); } protected void _bind(final WNullLiteral p) { this.inferredNode(p); } protected void _bind(final WNumberLiteral l) { this.fixedNode(WollokType.WInt, l); } protected void _bind(final WStringLiteral l) { this.fixedNode(WollokType.WString, l); } protected void _bind(final WBooleanLiteral l) { this.fixedNode(WollokType.WBoolean, l); } protected void _bind(final WMemberFeatureCall call) { this.inferredNode(call); WExpression _memberCallTarget = call.getMemberCallTarget(); if ((_memberCallTarget instanceof WThis)) { WMethodDeclaration _method = WollokModelExtensions.method(call); WMethodContainer _declaringContext = WollokModelExtensions.declaringContext(_method); String _feature = call.getFeature(); EList<WExpression> _memberCallArguments = call.getMemberCallArguments(); final WMethodDeclaration referencedMethod = WMethodContainerExtensions.lookupMethod( _declaringContext, _feature, _memberCallArguments); this.operator_spaceship(call, referencedMethod); } } public boolean bindExactlyTo(final TypedNode from, final TypedNode to) { ExactTypeBound _exactTypeBound = new ExactTypeBound(from, to); return this.bounds.add(_exactTypeBound); } public boolean bindAsSuperTypeOf( final TypedNode bindSource, final TypedNode from, final TypedNode to) { SuperTypeBound _superTypeBound = new SuperTypeBound(bindSource, from, to); return this.bounds.add(_superTypeBound); } public boolean bindAsSuperTypeOf(final TypedNode from, final TypedNode to) { SuperTypeBound _superTypeBound = new SuperTypeBound(from, to); return this.bounds.add(_superTypeBound); } public boolean operator_spaceship(final EObject from, final EObject to) { TypedNode _node = this.getNode(from); TypedNode _node_1 = this.getNode(to); return this.bindExactlyTo(_node, _node_1); } public void operator_tripleLessThan(final EObject obj, final WollokType expected) { TypedNode _node = this.getNode(obj); _node.expectType(expected); } public Iterable<TypeBound> getBounds(final TypedNode node) { final Function1<TypeBound, Boolean> _function = new Function1<TypeBound, Boolean>() { public Boolean apply(final TypeBound b) { return Boolean.valueOf(b.isFor(node)); } }; return IterableExtensions.<TypeBound>filter(this.bounds, _function); } public void bind(final EObject a) { if (a instanceof WAssignment) { _bind((WAssignment) a); return; } else if (a instanceof WBinaryOperation) { _bind((WBinaryOperation) a); return; } else if (a instanceof WBlockExpression) { _bind((WBlockExpression) a); return; } else if (a instanceof WBooleanLiteral) { _bind((WBooleanLiteral) a); return; } else if (a instanceof WIfExpression) { _bind((WIfExpression) a); return; } else if (a instanceof WMemberFeatureCall) { _bind((WMemberFeatureCall) a); return; } else if (a instanceof WNullLiteral) { _bind((WNullLiteral) a); return; } else if (a instanceof WNumberLiteral) { _bind((WNumberLiteral) a); return; } else if (a instanceof WParameter) { _bind((WParameter) a); return; } else if (a instanceof WStringLiteral) { _bind((WStringLiteral) a); return; } else if (a instanceof WVariableDeclaration) { _bind((WVariableDeclaration) a); return; } else if (a instanceof WVariableReference) { _bind((WVariableReference) a); return; } else if (a instanceof WClass) { _bind((WClass) a); return; } else if (a instanceof WMethodDeclaration) { _bind((WMethodDeclaration) a); return; } else if (a instanceof WProgram) { _bind((WProgram) a); return; } else { throw new IllegalArgumentException( "Unhandled parameter types: " + Arrays.<Object>asList(a).toString()); } } }
private ArrayList<AbstractRule> copyRuleStubs( final RuleNames names, final Map<RuleWithParameterValues, AbstractRule> origToCopy, final List<AbstractRule> rulesToCopy, final boolean discardTypeRef) { final ArrayList<AbstractRule> result = CollectionLiterals.<AbstractRule>newArrayList(); for (final AbstractRule rule : rulesToCopy) { { String ruleName = names.getAntlrRuleName(rule); boolean _matched = false; if (rule instanceof ParserRule) { _matched = true; List<Parameter> params = ((ParserRule) rule).getParameters(); boolean _isEmpty = params.isEmpty(); if (_isEmpty) { ParserRule copy = this.<ParserRule>copy(((ParserRule) rule)); copy.setName(ruleName); boolean _isFragment = ((ParserRule) rule).isFragment(); copy.setFragment(_isFragment); boolean _isWildcard = ((ParserRule) rule).isWildcard(); copy.setWildcard(_isWildcard); if ((!discardTypeRef)) { TypeRef _type = ((ParserRule) rule).getType(); TypeRef _copyTypeRef = this.copyTypeRef(_type); copy.setType(_copyTypeRef); } this.attachTo(copy, rule, origToCopy); result.add(copy); } else { ImmutableSet<Parameter> _copyOf = ImmutableSet.<Parameter>copyOf(params); Set<Set<Parameter>> _powerSet = Sets.<Parameter>powerSet(_copyOf); final Procedure2<Set<Parameter>, Integer> _function = (Set<Parameter> parameterConfig, Integer i) -> { RuleWithParameterValues parameterValues = new RuleWithParameterValues(rule, parameterConfig); ParserRule copy_1 = this.<ParserRule>copy(((ParserRule) rule)); String _antlrRuleName = names.getAntlrRuleName(rule, (i).intValue()); copy_1.setName(_antlrRuleName); boolean _isFragment_1 = ((ParserRule) rule).isFragment(); copy_1.setFragment(_isFragment_1); boolean _isWildcard_1 = ((ParserRule) rule).isWildcard(); copy_1.setWildcard(_isWildcard_1); if ((!discardTypeRef)) { TypeRef _type_1 = ((ParserRule) rule).getType(); TypeRef _copyTypeRef_1 = this.copyTypeRef(_type_1); copy_1.setType(_copyTypeRef_1); } origToCopy.put(parameterValues, copy_1); parameterValues.attachToEmfObject(copy_1); result.add(copy_1); }; IterableExtensions.<Set<Parameter>>forEach(_powerSet, _function); } } if (!_matched) { if (rule instanceof TerminalRule) { _matched = true; TerminalRule orig = ((TerminalRule) rule); TerminalRule copy = this.<TerminalRule>copy(orig); copy.setName(ruleName); boolean _isFragment = orig.isFragment(); copy.setFragment(_isFragment); this.attachTo(copy, orig, origToCopy); result.add(copy); } } if (!_matched) { if (rule instanceof EnumRule) { _matched = true; EnumRule copy = this.<EnumRule>copy(((EnumRule) rule)); copy.setName(ruleName); this.attachTo(copy, rule, origToCopy); result.add(copy); } } } } return result; }
public EntryPointCodeConcept(final P parent, final String phaseLabel) { super(parent); ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList(); this.phaseLabelList = _newArrayList; this.phaseLabel = phaseLabel; }
public List<Line> apply() { ArrayList<Line> _newArrayList = CollectionLiterals.<Line>newArrayList(); return _newArrayList; }