From 0ee00cbd2a13141ad4d6a506b937094386a5ac24 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Thu, 29 Jun 2017 18:35:53 -0700 Subject: [PATCH] Emmet Error handling Fixes #29897 --- extensions/emmet/npm-shrinkwrap.json | 6 ++-- extensions/emmet/package.json | 2 +- extensions/emmet/src/abbreviationActions.ts | 24 +++++++++------ extensions/emmet/src/balance.ts | 15 +++------- .../emmet/src/defaultCompletionProvider.ts | 14 ++++----- extensions/emmet/src/matchTag.ts | 13 ++++---- extensions/emmet/src/mergeLines.ts | 22 +++++++------- extensions/emmet/src/removeTag.ts | 29 +++++++++++++----- extensions/emmet/src/selectItem.ts | 12 ++------ extensions/emmet/src/selectItemHTML.ts | 8 +++++ extensions/emmet/src/selectItemStylesheet.ts | 7 ++++- extensions/emmet/src/splitJoinTag.ts | 22 +++++++------- extensions/emmet/src/toggleComment.ts | 11 ++----- extensions/emmet/src/updateTag.ts | 20 ++++++------- extensions/emmet/src/util.ts | 30 +++++++++++-------- 15 files changed, 129 insertions(+), 106 deletions(-) diff --git a/extensions/emmet/npm-shrinkwrap.json b/extensions/emmet/npm-shrinkwrap.json index feafae301ac44..4fe675cd7a475 100644 --- a/extensions/emmet/npm-shrinkwrap.json +++ b/extensions/emmet/npm-shrinkwrap.json @@ -118,9 +118,9 @@ "resolved": "https://registry.npmjs.org/@emmetio/variable-resolver/-/variable-resolver-0.2.1.tgz" }, "vscode-emmet-helper": { - "version": "0.0.16", - "from": "vscode-emmet-helper@0.0.16", - "resolved": "https://registry.npmjs.org/vscode-emmet-helper/-/vscode-emmet-helper-0.0.16.tgz" + "version": "0.0.17", + "from": "vscode-emmet-helper@0.0.17", + "resolved": "https://registry.npmjs.org/vscode-emmet-helper/-/vscode-emmet-helper-0.0.17.tgz" } } } diff --git a/extensions/emmet/package.json b/extensions/emmet/package.json index 9a40fa5f46191..676c2586b5685 100644 --- a/extensions/emmet/package.json +++ b/extensions/emmet/package.json @@ -73,6 +73,6 @@ "@emmetio/html-matcher": "^0.3.1", "@emmetio/css-parser": "^0.3.0", "@emmetio/math-expression": "^0.1.1", - "vscode-emmet-helper":"0.0.16" + "vscode-emmet-helper":"0.0.17" } } \ No newline at end of file diff --git a/extensions/emmet/src/abbreviationActions.ts b/extensions/emmet/src/abbreviationActions.ts index 3af0719f9584f..1d940dbd66b97 100644 --- a/extensions/emmet/src/abbreviationActions.ts +++ b/extensions/emmet/src/abbreviationActions.ts @@ -5,12 +5,9 @@ import * as vscode from 'vscode'; import { expand } from '@emmetio/expand-abbreviation'; -import parseStylesheet from '@emmetio/css-parser'; -import parse from '@emmetio/html-matcher'; import { Node, HtmlNode, Rule } from 'EmmetNode'; -import { getNode, getInnerRange, getMappingForIncludedLanguages } from './util'; +import { getNode, getInnerRange, getMappingForIncludedLanguages, parse, validate } from './util'; import { getExpandOptions, extractAbbreviation, isStyleSheet, isAbbreviationValid, getEmmetMode } from 'vscode-emmet-helper'; -import { DocumentStreamReader } from './bufferStream'; interface ExpandAbbreviationInput { syntax: string; @@ -22,7 +19,7 @@ interface ExpandAbbreviationInput { export function wrapWithAbbreviation(args) { const syntax = getSyntaxFromArgs(args); - if (!syntax) { + if (!syntax || !validate()) { return; } @@ -79,14 +76,16 @@ export function wrapWithAbbreviation(args) { export function expandAbbreviation(args) { const syntax = getSyntaxFromArgs(args); - if (!syntax) { + if (!syntax || !validate()) { return; } const editor = vscode.window.activeTextEditor; - let parseContent = isStyleSheet(syntax) ? parseStylesheet : parse; - let rootNode: Node = parseContent(new DocumentStreamReader(editor.document)); + let rootNode = parse(editor.document); + if (!rootNode) { + return; + } let abbreviationList: ExpandAbbreviationInput[] = []; let firstAbbreviation: string; @@ -100,6 +99,7 @@ export function expandAbbreviation(args) { [rangeToReplace, abbreviation] = extractAbbreviation(editor.document, position); } if (!isAbbreviationValid(syntax, abbreviation)) { + vscode.window.showErrorMessage('Emmet: Invalid abbreviation'); return; } @@ -193,7 +193,13 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex */ function expandAbbr(input: ExpandAbbreviationInput, newLine: string): string { // Expand the abbreviation - let expandedText = expand(input.abbreviation, getExpandOptions(input.syntax, input.textToWrap)); + let expandedText; + try { + expandedText = expand(input.abbreviation, getExpandOptions(input.syntax, input.textToWrap)); + } catch (e) { + vscode.window.showErrorMessage('Failed to expand abbreviation'); + } + if (!expandedText) { return; } diff --git a/extensions/emmet/src/balance.ts b/extensions/emmet/src/balance.ts index 8158be1b43bad..164b4cb0c3753 100644 --- a/extensions/emmet/src/balance.ts +++ b/extensions/emmet/src/balance.ts @@ -4,11 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import parse from '@emmetio/html-matcher'; import { HtmlNode } from 'EmmetNode'; -import { DocumentStreamReader } from './bufferStream'; -import { isStyleSheet } from 'vscode-emmet-helper'; -import { getNode } from './util'; +import { getNode, parse, validate } from './util'; export function balanceOut() { balance(true); @@ -20,20 +17,16 @@ export function balanceIn() { function balance(out: boolean) { let editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor is active'); + if (!validate(false)) { return; } - if (isStyleSheet(editor.document.languageId)) { - return; - } - let getRangeFunction = out ? getRangeToBalanceOut : getRangeToBalanceIn; - let rootNode: HtmlNode = parse(new DocumentStreamReader(editor.document)); + let rootNode = parse(editor.document); if (!rootNode) { return; } + let getRangeFunction = out ? getRangeToBalanceOut : getRangeToBalanceIn; let newSelections: vscode.Selection[] = []; editor.selections.forEach(selection => { let range = getRangeFunction(editor.document, selection, rootNode); diff --git a/extensions/emmet/src/defaultCompletionProvider.ts b/extensions/emmet/src/defaultCompletionProvider.ts index 1118fdf42f667..0ce04b7653ec9 100644 --- a/extensions/emmet/src/defaultCompletionProvider.ts +++ b/extensions/emmet/src/defaultCompletionProvider.ts @@ -4,13 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import parseStylesheet from '@emmetio/css-parser'; -import parse from '@emmetio/html-matcher'; -import { Node, HtmlNode } from 'EmmetNode'; -import { DocumentStreamReader } from './bufferStream'; +import { HtmlNode } from 'EmmetNode'; import { EmmetCompletionItemProvider, isStyleSheet, getEmmetMode } from 'vscode-emmet-helper'; import { isValidLocationForEmmetAbbreviation } from './abbreviationActions'; -import { getNode, getInnerRange, getMappingForIncludedLanguages } from './util'; +import { getNode, getInnerRange, getMappingForIncludedLanguages, parse } from './util'; export class DefaultCompletionItemProvider implements vscode.CompletionItemProvider { @@ -46,8 +43,11 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi if (!syntax) { return syntax; } - let parseContent = isStyleSheet(syntax) ? parseStylesheet : parse; - let rootNode: Node = parseContent(new DocumentStreamReader(document)); + let rootNode = parse(document, false); + if (!rootNode) { + return; + } + let currentNode = getNode(rootNode, position); if (!isStyleSheet(syntax)) { diff --git a/extensions/emmet/src/matchTag.ts b/extensions/emmet/src/matchTag.ts index 686bded335bea..52222a157c9fa 100644 --- a/extensions/emmet/src/matchTag.ts +++ b/extensions/emmet/src/matchTag.ts @@ -4,22 +4,20 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import parse from '@emmetio/html-matcher'; import { HtmlNode } from 'EmmetNode'; -import { DocumentStreamReader } from './bufferStream'; -import { getNode } from './util'; +import { getNode, parse, validate } from './util'; export function matchTag() { let editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor is active'); + if (!validate(false)) { return; } - let rootNode: HtmlNode = parse(new DocumentStreamReader(editor.document)); + let rootNode = parse(editor.document); if (!rootNode) { return; } + let updatedSelections = []; editor.selections.forEach(selection => { let updatedSelection = getUpdatedSelections(editor, selection.start, rootNode); @@ -35,6 +33,9 @@ export function matchTag() { function getUpdatedSelections(editor: vscode.TextEditor, position: vscode.Position, rootNode: HtmlNode): vscode.Selection { let currentNode = getNode(rootNode, position, true); + if (!currentNode) { + return; + } // If no closing tag or cursor is between open and close tag, then no-op if (!currentNode.close || (position.isAfter(currentNode.open.end) && position.isBefore(currentNode.close.start))) { diff --git a/extensions/emmet/src/mergeLines.ts b/extensions/emmet/src/mergeLines.ts index cc60826f10d6a..927db50d97196 100644 --- a/extensions/emmet/src/mergeLines.ts +++ b/extensions/emmet/src/mergeLines.ts @@ -4,30 +4,26 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import parse from '@emmetio/html-matcher'; import { Node } from 'EmmetNode'; -import { DocumentStreamReader } from './bufferStream'; -import { isStyleSheet } from 'vscode-emmet-helper'; -import { getNode } from './util'; +import { getNode, parse, validate } from './util'; export function mergeLines() { let editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor is active'); - return; - } - if (isStyleSheet(editor.document.languageId)) { + if (!validate(false)) { return; } - let rootNode: Node = parse(new DocumentStreamReader(editor.document)); + let rootNode = parse(editor.document); if (!rootNode) { return; } + editor.edit(editBuilder => { editor.selections.reverse().forEach(selection => { let [rangeToReplace, textToReplaceWith] = getRangesToReplace(editor.document, selection, rootNode); - editBuilder.replace(rangeToReplace, textToReplaceWith); + if (rangeToReplace && textToReplaceWith) { + editBuilder.replace(rangeToReplace, textToReplaceWith); + } }); }); } @@ -43,6 +39,10 @@ function getRangesToReplace(document: vscode.TextDocument, selection: vscode.Sel endNodeToUpdate = getNode(rootNode, selection.end, true); } + if (!startNodeToUpdate || !endNodeToUpdate) { + return [null, null]; + } + let rangeToReplace = new vscode.Range(startNodeToUpdate.start, endNodeToUpdate.end); let textToReplaceWith = document.getText(rangeToReplace).replace(/\r\n|\n/g, '').replace(/>\s*<'); diff --git a/extensions/emmet/src/removeTag.ts b/extensions/emmet/src/removeTag.ts index 1987fba5066f4..4594db4202298 100644 --- a/extensions/emmet/src/removeTag.ts +++ b/extensions/emmet/src/removeTag.ts @@ -4,12 +4,17 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { getOpenCloseRange } from './util'; +import { parse, validate, getNode } from './util'; +import { HtmlNode } from 'EmmetNode'; export function removeTag() { let editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor is active'); + if (!validate(false)) { + return; + } + + let rootNode = parse(editor.document); + if (!rootNode) { return; } @@ -20,7 +25,7 @@ export function removeTag() { let rangesToRemove = []; editor.selections.reverse().forEach(selection => { - rangesToRemove = rangesToRemove.concat(getRangeToRemove(editor, selection, indentInSpaces)); + rangesToRemove = rangesToRemove.concat(getRangeToRemove(editor, rootNode, selection, indentInSpaces)); }); editor.edit(editBuilder => { @@ -30,8 +35,19 @@ export function removeTag() { }); } -function getRangeToRemove(editor: vscode.TextEditor, selection: vscode.Selection, indentInSpaces: string): vscode.Range[] { - let [openRange, closeRange] = getOpenCloseRange(editor.document, selection.start); +function getRangeToRemove(editor: vscode.TextEditor, rootNode: HtmlNode, selection: vscode.Selection, indentInSpaces: string): vscode.Range[] { + + let nodeToUpdate = getNode(rootNode, selection.start); + if (!nodeToUpdate) { + return []; + } + + let openRange = new vscode.Range(nodeToUpdate.open.start, nodeToUpdate.open.end); + let closeRange = null; + if (nodeToUpdate.close) { + closeRange = new vscode.Range(nodeToUpdate.close.start, nodeToUpdate.close.end); + } + if (!openRange.contains(selection.start) && !closeRange.contains(selection.start)) { return []; } @@ -50,4 +66,3 @@ function getRangeToRemove(editor: vscode.TextEditor, selection: vscode.Selection return ranges; } - diff --git a/extensions/emmet/src/selectItem.ts b/extensions/emmet/src/selectItem.ts index df63432a108fe..d15675d59a402 100644 --- a/extensions/emmet/src/selectItem.ts +++ b/extensions/emmet/src/selectItem.ts @@ -4,13 +4,9 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { validate } from './util'; +import { validate, parse } from './util'; import { nextItemHTML, prevItemHTML } from './selectItemHTML'; import { nextItemStylesheet, prevItemStylesheet } from './selectItemStylesheet'; -import parseStylesheet from '@emmetio/css-parser'; -import parse from '@emmetio/html-matcher'; -import { Node } from 'EmmetNode'; -import { DocumentStreamReader } from './bufferStream'; import { isStyleSheet } from 'vscode-emmet-helper'; @@ -22,22 +18,20 @@ export function fetchSelectItem(direction: string): void { let nextItem; let prevItem; - let parseContent; if (isStyleSheet(editor.document.languageId)) { nextItem = nextItemStylesheet; prevItem = prevItemStylesheet; - parseContent = parseStylesheet; } else { nextItem = nextItemHTML; prevItem = prevItemHTML; - parseContent = parse; } - let rootNode: Node = parseContent(new DocumentStreamReader(editor.document)); + let rootNode = parse(editor.document); if (!rootNode) { return; } + let newSelections: vscode.Selection[] = []; editor.selections.forEach(selection => { const selectionStart = selection.isReversed ? selection.active : selection.anchor; diff --git a/extensions/emmet/src/selectItemHTML.ts b/extensions/emmet/src/selectItemHTML.ts index 1c1445a6be609..1b234e2f34944 100644 --- a/extensions/emmet/src/selectItemHTML.ts +++ b/extensions/emmet/src/selectItemHTML.ts @@ -11,6 +11,10 @@ export function nextItemHTML(selectionStart: vscode.Position, selectionEnd: vsco let currentNode = getNode(rootNode, selectionEnd); let nextNode: HtmlNode; + if (!currentNode) { + return; + } + if (currentNode.type !== 'comment') { // If cursor is in the tag name, select tag if (selectionEnd.isBefore(currentNode.open.start.translate(0, currentNode.name.length))) { @@ -53,6 +57,10 @@ export function prevItemHTML(selectionStart: vscode.Position, selectionEnd: vsco let currentNode = getNode(rootNode, selectionStart); let prevNode: HtmlNode; + if (!currentNode) { + return; + } + if (currentNode.type !== 'comment' && selectionStart.translate(0, -1).isAfter(currentNode.open.start)) { if (selectionStart.isBefore(currentNode.open.end) || !currentNode.firstChild) { diff --git a/extensions/emmet/src/selectItemStylesheet.ts b/extensions/emmet/src/selectItemStylesheet.ts index 537af3cfd32e9..09f0d6103a9cd 100644 --- a/extensions/emmet/src/selectItemStylesheet.ts +++ b/extensions/emmet/src/selectItemStylesheet.ts @@ -12,7 +12,9 @@ export function nextItemStylesheet(startOffset: vscode.Position, endOffset: vsco if (!currentNode) { currentNode = rootNode; } - + if (!currentNode) { + return; + } // Full property is selected, so select full property value next if (currentNode.type === 'property' && startOffset.isEqual(currentNode.start) && endOffset.isEqual(currentNode.end)) { return getSelectionFromProperty(currentNode, editor.document, startOffset, endOffset, true, 'next'); @@ -53,6 +55,9 @@ export function prevItemStylesheet(startOffset: vscode.Position, endOffset: vsco if (!currentNode) { currentNode = rootNode; } + if (!currentNode) { + return; + } // Full property value is selected, so select the whole property next if (currentNode.type === 'property' && startOffset.isEqual((currentNode).valueToken.start) && endOffset.isEqual((currentNode).valueToken.end)) { diff --git a/extensions/emmet/src/splitJoinTag.ts b/extensions/emmet/src/splitJoinTag.ts index 9fdb892a752ee..cdbed5a572e88 100644 --- a/extensions/emmet/src/splitJoinTag.ts +++ b/extensions/emmet/src/splitJoinTag.ts @@ -4,30 +4,26 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import parse from '@emmetio/html-matcher'; import Node from '@emmetio/node'; -import { DocumentStreamReader } from './bufferStream'; -import { isStyleSheet } from 'vscode-emmet-helper'; -import { getNode } from './util'; +import { getNode, parse, validate } from './util'; export function splitJoinTag() { let editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor is active'); - return; - } - if (isStyleSheet(editor.document.languageId)) { + if (!validate(false)) { return; } - let rootNode: Node = parse(new DocumentStreamReader(editor.document)); + let rootNode = parse(editor.document); if (!rootNode) { return; } + editor.edit(editBuilder => { editor.selections.reverse().forEach(selection => { let [rangeToReplace, textToReplaceWith] = getRangesToReplace(editor.document, selection, rootNode); - editBuilder.replace(rangeToReplace, textToReplaceWith); + if (rangeToReplace && textToReplaceWith) { + editBuilder.replace(rangeToReplace, textToReplaceWith); + } }); }); } @@ -37,6 +33,10 @@ function getRangesToReplace(document: vscode.TextDocument, selection: vscode.Sel let rangeToReplace: vscode.Range; let textToReplaceWith: string; + if (!nodeToUpdate) { + return [null, null]; + } + if (!nodeToUpdate.close) { // Split Tag let nodeText = document.getText(new vscode.Range(nodeToUpdate.start, nodeToUpdate.end)); diff --git a/extensions/emmet/src/toggleComment.ts b/extensions/emmet/src/toggleComment.ts index e4287a7337fbc..8f9200b96c5a4 100644 --- a/extensions/emmet/src/toggleComment.ts +++ b/extensions/emmet/src/toggleComment.ts @@ -4,11 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { getNodesInBetween, getNode } from './util'; -import parse from '@emmetio/html-matcher'; -import parseStylesheet from '@emmetio/css-parser'; +import { getNodesInBetween, getNode, parse } from './util'; import { Node, Stylesheet } from 'EmmetNode'; -import { DocumentStreamReader } from './bufferStream'; import { isStyleSheet } from 'vscode-emmet-helper'; const startCommentStylesheet = '/*'; @@ -26,24 +23,22 @@ export function toggleComment() { let toggleCommentInternal; let startComment; let endComment; - let parseContent; if (isStyleSheet(editor.document.languageId)) { - parseContent = parseStylesheet; toggleCommentInternal = toggleCommentStylesheet; startComment = startCommentStylesheet; endComment = endCommentStylesheet; } else { - parseContent = parse; toggleCommentInternal = toggleCommentHTML; startComment = startCommentHTML; endComment = endCommentHTML; } - let rootNode = parseContent(new DocumentStreamReader(editor.document)); + let rootNode = parse(editor.document); if (!rootNode) { return; } + editor.edit(editBuilder => { editor.selections.reverse().forEach(selection => { let [rangesToUnComment, rangeToComment] = toggleCommentInternal(editor.document, selection, rootNode); diff --git a/extensions/emmet/src/updateTag.ts b/extensions/emmet/src/updateTag.ts index 9b0d55043b442..c77eb1614058f 100644 --- a/extensions/emmet/src/updateTag.ts +++ b/extensions/emmet/src/updateTag.ts @@ -4,22 +4,19 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import parse from '@emmetio/html-matcher'; import { HtmlNode } from 'EmmetNode'; -import { DocumentStreamReader } from './bufferStream'; -import { getNode } from './util'; +import { getNode, parse, validate } from './util'; export function updateTag(tagName: string) { let editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor is active'); + if (!validate(false)) { return; } - - let rootNode: HtmlNode = parse(new DocumentStreamReader(editor.document)); + let rootNode = parse(editor.document); if (!rootNode) { return; } + let rangesToUpdate = []; editor.selections.reverse().forEach(selection => { rangesToUpdate = rangesToUpdate.concat(getRangesToUpdate(editor, selection, rootNode)); @@ -34,14 +31,17 @@ export function updateTag(tagName: string) { function getRangesToUpdate(editor: vscode.TextEditor, selection: vscode.Selection, rootNode: HtmlNode): vscode.Range[] { let nodeToUpdate = getNode(rootNode, selection.start); + if (!nodeToUpdate) { + return []; + } - let openStart = (nodeToUpdate.open.start).translate(0, 1); + let openStart = nodeToUpdate.open.start.translate(0, 1); let openEnd = openStart.translate(0, nodeToUpdate.name.length); let ranges = [new vscode.Range(openStart, openEnd)]; if (nodeToUpdate.close) { - let closeStart = (nodeToUpdate.close.start).translate(0, 2); - let closeEnd = (nodeToUpdate.close.end).translate(0, -1); + let closeStart = nodeToUpdate.close.start.translate(0, 2); + let closeEnd = nodeToUpdate.close.end.translate(0, -1); ranges.push(new vscode.Range(closeStart, closeEnd)); } return ranges; diff --git a/extensions/emmet/src/util.ts b/extensions/emmet/src/util.ts index 9444dba38442e..bfca96f15fa80 100644 --- a/extensions/emmet/src/util.ts +++ b/extensions/emmet/src/util.ts @@ -5,6 +5,7 @@ import * as vscode from 'vscode'; import parse from '@emmetio/html-matcher'; +import parseStylesheet from '@emmetio/css-parser'; import { Node, HtmlNode } from 'EmmetNode'; import { DocumentStreamReader } from './bufferStream'; import { isStyleSheet } from 'vscode-emmet-helper'; @@ -33,6 +34,7 @@ export const MAPPED_MODES: Object = { 'handlebars': 'html', 'php': 'html' }; + export function validate(allowStylesheet: boolean = true): boolean { let editor = vscode.window.activeTextEditor; if (!editor) { @@ -64,7 +66,22 @@ export function getMappingForIncludedLanguages(): any { return finalMappedModes; } - +/** + * Parses the given document using emmet parsing modules + * @param document + */ +export function parse(document: vscode.TextDocument, showError: boolean = true): Node { + let parseContent = isStyleSheet(document.languageId) ? parseStylesheet : parse; + let rootNode: Node; + try { + rootNode = parseContent(new DocumentStreamReader(document)); + } catch (e) { + if (showError) { + vscode.window.showErrorMessage('Emmet: Failed to parse the file'); + } + } + return rootNode; +} /** * Returns node corresponding to given position in the given root node @@ -104,17 +121,6 @@ export function getInnerRange(currentNode: HtmlNode): vscode.Range { return new vscode.Range(currentNode.open.end, currentNode.close.start); } -export function getOpenCloseRange(document: vscode.TextDocument, position: vscode.Position): [vscode.Range, vscode.Range] { - let rootNode: HtmlNode = parse(new DocumentStreamReader(document)); - let nodeToUpdate = getNode(rootNode, position); - let openRange = new vscode.Range(nodeToUpdate.open.start, nodeToUpdate.open.end); - let closeRange = null; - if (nodeToUpdate.close) { - closeRange = new vscode.Range(nodeToUpdate.close.start, nodeToUpdate.close.end); - } - return [openRange, closeRange]; -} - export function getDeepestNode(node: Node): Node { if (!node || !node.children || node.children.length === 0 || !node.children.find(x => x.type !== 'comment')) { return node;