public <T extends Object, U extends Object> Iterable<T> select(
     final AbstractNodeMappingCall<T, U> nodeMappingCall, final U domainArgument) {
   boolean _equals = Objects.equal(domainArgument, null);
   if (_equals) {
     return Collections.<T>unmodifiableList(CollectionLiterals.<T>newArrayList());
   }
   if ((nodeMappingCall instanceof NodeMappingCall<?, ?>)) {
     final NodeMappingCall<T, U> nodeMappingCallCasted = ((NodeMappingCall<T, U>) nodeMappingCall);
     Function1<? super U, ? extends T> _selector = nodeMappingCallCasted.getSelector();
     final T nodeObject =
         ((Function1<? super Object, ? extends T>)
                 ((Function1<? super Object, ? extends T>) _selector))
             .apply(domainArgument);
     boolean _equals_1 = Objects.equal(nodeObject, null);
     if (_equals_1) {
       return Collections.<T>unmodifiableList(CollectionLiterals.<T>newArrayList());
     } else {
       return Collections.<T>unmodifiableList(CollectionLiterals.<T>newArrayList(nodeObject));
     }
   } else {
     if ((nodeMappingCall instanceof MultiNodeMappingCall<?, ?>)) {
       final MultiNodeMappingCall<T, U> nodeMappingCallCasted_1 =
           ((MultiNodeMappingCall<T, U>) nodeMappingCall);
       Function1<? super U, ? extends Iterable<? extends T>> _selector_1 =
           nodeMappingCallCasted_1.getSelector();
       Iterable<T> _apply =
           ((Function1<? super Object, ? extends Iterable<T>>)
                   ((Function1<? super Object, ? extends Iterable<T>>) _selector_1))
               .apply(domainArgument);
       return IterableExtensions.<T>filterNull(_apply);
     }
   }
   return null;
 }
Beispiel #2
0
 public void reset() {
   super.reset();
   HashMap<String, JavaBuilderState> _newHashMap =
       CollectionLiterals.<String, JavaBuilderState>newHashMap();
   this.javaBuildState = _newHashMap;
   ArrayList<UnconfirmedStructuralChangesDelta> _newArrayList =
       CollectionLiterals.<UnconfirmedStructuralChangesDelta>newArrayList();
   this.unconfirmedDeltas = _newArrayList;
 }
 public String subClassAlternatives(final EClass eClazz) {
   String _xblockexpression = null;
   {
     ArrayList<EClass> _newArrayList = CollectionLiterals.<EClass>newArrayList(eClazz);
     Iterable<EClass> _subClasses = Ecore2XtextExtensions.subClasses(eClazz);
     Iterable<EClass> list = Iterables.<EClass>concat(_newArrayList, _subClasses);
     final Function1<EClass, Boolean> _function =
         new Function1<EClass, Boolean>() {
           public Boolean apply(final EClass c) {
             boolean _needsConcreteRule = Ecore2XtextExtensions.needsConcreteRule(c);
             return Boolean.valueOf(_needsConcreteRule);
           }
         };
     Iterable<EClass> _filter = IterableExtensions.<EClass>filter(list, _function);
     list = _filter;
     final Function1<EClass, String> _function_1 =
         new Function1<EClass, String>() {
           public String apply(final EClass it) {
             String _concreteRuleName = Ecore2XtextExtensions.concreteRuleName(it);
             return _concreteRuleName;
           }
         };
     Iterable<String> _map = IterableExtensions.<EClass, String>map(list, _function_1);
     String _join = IterableExtensions.join(_map, " | ");
     _xblockexpression = (_join);
   }
   return _xblockexpression;
 }
 @Check
 public void checkUniqueListItemInDecomposition(final Decomposition decomposition) {
   final HashSet<ListItem> visitedListItems = CollectionLiterals.<ListItem>newHashSet();
   EList<ListItem> items = decomposition.getItems();
   ListIterator<ListItem> i = items.listIterator();
   while (i.hasNext()) {
     {
       ListItem d = i.next();
       boolean _contains = visitedListItems.contains(d);
       if (_contains) {
         String _name = d.getName();
         String _plus = ("duplicate item reference \'" + _name);
         String _plus_1 = (_plus + "\' in list");
         EReference _decomposition_Items =
             IntentSpecificationPackage.eINSTANCE.getDecomposition_Items();
         String _name_1 = d.getName();
         this.warning(
             _plus_1,
             _decomposition_Items,
             IntentSpecificationValidator.UNIQUE_LIST_ITEM_DECOMPOSITION,
             _name_1);
       }
       visitedListItems.add(d);
     }
   }
 }
 @Check
 public void checkUniqueDecompositionInIntent(final Intent intent) {
   final HashSet<String> visitedDecompositionTypeNames = CollectionLiterals.<String>newHashSet();
   EList<Decomposition> decompositions = intent.getDecompositions();
   ListIterator<Decomposition> i = decompositions.listIterator();
   while (i.hasNext()) {
     {
       Decomposition _next = i.next();
       Decomposition d = ((Decomposition) _next);
       DecompositionType _type = d.getType();
       String typeName = _type.getTypeName();
       boolean _contains = visitedDecompositionTypeNames.contains(typeName);
       if (_contains) {
         EReference _intent_Decompositions =
             IntentSpecificationPackage.eINSTANCE.getIntent_Decompositions();
         String _name = d.getName();
         this.warning(
             (("duplicate decomposition type \'" + typeName) + "\' in intent"),
             _intent_Decompositions,
             IntentSpecificationValidator.UNIQUE_DECOMPOSITION_INTENT,
             _name);
       }
       visitedDecompositionTypeNames.add(typeName);
     }
   }
 }
  @Accessors
  public static class P2Coordinates {
    private String bundleId;

    private String version;

    private Set<String> packages = CollectionLiterals.<String>newHashSet();

    @Pure
    public String getBundleId() {
      return this.bundleId;
    }

    public void setBundleId(final String bundleId) {
      this.bundleId = bundleId;
    }

    @Pure
    public String getVersion() {
      return this.version;
    }

    public void setVersion(final String version) {
      this.version = version;
    }

    @Pure
    public Set<String> getPackages() {
      return this.packages;
    }

    public void setPackages(final Set<String> packages) {
      this.packages = packages;
    }
  }
 @Check
 public void checkUniqueModelItemInListItem(final ListItem item) {
   final HashSet<ModelItem> visitedModelItems = CollectionLiterals.<ModelItem>newHashSet();
   EList<ModelItem> items = item.getModelReferences();
   ListIterator<ModelItem> i = items.listIterator();
   while (i.hasNext()) {
     {
       ModelItem _next = i.next();
       ModelItem d = ((ModelItem) _next);
       boolean _contains = visitedModelItems.contains(d);
       if (_contains) {
         String _name = d.getName();
         String _plus = ("duplicate model reference \'" + _name);
         String _plus_1 = (_plus + "\' in models");
         EReference _listItem_ModelReferences =
             IntentSpecificationPackage.eINSTANCE.getListItem_ModelReferences();
         String _name_1 = d.getName();
         this.warning(
             _plus_1,
             _listItem_ModelReferences,
             IntentSpecificationValidator.UNIQUE_MODEL_ITEM_LIST_ITEM,
             _name_1);
       }
       visitedModelItems.add(d);
     }
   }
 }
 @Check
 public void checkUniqueIntentsInRefinement(final Refinement refinement) {
   final HashSet<String> visitedIntentTypeNames = CollectionLiterals.<String>newHashSet();
   EList<Intent> intents = refinement.getIntents();
   ListIterator<Intent> i = intents.listIterator();
   while (i.hasNext()) {
     {
       Intent _next = i.next();
       Intent d = ((Intent) _next);
       IntentType _type = d.getType();
       String typeName = _type.getTypeName();
       boolean _contains = visitedIntentTypeNames.contains(typeName);
       if (_contains) {
         EReference _refinement_Intents =
             IntentSpecificationPackage.eINSTANCE.getRefinement_Intents();
         String _name = d.getName();
         this.warning(
             (("duplicate intent type \'" + typeName) + "\' in refinement"),
             _refinement_Intents,
             IntentSpecificationValidator.UNIQUE_INTENTS_REFINEMENT,
             _name);
       }
       visitedIntentTypeNames.add(typeName);
     }
   }
 }
 public List<String> initialHiddenTokens(final Grammar it) {
   List<String> _xblockexpression = null;
   {
     boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens();
     if (_isDefinesHiddenTokens) {
       EList<AbstractRule> _hiddenTokens = it.getHiddenTokens();
       final Function1<AbstractRule, String> _function =
           new Function1<AbstractRule, String>() {
             @Override
             public String apply(final AbstractRule it) {
               return GrammarAccessExtensions.this.ruleName(it);
             }
           };
       List<String> _map = ListExtensions.<AbstractRule, String>map(_hiddenTokens, _function);
       return IterableExtensions.<String>toList(_map);
     }
     EList<Grammar> _usedGrammars = it.getUsedGrammars();
     int _size = _usedGrammars.size();
     boolean _equals = (_size == 1);
     if (_equals) {
       EList<Grammar> _usedGrammars_1 = it.getUsedGrammars();
       Grammar _head = IterableExtensions.<Grammar>head(_usedGrammars_1);
       return this.initialHiddenTokens(_head);
     }
     _xblockexpression = CollectionLiterals.<String>emptyList();
   }
   return _xblockexpression;
 }
 private void copyFields(
     final EObject objectWithReference,
     final Iterable<XtendMember> members,
     final Set<String> fieldNames) {
   boolean _not = (!(objectWithReference instanceof XtendClass));
   if (_not) {
     return;
   }
   final XtendClass type = ((XtendClass) objectWithReference);
   final ArrayList<XtendField> newFields = CollectionLiterals.<XtendField>newArrayList();
   Iterable<XtendField> _filter = Iterables.<XtendField>filter(members, XtendField.class);
   for (final XtendField field : _filter) {
     String _name = field.getName();
     boolean _contains = fieldNames.contains(_name);
     boolean _not_1 = (!_contains);
     if (_not_1) {
       final XtendField copiedMember = this._expressionCopier.<XtendField>cloneWithProxies(field);
       SourceAdapter.adapt(copiedMember, field);
       newFields.add(((XtendField) copiedMember));
       String _name_1 = field.getName();
       fieldNames.add(_name_1);
     }
   }
   EList<XtendMember> _members = type.getMembers();
   _members.addAll(newFields);
 }
 public void assertNonSmoking(final CharSequence input) throws Exception {
   final String string = input.toString();
   final List<CommonToken> tokenList = CollectionLiterals.<CommonToken>newArrayList();
   {
     final Lexer lexer = this.lexerProvider.get();
     ANTLRStringStream _aNTLRStringStream = new ANTLRStringStream(string);
     lexer.setCharStream(_aNTLRStringStream);
     Token token = lexer.nextToken();
     boolean _notEquals = (!Objects.equal(token, Token.EOF_TOKEN));
     boolean _while = _notEquals;
     while (_while) {
       {
         tokenList.add(((CommonToken) token));
         Token _nextToken = lexer.nextToken();
         token = _nextToken;
       }
       boolean _notEquals_1 = (!Objects.equal(token, Token.EOF_TOKEN));
       _while = _notEquals_1;
     }
   }
   for (final CommonToken token : tokenList) {
     {
       final int start = token.getStartIndex();
       String _text = token.getText();
       final int length = _text.length();
       String _substring = string.substring(0, start);
       String _substring_1 = string.substring((start + length));
       String _plus = (_substring + _substring_1);
       this.processFile(_plus);
     }
   }
 }
 public FlattenedGrammarAccess(final RuleNames names, final RuleFilter filter) {
   final Grammar grammar = names.getContextGrammar();
   Grammar flattenedGrammar = this.<Grammar>copy(grammar);
   String _name = grammar.getName();
   flattenedGrammar.setName(_name);
   LinkedHashMap<RuleWithParameterValues, AbstractRule> origToCopy =
       Maps.<RuleWithParameterValues, AbstractRule>newLinkedHashMap();
   List<AbstractRule> _rules = filter.getRules(grammar);
   boolean _isDiscardRuleTypeRef = filter.isDiscardRuleTypeRef();
   final ArrayList<AbstractRule> copies =
       this.copyRuleStubs(names, origToCopy, _rules, _isDiscardRuleTypeRef);
   EList<AbstractRule> _rules_1 = flattenedGrammar.getRules();
   Iterables.<AbstractRule>addAll(_rules_1, copies);
   Multimap<TerminalRule, AbstractRule> calledFrom = this.copyRuleBodies(copies, origToCopy);
   this.setHiddenTokens(flattenedGrammar, grammar, origToCopy);
   this.markAsFragment(calledFrom);
   boolean _isDiscardUnreachableRules = filter.isDiscardUnreachableRules();
   if (_isDiscardUnreachableRules) {
     Set<AbstractRule> usedRules = CollectionLiterals.<AbstractRule>newHashSet();
     boolean _isDiscardTerminalRules = filter.isDiscardTerminalRules();
     boolean _not = (!_isDiscardTerminalRules);
     if (_not) {
       List<TerminalRule> _allTerminalRules = GrammarUtil.allTerminalRules(flattenedGrammar);
       usedRules.addAll(_allTerminalRules);
     }
     UsedRulesFinder finder = new UsedRulesFinder(usedRules);
     finder.compute(flattenedGrammar);
     EList<AbstractRule> _rules_2 = flattenedGrammar.getRules();
     _rules_2.retainAll(usedRules);
   }
   this.flattenedGrammar = flattenedGrammar;
   OriginalGrammar _originalGrammar = new OriginalGrammar(grammar);
   _originalGrammar.attachToEmfObject(flattenedGrammar);
 }
 @Override
 public Iterable<? extends AbstractFile> getFiles() {
   ArrayList<AbstractFile> _xblockexpression = null;
   {
     final ArrayList<AbstractFile> files = CollectionLiterals.<AbstractFile>newArrayList();
     Iterable<? extends AbstractFile> _files = super.getFiles();
     Iterables.<AbstractFile>addAll(files, _files);
     TestProjectDescriptor _testProject = this.getTestProject();
     boolean _isInlined = _testProject.isInlined();
     if (_isInlined) {
       TestProjectDescriptor _testProject_1 = this.getTestProject();
       Iterable<? extends AbstractFile> _files_1 = _testProject_1.getFiles();
       final Function1<AbstractFile, Boolean> _function =
           (AbstractFile fileFromTestProject) -> {
             final Function1<AbstractFile, Boolean> _function_1 =
                 (AbstractFile it) -> {
                   String _relativePath = it.getRelativePath();
                   String _relativePath_1 = fileFromTestProject.getRelativePath();
                   return Boolean.valueOf(Objects.equal(_relativePath, _relativePath_1));
                 };
             boolean _exists = IterableExtensions.<AbstractFile>exists(files, _function_1);
             return Boolean.valueOf((!_exists));
           };
       Iterable<? extends AbstractFile> _filter = IterableExtensions.filter(_files_1, _function);
       Iterables.<AbstractFile>addAll(files, _filter);
     }
     _xblockexpression = files;
   }
   return _xblockexpression;
 }
 protected void extend(
     final CompletionType type,
     final TokenSet[] tokenSets,
     final AbstractElement followElement,
     final CompletionProvider<CompletionParameters> contrib) {
   boolean _containsKey = this.myFollowElementBasedContributors.containsKey(type);
   boolean _not = (!_containsKey);
   if (_not) {
     HashMap<TokenSet, Multimap<AbstractElement, CompletionProvider<CompletionParameters>>>
         _newHashMap =
             CollectionLiterals
                 .<TokenSet, Multimap<AbstractElement, CompletionProvider<CompletionParameters>>>
                     newHashMap();
     this.myFollowElementBasedContributors.put(type, _newHashMap);
   }
   final Map<TokenSet, Multimap<AbstractElement, CompletionProvider<CompletionParameters>>> map =
       this.myFollowElementBasedContributors.get(type);
   for (final TokenSet tokenSet : tokenSets) {
     {
       boolean _containsKey_1 = map.containsKey(tokenSet);
       boolean _not_1 = (!_containsKey_1);
       if (_not_1) {
         ArrayListMultimap<AbstractElement, CompletionProvider<CompletionParameters>> _create =
             ArrayListMultimap.<AbstractElement, CompletionProvider<CompletionParameters>>create();
         map.put(tokenSet, _create);
       }
       final Multimap<AbstractElement, CompletionProvider<CompletionParameters>> providers =
           map.get(tokenSet);
       providers.put(followElement, contrib);
     }
   }
 }
 public Set<ProjectDescriptor> getEnabledProjects() {
   ImmutableSet<ProjectDescriptor> _xblockexpression = null;
   {
     final Function1<ProjectDescriptor, Boolean> _function =
         new Function1<ProjectDescriptor, Boolean>() {
           @Override
           public Boolean apply(final ProjectDescriptor it) {
             return Boolean.valueOf(it.isEnabled());
           }
         };
     final Iterable<? extends ProjectDescriptor> productionProjects =
         IterableExtensions.filter(
             Collections.<ProjectDescriptor>unmodifiableList(
                 CollectionLiterals.<ProjectDescriptor>newArrayList(
                     this.runtimeProject,
                     this.ideProject,
                     this.uiProject,
                     this.intellijProject,
                     this.webProject,
                     this.parentProject,
                     this.targetPlatformProject)),
             _function);
     Iterable<TestedProjectDescriptor> _filter =
         Iterables.<TestedProjectDescriptor>filter(
             productionProjects, TestedProjectDescriptor.class);
     final Function1<TestedProjectDescriptor, TestProjectDescriptor> _function_1 =
         new Function1<TestedProjectDescriptor, TestProjectDescriptor>() {
           @Override
           public TestProjectDescriptor apply(final TestedProjectDescriptor it) {
             return it.getTestProject();
           }
         };
     Iterable<TestProjectDescriptor> _map =
         IterableExtensions.<TestedProjectDescriptor, TestProjectDescriptor>map(
             _filter, _function_1);
     final Function1<TestProjectDescriptor, Boolean> _function_2 =
         new Function1<TestProjectDescriptor, Boolean>() {
           @Override
           public Boolean apply(final TestProjectDescriptor it) {
             boolean _and = false;
             boolean _isEnabled = it.isEnabled();
             if (!_isEnabled) {
               _and = false;
             } else {
               boolean _isSeparate = it.isSeparate();
               _and = _isSeparate;
             }
             return Boolean.valueOf(_and);
           }
         };
     final Iterable<TestProjectDescriptor> testProjects =
         IterableExtensions.<TestProjectDescriptor>filter(_map, _function_2);
     Iterable<ProjectDescriptor> _plus =
         Iterables.<ProjectDescriptor>concat(productionProjects, testProjects);
     _xblockexpression = ImmutableSet.<ProjectDescriptor>copyOf(_plus);
   }
   return _xblockexpression;
 }
 @Check
 public void checkDuplicateFeatureName(final MobaEntity dto) {
   Map<String, MobaEntityFeature> _xifexpression = null;
   MobaEntity _superType = dto.getSuperType();
   boolean _notEquals = (!Objects.equal(_superType, null));
   if (_notEquals) {
     Map<String, MobaEntityFeature> _xtrycatchfinallyexpression = null;
     try {
       MobaEntity _superType_1 = dto.getSuperType();
       List<MobaEntityFeature> _allFeatures = _superType_1.getAllFeatures();
       final Function1<MobaEntityFeature, String> _function =
           (MobaEntityFeature it) -> {
             return it.getName();
           };
       _xtrycatchfinallyexpression =
           IterableExtensions.<String, MobaEntityFeature>toMap(_allFeatures, _function);
     } catch (final Throwable _t) {
       if (_t instanceof RecursionException) {
         final RecursionException ex = (RecursionException) _t;
         _xtrycatchfinallyexpression = Collections.<String, MobaEntityFeature>emptyMap();
       } else {
         throw Exceptions.sneakyThrow(_t);
       }
     }
     _xifexpression = _xtrycatchfinallyexpression;
   } else {
     _xifexpression = Collections.<String, MobaEntityFeature>emptyMap();
   }
   final Map<String, MobaEntityFeature> superFeatureMap = _xifexpression;
   final Set<String> currentFeatures = CollectionLiterals.<String>newHashSet();
   int index = 0;
   EList<MobaEntityFeature> _features = dto.getFeatures();
   for (final MobaEntityFeature feature : _features) {
     {
       String _name = feature.getName();
       boolean _containsKey = superFeatureMap.containsKey(_name);
       if (_containsKey) {
         this.error(
             "Supertype contains same feature name",
             dto,
             MobaPackage.Literals.MOBA_ENTITY__FEATURES,
             index);
       }
       String _name_1 = feature.getName();
       boolean _contains = currentFeatures.contains(_name_1);
       if (_contains) {
         this.error(
             "Feature name must be unique",
             dto,
             MobaPackage.Literals.MOBA_ENTITY__FEATURES,
             index);
       }
       String _name_2 = feature.getName();
       currentFeatures.add(_name_2);
       index++;
     }
   }
 }
@EmfAdaptable
@SuppressWarnings("all")
public class PreferenceValuesByLanguage {
  public static class PreferenceValuesByLanguageAdapter extends AdapterImpl {
    private PreferenceValuesByLanguage element;

    public PreferenceValuesByLanguageAdapter(final PreferenceValuesByLanguage element) {
      this.element = element;
    }

    public PreferenceValuesByLanguage get() {
      return this.element;
    }

    public boolean isAdapterForType(final Object object) {
      return object == PreferenceValuesByLanguage.class;
    }
  }

  private final Map<String, IPreferenceValues> preferencesByLanguage =
      CollectionLiterals.<String, IPreferenceValues>newHashMap();

  public IPreferenceValues get(final String languageId) {
    return this.preferencesByLanguage.get(languageId);
  }

  public IPreferenceValues put(final String languageId, final IPreferenceValues values) {
    return this.preferencesByLanguage.put(languageId, values);
  }

  public static PreferenceValuesByLanguage findInEmfObject(final Notifier emfObject) {
    for (Adapter adapter : emfObject.eAdapters()) {
      if (adapter
          instanceof
          org.eclipse.xtext.preferences.PreferenceValuesByLanguage
              .PreferenceValuesByLanguageAdapter) {
        return ((org.eclipse.xtext.preferences.PreferenceValuesByLanguage
                    .PreferenceValuesByLanguageAdapter)
                adapter)
            .get();
      }
    }
    return null;
  }

  public void attachToEmfObject(final Notifier emfObject) {
    PreferenceValuesByLanguage result = findInEmfObject(emfObject);
    if (result != null)
      throw new IllegalStateException(
          "The given EMF object already contains an adapter for PreferenceValuesByLanguage");
    org.eclipse.xtext.preferences.PreferenceValuesByLanguage.PreferenceValuesByLanguageAdapter
        adapter =
            new org.eclipse.xtext.preferences.PreferenceValuesByLanguage
                .PreferenceValuesByLanguageAdapter(this);
    emfObject.eAdapters().add(adapter);
  }
}
 public void resolve() {
   boolean _equals = Objects.equal(this.resolved, null);
   if (_equals) {
     HashMap<QualifiedName, GeneratorScope.Sortable> _newHashMap =
         CollectionLiterals.<QualifiedName, GeneratorScope.Sortable>newHashMap();
     this.resolved = _newHashMap;
     final ArrayList<GeneratorScope.Sortable> temp =
         CollectionLiterals.<GeneratorScope.Sortable>newArrayList();
     Iterable<IEObjectDescription> _allElements = this.delegate.getAllElements();
     for (final IEObjectDescription desc : _allElements) {
       GeneratorScope.Sortable _sortable = new GeneratorScope.Sortable(desc);
       temp.add(_sortable);
     }
     Collections.<GeneratorScope.Sortable>sort(temp);
     for (final GeneratorScope.Sortable desc_1 : temp) {
       this.resolved.put(desc_1.name, desc_1);
     }
   }
 }
Beispiel #19
0
 @Test
 public void testShouldLoadFromStorage() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("package mypack");
     _builder.newLine();
     _builder.newLine();
     _builder.append("class MyClass {");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("public def void foo() {");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("}");
     _builder.newLine();
     _builder.append("}");
     _builder.newLine();
     final IFile file = this.helper.createFile("mypack/MyClass.xtend", _builder.toString());
     IResourcesSetupUtil.waitForAutoBuild();
     final URI uri = this.uriMapper.getUri(file);
     IProject _project = file.getProject();
     final ResourceSet resourceSet = this.resourceSetProvider.get(_project);
     SourceLevelURIsAdapter.setSourceLevelUris(
         resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
     Resource _createResource = resourceSet.createResource(uri);
     final StorageAwareResource resource = ((StorageAwareResource) _createResource);
     final Procedure0 _function =
         new Procedure0() {
           @Override
           public void apply() {
             IResourceStorageFacade _resourceStorageFacade = resource.getResourceStorageFacade();
             boolean _shouldLoadFromStorage =
                 _resourceStorageFacade.shouldLoadFromStorage(resource);
             Assert.assertTrue(_shouldLoadFromStorage);
           }
         };
     this.doWorkInJob(_function);
     NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
     file.delete(true, _nullProgressMonitor);
     IResourcesSetupUtil.waitForAutoBuild();
     final Procedure0 _function_1 =
         new Procedure0() {
           @Override
           public void apply() {
             IResourceStorageFacade _resourceStorageFacade = resource.getResourceStorageFacade();
             boolean _shouldLoadFromStorage =
                 _resourceStorageFacade.shouldLoadFromStorage(resource);
             Assert.assertFalse(_shouldLoadFromStorage);
           }
         };
     this.doWorkInJob(_function_1);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
 public <T extends Object, U extends Object> Iterable<? extends XLabel> execute(
     final AbstractLabelMappingCall<T, U> labelMappingCall, final U domainArgument) {
   final Iterable<T> labelObjects = this.<T, U>select(labelMappingCall, domainArgument);
   final ArrayList<XLabel> result = CollectionLiterals.<XLabel>newArrayList();
   for (final T labelObject : labelObjects) {
     AbstractLabelMapping<T> _labelMapping = labelMappingCall.getLabelMapping();
     XLabel _createLabel = this.<T>createLabel(labelObject, _labelMapping);
     result.add(_createLabel);
   }
   return result;
 }
/** @noreference */
@SuppressWarnings("all")
public class CompositeGeneratorFragment implements IXtextGeneratorFragment {
  @Accessors(AccessorType.PROTECTED_GETTER)
  private final List<IXtextGeneratorFragment> fragments =
      CollectionLiterals.<IXtextGeneratorFragment>newArrayList();

  public void addFragment(final IXtextGeneratorFragment fragment) {
    if ((fragment == this)) {
      throw new IllegalArgumentException();
    }
    this.fragments.add(fragment);
  }

  @Override
  public void checkConfiguration(final Issues issues) {
    for (final IXtextGeneratorFragment fragment : this.fragments) {
      fragment.checkConfiguration(issues);
    }
  }

  @Override
  public void generate() {
    final CompositeGeneratorException composite = new CompositeGeneratorException();
    for (final IXtextGeneratorFragment fragment : this.fragments) {
      try {
        fragment.generate();
      } catch (final Throwable _t) {
        if (_t instanceof Exception) {
          final Exception e = (Exception) _t;
          composite.addException(e);
        } else {
          throw Exceptions.sneakyThrow(_t);
        }
      }
    }
    boolean _hasExceptions = composite.hasExceptions();
    if (_hasExceptions) {
      throw composite;
    }
  }

  @Override
  public void initialize(final Injector injector) {
    for (final IXtextGeneratorFragment fragment : this.fragments) {
      fragment.initialize(injector);
    }
  }

  @Pure
  protected List<IXtextGeneratorFragment> getFragments() {
    return this.fragments;
  }
}
 protected void createFollowElementBasedProposals(
     final CompletionParameters parameters, final CompletionResultSet result) {
   boolean _or = false;
   boolean _isEmpty = this.myFollowElementBasedContributors.isEmpty();
   if (_isEmpty) {
     _or = true;
   } else {
     CompletionType _completionType = parameters.getCompletionType();
     boolean _containsKey = this.myFollowElementBasedContributors.containsKey(_completionType);
     boolean _not = (!_containsKey);
     _or = _not;
   }
   if (_or) {
     return;
   }
   Editor _editor = parameters.getEditor();
   int _offset = parameters.getOffset();
   final TokenSet tokenSet = this._tokenSetProvider.getTokenSet(((EditorEx) _editor), _offset);
   CompletionType _completionType_1 = parameters.getCompletionType();
   Map<TokenSet, Multimap<AbstractElement, CompletionProvider<CompletionParameters>>> _get =
       this.myFollowElementBasedContributors.get(_completionType_1);
   final Multimap<AbstractElement, CompletionProvider<CompletionParameters>> element2provider =
       _get.get(tokenSet);
   boolean _equals = Objects.equal(element2provider, null);
   if (_equals) {
     return;
   }
   final Set<AbstractElement> followElements = this.computeFollowElements(parameters);
   final HashSet<CompletionProvider<CompletionParameters>> calledProviders =
       CollectionLiterals.<CompletionProvider<CompletionParameters>>newHashSet();
   Set<AbstractElement> _keySet = element2provider.keySet();
   for (final AbstractElement followElement : _keySet) {
     {
       final ProcessingContext context = new ProcessingContext();
       boolean _contains = followElements.contains(followElement);
       if (_contains) {
         final Collection<CompletionProvider<CompletionParameters>> providers =
             element2provider.get(followElement);
         for (final CompletionProvider<CompletionParameters> provider : providers) {
           boolean _add = calledProviders.add(provider);
           if (_add) {
             provider.addCompletionVariants(parameters, context, result);
             boolean _isStopped = result.isStopped();
             if (_isStopped) {
               return;
             }
           }
         }
       }
     }
   }
 }
 @Override
 public List<TextRange> getRanges() {
   List<TextRange> _xblockexpression = null;
   {
     final TextRange rangeInElement = this.getRangeInElement();
     final TextRange rangeToHighlightInElement = this.getRangeToHighlightInElement();
     List<TextRange> _xifexpression = null;
     boolean _equals = Objects.equal(rangeInElement, rangeToHighlightInElement);
     if (_equals) {
       _xifexpression =
           Collections.<TextRange>unmodifiableList(
               CollectionLiterals.<TextRange>newArrayList(rangeInElement));
     } else {
       _xifexpression =
           Collections.<TextRange>unmodifiableList(
               CollectionLiterals.<TextRange>newArrayList(
                   rangeInElement, rangeToHighlightInElement));
     }
     _xblockexpression = _xifexpression;
   }
   return _xblockexpression;
 }
Beispiel #24
0
 public List<Integer> test() {
   ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList("red", "green");
   final Function1<String, Integer> _function =
       new Function1<String, Integer>() {
         public Integer apply(final String it) {
           int _length = it.length();
           return Integer.valueOf(_length);
         }
       };
   List<Integer> _map = ListExtensions.<String, Integer>map(_newArrayList, _function);
   List<Integer> _reverseView = ListExtensions.<Integer>reverseView(_map);
   return _reverseView;
 }
 public <T extends Object, U extends Object> Iterable<XNode> execute(
     final AbstractNodeMappingCall<T, U> nodeMappingCall,
     final U domainArgument,
     final InterpreterContext context) {
   final Iterable<T> nodeObjects = this.<T, U>select(nodeMappingCall, domainArgument);
   final ArrayList<XNode> result = CollectionLiterals.<XNode>newArrayList();
   for (final T nodeObject : nodeObjects) {
     NodeMapping<T> _nodeMapping = nodeMappingCall.getNodeMapping();
     XNode _createNode = this.<T>createNode(nodeObject, _nodeMapping, context);
     result.add(_createNode);
   }
   return result;
 }
 @Override
 public Object[] getVariants() {
   ArrayList<LookupElementBuilder> _xblockexpression = null;
   {
     ProgressIndicatorProvider.checkCanceled();
     ICrossReferenceDescription crossReferenceDescription = this.getCrossReferenceDescription();
     boolean _equals = Objects.equal(crossReferenceDescription, null);
     if (_equals) {
       return ((Object[])
           Conversions.unwrapArray(CollectionLiterals.<Object>emptyList(), Object.class));
     }
     ArrayList<LookupElementBuilder> variants =
         CollectionLiterals.<LookupElementBuilder>newArrayList();
     Iterable<IEObjectDescription> _variants = crossReferenceDescription.getVariants();
     for (final IEObjectDescription objectDescription : _variants) {
       {
         ProgressIndicatorProvider.checkCanceled();
         QualifiedName _name = objectDescription.getName();
         String name = this.qualifiedNameConverter.toString(_name);
         BaseXtextFile _xtextFile = this.myElement.getXtextFile();
         XtextResource _resource = _xtextFile.getResource();
         PsiElement element =
             this.psiModelAssociations.getPsiElement(objectDescription, _resource);
         boolean _notEquals = (!Objects.equal(element, null));
         if (_notEquals) {
           LookupElementBuilder _create = LookupElementBuilder.create(name);
           PsiElement _navigationElement = element.getNavigationElement();
           PsiFile _containingFile = _navigationElement.getContainingFile();
           String _name_1 = _containingFile.getName();
           LookupElementBuilder _withTypeText = _create.withTypeText(_name_1);
           variants.add(_withTypeText);
         }
       }
     }
     _xblockexpression = variants;
   }
   return ((Object[]) Conversions.unwrapArray(_xblockexpression, Object.class));
 }
Beispiel #27
0
 protected void doWorkInJob(final Procedure0 work) {
   try {
     final ArrayList<Throwable> throwables = CollectionLiterals.<Throwable>newArrayList();
     StringConcatenation _builder = new StringConcatenation();
     Class<? extends ResourceStorageTest> _class = this.getClass();
     String _name = _class.getName();
     _builder.append(_name, "");
     _builder.append(".TestJob");
     final Procedure1<Job> _function =
         new Procedure1<Job>() {
           @Override
           public void apply(final Job it) {
             ISchedulingRule _newSequence = SchedulingRuleFactory.INSTANCE.newSequence();
             it.setRule(_newSequence);
           }
         };
     final Job testShouldLoadFromStorageJob =
         ObjectExtensions.<Job>operator_doubleArrow(
             new Job(_builder.toString()) {
               @Override
               protected IStatus run(final IProgressMonitor monitor) {
                 IStatus _xblockexpression = null;
                 {
                   try {
                     work.apply();
                   } catch (final Throwable _t) {
                     if (_t instanceof Throwable) {
                       final Throwable t = (Throwable) _t;
                       throwables.add(t);
                     } else {
                       throw Exceptions.sneakyThrow(_t);
                     }
                   }
                   _xblockexpression = Status.OK_STATUS;
                 }
                 return _xblockexpression;
               }
             },
             _function);
     testShouldLoadFromStorageJob.schedule();
     testShouldLoadFromStorageJob.join();
     final Throwable t = IterableExtensions.<Throwable>head(throwables);
     boolean _notEquals = (!Objects.equal(t, null));
     if (_notEquals) {
       Throwables.propagate(t);
     }
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
 protected Set<AbstractElement> computeFollowElements(final CompletionParameters parameters) {
   Editor _editor = parameters.getEditor();
   Document _document = _editor.getDocument();
   PsiElement _position = parameters.getPosition();
   ASTNode _node = _position.getNode();
   int _startOffset = _node.getStartOffset();
   TextRange _textRange = new TextRange(0, _startOffset);
   final String text = _document.getText(_textRange);
   final Collection<FollowElement> followElements =
       this.contentAssistParser.getFollowElements(text, false);
   final HashSet<AbstractElement> allElements = CollectionLiterals.<AbstractElement>newHashSet();
   this.followElementComputer.computeFollowElements(followElements, allElements);
   return allElements;
 }
Beispiel #29
0
 public String blah(final String input) {
   final ArrayList<?> _cacheKey = CollectionLiterals.newArrayList(input);
   final String _result;
   synchronized (_createCache_blah) {
     if (_createCache_blah.containsKey(_cacheKey)) {
       return _createCache_blah.get(_cacheKey);
     }
     String _string = new String();
     _result = _string;
     _createCache_blah.put(_cacheKey, _result);
   }
   _init_blah(_result, input);
   return _result;
 }
 /**
  * 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 {
     boolean _isOutputFolderIncluded = this.isOutputFolderIncluded();
     HashSet<IJavaProject> _newHashSet = CollectionLiterals.<IJavaProject>newHashSet();
     this.collectClasspathURLs(projectToUse, urls, _isOutputFolderIncluded, _newHashSet);
   } catch (final Throwable _t) {
     if (_t instanceof JavaModelException) {
       final JavaModelException e = (JavaModelException) _t;
       boolean _isDoesNotExist = e.isDoesNotExist();
       boolean _not = (!_isDoesNotExist);
       if (_not) {
         String _message = e.getMessage();
         JdtBasedProcessorProvider.LOG.error(_message, e);
       }
     } else {
       throw Exceptions.sneakyThrow(_t);
     }
   }
   ClassLoader _parentClassLoader = this.getParentClassLoader();
   return new URLClassLoader(
       ((URL[]) Conversions.unwrapArray(urls, URL.class)), _parentClassLoader);
 }