Java Code Examples for org.eclipse.xtext.xbase.lib.CollectionLiterals

The following examples show how to use org.eclipse.xtext.xbase.lib.CollectionLiterals. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lsp4j   Source File: TypeAdapterImplProcessor.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private ArrayList<FieldDeclaration> getTargetFields(final TypeReference targetType, @Extension final TransformationContext context) {
  final Type objectType = context.newTypeReference(Object.class).getType();
  final ArrayList<FieldDeclaration> targetFields = CollectionLiterals.<FieldDeclaration>newArrayList();
  TypeReference typeRef = targetType;
  while ((!Objects.equal(typeRef.getType(), objectType))) {
    {
      Type _type = typeRef.getType();
      final ClassDeclaration clazz = ((ClassDeclaration) _type);
      final Function1<FieldDeclaration, Boolean> _function = (FieldDeclaration it) -> {
        boolean _isStatic = it.isStatic();
        return Boolean.valueOf((!_isStatic));
      };
      Iterable<? extends FieldDeclaration> _filter = IterableExtensions.filter(clazz.getDeclaredFields(), _function);
      Iterables.<FieldDeclaration>addAll(targetFields, _filter);
      typeRef = clazz.getExtendedClass();
    }
  }
  return targetFields;
}
 
Example 2
Source Project: xtext-core   Source File: DocumentTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testUpdate_01() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("hello world");
  _builder.newLine();
  _builder.append("foo");
  _builder.newLine();
  _builder.append("bar");
  _builder.newLine();
  String _normalize = this.normalize(_builder);
  Document _document = new Document(Integer.valueOf(1), _normalize);
  final Procedure1<Document> _function = (Document it) -> {
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("hello world");
    _builder_1.newLine();
    _builder_1.append("bar");
    _builder_1.newLine();
    TextDocumentContentChangeEvent _change = this.change(this.position(1, 0), this.position(2, 0), "");
    Assert.assertEquals(this.normalize(_builder_1), it.applyTextDocumentChanges(
      Collections.<TextDocumentContentChangeEvent>unmodifiableList(CollectionLiterals.<TextDocumentContentChangeEvent>newArrayList(_change))).getContents());
  };
  ObjectExtensions.<Document>operator_doubleArrow(_document, _function);
}
 
Example 3
@Override
public Iterable<? extends AbstractFile> getFiles() {
  final ArrayList<AbstractFile> files = CollectionLiterals.<AbstractFile>newArrayList();
  Iterable<? extends AbstractFile> _files = super.getFiles();
  Iterables.<AbstractFile>addAll(files, _files);
  PlainTextFile _grammarFile = this.getGrammarFile();
  files.add(_grammarFile);
  PlainTextFile _file = this.file(Outlet.MAIN_JAVA, this.getWorkflowFilePath(), this.workflow());
  files.add(_file);
  PlainTextFile _workflowLaunchConfigFile = this.getWorkflowLaunchConfigFile();
  files.add(_workflowLaunchConfigFile);
  boolean _isEclipsePluginProject = this.getConfig().getRuntimeProject().isEclipsePluginProject();
  if (_isEclipsePluginProject) {
    PlainTextFile _launchConfigFile = this.getLaunchConfigFile();
    files.add(_launchConfigFile);
  }
  boolean _isPlainMavenBuild = this.isPlainMavenBuild();
  if (_isPlainMavenBuild) {
    PlainTextFile _file_1 = this.file(Outlet.ROOT, "jar-with-ecore-model.xml", this.jarDescriptor());
    files.add(_file_1);
  }
  return files;
}
 
Example 4
Source Project: xtext-extras   Source File: HiddenLeafAccess.java    License: Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source Project: xtext-core   Source File: ContentAssistFragment2.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public Set<String> getFQFeatureNamesToExclude(final Grammar g) {
  Set<String> _xifexpression = null;
  Grammar _nonTerminalsSuperGrammar = GrammarUtil2.getNonTerminalsSuperGrammar(g);
  boolean _tripleNotEquals = (_nonTerminalsSuperGrammar != null);
  if (_tripleNotEquals) {
    Sets.SetView<String> _xblockexpression = null;
    {
      final Set<String> thisGrammarFqFeatureNames = IterableExtensions.<String>toSet(this.computeFQFeatureNames(g));
      final Function1<Grammar, Iterable<String>> _function = (Grammar it) -> {
        return this.computeFQFeatureNames(it);
      };
      final Set<String> superGrammarsFqFeatureNames = IterableExtensions.<String>toSet(Iterables.<String>concat(ListExtensions.<Grammar, Iterable<String>>map(GrammarUtil.allUsedGrammars(g), _function)));
      _xblockexpression = Sets.<String>intersection(thisGrammarFqFeatureNames, superGrammarsFqFeatureNames);
    }
    _xifexpression = _xblockexpression;
  } else {
    _xifexpression = CollectionLiterals.<String>emptySet();
  }
  return _xifexpression;
}
 
Example 6
Source Project: xtext-xtend   Source File: Solution_021.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public static void main(final String[] args) {
  HashSet<Integer> result = CollectionLiterals.<Integer>newHashSet();
  final int max = 10000;
  IntegerRange _upTo = new IntegerRange(1, max);
  for (final Integer i : _upTo) {
    boolean _contains = result.contains(i);
    boolean _not = (!_contains);
    if (_not) {
      final Integer sumOfDivisors = Solution_021.sumOfDivisors((i).intValue());
      if (((!Objects.equal(sumOfDivisors, i)) && ((sumOfDivisors).intValue() <= max))) {
        final Integer otherSumOfDivisors = Solution_021.sumOfDivisors((sumOfDivisors).intValue());
        boolean _equals = Objects.equal(otherSumOfDivisors, i);
        if (_equals) {
          result.add(i);
          result.add(sumOfDivisors);
        }
      }
    }
  }
  final Function2<Integer, Integer, Integer> _function = (Integer i1, Integer i2) -> {
    return Integer.valueOf(((i1).intValue() + (i2).intValue()));
  };
  InputOutput.<Integer>println(IterableExtensions.<Integer>reduce(result, _function));
}
 
Example 7
/**
 * Construct a Classloader with the classpathentries from the provided and all upstream-projects,
 * except the output folders of the local project.
 */
protected URLClassLoader createClassLoaderForJavaProject(final IJavaProject projectToUse) {
  final LinkedHashSet<URL> urls = CollectionLiterals.<URL>newLinkedHashSet();
  try {
    this.collectClasspathURLs(projectToUse, urls, this.isOutputFolderIncluded(), CollectionLiterals.<IJavaProject>newHashSet());
  } catch (final Throwable _t) {
    if (_t instanceof JavaModelException) {
      final JavaModelException e = (JavaModelException)_t;
      boolean _isDoesNotExist = e.isDoesNotExist();
      boolean _not = (!_isDoesNotExist);
      if (_not) {
        JdtBasedProcessorProvider.LOG.error(e.getMessage(), e);
      }
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
  ClassLoader _parentClassLoader = this.getParentClassLoader();
  return new URLClassLoader(((URL[])Conversions.unwrapArray(urls, URL.class)), _parentClassLoader);
}
 
Example 8
public Map<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>> getGrammarConstraints(final Grammar grammar, final EClass clazz) {
  final Map<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>> result = CollectionLiterals.<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>>newLinkedHashMap();
  final SerializationContextMap<IGrammarConstraintProvider.IConstraint> constraints = this.gcp.getConstraints(grammar);
  List<SerializationContextMap.Entry<IGrammarConstraintProvider.IConstraint>> _values = constraints.values();
  for (final SerializationContextMap.Entry<IGrammarConstraintProvider.IConstraint> e : _values) {
    {
      final IGrammarConstraintProvider.IConstraint constraint = e.getValue();
      EClass _type = constraint.getType();
      boolean _tripleEquals = (_type == clazz);
      if (_tripleEquals) {
        List<ISerializationContext> contexts = result.get(constraint);
        if ((contexts == null)) {
          contexts = CollectionLiterals.<ISerializationContext>newArrayList();
          result.put(constraint, contexts);
        }
        contexts.addAll(e.getContexts(clazz));
      }
    }
  }
  return result;
}
 
Example 9
Source Project: xtext-core   Source File: IncrementalBuilderTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@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"));
}
 
Example 10
@Test
public void simple() {
  final TraceRegionToStringTester tester = new TraceRegionToStringTester();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("foo bar");
  _builder.newLine();
  tester.setLocalText(_builder.toString());
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("baz buz");
  _builder_1.newLine();
  tester.setRemote1(_builder_1.toString());
  SourceRelativeURI _uri1 = tester.getUri1();
  TraceRegionToStringTester.Location _location = new TraceRegionToStringTester.Location(4, 2, _uri1);
  TraceRegionToStringTester.Region _region = new TraceRegionToStringTester.Region(1, 2, Collections.<ILocationData>unmodifiableList(CollectionLiterals.<ILocationData>newArrayList(_location)));
  tester.setTrace(_region);
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("-- local1 --- | -- remote1 --");
  _builder_2.newLine();
  _builder_2.append("f[1[oo]1] bar | baz [1[bu]1]z");
  _builder_2.newLine();
  _builder_2.append("-----------------------------");
  _builder_2.newLine();
  _builder_2.append("1: D 1-2 Region -> Location[4,2,remote1]");
  _builder_2.newLine();
  this.operator_tripleEquals(tester, _builder_2);
}
 
Example 11
Source Project: xtext-lib   Source File: AccessorsProcessor.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public List<String> getPossibleGetterNames(final FieldDeclaration it) {
  final ArrayList<String> names = CollectionLiterals.<String>newArrayList();
  if ((((this.isBooleanType(this.orObject(it.getType())) && it.getSimpleName().startsWith("is")) && (it.getSimpleName().length() > 2)) && Character.isUpperCase(it.getSimpleName().charAt(2)))) {
    String _simpleName = it.getSimpleName();
    names.add(_simpleName);
  }
  List<String> _xifexpression = null;
  boolean _isBooleanType = this.isBooleanType(this.orObject(it.getType()));
  if (_isBooleanType) {
    _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("is", "get"));
  } else {
    _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("get"));
  }
  final Function1<String, String> _function = (String prefix) -> {
    String _firstUpper = StringExtensions.toFirstUpper(it.getSimpleName());
    return (prefix + _firstUpper);
  };
  names.addAll(ListExtensions.<String, String>map(_xifexpression, _function));
  return names;
}
 
Example 12
Source Project: xtext-eclipse   Source File: ContentAssistTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPropertyTemplateProposal() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("entity E {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append(this.c, "\t");
  _builder.newLineIfNotEmpty();
  _builder.append("}");
  _builder.newLine();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("entity E {");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("propertyName : typeName");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  this.testContentAssistant(_builder, 
    Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("Operation - template for an Operation", "Property - template for a Property", "op")), "Property - template for a Property", _builder_1.toString());
}
 
Example 13
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 = (EClass c) -> {
      return Boolean.valueOf(Ecore2XtextExtensions.needsConcreteRule(c));
    };
    list = IterableExtensions.<EClass>filter(list, _function);
    final Function1<EClass, String> _function_1 = (EClass it) -> {
      return Ecore2XtextExtensions.concreteRuleName(it);
    };
    _xblockexpression = IterableExtensions.join(IterableExtensions.<EClass, String>map(list, _function_1), " | ");
  }
  return _xblockexpression;
}
 
Example 14
Source Project: xtext-eclipse   Source File: Xbase08_Loops.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public ArrayList<String> myMethod() throws Throwable {
  ArrayList<String> _xblockexpression = null;
  {
    final ArrayList<String> list = CollectionLiterals.<String>newArrayList("foo", "bar", "baz");
    final ArrayList<String> result = new ArrayList<String>();
    List<String> _reverse = ListExtensions.<String>reverse(list);
    for (final String x : _reverse) {
      String _upperCase = x.toUpperCase();
      result.add(_upperCase);
    }
    /* result; */
    int i = 0;
    while ((i < list.size())) {
      {
        String _get = list.get(i);
        String _plus = ("whiled-" + _get);
        result.add(_plus);
        i = (i + 1);
      }
    }
    _xblockexpression = result;
  }
  return _xblockexpression;
}
 
Example 15
Source Project: xtext-core   Source File: IndexOnlyProjectTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Shows that the resource is not validated during incremental build
 */
@Test
public void testIncrementalBuildNoValidation() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("type Test {");
  _builder.newLine();
  _builder.append("    ");
  _builder.append("NonExisting foo");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.writeFile("MyType1.testlang", _builder);
  this.initialize();
  Assert.assertTrue(IterableExtensions.join(this.getDiagnostics().entrySet(), ","), this.getDiagnostics().isEmpty());
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("type NonExisting {");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  final String path = this.writeFile("MyType2.testlang", _builder_1);
  WorkspaceService _workspaceService = this.languageServer.getWorkspaceService();
  FileEvent _fileEvent = new FileEvent(path, FileChangeType.Created);
  DidChangeWatchedFilesParams _didChangeWatchedFilesParams = new DidChangeWatchedFilesParams(Collections.<FileEvent>unmodifiableList(CollectionLiterals.<FileEvent>newArrayList(_fileEvent)));
  _workspaceService.didChangeWatchedFiles(_didChangeWatchedFilesParams);
  Assert.assertTrue(IterableExtensions.join(this.getDiagnostics().entrySet(), ","), this.getDiagnostics().isEmpty());
}
 
Example 16
@Override
public Set<String> getDevelopmentBundles() {
  final LinkedHashSet<String> result = CollectionLiterals.<String>newLinkedHashSet(
    "org.eclipse.xtext.xbase", 
    "org.eclipse.xtext.common.types", 
    "org.eclipse.xtext.xtext.generator", 
    "org.eclipse.emf.codegen.ecore", 
    "org.eclipse.emf.mwe.utils", 
    "org.eclipse.emf.mwe2.launch", 
    "org.eclipse.emf.mwe2.lib", 
    "org.objectweb.asm", 
    "org.apache.commons.logging", 
    "org.apache.log4j");
  boolean _isFromExistingEcoreModels = this.isFromExistingEcoreModels();
  if (_isFromExistingEcoreModels) {
    final Function1<EPackageInfo, Boolean> _function = (EPackageInfo it) -> {
      String _fileExtension = it.getGenmodelURI().fileExtension();
      return Boolean.valueOf(Objects.equal(_fileExtension, "xcore"));
    };
    boolean _exists = IterableExtensions.<EPackageInfo>exists(this.getConfig().getEcore2Xtext().getEPackageInfos(), _function);
    if (_exists) {
      result.add("org.eclipse.emf.ecore.xcore");
    }
  }
  return result;
}
 
Example 17
Source Project: xtext-xtend   Source File: MethodBuilderTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testXtendExceptions() {
  AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
  final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
    it.setContext(this.getXtendClass());
    it.setMethodName("foo");
    LightweightTypeReference _createTypeRef = this.createTypeRef(Exception.class, this.getXtendClass());
    LightweightTypeReference _createTypeRef_1 = this.createTypeRef(RuntimeException.class, this.getXtendClass());
    it.setExceptions(Collections.<LightweightTypeReference>unmodifiableList(CollectionLiterals.<LightweightTypeReference>newArrayList(_createTypeRef, _createTypeRef_1)));
  };
  AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("def foo() throws Exception, RuntimeException {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append(AbstractBuilderTest.DEFAULT_BODY, "  ");
  _builder.newLineIfNotEmpty();
  _builder.append("}");
  this.assertBuilds(_doubleArrow, _builder.toString());
}
 
Example 18
Source Project: xtext-xtend   Source File: ASTFlattenerUtils.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private Iterable<StringLiteral> collectCompatibleNodes(final InfixExpression node) {
  final ArrayList<StringLiteral> strings = CollectionLiterals.<StringLiteral>newArrayList();
  InfixExpression.Operator _operator = node.getOperator();
  boolean _notEquals = (!Objects.equal(_operator, InfixExpression.Operator.PLUS));
  if (_notEquals) {
    return strings;
  }
  final Expression left = node.getLeftOperand();
  if ((left instanceof StringLiteral)) {
    strings.add(((StringLiteral)left));
  } else {
    if ((left instanceof InfixExpression)) {
      Iterables.<StringLiteral>addAll(strings, this.collectCompatibleNodes(((InfixExpression)left)));
    }
  }
  final Expression right = node.getRightOperand();
  if ((right instanceof StringLiteral)) {
    strings.add(((StringLiteral)right));
  } else {
    if ((right instanceof InfixExpression)) {
      Iterables.<StringLiteral>addAll(strings, this.collectCompatibleNodes(((InfixExpression)right)));
    }
  }
  Iterables.<StringLiteral>addAll(strings, Iterables.<StringLiteral>filter(node.extendedOperands(), StringLiteral.class));
  return strings;
}
 
Example 19
@Override
public void assertProcessing(final Pair<String, String> macroFile, final Pair<String, String> clientFile, final Procedure1<? super CompilationUnitImpl> expectations) {
  try {
    final XtextResourceSet resourceSet = this.compileMacroResourceSet(macroFile, clientFile);
    final Resource singleResource = IterableExtensions.<Resource>head(resourceSet.getResources());
    singleResource.load(CollectionLiterals.<Object, Object>emptyMap());
    final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
      it.getGeneratedCode();
      final CompilationUnitImpl unit = this.compilationUnitProvider.get();
      final XtendFile xtendFile = IterableExtensions.<XtendFile>head(Iterables.<XtendFile>filter(singleResource.getContents(), XtendFile.class));
      unit.setXtendFile(xtendFile);
      expectations.apply(unit);
    };
    this.compiler.compile(resourceSet, _function);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 20
Source Project: sarl   Source File: SARLValidator.java    License: Apache License 2.0 5 votes vote down vote up
private void checkRedundantInterfaces(
		XtendTypeDeclaration element,
		EReference structuralElement,
		Iterable<? extends JvmTypeReference> interfaces,
		Iterable<? extends JvmTypeReference> superTypes) {
	final List<LightweightTypeReference> knownInterfaces = CollectionLiterals.newArrayList();
	for (final JvmTypeReference interfaceRef : interfaces) {
		final LightweightTypeReference lightweightInterfaceReference = toLightweightTypeReference(interfaceRef);
		// Detect if an interface is specified two types for the same type.
		if (!checkRedundantInterfaceInSameType(
				element, structuralElement,
				lightweightInterfaceReference,
				knownInterfaces)) {
			// Check the interface against the super-types
			if (superTypes != null && !isIgnored(REDUNDANT_INTERFACE_IMPLEMENTATION, element)) {
				for (final JvmTypeReference superType : superTypes) {
					final LightweightTypeReference lightweightSuperType = toLightweightTypeReference(superType);
					if (memberOfTypeHierarchy(lightweightSuperType, lightweightInterfaceReference)) {
						addIssue(MessageFormat.format(
								Messages.SARLValidator_52,
								canonicalName(lightweightInterfaceReference),
								canonicalName(lightweightSuperType)),
								element,
								structuralElement,
								// The index of the element to highlight in the super-types
								knownInterfaces.size(),
								REDUNDANT_INTERFACE_IMPLEMENTATION,
								canonicalName(lightweightInterfaceReference),
								"unknow"); //$NON-NLS-1$
					}
				}
			}
		}
		// Prepare next loop
		knownInterfaces.add(lightweightInterfaceReference);
	}
}
 
Example 21
@Test
public void testResourcesAreInMap_02() {
  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.getResources().remove(resource);
  Assert.assertTrue(resource.eAdapters().isEmpty());
  Assert.assertEquals(0, rs.getURIResourceMap().size());
}
 
Example 22
Source Project: xtext-core   Source File: SerializerFragment2.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static <K extends Object, V extends Object> Map<K, V> toMap(final Iterable<Pair<K, V>> items) {
  LinkedHashMap<K, V> _xblockexpression = null;
  {
    final LinkedHashMap<K, V> result = CollectionLiterals.<K, V>newLinkedHashMap();
    for (final Pair<K, V> i : items) {
      result.put(i.getKey(), i.getValue());
    }
    _xblockexpression = result;
  }
  return _xblockexpression;
}
 
Example 23
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
  RefactoringTestParameters _refactoringTestParameters = new RefactoringTestParameters();
  final Procedure1<RefactoringTestParameters> _function = (RefactoringTestParameters it) -> {
    it.setUseInlineRefactoring(true);
    it.setUsePreview(false);
  };
  RefactoringTestParameters _doubleArrow = ObjectExtensions.<RefactoringTestParameters>operator_doubleArrow(_refactoringTestParameters, _function);
  return Collections.<Object[]>unmodifiableList(CollectionLiterals.<Object[]>newArrayList(new Object[] { _doubleArrow }));
}
 
Example 24
protected ISourceAppender appendParameters(final ISourceAppender appendable) {
  ISourceAppender _xblockexpression = null;
  {
    appendable.append("(");
    final HashSet<String> notAllowed = CollectionLiterals.<String>newHashSet();
    boolean _isEmpty = this.parameterBuilders.isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
      AbstractParameterBuilder _last = IterableExtensions.<AbstractParameterBuilder>last(this.parameterBuilders);
      _last.setVarArgsFlag(this.varArgsFlag);
    }
    int _size = this.parameterBuilders.size();
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true);
    for (final Integer i : _doubleDotLessThan) {
      {
        final AbstractParameterBuilder parameterBuilder = this.parameterBuilders.get((i).intValue());
        final VariableNameAcceptor acceptor = new VariableNameAcceptor(notAllowed);
        String _name = parameterBuilder.getName();
        boolean _tripleEquals = (_name == null);
        if (_tripleEquals) {
          this._jdtVariableCompletions.getVariableProposals(parameterBuilder.getType().getIdentifier(), this.getContext(), 
            JdtVariableCompletions.VariableType.PARAMETER, notAllowed, acceptor);
          parameterBuilder.setName(acceptor.getVariableName());
        }
        parameterBuilder.build(appendable);
        int _size_1 = this.parameterBuilders.size();
        int _minus = (_size_1 - 1);
        boolean _notEquals = ((i).intValue() != _minus);
        if (_notEquals) {
          appendable.append(", ");
        }
      }
    }
    _xblockexpression = appendable.append(")");
  }
  return _xblockexpression;
}
 
Example 25
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
  RefactoringTestParameters _refactoringTestParameters = new RefactoringTestParameters();
  final Procedure1<RefactoringTestParameters> _function = (RefactoringTestParameters it) -> {
    it.setUseInlineRefactoring(false);
    it.setUsePreview(false);
  };
  RefactoringTestParameters _doubleArrow = ObjectExtensions.<RefactoringTestParameters>operator_doubleArrow(_refactoringTestParameters, _function);
  return Collections.<Object[]>unmodifiableList(CollectionLiterals.<Object[]>newArrayList(new Object[] { _doubleArrow }));
}
 
Example 26
Source Project: xtext-extras   Source File: JvmModelGenerator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
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));
  if (((adapter != null) && (!StringExtensions.isNullOrEmpty(adapter.getDocumentation())))) {
    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);
    }
  }
}
 
Example 27
Source Project: xtext-extras   Source File: HiddenLeafAccess.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected List<ILeafNode> findPreviousHiddenLeafs(final INode node) {
  List<ILeafNode> _xblockexpression = null;
  {
    INode current = node;
    while ((current instanceof ICompositeNode)) {
      current = ((ICompositeNode)current).getLastChild();
    }
    final ArrayList<ILeafNode> result = CollectionLiterals.<ILeafNode>newArrayList();
    if ((current != null)) {
      final NodeIterator ni = new NodeIterator(current);
      while (ni.hasPrevious()) {
        {
          final INode previous = ni.previous();
          if (((!Objects.equal(previous, current)) && (previous instanceof ILeafNode))) {
            boolean _isHidden = ((ILeafNode) previous).isHidden();
            if (_isHidden) {
              result.add(((ILeafNode) previous));
            } else {
              return ListExtensions.<ILeafNode>reverse(result);
            }
          }
        }
      }
    }
    _xblockexpression = ListExtensions.<ILeafNode>reverse(result);
  }
  return _xblockexpression;
}
 
Example 28
Source Project: xtext-core   Source File: Ecore2XtextExtensions.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static Iterable<EClass> subClasses(final EClass it) {
  Iterable<EClass> _xifexpression = null;
  EPackage _ePackage = it.getEPackage();
  boolean _tripleEquals = (_ePackage == null);
  if (_tripleEquals) {
    _xifexpression = CollectionLiterals.<EClass>emptyList();
  } else {
    final Function1<EClass, Boolean> _function = (EClass c) -> {
      return Boolean.valueOf(c.getEAllSuperTypes().contains(it));
    };
    _xifexpression = IterableExtensions.<EClass>filter(Iterables.<EClass>filter(it.getEPackage().getEClassifiers(), EClass.class), _function);
  }
  return _xifexpression;
}
 
Example 29
@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")));
  }
}
 
Example 30
Source Project: xtext-xtend   Source File: Solution_015.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public Solution_015(final int gridSize) {
  this.internalGridSize = (gridSize + 1);
  this.numberOfNodes = (this.internalGridSize * this.internalGridSize);
  this.solutions = CollectionLiterals.<Long>newArrayList();
  final Consumer<Integer> _function = (Integer it) -> {
    this.solutions.add(Long.valueOf((-1L)));
  };
  new IntegerRange(0, (this.numberOfNodes - 2)).forEach(_function);
  this.solutions.add(Long.valueOf(1L));
}