<commit_before>use std::iter::successors;

use hir::Semantics;
use ide_db::RootDatabase;
use syntax::{
    algo::{self, skip_trivia_token},
    ast::{self, AstNode, AstToken},
    Direction, NodeOrToken,
    SyntaxKind::{self, *},
    SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, T,
};

use crate::FileRange;

// Feature: Extend Selection
//
// Extends the current selection to the encompassing syntactic construct
// (expression, statement, item, module, etc). It works with multiple cursors.
//
// |===
// | Editor  | Shortcut
//
// | VS Code | kbd:[Ctrl+Shift+→]
// |===
pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
    let sema = Semantics::new(db);
    let src = sema.parse(frange.file_id);
    try_extend_selection(&sema, src.syntax(), frange).unwrap_or(frange.range)
}

fn try_extend_selection(
    sema: &Semantics<RootDatabase>,
    root: &SyntaxNode,<commit_msg>Remove documentation of obsolete extend selection command<commit_after>use std::iter::successors;

use hir::Semantics;
use ide_db::RootDatabase;
use syntax::{
    algo::{self, skip_trivia_token},
    ast::{self, AstNode, AstToken},
    Direction, NodeOrToken,
    SyntaxKind::{self, *},
    SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, T,
};

use crate::FileRange;

// Feature: Expand and Shrink Selection
//
// Extends or shrinks the current selection to the encompassing syntactic construct
// (expression, statement, item, module, etc). It works with multiple cursors.
//
// This is a standard LSP feature and not a protocol extension.
//
// |===
// | Editor  | Shortcut
//
// | VS Code | kbd:[Alt+Shift+→], kbd:[Alt+Shift+←]
// |===
pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
    let sema = Semantics::new(db);
    let src = sema.parse(frange.file_id);
    try_extend_selection(&sema, src.syntax(), frange).unwrap_or(frange.range)
}

fn try_extend_selection(
    sema: &Semantics<RootDatabase>,
    root: &SyntaxNode,
{'fraction_non_alphanumeric': 0.14763092269326683, 'fraction_numerical': 0.0, 'mean_word_length': 4.48087431693989, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5505896', 'n_tokens_mistral': 674, 'n_tokens_neox': 662, 'n_words': 167}