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

The following examples show how to use org.eclipse.xtext.xbase.lib.CollectionLiterals. 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: IndexOnlyProjectTest.java    From xtext-core with 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 #2
Source File: RuntimeProjectDescriptor.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 #3
Source File: DocumentTest.java    From xtext-core with 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 #4
Source File: ActiveAnnotationsRuntimeTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #5
Source File: ASTFlattenerUtils.java    From xtext-xtend with 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 #6
Source File: TypeAdapterImplProcessor.java    From lsp4j with 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 #7
Source File: HiddenLeafAccess.java    From xtext-extras with 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 #8
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 #9
Source File: Solution_021.java    From xtext-xtend with 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 #10
Source File: JdtBasedProcessorProvider.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #11
Source File: SemanticSequencerExtensions.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
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 #12
Source File: IncrementalBuilderTest.java    From xtext-core with 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 #13
Source File: TraceRegionToStringTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 #14
Source File: MethodBuilderTest.java    From xtext-xtend with 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 #15
Source File: RuntimeProjectDescriptor.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 #16
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 #17
Source File: ContentAssistTest.java    From xtext-eclipse with 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 #18
Source File: Ecore2XtextGrammarCreator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
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 #19
Source File: Xbase08_Loops.java    From xtext-eclipse with 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 #20
Source File: NamedSerializationContextProvider.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public NamedSerializationContextProvider(final Grammar grammar) {
  final Function1<Pair<Integer, ParserRule>, Pair<ParserRule, Integer>> _function = (Pair<Integer, ParserRule> it) -> {
    ParserRule _value = it.getValue();
    Integer _key = it.getKey();
    return Pair.<ParserRule, Integer>of(_value, _key);
  };
  this.rules = CollectionLiterals.<ParserRule, Integer>newHashMap(((Pair<? extends ParserRule, ? extends Integer>[])Conversions.unwrapArray(IterableExtensions.<Pair<Integer, ParserRule>, Pair<ParserRule, Integer>>map(IterableExtensions.<ParserRule>indexed(GrammarUtil.allParserRules(grammar)), _function), Pair.class)));
}
 
Example #21
Source File: TestProjectDescriptor.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
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.TEST_JAVA, Outlet.TEST_RESOURCES, Outlet.TEST_SRC_GEN, Outlet.TEST_XTEND_GEN)), _function));
}
 
Example #22
Source File: CommonSuperTypeTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testCommonSuperType_23() {
  try {
    this.function("def void m() {}");
    ITypeReferenceOwner _owner = this.getOwner();
    AnyTypeReference _anyTypeReference = new AnyTypeReference(_owner);
    ITypeReferenceOwner _owner_1 = this.getOwner();
    AnyTypeReference _anyTypeReference_1 = new AnyTypeReference(_owner_1);
    final List<LightweightTypeReference> types = CollectionLiterals.<LightweightTypeReference>newImmutableList(_anyTypeReference, _anyTypeReference_1);
    final LightweightTypeReference superType = this.getServices().getTypeConformanceComputer().getCommonSuperType(types, this.getOwner());
    Assert.assertEquals("null", superType.getSimpleName());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #23
Source File: SameClassNamesTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void createProjects() {
  try {
    this.first = this.createPluginProject("first", ((String[])Conversions.unwrapArray(WorkbenchTestHelper.DEFAULT_REQ_BUNDLES, String.class)));
    Iterable<String> _plus = Iterables.<String>concat(WorkbenchTestHelper.DEFAULT_REQ_BUNDLES, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("first")));
    this.second = this.createPluginProject("second", ((String[])Conversions.unwrapArray(_plus, String.class)));
    this.third = this.createPluginProject("third", ((String[])Conversions.unwrapArray(WorkbenchTestHelper.DEFAULT_REQ_BUNDLES, String.class)));
    IResourcesSetupUtil.reallyWaitForAutoBuild();
    this.testHelper.closeWelcomePage();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #24
Source File: SARLValidator.java    From sarl with 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 #25
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPersistedWithOtherResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile1." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    String _primaryFileExtension_1 = this._fileExtensionProvider.getPrimaryFileExtension();
    String _plus = ("MyProject/myfile2." + _primaryFileExtension_1);
    final Resource resource = rs.createResource(URI.createPlatformResourceURI(_plus, true));
    StringInputStream _stringInputStream = new StringInputStream("stuff bar");
    resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile1.testlanguage exported=[foo]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile2.testlanguage exported=[bar]");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String expected = _builder.toString();
    Assert.assertEquals(expected, this.formatContainers(rs));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #26
Source File: Case_7.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public Map.Entry<String, List<String>> bug345449() {
  Map.Entry<String, List<String>> _xblockexpression = null;
  {
    final ArrayList<Map.Entry<String, List<String>>> result = CollectionLiterals.<Map.Entry<String, List<String>>>newArrayList();
    Map.Entry<String, List<String>> _head = null;
    if (result!=null) {
      _head=IterableExtensions.<Map.Entry<String, List<String>>>head(result);
    }
    _xblockexpression = _head;
  }
  return _xblockexpression;
}
 
Example #27
Source File: ProjectDescriptor.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public Set<ExternalDependency> getExternalDependencies() {
  final LinkedHashSet<ExternalDependency> deps = CollectionLiterals.<ExternalDependency>newLinkedHashSet();
  Set<EPackageInfo> _ePackageInfos = this.config.getEcore2Xtext().getEPackageInfos();
  for (final EPackageInfo ePackage : _ePackageInfos) {
    ExternalDependency _createBundleDependency = ExternalDependency.createBundleDependency(ePackage.getBundleID());
    deps.add(_createBundleDependency);
  }
  return deps;
}
 
Example #28
Source File: FjFirstTypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected Result<List<Field>> applyRuleFields(final RuleEnvironment G, final RuleApplicationTrace _trace_, final org.eclipse.xsemantics.example.fj.fj.Class cl) throws RuleFailedException {
  List<Field> fields = null; // output parameter
  final List<org.eclipse.xsemantics.example.fj.fj.Class> superclasses = this.superclassesInternal(_trace_, cl);
  Collections.reverse(superclasses);
  fields = CollectionLiterals.<Field>newArrayList();
  for (final org.eclipse.xsemantics.example.fj.fj.Class superclass : superclasses) {
    List<Field> _typeSelect = EcoreUtil2.<Field>typeSelect(
      superclass.getMembers(), 
      Field.class);
    Iterables.<Field>addAll(fields, _typeSelect);
  }
  /* fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) ) or true */
  {
    RuleFailedException previousFailure = null;
    try {
      List<Field> _typeSelect_1 = EcoreUtil2.<Field>typeSelect(
        cl.getMembers(), 
        Field.class);
      boolean _add = Iterables.<Field>addAll(fields, _typeSelect_1);
      /* fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) ) */
      if (!_add) {
        sneakyThrowRuleFailedException("fields += EcoreUtil2::typeSelect( cl.members, typeof(Field) )");
      }
    } catch (Exception e) {
      previousFailure = extractRuleFailedException(e);
      /* true */
    }
  }
  return new Result<List<Field>>(fields);
}
 
Example #29
Source File: AbstractXtextResourceSetTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 #30
Source File: StatemachineContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void empty() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append(this.c);
  _builder.newLineIfNotEmpty();
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("resetEvents");
  _builder_1.newLine();
  this.testContentAssistant(_builder, 
    Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("commands", "events", "resetEvents", "state")), "resetEvents", _builder_1.toString());
}