code: public void collectImports(final XtextResource state, final ITextRegion selectedRegion, final ImportsAcceptor acceptor) {
      ICompositeNode rootNode = state.getParseResult().getRootNode();
      final EObject selectedSemanticObj = this.findActualSemanticObjectFor(rootNode, selectedRegion);
      final Iterable<ILeafNode> contentsIterator = NodeModelUtils.findActualNodeFor(selectedSemanticObj).getLeafNodes();
      for (final ILeafNode node : contentsIterator) {
        {
          final ITextRegion nodeRegion = node.getTotalTextRegion();
          boolean _contains = selectedRegion.contains(nodeRegion);
          if (_contains) {
            final EObject semanticElement = node.getSemanticElement();
            if ((semanticElement != null)) {
              this.visit(semanticElement, NodeModelUtils.findActualNodeFor(semanticElement), acceptor);
            }
          }
          if ((node.isHidden() && this.grammarAccess.getML_COMMENTRule().equals(node.getGrammarElement()))) {
            this.addJavaDocReferences(node, selectedRegion, acceptor);
          }
        }
      }
    }
docs: Collects import declarations in XtextResource for the given range (selectedRegion)