<commit_before>/* --------------------------------------------------------------------------------------------
 * Copyright (c) <NAME>. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 * ------------------------------------------------------------------------------------------ */
'use strict';

import { TextDocument, Position, Range, TextEdit } from 'vscode-languageserver';
import { DockerHighlight } from './dockerHighlight';

export class DockerRename {

	public rename(document: TextDocument, position: Position, newName: string): TextEdit[] {
		let edits = [];
		let highlighter = new DockerHighlight();
		let highlightRanges = highlighter.computeHighlightRanges(document, position);
		if (highlightRanges.length !== 0) {
			let content = document.getText();
			for (let highlightRange of highlightRanges) {
				let start = document.offsetAt(highlightRange.range.start);
				let end = document.offsetAt(highlightRange.range.end);
				let target = content.substring(start, end);
				if (target.indexOf("${") === 0) {
					let range = Range.create(document.positionAt(start + 2), document.positionAt(end - 1));
					edits.push(TextEdit.replace(range, newName));
				} else if (target.indexOf('$') === 0) {
					let range = Range.create(document.positionAt(start + 1), highlightRange.range.end);
					edits.push(TextEdit.replace(range, newName));
				} else {
					edits.push(TextEdit.replace(highlightRange.range, newName));
				}
			}
		}
		return edits;
	}
}<commit_msg>WIP #51 Remove unnecessary code<commit_after>/* --------------------------------------------------------------------------------------------
 * Copyright (c) <NAME>. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 * ------------------------------------------------------------------------------------------ */
'use strict';

import { TextDocument, Position, Range, TextEdit } from 'vscode-languageserver';
import { DockerHighlight } from './dockerHighlight';

export class DockerRename {

	public rename(document: TextDocument, position: Position, newName: string): TextEdit[] {
		let edits = [];
		let highlighter = new DockerHighlight();
		let highlightRanges = highlighter.computeHighlightRanges(document, position);
		for (let highlightRange of highlightRanges) {
			edits.push(TextEdit.replace(highlightRange.range, newName));
		}
		return edits;
	}
}
{'fraction_non_alphanumeric': 0.2544498381877023, 'fraction_numerical': 0.003236245954692557, 'mean_word_length': 2.2973333333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1415253', 'n_tokens_mistral': 704, 'n_tokens_neox': 607, 'n_words': 171}