org.eclipse.xtext.xbase.lib.ListExtensions Java Examples

The following examples show how to use org.eclipse.xtext.xbase.lib.ListExtensions. 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 File: MemberFromSuperImplementor.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public void appendConstructorFromSuper(final XtendClass overrider, final IResolvedConstructor superConstructor, final ISourceAppender appendable) {
  final JvmGenericType inferredType = this.associations.getInferredType(overrider);
  final AbstractConstructorBuilder constructorBuilder = this.codeBuilderFactory.createConstructorBuilder(inferredType);
  this.initializeExecutableBuilder(constructorBuilder, inferredType, superConstructor);
  final Procedure1<ISourceAppender> _function = (ISourceAppender it) -> {
    boolean _isEmpty = superConstructor.getResolvedParameterTypes().isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("super(");
      final Function1<JvmFormalParameter, String> _function_1 = (JvmFormalParameter it_1) -> {
        return it_1.getSimpleName();
      };
      String _join = IterableExtensions.join(ListExtensions.<JvmFormalParameter, String>map(superConstructor.getDeclaration().getParameters(), _function_1), ", ");
      _builder.append(_join);
      _builder.append(")");
      it.append(_builder);
    }
  };
  constructorBuilder.setBodyGenerator(_function);
  boolean _isValid = constructorBuilder.isValid();
  if (_isValid) {
    constructorBuilder.build(appendable);
  }
}
 
Example #2
Source File: ContentAssistFragment2.java    From xtext-core with 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 #3
Source File: ImplicitlyImportedFeatures.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected List<Class<?>> getExtensionClasses() {
	return Lists.<Class<?>> newArrayList(
		ArrayExtensions.class,
		BigDecimalExtensions.class,
		BigIntegerExtensions.class,
		BooleanExtensions.class,
		ByteExtensions.class,
		CharacterExtensions.class,
		CollectionExtensions.class,
		ComparableExtensions.class,
		DoubleExtensions.class,
		FloatExtensions.class,
		FunctionExtensions.class,
		IntegerExtensions.class,
		IterableExtensions.class,
		IteratorExtensions.class,
		ListExtensions.class,
		LongExtensions.class,
		MapExtensions.class,
		ObjectExtensions.class,
		ProcedureExtensions.class,
		ShortExtensions.class,
		StringExtensions.class);
}
 
Example #4
Source File: ResolvedOperationTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testListToArrayHasTwoOrThreeCandidates() {
  final IResolvedOperation operation = this.toOperation("(null as java.util.List<String>).toArray(null)");
  final List<JvmOperation> candidates = operation.getOverriddenAndImplementedMethodCandidates();
  final Function1<JvmOperation, String> _function = (JvmOperation it) -> {
    return it.getIdentifier();
  };
  final String message = IterableExtensions.join(ListExtensions.<JvmOperation, String>map(candidates, _function), ", ");
  try {
    Assert.assertEquals(message, 2, candidates.size());
  } catch (final Throwable _t) {
    if (_t instanceof AssertionError) {
      Assert.assertEquals(message, 3, candidates.size());
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
Example #5
Source File: TemplateNode.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void appendImmediate(Object object, String indentation) {
	List<IGeneratorNode> removed = Lists.<IGeneratorNode>newArrayList();
	for (int i = currentParent.getChildren().size() - 1; i >= 0; i--) {
		IGeneratorNode node = currentParent.getChildren().get(i);
		if (node instanceof TextNode && !TemplateNode.hasContent(((TextNode) node).getText())) {
			removed.add(currentParent.getChildren().remove(i));
		} else {
			if (node instanceof NewLineNode) {
				removed.add(currentParent.getChildren().remove(i));
			} else {
				append(object, indentation);
				ListExtensions.reverse(removed).forEach(it -> append(it, indentation));
				return;
			}
		}
	}
	append(object, indentation);
}
 
Example #6
Source File: InMemoryJavaCompiler.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/");
    final String fileName = (_join + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #7
Source File: AccessorsProcessor.java    From xtext-lib with 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 #8
Source File: CompositeQuickfixTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMultiQuickAssist() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("c {\tbadname { foo {} } }");
  _builder.newLine();
  _builder.append("a {\tbadname { bar {} } }");
  _builder.newLine();
  final IFile resource = this.dslFile(_builder);
  final XtextEditor editor = this.openEditor(resource);
  final ICompletionProposal[] proposals = this.computeQuickAssistProposals(editor, 1);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("Fix Bad Names");
  final Function1<ICompletionProposal, String> _function = (ICompletionProposal it) -> {
    return it.getDisplayString();
  };
  Assert.assertEquals(_builder_1.toString(), IterableExtensions.join(ListExtensions.<ICompletionProposal, String>map(((List<ICompletionProposal>)Conversions.doWrapArray(proposals)), _function), "\n"));
  IterableExtensions.<ICompletionProposal>head(((Iterable<ICompletionProposal>)Conversions.doWrapArray(proposals))).apply(editor.getDocument());
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("newElement { } c {\tgoodname { foo {} } }");
  _builder_2.newLine();
  _builder_2.append("a {\tbadname { bar {} } }");
  _builder_2.newLine();
  Assert.assertEquals(_builder_2.toString(), editor.getDocument().get());
}
 
Example #9
Source File: CompositeQuickfixTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testNoCrossRef() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("fixable_a {\tref fixable_b }");
  _builder.newLine();
  _builder.append("fixable_b {\tref fixable_a }");
  _builder.newLine();
  final IFile resource = this.dslFile(_builder);
  final XtextEditor editor = this.openEditor(resource);
  final ICompletionProposal[] proposals = this.computeQuickAssistProposals(editor, 1);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("rename fixable");
  final Function1<ICompletionProposal, String> _function = (ICompletionProposal it) -> {
    return it.getDisplayString();
  };
  Assert.assertEquals(_builder_1.toString(), IterableExtensions.join(ListExtensions.<ICompletionProposal, String>map(((List<ICompletionProposal>)Conversions.doWrapArray(proposals)), _function), "\n"));
  IterableExtensions.<ICompletionProposal>head(((Iterable<ICompletionProposal>)Conversions.doWrapArray(proposals))).apply(editor.getDocument());
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("fixedName {\tref fixable_b }");
  _builder_2.newLine();
  _builder_2.append("fixable_b {\tref fixable_a }");
  _builder_2.newLine();
  Assert.assertEquals(_builder_2.toString(), editor.getDocument().get());
}
 
Example #10
Source File: ResourceMoveTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void performMove(final IContainer theDestination, final IResource... theResources) {
  try {
    MoveResourcesDescriptor _moveResourcesDescriptor = new MoveResourcesDescriptor();
    final Procedure1<MoveResourcesDescriptor> _function = (MoveResourcesDescriptor it) -> {
      final Function1<IResource, IPath> _function_1 = (IResource it_1) -> {
        return it_1.getFullPath();
      };
      it.setResourcePathsToMove(((IPath[])Conversions.unwrapArray(ListExtensions.<IResource, IPath>map(((List<IResource>)Conversions.doWrapArray(theResources)), _function_1), IPath.class)));
      it.setDestinationPath(theDestination.getFullPath());
    };
    MoveResourcesDescriptor _doubleArrow = ObjectExtensions.<MoveResourcesDescriptor>operator_doubleArrow(_moveResourcesDescriptor, _function);
    this.performRefactoring(_doubleArrow);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #11
Source File: InMemoryJavaCompiler.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/");
    final String fileName = (_join + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #12
Source File: AbstractLanguageServerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected void testFormatting(final Procedure1<? super DocumentFormattingParams> paramsConfigurator, final Procedure1<? super FormattingConfiguration> configurator) {
  try {
    @Extension
    final FormattingConfiguration configuration = new FormattingConfiguration();
    configuration.setFilePath(("MyModel." + this.fileExtension));
    configurator.apply(configuration);
    final FileInfo fileInfo = this.initializeContext(configuration);
    DocumentFormattingParams _documentFormattingParams = new DocumentFormattingParams();
    final Procedure1<DocumentFormattingParams> _function = (DocumentFormattingParams it) -> {
      String _uri = fileInfo.getUri();
      TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(_uri);
      it.setTextDocument(_textDocumentIdentifier);
      if ((paramsConfigurator != null)) {
        paramsConfigurator.apply(it);
      }
    };
    DocumentFormattingParams _doubleArrow = ObjectExtensions.<DocumentFormattingParams>operator_doubleArrow(_documentFormattingParams, _function);
    final CompletableFuture<List<? extends TextEdit>> changes = this.languageServer.formatting(_doubleArrow);
    String _contents = fileInfo.getContents();
    final Document result = new Document(Integer.valueOf(1), _contents).applyChanges(ListExtensions.<TextEdit>reverse(CollectionLiterals.<TextEdit>newArrayList(((TextEdit[])Conversions.unwrapArray(changes.get(), TextEdit.class)))));
    this.assertEqualsStricter(configuration.getExpectedText(), result.getContents());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #13
Source File: EclipseFileSystemSupportImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Iterable<? extends Path> getChildren(final URI uri, final Path path) {
  final IResource resource = this.findMember(uri);
  if ((resource instanceof IContainer)) {
    try {
      final Function1<IResource, Path> _function = (IResource it) -> {
        String _string = it.getFullPath().toString();
        return new Path(_string);
      };
      return ListExtensions.<IResource, Path>map(((List<IResource>)Conversions.doWrapArray(((IContainer)resource).members())), _function);
    } catch (final Throwable _t) {
      if (_t instanceof CoreException) {
        final CoreException exc = (CoreException)_t;
        String _message = exc.getMessage();
        throw new IllegalArgumentException(_message, exc);
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
  return CollectionLiterals.<Path>emptyList();
}
 
Example #14
Source File: EclipseFileSystemSupportImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected java.net.URI toURI(final URI uri, final List<String> trailingSegments) {
  java.net.URI _xblockexpression = null;
  {
    final IResource resource = this.findMember(uri);
    if ((resource == null)) {
      String _lastSegment = uri.lastSegment();
      trailingSegments.add(_lastSegment);
      return this.toURI(uri.trimSegments(1), trailingSegments);
    }
    final Function2<IPath, String, IPath> _function = (IPath $0, String $1) -> {
      return $0.append($1);
    };
    _xblockexpression = URIUtil.toURI(IterableExtensions.<String, IPath>fold(ListExtensions.<String>reverse(trailingSegments), resource.getLocation(), _function));
  }
  return _xblockexpression;
}
 
Example #15
Source File: Movies.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public List<Movie> apply() {
  try {
    final Function1<String, Movie> _function = (String line) -> {
      final Iterator<String> segments = ((List<String>)Conversions.doWrapArray(line.split("  "))).iterator();
      String _next = segments.next();
      int _parseInt = Integer.parseInt(segments.next());
      double _parseDouble = Double.parseDouble(segments.next());
      long _parseLong = Long.parseLong(segments.next());
      Set<String> _set = IteratorExtensions.<String>toSet(segments);
      return new Movie(_next, _parseInt, _parseDouble, _parseLong, _set);
    };
    List<Movie> _map = ListExtensions.<String, Movie>map(CharStreams.readLines(new FileReader("data.csv")), _function);
    return _map;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #16
Source File: ActiveAnnotationsInSameProjectTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public void assertHasErrors(final IFile file, final String msgPart) {
  try {
    final IMarker[] findMarkers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    for (final IMarker iMarker : findMarkers) {
      {
        final String message = MarkerUtilities.getMessage(iMarker);
        if (((MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) && message.contains(msgPart))) {
          return;
        }
      }
    }
    IPath _fullPath = file.getFullPath();
    String _plus = ((("Expected an error marker containing \'" + msgPart) + "\' on ") + _fullPath);
    String _plus_1 = (_plus + " but found ");
    final Function1<IMarker, String> _function = (IMarker it) -> {
      return MarkerUtilities.getMessage(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<IMarker, String>map(((List<IMarker>)Conversions.doWrapArray(findMarkers)), _function), ",");
    String _plus_2 = (_plus_1 + _join);
    Assert.fail(_plus_2);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #17
Source File: Bug456264Test.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testAddError() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("@org.eclipse.xtend.core.tests.macro.Bug456264 class C {}");
  _builder.newLine();
  final IAcceptor<XtendCompilerTester.CompilationResult> _function = (XtendCompilerTester.CompilationResult it) -> {
    final List<? extends Problem> problems = it.getAllProblems();
    final Function1<Problem, String> _function_1 = (Problem it_1) -> {
      return it_1.getMessage();
    };
    Assert.assertEquals(ListExtensions.map(problems, _function_1).toString(), 1, problems.size());
    Assert.assertEquals("My error message", IterableExtensions.head(problems).getMessage());
    final List<? extends Problem> specificProblems = it.getProblems(IterableExtensions.head(it.getCompilationUnit().getSourceTypeDeclarations()));
    Assert.assertEquals(specificProblems.toString(), 1, problems.size());
    Assert.assertEquals("My error message", IterableExtensions.head(specificProblems).getMessage());
  };
  this._xtendCompilerTester.compile(_builder, _function);
}
 
Example #18
Source File: AnnotationWithNestedEnumProcessorTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testBug487559_01() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("import org.eclipse.xtend.core.tests.macro.AnnotationWithNestedEnum");
  _builder.newLine();
  _builder.newLine();
  _builder.append("@org.eclipse.xtend.core.tests.macro.AnnotationWithNestedEnum");
  _builder.newLine();
  _builder.append("class Client {");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final IAcceptor<XtendCompilerTester.CompilationResult> _function = (XtendCompilerTester.CompilationResult it) -> {
    final Function1<Problem, String> _function_1 = (Problem it_1) -> {
      return it_1.getMessage();
    };
    Assert.assertTrue(IterableExtensions.join(ListExtensions.map(it.getAllProblems(), _function_1), ", "), it.getAllProblems().isEmpty());
  };
  this._xtendCompilerTester.compile(_builder, _function);
}
 
Example #19
Source File: SameClassNamesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDuplicateNames_04() {
  try {
    final IJavaProject javaProject = JavaCore.create(this.second);
    final IClasspathEntry[] cp = javaProject.getRawClasspath();
    final List<IClasspathEntry> reversed = ListExtensions.<IClasspathEntry>reverse(((List<IClasspathEntry>)Conversions.doWrapArray(cp)));
    javaProject.setRawClasspath(((IClasspathEntry[])Conversions.unwrapArray(reversed, IClasspathEntry.class)), null);
    IResourcesSetupUtil.reallyWaitForAutoBuild();
    this.testHelper.createFileImpl("first/src/com/acme/A.xtend", "package com.acme class A { new(String s) {} }");
    this.testHelper.createFileImpl("second/src/com/acme/A.xtend", "package com.acme class A { new(int i) {} }");
    this.testHelper.createFileImpl("second/src/com/acme/B.xtend", "package com.acme class B extends A { new() { super(1) } }");
    this.testHelper.createFileImpl("third/src/com/acme/A.xtend", "package com.acme class A {}");
    IResourcesSetupUtil.waitForBuild();
    IResourcesSetupUtil.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #20
Source File: SyntacticSequencerExtensions.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
public List<EqualAmbiguousTransitions> getAllAmbiguousTransitionsBySyntax() {
  if ((this.ambiguousTransitions != null)) {
    return this.ambiguousTransitions;
  }
  final Map<GrammarAlias.AbstractElementAlias, EqualAmbiguousTransitions> result = CollectionLiterals.<GrammarAlias.AbstractElementAlias, EqualAmbiguousTransitions>newHashMap();
  Set<ISyntacticSequencerPDAProvider.ISynTransition> _allAmbiguousTransitions = this.getAllAmbiguousTransitions();
  for (final ISyntacticSequencerPDAProvider.ISynTransition transition : _allAmbiguousTransitions) {
    List<GrammarAlias.AbstractElementAlias> _ambiguousSyntaxes = transition.getAmbiguousSyntaxes();
    for (final GrammarAlias.AbstractElementAlias syntax : _ambiguousSyntaxes) {
      {
        EqualAmbiguousTransitions list = result.get(syntax);
        if ((list == null)) {
          String _elementAliasToIdentifier = this.elementAliasToIdentifier(syntax);
          EqualAmbiguousTransitions _equalAmbiguousTransitions = new EqualAmbiguousTransitions(_elementAliasToIdentifier, syntax);
          list = _equalAmbiguousTransitions;
          result.put(syntax, list);
        }
        list.getTransitions().add(transition);
      }
    }
  }
  this.ambiguousTransitions = CollectionLiterals.<EqualAmbiguousTransitions>newArrayList(((EqualAmbiguousTransitions[])Conversions.unwrapArray(result.values(), EqualAmbiguousTransitions.class)));
  ListExtensions.<EqualAmbiguousTransitions>sortInplace(this.ambiguousTransitions);
  return this.ambiguousTransitions;
}
 
Example #21
Source File: XtendConstructorDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends TypeReference> getExceptions() {
  final Function1<JvmTypeReference, TypeReference> _function = (JvmTypeReference it) -> {
    return this.getCompilationUnit().toTypeReference(it);
  };
  return ListExtensions.<JvmTypeReference, TypeReference>map(this.getDelegate().getExceptions(), _function);
}
 
Example #22
Source File: SyntacticSequencerExtensions.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected String elementAliasToIdentifier(final GrammarAlias.AbstractElementAlias alias) {
  final Set<String> rulesSet = CollectionLiterals.<String>newHashSet();
  final String body = this.elementAliasToIdentifier(alias, rulesSet, false);
  final List<String> rulesList = CollectionLiterals.<String>newArrayList(((String[])Conversions.unwrapArray(rulesSet, String.class)));
  ListExtensions.<String>sortInplace(rulesList);
  final String rule = IterableExtensions.join(rulesList, "_");
  return ((rule + "_") + body);
}
 
Example #23
Source File: ProjectDescriptor.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.15 (changed return value use 'path' of 'SourceFolderDescriptor' to get same result as before)
 */
public Set<SourceFolderDescriptor> getSourceFolders() {
  final Function1<Outlet, SourceFolderDescriptor> _function = (Outlet it) -> {
    String _sourceFolder = this.sourceFolder(it);
    boolean _isTest = this.isTest(it);
    return new SourceFolderDescriptor(_sourceFolder, _isTest);
  };
  return IterableExtensions.<SourceFolderDescriptor>toSet(ListExtensions.<Outlet, SourceFolderDescriptor>map(Collections.<Outlet>unmodifiableList(CollectionLiterals.<Outlet>newArrayList(Outlet.MAIN_JAVA, Outlet.MAIN_RESOURCES, Outlet.MAIN_SRC_GEN, Outlet.MAIN_XTEND_GEN)), _function));
}
 
Example #24
Source File: TypeReferenceImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<TypeReference> getActualTypeArguments() {
  final Function1<LightweightTypeReference, TypeReference> _function = (LightweightTypeReference it) -> {
    return this.getCompilationUnit().toTypeReference(it);
  };
  return ListExtensions.<LightweightTypeReference, TypeReference>map(this.getDelegate().getTypeArguments(), _function);
}
 
Example #25
Source File: XtendInterfaceDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends TypeReference> getExtendedInterfaces() {
  final Function1<JvmTypeReference, TypeReference> _function = (JvmTypeReference it) -> {
    return this.getCompilationUnit().toTypeReference(it);
  };
  return ListExtensions.<JvmTypeReference, TypeReference>map(this.getDelegate().getExtends(), _function);
}
 
Example #26
Source File: JvmMethodDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends MethodDeclaration> getOverriddenOrImplementedMethods() {
  final ResolvedFeatures resolvedFeatures = this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(this.getDelegate().getDeclaringType());
  final IResolvedOperation resolvedOperation = resolvedFeatures.getResolvedOperation(this.getDelegate());
  final List<IResolvedOperation> overriddenOrImplemented = resolvedOperation.getOverriddenAndImplementedMethods();
  final Function1<IResolvedOperation, MemberDeclaration> _function = (IResolvedOperation it) -> {
    return this.getCompilationUnit().toMemberDeclaration(it.getDeclaration());
  };
  return Iterables.<MethodDeclaration>filter(ListExtensions.<IResolvedOperation, MemberDeclaration>map(overriddenOrImplemented, _function), MethodDeclaration.class);
}
 
Example #27
Source File: XtendClassDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends TypeReference> getImplementedInterfaces() {
  final Function1<JvmTypeReference, TypeReference> _function = (JvmTypeReference it) -> {
    return this.getCompilationUnit().toTypeReference(it);
  };
  return ListExtensions.<JvmTypeReference, TypeReference>map(this.getDelegate().getImplements(), _function);
}
 
Example #28
Source File: TypeUsageCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private void hasUnresolvedType(final Resource resource, final String... typeNames) {
  final TypeUsages typeUsages = this.typeUsageCollector.collectTypeUsages(((XtextResource) resource));
  final Function1<TypeUsage, String> _function = (TypeUsage it) -> {
    return it.getUsedTypeName();
  };
  final Set<String> usedNames = IterableExtensions.<String>toSet(ListExtensions.<TypeUsage, String>map(typeUsages.getUnresolvedTypeUsages(), _function));
  Assert.assertEquals(IterableExtensions.<String>toSet(((Iterable<String>)Conversions.doWrapArray(typeNames))), usedNames);
}
 
Example #29
Source File: TypeUsageCollectorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private void hasUnresolvedTypeSuffix(final CharSequence xtendFile, final String... suffix) {
  try {
    final Resource resource = this.file(xtendFile.toString()).eResource();
    final TypeUsages typeUsages = this.typeUsageCollector.collectTypeUsages(((XtextResource) resource));
    final Function1<TypeUsage, String> _function = (TypeUsage it) -> {
      return it.getSuffix();
    };
    final Set<String> foundSuffix = IterableExtensions.<String>toSet(ListExtensions.<TypeUsage, String>map(typeUsages.getUnresolvedTypeUsages(), _function));
    Assert.assertEquals(IterableExtensions.<String>toSet(((Iterable<String>)Conversions.doWrapArray(suffix))), foundSuffix);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #30
Source File: XtendMethodDeclarationImpl.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends ParameterDeclaration> getParameters() {
  final Function1<XtendParameter, XtendParameterDeclarationImpl> _function = (XtendParameter it) -> {
    return this.getCompilationUnit().toXtendParameterDeclaration(it);
  };
  return ListExtensions.<XtendParameter, XtendParameterDeclarationImpl>map(this.getDelegate().getParameters(), _function);
}