コード例 #1
0
ファイル: Example2.java プロジェクト: aaronwalker/Jnario
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 private void setHiddenTokens(
     final Grammar copy,
     final Grammar orig,
     final Map<RuleWithParameterValues, AbstractRule> origToCopy) {
   if ((orig == null)) {
     copy.setDefinesHiddenTokens(true);
   } else {
     boolean _isDefinesHiddenTokens = orig.isDefinesHiddenTokens();
     boolean _not = (!_isDefinesHiddenTokens);
     if (_not) {
       EList<Grammar> _usedGrammars = orig.getUsedGrammars();
       Grammar _head = IterableExtensions.<Grammar>head(_usedGrammars);
       this.setHiddenTokens(copy, _head, origToCopy);
     } else {
       copy.setDefinesHiddenTokens(true);
       EList<AbstractRule> _hiddenTokens = copy.getHiddenTokens();
       EList<AbstractRule> _hiddenTokens_1 = orig.getHiddenTokens();
       final Function1<AbstractRule, AbstractRule> _function =
           (AbstractRule hidden) -> {
             RuleWithParameterValues _ruleWithParameterValues =
                 new RuleWithParameterValues(hidden);
             return origToCopy.get(_ruleWithParameterValues);
           };
       List<AbstractRule> _map =
           ListExtensions.<AbstractRule, AbstractRule>map(_hiddenTokens_1, _function);
       Iterables.<AbstractRule>addAll(_hiddenTokens, _map);
     }
   }
 }
コード例 #4
0
 @Override
 protected PsiElement getInternalNavigationElement() {
   List<INode> _findNodesForFeature = NodeModelUtils.findNodesForFeature(this.owner, this.feature);
   final Function1<INode, Iterable<ILeafNode>> _function =
       new Function1<INode, Iterable<ILeafNode>>() {
         @Override
         public Iterable<ILeafNode> apply(final INode it) {
           return it.getLeafNodes();
         }
       };
   List<Iterable<ILeafNode>> _map =
       ListExtensions.<INode, Iterable<ILeafNode>>map(_findNodesForFeature, _function);
   Iterable<ILeafNode> _flatten = Iterables.<ILeafNode>concat(_map);
   final Function1<ILeafNode, Boolean> _function_1 =
       new Function1<ILeafNode, Boolean>() {
         @Override
         public Boolean apply(final ILeafNode it) {
           boolean _isHidden = it.isHidden();
           return Boolean.valueOf((!_isHidden));
         }
       };
   Iterable<ILeafNode> _filter = IterableExtensions.<ILeafNode>filter(_flatten, _function_1);
   ILeafNode _head = IterableExtensions.<ILeafNode>head(_filter);
   ASTNode _aSTNode = this.xtextFile.getASTNode(_head);
   return _aSTNode.getPsi();
 }
コード例 #5
0
 public String defaultValue(final AbstractElement ele, final Set<AbstractElement> visited) {
   String _switchResult = null;
   boolean _matched = false;
   if (!_matched) {
     boolean _add = visited.add(ele);
     boolean _not = (!_add);
     if (_not) {
       _matched = true;
       _switchResult = "";
     }
   }
   if (!_matched) {
     boolean _isOptionalCardinality = GrammarUtil.isOptionalCardinality(ele);
     if (_isOptionalCardinality) {
       _matched = true;
       _switchResult = "";
     }
   }
   if (!_matched) {
     if (ele instanceof Alternatives) {
       _matched = true;
       EList<AbstractElement> _elements = ((Alternatives) ele).getElements();
       AbstractElement _head = IterableExtensions.<AbstractElement>head(_elements);
       _switchResult = this.defaultValue(_head, visited);
     }
   }
   if (!_matched) {
     if (ele instanceof Group) {
       _matched = true;
       EList<AbstractElement> _elements = ((Group) ele).getElements();
       final Function1<AbstractElement, String> _function =
           new Function1<AbstractElement, String>() {
             @Override
             public String apply(final AbstractElement e) {
               return AbstractSyntacticSequencer.this.defaultValue(e, visited);
             }
           };
       List<String> _map = ListExtensions.<AbstractElement, String>map(_elements, _function);
       _switchResult = IterableExtensions.join(_map);
     }
   }
   if (!_matched) {
     if (ele instanceof Keyword) {
       _matched = true;
       _switchResult = ((Keyword) ele).getValue();
     }
   }
   if (!_matched) {
     if (ele instanceof RuleCall) {
       _matched = true;
       AbstractRule _rule = ((RuleCall) ele).getRule();
       AbstractElement _alternatives = _rule.getAlternatives();
       _switchResult = this.defaultValue(_alternatives, visited);
     }
   }
   if (!_matched) {
     _switchResult = "";
   }
   return _switchResult;
 }
コード例 #6
0
ファイル: SpeADLValidator.java プロジェクト: victornoel/may
 @Check
 public void checkUseArgsAgainstParameters(final SpeciesReference reference) {
   Species _species = reference.getSpecies();
   EList<Feature> _parameters = _species.getParameters();
   final int numParameters = _parameters.size();
   EList<Feature> _arguments = reference.getArguments();
   int _size = _arguments.size();
   boolean _notEquals = (numParameters != _size);
   if (_notEquals) {
     Species _species_1 = reference.getSpecies();
     String _name = _species_1.getName();
     String _plus = ("Incorrect number of arguments for species " + _name);
     String _plus_1 = (_plus + "(");
     Species _species_2 = reference.getSpecies();
     EList<Feature> _parameters_1 = _species_2.getParameters();
     final Function1<Feature, String> _function =
         new Function1<Feature, String>() {
           public String apply(final Feature it) {
             return it.getName();
           }
         };
     List<String> _map = ListExtensions.<Feature, String>map(_parameters_1, _function);
     String _join = IterableExtensions.join(_map, ",");
     String _plus_2 = (_plus_1 + _join);
     String _plus_3 = (_plus_2 + ")");
     String _plus_4 = (_plus_3 + "; it cannot be parameterized with arguments ");
     String _plus_5 = (_plus_4 + "(");
     EList<Feature> _arguments_1 = reference.getArguments();
     final Function1<Feature, String> _function_1 =
         new Function1<Feature, String>() {
           public String apply(final Feature it) {
             return it.getName();
           }
         };
     List<String> _map_1 = ListExtensions.<Feature, String>map(_arguments_1, _function_1);
     String _join_1 = IterableExtensions.join(_map_1, ",");
     String _plus_6 = (_plus_5 + _join_1);
     String _plus_7 = (_plus_6 + ")");
     this.error(_plus_7, SpeadlPackage.Literals.SPECIES_REFERENCE__ARGUMENTS);
   }
 }
コード例 #7
0
ファイル: HtmlExtensions.java プロジェクト: dschulten/xtext
 protected CharSequence _toHtml(final List<EObject> it) {
   final Function1<EObject, CharSequence> _function =
       new Function1<EObject, CharSequence>() {
         public CharSequence apply(final EObject it) {
           CharSequence _html = HtmlExtensions.this.toHtml(it);
           return _html;
         }
       };
   List<CharSequence> _map = ListExtensions.<EObject, CharSequence>map(it, _function);
   String _join = IterableExtensions.join(_map);
   return _join;
 }
コード例 #8
0
ファイル: GitExtensions.java プロジェクト: joergreichert/xDoc
 public Set<String> apply() {
   EList<EClassifier> _eClassifiers = TypesPackage.eINSTANCE.getEClassifiers();
   final Function1<EClassifier, String> _function =
       new Function1<EClassifier, String>() {
         public String apply(final EClassifier it) {
           String _name = it.getName();
           return _name;
         }
       };
   List<String> _map = ListExtensions.<EClassifier, String>map(_eClassifiers, _function);
   Set<String> _set = IterableExtensions.<String>toSet(_map);
   return _set;
 }
コード例 #9
0
ファイル: VaryGrammarIndex.java プロジェクト: TatyPerson/Vary
 public Iterable<IEObjectDescription> getVisibleEObjectDescriptions(final EObject o) {
   List<IContainer> _visibleContainers = this.getVisibleContainers(o);
   final Function1<IContainer, Iterable<IEObjectDescription>> _function =
       new Function1<IContainer, Iterable<IEObjectDescription>>() {
         @Override
         public Iterable<IEObjectDescription> apply(final IContainer container) {
           return container.getExportedObjects();
         }
       };
   List<Iterable<IEObjectDescription>> _map =
       ListExtensions.<IContainer, Iterable<IEObjectDescription>>map(
           _visibleContainers, _function);
   return Iterables.<IEObjectDescription>concat(_map);
 }
コード例 #10
0
 protected List<AbstractElement> _contentsAsList(final CompoundElement it) {
   EList<AbstractElement> _elements = it.getElements();
   final Function1<AbstractElement, List<AbstractElement>> _function =
       new Function1<AbstractElement, List<AbstractElement>>() {
         @Override
         public List<AbstractElement> apply(final AbstractElement it) {
           return GrammarAccessExtensions.this.contentsAsList(it);
         }
       };
   List<List<AbstractElement>> _map =
       ListExtensions.<AbstractElement, List<AbstractElement>>map(_elements, _function);
   Iterable<AbstractElement> _flatten = Iterables.<AbstractElement>concat(_map);
   return IterableExtensions.<AbstractElement>toList(_flatten);
 }
コード例 #11
0
ファイル: HoverService.java プロジェクト: ghaith/xtext
 protected String addIconDivs(final IImageDescription it, final String nameHtml) {
   String _switchResult = null;
   boolean _matched = false;
   if (it instanceof SimpleImageDescription) {
     _matched = true;
     String _imageID = ((SimpleImageDescription) it).getImageID();
     String _plus = (_imageID + "-icon");
     _switchResult = this.surroundWithDiv(nameHtml, _plus);
   }
   if (!_matched) {
     if (it instanceof AlternativeImageDescription) {
       _matched = true;
       List<String> _imageIDs = ((AlternativeImageDescription) it).getImageIDs();
       final Function1<String, String> _function =
           new Function1<String, String>() {
             @Override
             public String apply(final String it) {
               return (it + "-icon");
             }
           };
       List<String> _map = ListExtensions.<String, String>map(_imageIDs, _function);
       _switchResult =
           this.surroundWithDiv(
               nameHtml, ((String[]) Conversions.unwrapArray(_map, String.class)));
     }
   }
   if (!_matched) {
     if (it instanceof DecoratedImageDescription) {
       _matched = true;
       List<IImageDescription> _decorators = ((DecoratedImageDescription) it).getDecorators();
       IImageDescription _baseImage = ((DecoratedImageDescription) it).getBaseImage();
       Iterable<IImageDescription> _plus =
           Iterables.<IImageDescription>concat(
               _decorators,
               Collections.<IImageDescription>unmodifiableList(
                   CollectionLiterals.<IImageDescription>newArrayList(_baseImage)));
       final Function2<String, IImageDescription, String> _function =
           new Function2<String, IImageDescription, String>() {
             @Override
             public String apply(final String $0, final IImageDescription $1) {
               return HoverService.this.addIconDivs($1, $0);
             }
           };
       _switchResult =
           IterableExtensions.<IImageDescription, String>fold(_plus, nameHtml, _function);
     }
   }
   return _switchResult;
 }
コード例 #12
0
ファイル: GitExtensions.java プロジェクト: joergreichert/xDoc
 public Set<String> apply() {
   EList<EClassifier> _eClassifiers = XbasePackage.eINSTANCE.getEClassifiers();
   final Function1<EClassifier, String> _function =
       new Function1<EClassifier, String>() {
         public String apply(final EClassifier it) {
           String _name = it.getName();
           return _name;
         }
       };
   List<String> _map = ListExtensions.<EClassifier, String>map(_eClassifiers, _function);
   EList<EClassifier> _eClassifiers_1 = XtypePackage.eINSTANCE.getEClassifiers();
   final Function1<EClassifier, String> _function_1 =
       new Function1<EClassifier, String>() {
         public String apply(final EClassifier it) {
           String _name = it.getName();
           return _name;
         }
       };
   List<String> _map_1 =
       ListExtensions.<EClassifier, String>map(_eClassifiers_1, _function_1);
   Iterable<String> _plus = Iterables.<String>concat(_map, _map_1);
   Set<String> _set = IterableExtensions.<String>toSet(_plus);
   return _set;
 }
コード例 #13
0
 public boolean isCalled(final AbstractRule rule, final Grammar grammar) {
   boolean _xblockexpression = false;
   {
     final List<AbstractRule> allRules = GrammarUtil.allRules(grammar);
     boolean _or = false;
     int _indexOf = allRules.indexOf(rule);
     boolean _equals = (_indexOf == 0);
     if (_equals) {
       _or = true;
     } else {
       final Function1<AbstractRule, List<EObject>> _function =
           new Function1<AbstractRule, List<EObject>>() {
             @Override
             public List<EObject> apply(final AbstractRule it) {
               return EcoreUtil2.eAllContentsAsList(it);
             }
           };
       List<List<EObject>> _map =
           ListExtensions.<AbstractRule, List<EObject>>map(allRules, _function);
       Iterable<EObject> _flatten = Iterables.<EObject>concat(_map);
       Iterable<RuleCall> _filter = Iterables.<RuleCall>filter(_flatten, RuleCall.class);
       final Function1<RuleCall, Boolean> _function_1 =
           new Function1<RuleCall, Boolean>() {
             @Override
             public Boolean apply(final RuleCall ruleCall) {
               AbstractRule _rule = ruleCall.getRule();
               return Boolean.valueOf((!Objects.equal(_rule, null)));
             }
           };
       Iterable<RuleCall> _filter_1 = IterableExtensions.<RuleCall>filter(_filter, _function_1);
       final Function1<RuleCall, AbstractRule> _function_2 =
           new Function1<RuleCall, AbstractRule>() {
             @Override
             public AbstractRule apply(final RuleCall ruleCall) {
               return ruleCall.getRule();
             }
           };
       Iterable<AbstractRule> _map_1 =
           IterableExtensions.<RuleCall, AbstractRule>map(_filter_1, _function_2);
       List<AbstractRule> _list = IterableExtensions.<AbstractRule>toList(_map_1);
       boolean _contains = _list.contains(rule);
       _or = _contains;
     }
     _xblockexpression = _or;
   }
   return _xblockexpression;
 }
コード例 #14
0
 protected List<? extends PsiElement> getOriginalElements(final PsiElement element) {
   if ((element instanceof PsiNameIdentifierOwner)) {
     PsiElement _nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier();
     return this.getOriginalElements(_nameIdentifier);
   }
   List<? extends PsiElement> _originalElements = this.traceProvider.getOriginalElements(element);
   final Function1<PsiElement, PsiNamedElement> _function =
       new Function1<PsiElement, PsiNamedElement>() {
         @Override
         public PsiNamedElement apply(final PsiElement it) {
           return PsiTreeUtil.<PsiNamedElement>getParentOfType(it, PsiNamedElement.class, false);
         }
       };
   List<PsiNamedElement> _map = ListExtensions.map(_originalElements, _function);
   Iterable<PsiNamedElement> _filterNull = IterableExtensions.<PsiNamedElement>filterNull(_map);
   Set<PsiNamedElement> _set = IterableExtensions.<PsiNamedElement>toSet(_filterNull);
   final List<PsiNamedElement> result = IterableExtensions.<PsiNamedElement>toList(_set);
   return result;
 }
コード例 #15
0
 protected String root(final EObject xtendClass) {
   final XtendFile specFile =
       EcoreUtil2.<XtendFile>getContainerOfType(xtendClass, XtendFile.class);
   final String packageName = specFile.getPackage();
   boolean _equals = Objects.equal(packageName, null);
   if (_equals) {
     return "";
   }
   final String[] fragments = packageName.split("\\.");
   final Function1<String, String> _function =
       new Function1<String, String>() {
         public String apply(final String s) {
           return "../";
         }
       };
   final List<String> path =
       ListExtensions.<String, String>map(
           ((List<String>) Conversions.doWrapArray(fragments)), _function);
   return IterableExtensions.join(path, "");
 }
コード例 #16
0
 protected Iterable<FindUsagesHandler> getSecondaryHandlers(final PsiElement element) {
   List<? extends PsiElement> _secondaryElements = this.getSecondaryElements(element);
   final Function1<PsiElement, FindUsagesHandler> _function =
       new Function1<PsiElement, FindUsagesHandler>() {
         @Override
         public FindUsagesHandler apply(final PsiElement it) {
           return GeneratedSourceAwareUsagesHandlerFactory.this.delegateFindUsagesHandler(it);
         }
       };
   List<FindUsagesHandler> _map = ListExtensions.map(_secondaryElements, _function);
   final Function1<FindUsagesHandler, Boolean> _function_1 =
       new Function1<FindUsagesHandler, Boolean>() {
         @Override
         public Boolean apply(final FindUsagesHandler it) {
           boolean _isNullHandler =
               GeneratedSourceAwareUsagesHandlerFactory.this.isNullHandler(it);
           return Boolean.valueOf((!_isNullHandler));
         }
       };
   return IterableExtensions.<FindUsagesHandler>filter(_map, _function_1);
 }
コード例 #17
0
ファイル: SpeADLValidator.java プロジェクト: victornoel/may
 @Check
 public void checkBound(final Part ci) {
   AbstractComponent _abstractComponent = this._speADLUtils.abstractComponent(ci);
   Iterable<RequiredPort> _allRequires = this._speADLUtils.getAllRequires(_abstractComponent);
   final Set<RequiredPort> toBind = IterableExtensions.<RequiredPort>toSet(_allRequires);
   EList<Binding> _bindings = ci.getBindings();
   final Function1<Binding, RequiredPort> _function =
       new Function1<Binding, RequiredPort>() {
         public RequiredPort apply(final Binding it) {
           return it.getFrom();
         }
       };
   List<RequiredPort> _map = ListExtensions.<Binding, RequiredPort>map(_bindings, _function);
   final Set<RequiredPort> bound = IterableExtensions.<RequiredPort>toSet(_map);
   toBind.removeAll(bound);
   boolean _isEmpty = toBind.isEmpty();
   boolean _not = (!_isEmpty);
   if (_not) {
     this.error(
         "Missing bindings for required ports", SpeadlPackage.Literals.CONTENT_ELEMENT__NAME);
   }
 }
コード例 #18
0
 protected List<AbstractElement> _contentsAsList(final UnorderedGroup it) {
   ArrayList<AbstractElement> _xblockexpression = null;
   {
     final ArrayList<AbstractElement> result =
         CollectionLiterals.<AbstractElement>newArrayList(it);
     EList<AbstractElement> _elements = it.getElements();
     final Function1<AbstractElement, List<AbstractElement>> _function =
         new Function1<AbstractElement, List<AbstractElement>>() {
           @Override
           public List<AbstractElement> apply(final AbstractElement it) {
             return GrammarAccessExtensions.this.contentsAsList(it);
           }
         };
     List<List<AbstractElement>> _map =
         ListExtensions.<AbstractElement, List<AbstractElement>>map(_elements, _function);
     Iterable<AbstractElement> _flatten = Iterables.<AbstractElement>concat(_map);
     List<AbstractElement> _list = IterableExtensions.<AbstractElement>toList(_flatten);
     Iterables.<AbstractElement>addAll(result, _list);
     _xblockexpression = result;
   }
   return _xblockexpression;
 }
コード例 #19
0
 public String parametersSignature(final WMethodDeclaration m) {
   String _xifexpression = null;
   EList<WParameter> _parameters = m.getParameters();
   boolean _isEmpty = _parameters.isEmpty();
   if (_isEmpty) {
     _xifexpression = "";
   } else {
     EList<WParameter> _parameters_1 = m.getParameters();
     final Function1<WParameter, String> _function =
         new Function1<WParameter, String>() {
           public String apply(final WParameter it) {
             WollokType _type = ObjectLiteralWollokType.this.type(it);
             return _type.getName();
           }
         };
     List<String> _map = ListExtensions.<WParameter, String>map(_parameters_1, _function);
     String _join = IterableExtensions.join(_map, ", ");
     String _plus = ("(" + _join);
     _xifexpression = (_plus + ")");
   }
   return _xifexpression;
 }
コード例 #20
0
 @Override
 public CharSequence getFileContents(final SerializerGenFileNames.GenFileName filename) {
   String _xblockexpression = null;
   {
     String _packageName = filename.getPackageName();
     String _fileHeader = this._naming.fileHeader();
     final JavaFile file = new JavaFile(_packageName, _fileHeader);
     file.imported(org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer.class);
     file.imported(RuleCall.class);
     file.imported(INode.class);
     file.imported(ISyntacticSequencerPDAProvider.ISynTransition.class);
     file.imported(Inject.class);
     file.imported(IGrammarAccess.class);
     file.imported(EObject.class);
     file.imported(List.class);
     file.imported(GrammarAlias.AbstractElementAlias.class);
     String _annotationImports = this._naming.annotationImports();
     boolean _notEquals = (!Objects.equal(_annotationImports, null));
     if (_notEquals) {
       String _annotationImports_1 = this._naming.annotationImports();
       String[] _split = _annotationImports_1.split("(import)|;");
       final Function1<String, String> _function =
           new Function1<String, String>() {
             @Override
             public String apply(final String it) {
               return it.trim();
             }
           };
       List<String> _map =
           ListExtensions.<String, String>map(
               ((List<String>) Conversions.doWrapArray(_split)), _function);
       final Function1<String, Boolean> _function_1 =
           new Function1<String, Boolean>() {
             @Override
             public Boolean apply(final String it) {
               boolean _isEmpty = it.isEmpty();
               return Boolean.valueOf((!_isEmpty));
             }
           };
       Iterable<String> _filter = IterableExtensions.<String>filter(_map, _function_1);
       final Procedure1<String> _function_2 =
           new Procedure1<String>() {
             @Override
             public void apply(final String it) {
               file.imported(it);
             }
           };
       IterableExtensions.<String>forEach(_filter, _function_2);
     }
     String _xifexpression = null;
     boolean _isAbstract = filename.isAbstract();
     if (_isAbstract) {
       _xifexpression = "abstract ";
     } else {
       _xifexpression = "";
     }
     final String _abstract = _xifexpression;
     StringConcatenation _builder = new StringConcatenation();
     String _classAnnotations = this._naming.classAnnotations();
     _builder.append(_classAnnotations, "");
     _builder.append("@SuppressWarnings(\"all\")");
     _builder.newLineIfNotEmpty();
     _builder.append("public ");
     _builder.append(_abstract, "");
     _builder.append("class ");
     String _simpleName = filename.getSimpleName();
     _builder.append(_simpleName, "");
     _builder.append(" extends AbstractSyntacticSequencer {");
     _builder.newLineIfNotEmpty();
     _builder.newLine();
     _builder.append("\t");
     _builder.append("protected ");
     String _gaFQName = this.grammarAccess.gaFQName(this.grammar);
     String _imported = file.imported(_gaFQName);
     _builder.append(_imported, "\t");
     _builder.append(" grammarAccess;");
     _builder.newLineIfNotEmpty();
     {
       List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax =
           this.util.getAllAmbiguousTransitionsBySyntax();
       for (final EqualAmbiguousTransitions group : _allAmbiguousTransitionsBySyntax) {
         _builder.append("\t");
         _builder.append("protected ");
         String _imported_1 =
             file.imported(
                 "org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias");
         _builder.append(_imported_1, "\t");
         _builder.append(" match_");
         String _identifyer = group.getIdentifyer();
         _builder.append(_identifyer, "\t");
         _builder.append(";");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("@Inject");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("protected void init(IGrammarAccess access) {");
     _builder.newLine();
     _builder.append("\t\t");
     _builder.append("grammarAccess = (");
     String _gaFQName_1 = this.grammarAccess.gaFQName(this.grammar);
     String _imported_2 = file.imported(_gaFQName_1);
     _builder.append(_imported_2, "\t\t");
     _builder.append(") access;");
     _builder.newLineIfNotEmpty();
     {
       List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_1 =
           this.util.getAllAmbiguousTransitionsBySyntax();
       for (final EqualAmbiguousTransitions group_1 : _allAmbiguousTransitionsBySyntax_1) {
         _builder.append("\t\t");
         _builder.append("match_");
         String _identifyer_1 = group_1.getIdentifyer();
         _builder.append(_identifyer_1, "\t\t");
         _builder.append(" = ");
         GrammarAlias.AbstractElementAlias _elementAlias = group_1.getElementAlias();
         String _elementAliasToConstructor =
             this.util.elementAliasToConstructor(_elementAlias, file);
         _builder.append(_elementAliasToConstructor, "\t\t");
         _builder.append(";");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.append("}");
     _builder.newLine();
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t");
     CharSequence _genGetUnassignedRuleCallTokens = this.genGetUnassignedRuleCallTokens(file);
     _builder.append(_genGetUnassignedRuleCallTokens, "\t");
     _builder.newLineIfNotEmpty();
     _builder.append("\t");
     _builder.newLine();
     {
       List<AbstractRule> _unassignedCalledTokenRules = this.unassignedCalledTokenRules();
       boolean _hasElements = false;
       for (final AbstractRule rule : _unassignedCalledTokenRules) {
         if (!_hasElements) {
           _hasElements = true;
         } else {
           _builder.appendImmediate("\n", "\t");
         }
         _builder.append("\t");
         boolean _isAbstract_1 = filename.isAbstract();
         String _genGetUnassignedRuleCallToken =
             this.genGetUnassignedRuleCallToken(file, rule, _isAbstract_1);
         _builder.append(_genGetUnassignedRuleCallToken, "\t");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t");
     CharSequence _genEmitUnassignedTokens = this.genEmitUnassignedTokens(file);
     _builder.append(_genEmitUnassignedTokens, "\t");
     _builder.newLineIfNotEmpty();
     _builder.newLine();
     {
       List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_2 =
           this.util.getAllAmbiguousTransitionsBySyntax();
       for (final EqualAmbiguousTransitions group_2 : _allAmbiguousTransitionsBySyntax_2) {
         _builder.append("\t");
         _builder.append("/**");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* Ambiguous syntax:");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*     ");
         GrammarAlias.AbstractElementAlias _elementAlias_1 = group_2.getElementAlias();
         String _string = _elementAlias_1.toString();
         String _replace = _string.replace("\n", "\n *     ");
         _builder.append(_replace, "\t ");
         _builder.newLineIfNotEmpty();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* This ambiguous syntax occurs at:");
         _builder.newLine();
         {
           List<ISyntacticSequencerPDAProvider.ISynTransition> _transitions =
               group_2.getTransitions();
           final Function1<ISyntacticSequencerPDAProvider.ISynTransition, String> _function_3 =
               new Function1<ISyntacticSequencerPDAProvider.ISynTransition, String>() {
                 @Override
                 public String apply(final ISyntacticSequencerPDAProvider.ISynTransition it) {
                   String _ambiguityInsideTransition = group_2.ambiguityInsideTransition(it);
                   return _ambiguityInsideTransition.trim();
                 }
               };
           List<String> _map_1 =
               ListExtensions.<ISyntacticSequencerPDAProvider.ISynTransition, String>map(
                   _transitions, _function_3);
           Set<String> _set = IterableExtensions.<String>toSet(_map_1);
           List<String> _sort = IterableExtensions.<String>sort(_set);
           for (final String trans : _sort) {
             _builder.append("\t");
             _builder.append(" ");
             _builder.append("*     ");
             String _string_1 = trans.toString();
             String _replace_1 = _string_1.replace("\n", "\n*     ");
             _builder.append(_replace_1, "\t ");
             _builder.newLineIfNotEmpty();
           }
         }
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*/");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("protected void emit_");
         String _identifyer_2 = group_2.getIdentifyer();
         _builder.append(_identifyer_2, "\t");
         _builder.append("(EObject semanticObject, ");
         String _imported_3 = file.imported(ISyntacticSequencerPDAProvider.ISynNavigable.class);
         _builder.append(_imported_3, "\t");
         _builder.append(" transition, List<INode> nodes) {");
         _builder.newLineIfNotEmpty();
         _builder.append("\t");
         _builder.append("\t");
         _builder.append("acceptNodes(transition, nodes);");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("}");
         _builder.newLine();
         _builder.append("\t");
         _builder.newLine();
       }
     }
     _builder.append("}");
     _builder.newLine();
     String _string_2 = _builder.toString();
     file.body = _string_2;
     _xblockexpression = file.toString();
   }
   return _xblockexpression;
 }
コード例 #21
0
ファイル: SpeADLValidator.java プロジェクト: victornoel/may
 @Check
 public void checkContentElementDuplicates(final AbstractComponent ac) {
   final HashSet<Pair<ContentElement, String>> names =
       CollectionLiterals.<Pair<ContentElement, String>>newHashSet();
   EList<Part> _parts = ac.getParts();
   final Function1<Part, Pair<ContentElement, String>> _function =
       new Function1<Part, Pair<ContentElement, String>>() {
         public Pair<ContentElement, String> apply(final Part it) {
           String _name = it.getName();
           return Pair.<ContentElement, String>of(((ContentElement) it), _name);
         }
       };
   List<Pair<ContentElement, String>> _map =
       ListExtensions.<Part, Pair<ContentElement, String>>map(_parts, _function);
   Iterables.<Pair<ContentElement, String>>addAll(names, _map);
   EList<ProvidedPort> _provides = ac.getProvides();
   final Function1<ProvidedPort, Pair<ContentElement, String>> _function_1 =
       new Function1<ProvidedPort, Pair<ContentElement, String>>() {
         public Pair<ContentElement, String> apply(final ProvidedPort it) {
           String _name = it.getName();
           return Pair.<ContentElement, String>of(((ContentElement) it), _name);
         }
       };
   List<Pair<ContentElement, String>> _map_1 =
       ListExtensions.<ProvidedPort, Pair<ContentElement, String>>map(_provides, _function_1);
   Iterables.<Pair<ContentElement, String>>addAll(names, _map_1);
   EList<RequiredPort> _requires = ac.getRequires();
   final Function1<RequiredPort, Pair<ContentElement, String>> _function_2 =
       new Function1<RequiredPort, Pair<ContentElement, String>>() {
         public Pair<ContentElement, String> apply(final RequiredPort it) {
           String _name = it.getName();
           return Pair.<ContentElement, String>of(((ContentElement) it), _name);
         }
       };
   List<Pair<ContentElement, String>> _map_2 =
       ListExtensions.<RequiredPort, Pair<ContentElement, String>>map(_requires, _function_2);
   Iterables.<Pair<ContentElement, String>>addAll(names, _map_2);
   final HashSet<Pair<ContentElement, String>> superNames =
       CollectionLiterals.<Pair<ContentElement, String>>newHashSet();
   Iterable<RequiredPort> _allRequires = this._speADLUtils.getAllRequires(ac);
   final Function1<RequiredPort, Pair<ContentElement, String>> _function_3 =
       new Function1<RequiredPort, Pair<ContentElement, String>>() {
         public Pair<ContentElement, String> apply(final RequiredPort it) {
           String _name = it.getName();
           return Pair.<ContentElement, String>of(((ContentElement) it), _name);
         }
       };
   Iterable<Pair<ContentElement, String>> _map_3 =
       IterableExtensions.<RequiredPort, Pair<ContentElement, String>>map(
           _allRequires, _function_3);
   Iterables.<Pair<ContentElement, String>>addAll(superNames, _map_3);
   Iterable<ProvidedPort> _allProvides = this._speADLUtils.getAllProvides(ac);
   final Function1<ProvidedPort, Pair<ContentElement, String>> _function_4 =
       new Function1<ProvidedPort, Pair<ContentElement, String>>() {
         public Pair<ContentElement, String> apply(final ProvidedPort it) {
           String _name = it.getName();
           return Pair.<ContentElement, String>of(((ContentElement) it), _name);
         }
       };
   Iterable<Pair<ContentElement, String>> _map_4 =
       IterableExtensions.<ProvidedPort, Pair<ContentElement, String>>map(
           _allProvides, _function_4);
   Iterables.<Pair<ContentElement, String>>addAll(superNames, _map_4);
   final Procedure2<Pair<ContentElement, String>, Integer> _function_5 =
       new Procedure2<Pair<ContentElement, String>, Integer>() {
         public void apply(final Pair<ContentElement, String> pn, final Integer index) {
           final ContentElement p = pn.getKey();
           final Function1<Pair<ContentElement, String>, Boolean> _function =
               new Function1<Pair<ContentElement, String>, Boolean>() {
                 public Boolean apply(final Pair<ContentElement, String> it) {
                   boolean _and = false;
                   ContentElement _key = it.getKey();
                   boolean _tripleNotEquals = (_key != p);
                   if (!_tripleNotEquals) {
                     _and = false;
                   } else {
                     String _value = it.getValue();
                     String _name = p.getName();
                     boolean _equals = Objects.equal(_value, _name);
                     _and = _equals;
                   }
                   return Boolean.valueOf(_and);
                 }
               };
           boolean _exists =
               IterableExtensions.<Pair<ContentElement, String>>exists(names, _function);
           if (_exists) {
             String _name = p.getName();
             String _plus = ("Duplicate name \'" + _name);
             String _plus_1 = (_plus + "\'");
             SpeADLValidator.this.error(_plus_1, p, SpeadlPackage.Literals.CONTENT_ELEMENT__NAME);
           } else {
             final Function1<Pair<ContentElement, String>, Boolean> _function_1 =
                 new Function1<Pair<ContentElement, String>, Boolean>() {
                   public Boolean apply(final Pair<ContentElement, String> it) {
                     boolean _and = false;
                     ContentElement _key = it.getKey();
                     boolean _tripleNotEquals = (_key != p);
                     if (!_tripleNotEquals) {
                       _and = false;
                     } else {
                       String _value = it.getValue();
                       String _name = p.getName();
                       boolean _equals = Objects.equal(_value, _name);
                       _and = _equals;
                     }
                     return Boolean.valueOf(_and);
                   }
                 };
             boolean _exists_1 =
                 IterableExtensions.<Pair<ContentElement, String>>exists(superNames, _function_1);
             if (_exists_1) {
               String _name_1 = p.getName();
               String _plus_2 = ("Duplicate name \'" + _name_1);
               String _plus_3 = (_plus_2 + "\' in specialized component");
               SpeADLValidator.this.error(
                   _plus_3, p, SpeadlPackage.Literals.CONTENT_ELEMENT__NAME);
             }
           }
         }
       };
   IterableExtensions.<Pair<ContentElement, String>>forEach(names, _function_5);
 }
コード例 #22
0
ファイル: HtmlExtensions.java プロジェクト: dschulten/xtext
 protected CharSequence internalToHtmlParagraph(final Object it) {
   CharSequence _switchResult = null;
   boolean matched = false;
   if (!matched) {
     if (it instanceof TextOrMarkup) {
       final TextOrMarkup _textOrMarkup = (TextOrMarkup) it;
       matched = true;
       EList<EObject> _contents = _textOrMarkup.getContents();
       CharSequence _internalToHtmlParagraph = this.internalToHtmlParagraph(_contents);
       _switchResult = _internalToHtmlParagraph;
     }
   }
   if (!matched) {
     if (it instanceof List) {
       final List<EObject> _list = (List<EObject>) it;
       matched = true;
       final Function1<EObject, CharSequence> _function =
           new Function1<EObject, CharSequence>() {
             public CharSequence apply(final EObject it) {
               CharSequence _internalToHtmlParagraph =
                   HtmlExtensions.this.internalToHtmlParagraph(it);
               return _internalToHtmlParagraph;
             }
           };
       List<CharSequence> _map = ListExtensions.<EObject, CharSequence>map(_list, _function);
       String _join = IterableExtensions.join(_map);
       _switchResult = _join;
     }
   }
   if (!matched) {
     if (it instanceof TextPart) {
       final TextPart _textPart = (TextPart) it;
       matched = true;
       String _xblockexpression = null;
       {
         String _text = _textPart.getText();
         String _quote = this.quote(_text);
         String[] _split = _quote.split("^\\s*$");
         final String[] paragraphs = _split;
         final String[] _typeConverted_paragraphs = (String[]) paragraphs;
         final Function1<String, Boolean> _function =
             new Function1<String, Boolean>() {
               public Boolean apply(final String it) {
                 boolean _isEmpty = it.isEmpty();
                 boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
                 return Boolean.valueOf(_operator_not);
               }
             };
         Iterable<String> _filter =
             IterableExtensions.<String>filter(
                 ((Iterable<String>) Conversions.doWrapArray(_typeConverted_paragraphs)),
                 _function);
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("</p>");
         _builder.newLine();
         _builder.append("<p>");
         _builder.newLine();
         String _join = IterableExtensions.join(_filter, _builder);
         _xblockexpression = (_join);
       }
       _switchResult = _xblockexpression;
     }
   }
   if (!matched) {
     if (it instanceof CodeBlock) {
       final CodeBlock _codeBlock = (CodeBlock) it;
       matched = true;
       CharSequence _internalToHtml = this.internalToHtml(_codeBlock, true);
       _switchResult = _internalToHtml;
     }
   }
   if (!matched) {
     CharSequence _html = this.toHtml(it);
     _switchResult = _html;
   }
   return _switchResult;
 }
コード例 #23
0
 public void clean() {
   if ((!this.enabled)) {
     return;
   }
   final ArrayList<String> directories = CollectionLiterals.<String>newArrayList();
   List<? extends ISubProjectConfig> _enabledProjects = this.config.getEnabledProjects();
   final Function1<ISubProjectConfig, IXtextGeneratorFileSystemAccess> _function =
       new Function1<ISubProjectConfig, IXtextGeneratorFileSystemAccess>() {
         @Override
         public IXtextGeneratorFileSystemAccess apply(final ISubProjectConfig it) {
           return it.getSrcGen();
         }
       };
   List<IXtextGeneratorFileSystemAccess> _map = ListExtensions.map(_enabledProjects, _function);
   IRuntimeProjectConfig _runtime = this.config.getRuntime();
   IXtextGeneratorFileSystemAccess _ecoreModel = _runtime.getEcoreModel();
   Iterable<IXtextGeneratorFileSystemAccess> _plus =
       Iterables.<IXtextGeneratorFileSystemAccess>concat(
           _map,
           Collections.<IXtextGeneratorFileSystemAccess>unmodifiableList(
               CollectionLiterals.<IXtextGeneratorFileSystemAccess>newArrayList(_ecoreModel)));
   Iterable<IXtextGeneratorFileSystemAccess> _filterNull =
       IterableExtensions.<IXtextGeneratorFileSystemAccess>filterNull(_plus);
   final Function1<IXtextGeneratorFileSystemAccess, String> _function_1 =
       new Function1<IXtextGeneratorFileSystemAccess, String>() {
         @Override
         public String apply(final IXtextGeneratorFileSystemAccess it) {
           return it.getPath();
         }
       };
   Iterable<String> _map_1 =
       IterableExtensions.<IXtextGeneratorFileSystemAccess, String>map(_filterNull, _function_1);
   final Function1<String, Boolean> _function_2 =
       new Function1<String, Boolean>() {
         @Override
         public Boolean apply(final String it) {
           File _file = new File(it);
           return Boolean.valueOf(_file.isDirectory());
         }
       };
   Iterable<String> _filter = IterableExtensions.<String>filter(_map_1, _function_2);
   Iterables.<String>addAll(directories, _filter);
   Iterables.<String>addAll(directories, this.extraDirectories);
   final DirectoryCleaner delegate = new DirectoryCleaner();
   delegate.setUseDefaultExcludes(this.useDefaultExcludes);
   final Procedure1<String> _function_3 =
       new Procedure1<String>() {
         @Override
         public void apply(final String it) {
           delegate.addExclude(it);
         }
       };
   IterableExtensions.<String>forEach(this.excludes, _function_3);
   final Procedure1<String> _function_4 =
       new Procedure1<String>() {
         @Override
         public void apply(final String it) {
           try {
             delegate.cleanFolder(it);
           } catch (Throwable _e) {
             throw Exceptions.sneakyThrow(_e);
           }
         }
       };
   IterableExtensions.<String>forEach(directories, _function_4);
 }
コード例 #24
0
 public CharSequence rule(final EClassifier it) {
   CharSequence _switchResult = null;
   boolean _matched = false;
   if (!_matched) {
     if (it instanceof EClass) {
       _matched = true;
       StringConcatenation _builder = new StringConcatenation();
       String _concreteRuleName = Ecore2XtextExtensions.concreteRuleName(((EClass) it));
       _builder.append(_concreteRuleName, "");
       _builder.append(" returns ");
       String _fqn = Ecore2XtextExtensions.fqn(it);
       _builder.append(_fqn, "");
       _builder.append(":");
       _builder.newLineIfNotEmpty();
       {
         boolean _onlyOptionalFeatures = Ecore2XtextExtensions.onlyOptionalFeatures(((EClass) it));
         if (_onlyOptionalFeatures) {
           _builder.append("\t");
           _builder.append("{");
           String _fqn_1 = Ecore2XtextExtensions.fqn(it);
           _builder.append(_fqn_1, "\t");
           _builder.append("}");
           _builder.newLineIfNotEmpty();
         }
       }
       {
         Iterable<EStructuralFeature> _prefixFeatures =
             Ecore2XtextExtensions.prefixFeatures(((EClass) it));
         for (final EStructuralFeature strF : _prefixFeatures) {
           _builder.append("\t");
           CharSequence _assigment = this.assigment(strF);
           _builder.append(_assigment, "\t");
           _builder.newLineIfNotEmpty();
         }
       }
       _builder.append("\t");
       _builder.append("\'");
       String _name = ((EClass) it).getName();
       _builder.append(_name, "\t");
       _builder.append("\'");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       CharSequence _idAssignment = this.idAssignment(((EClass) it));
       _builder.append(_idAssignment, "\t");
       {
         Iterable<EStructuralFeature> _inlinedFeatures =
             Ecore2XtextExtensions.inlinedFeatures(((EClass) it));
         boolean _isEmpty = IterableExtensions.isEmpty(_inlinedFeatures);
         boolean _not = (!_isEmpty);
         if (_not) {
           _builder.newLineIfNotEmpty();
           _builder.append("\t");
           _builder.append("\'{\'");
           _builder.newLine();
           {
             Iterable<EAttribute> _allAttributes =
                 Ecore2XtextExtensions.allAttributes(((EClass) it));
             for (final EAttribute attr : _allAttributes) {
               _builder.append("\t");
               _builder.append("\t");
               CharSequence _assigment_1 = this.assigment(attr);
               _builder.append(_assigment_1, "\t\t");
               _builder.newLineIfNotEmpty();
             }
           }
           {
             Iterable<EReference> _allCrossReferences =
                 Ecore2XtextExtensions.allCrossReferences(((EClass) it));
             for (final EReference ref : _allCrossReferences) {
               _builder.append("\t");
               _builder.append("\t");
               CharSequence _assigment_2 = this.assigment(ref);
               _builder.append(_assigment_2, "\t\t");
               _builder.newLineIfNotEmpty();
             }
           }
           {
             Iterable<EReference> _allContainmentReferences =
                 Ecore2XtextExtensions.allContainmentReferences(((EClass) it));
             for (final EReference conti : _allContainmentReferences) {
               _builder.append("\t");
               _builder.append("\t");
               CharSequence _assigment_3 = this.assigment(conti);
               _builder.append(_assigment_3, "\t\t");
               _builder.newLineIfNotEmpty();
             }
           }
           _builder.append("\t");
           _builder.append("\'}\'");
         }
       }
       _builder.append(";");
       _builder.newLineIfNotEmpty();
       _switchResult = _builder;
     }
   }
   if (!_matched) {
     if (it instanceof EDataType) {
       _matched = true;
       CharSequence _xifexpression = null;
       boolean _isSerializable = ((EDataType) it).isSerializable();
       if (_isSerializable) {
         StringConcatenation _builder = new StringConcatenation();
         String _uniqueName = UniqueNameUtil.uniqueName(it);
         _builder.append(_uniqueName, "");
         _builder.append(" returns ");
         String _fqn = Ecore2XtextExtensions.fqn(it);
         _builder.append(_fqn, "");
         _builder.append(":");
         _builder.newLineIfNotEmpty();
         _builder.append("\t");
         String _dataTypeRuleBody = Ecore2XtextExtensions.dataTypeRuleBody(((EDataType) it));
         _builder.append(_dataTypeRuleBody, "\t");
         _builder.append(";");
         _builder.newLineIfNotEmpty();
         _xifexpression = _builder;
       }
       _switchResult = _xifexpression;
     }
   }
   if (!_matched) {
     if (it instanceof EEnum) {
       _matched = true;
       StringConcatenation _builder = new StringConcatenation();
       _builder.append("enum ");
       String _name = ((EEnum) it).getName();
       String _quoteIfNeccesary = Ecore2XtextExtensions.quoteIfNeccesary(_name);
       _builder.append(_quoteIfNeccesary, "");
       _builder.append(" returns ");
       String _fqn = Ecore2XtextExtensions.fqn(it);
       _builder.append(_fqn, "");
       _builder.append(":");
       _builder.newLineIfNotEmpty();
       _builder.append("\t\t\t\t");
       EList<EEnumLiteral> _eLiterals = ((EEnum) it).getELiterals();
       final Function1<EEnumLiteral, String> _function =
           new Function1<EEnumLiteral, String>() {
             public String apply(final EEnumLiteral it) {
               String _name = it.getName();
               String _plus = (_name + " = \'");
               String _name_1 = it.getName();
               String _plus_1 = (_plus + _name_1);
               String _plus_2 = (_plus_1 + "\'");
               return _plus_2;
             }
           };
       List<String> _map = ListExtensions.<EEnumLiteral, String>map(_eLiterals, _function);
       String _join = IterableExtensions.join(_map, " | ");
       _builder.append(_join, "\t\t\t\t");
       _builder.append(";");
       _switchResult = _builder;
     }
   }
   if (!_matched) {
     String _plus = ("No rule template for " + it);
     IllegalStateException _illegalStateException = new IllegalStateException(_plus);
     throw _illegalStateException;
   }
   return _switchResult;
 }