예제 #1
0
 protected ICrossReferenceDescription getCrossReferenceDescription() {
   ICrossReferenceDescription _xblockexpression = null;
   {
     ASTNode _node = this.myElement.getNode();
     IElementType _elementType = _node.getElementType();
     EObject _grammarElement = ((IGrammarAwareElementType) _elementType).getGrammarElement();
     final CrossReference crossReference = ((CrossReference) _grammarElement);
     BaseXtextFile _xtextFile = this.myElement.getXtextFile();
     ASTNode _node_1 = this.myElement.getNode();
     final INode node = _xtextFile.getINode(_node_1);
     final EObject context = NodeModelUtils.findActualSemanticObjectFor(node);
     final EReference reference = GrammarUtil.getReference(crossReference);
     List<INode> _findNodesForFeature = NodeModelUtils.findNodesForFeature(context, reference);
     Iterable<Pair<Integer, INode>> _indexed =
         IterableExtensions.<INode>indexed(_findNodesForFeature);
     final Function1<Pair<Integer, INode>, Boolean> _function =
         new Function1<Pair<Integer, INode>, Boolean>() {
           @Override
           public Boolean apply(final Pair<Integer, INode> it) {
             boolean _and = false;
             INode _value = it.getValue();
             int _totalOffset = _value.getTotalOffset();
             int _totalOffset_1 = node.getTotalOffset();
             boolean _lessEqualsThan = (_totalOffset <= _totalOffset_1);
             if (!_lessEqualsThan) {
               _and = false;
             } else {
               INode _value_1 = it.getValue();
               int _totalEndOffset = _value_1.getTotalEndOffset();
               int _totalEndOffset_1 = node.getTotalEndOffset();
               boolean _greaterEqualsThan = (_totalEndOffset >= _totalEndOffset_1);
               _and = _greaterEqualsThan;
             }
             return Boolean.valueOf(_and);
           }
         };
     Pair<Integer, INode> _findFirst =
         IterableExtensions.<Pair<Integer, INode>>findFirst(_indexed, _function);
     Integer _key = null;
     if (_findFirst != null) {
       _key = _findFirst.getKey();
     }
     final Integer index = _key;
     _xblockexpression = this.crossReferenceDescriptionProvider.get(context, reference, index);
   }
   return _xblockexpression;
 }
예제 #2
0
 @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));
 }