提交 bf634bf4 编写于 作者: R Ramya Achutha Rao

Renaming utilties for clarity

上级 76392ae9
......@@ -6,7 +6,7 @@
import * as vscode from 'vscode';
import { expand } from '@emmetio/expand-abbreviation';
import { Node, HtmlNode, Rule } from 'EmmetNode';
import { getNode, getInnerRange, getMappingForIncludedLanguages, parse, validate } from './util';
import { getNode, getInnerRange, getMappingForIncludedLanguages, parseDocument, validate } from './util';
import { getExpandOptions, extractAbbreviation, isStyleSheet, isAbbreviationValid, getEmmetMode } from 'vscode-emmet-helper';
interface ExpandAbbreviationInput {
......@@ -88,7 +88,7 @@ export function expandAbbreviation(args) {
const editor = vscode.window.activeTextEditor;
let rootNode = parse(editor.document);
let rootNode = parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -5,7 +5,7 @@
import * as vscode from 'vscode';
import { HtmlNode } from 'EmmetNode';
import { getNode, parse, validate } from './util';
import { getNode, parseDocument, validate } from './util';
export function balanceOut() {
balance(true);
......@@ -21,7 +21,7 @@ function balance(out: boolean) {
return;
}
let rootNode = <HtmlNode>parse(editor.document);
let rootNode = <HtmlNode>parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
import { HtmlNode } from 'EmmetNode';
import { doComplete, isStyleSheet, getEmmetMode } from 'vscode-emmet-helper';
import { isValidLocationForEmmetAbbreviation } from './abbreviationActions';
import { getNode, getInnerRange, getMappingForIncludedLanguages, parse, getEmmetConfiguration } from './util';
import { getNode, getInnerRange, getMappingForIncludedLanguages, parseDocument, getEmmetConfiguration } from './util';
export class DefaultCompletionItemProvider implements vscode.CompletionItemProvider {
......@@ -61,7 +61,7 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
if (!syntax) {
return syntax;
}
let rootNode = parse(document, false);
let rootNode = parseDocument(document, false);
if (!rootNode) {
return;
}
......
......@@ -5,7 +5,7 @@
import * as vscode from 'vscode';
import { HtmlNode } from 'EmmetNode';
import { getNode, parse, validate } from './util';
import { getNode, parseDocument, validate } from './util';
export function matchTag() {
let editor = vscode.window.activeTextEditor;
......@@ -13,7 +13,7 @@ export function matchTag() {
return;
}
let rootNode = <HtmlNode>parse(editor.document);
let rootNode = <HtmlNode>parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -5,7 +5,7 @@
import * as vscode from 'vscode';
import { Node } from 'EmmetNode';
import { getNode, parse, validate } from './util';
import { getNode, parseDocument, validate } from './util';
export function mergeLines() {
let editor = vscode.window.activeTextEditor;
......@@ -13,7 +13,7 @@ export function mergeLines() {
return;
}
let rootNode = parse(editor.document);
let rootNode = parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Range, window, TextEditor } from 'vscode';
import { getCssProperty, getCssPropertyNode } from './util';
import { getCssPropertyFromRule, getCssPropertyFromDocument } from './util';
import { Property, Rule } from 'EmmetNode';
const vendorPrefixes = ['-webkit-', '-moz-', '-ms-', '-o-', ''];
......@@ -16,7 +16,7 @@ export function reflectCssValue() {
return;
}
let node = getCssPropertyNode(editor, editor.selection.active);
let node = getCssPropertyFromDocument(editor, editor.selection.active);
if (!node) {
return;
}
......@@ -45,7 +45,7 @@ function updateCSSNode(editor: TextEditor, property: Property) {
if (prefix === currentPrefix) {
return;
}
let vendorProperty = getCssProperty(rule, prefix + propertyName);
let vendorProperty = getCssPropertyFromRule(rule, prefix + propertyName);
if (vendorProperty) {
builder.replace(new Range(vendorProperty.valueToken.start, vendorProperty.valueToken.end), propertyValue);
}
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { parse, validate, getNode } from './util';
import { parseDocument, validate, getNode } from './util';
import { HtmlNode } from 'EmmetNode';
export function removeTag() {
......@@ -13,7 +13,7 @@ export function removeTag() {
return;
}
let rootNode = <HtmlNode>parse(editor.document);
let rootNode = <HtmlNode>parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { validate, parse } from './util';
import { validate, parseDocument } from './util';
import { nextItemHTML, prevItemHTML } from './selectItemHTML';
import { nextItemStylesheet, prevItemStylesheet } from './selectItemStylesheet';
import { isStyleSheet } from 'vscode-emmet-helper';
......@@ -27,7 +27,7 @@ export function fetchSelectItem(direction: string): void {
prevItem = prevItemHTML;
}
let rootNode = parse(editor.document);
let rootNode = parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -5,7 +5,7 @@
import * as vscode from 'vscode';
import Node from '@emmetio/node';
import { getNode, parse, validate } from './util';
import { getNode, parseDocument, validate } from './util';
export function splitJoinTag() {
let editor = vscode.window.activeTextEditor;
......@@ -13,7 +13,7 @@ export function splitJoinTag() {
return;
}
let rootNode = parse(editor.document);
let rootNode = parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { getNodesInBetween, getNode, parse } from './util';
import { getNodesInBetween, getNode, parseDocument } from './util';
import { Node, Stylesheet } from 'EmmetNode';
import { isStyleSheet } from 'vscode-emmet-helper';
......@@ -34,7 +34,7 @@ export function toggleComment() {
endComment = endCommentHTML;
}
let rootNode = parse(editor.document);
let rootNode = parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -11,7 +11,7 @@ import { TextEditor, Range, Position, window } from 'vscode';
import * as path from 'path';
import { getImageSize } from './imageSizeHelper';
import { isStyleSheet } from 'vscode-emmet-helper';
import { parse, getNode, iterateCSSToken, getCssProperty } from './util';
import { parseDocument, getNode, iterateCSSToken, getCssPropertyFromRule } from './util';
import { HtmlNode, CssToken, HtmlToken, Attribute, Property } from 'EmmetNode';
import { locateFile } from './locateFile';
import parseStylesheet from '@emmetio/css-parser';
......@@ -59,7 +59,7 @@ function updateImageSizeHTML(editor: TextEditor) {
function updateImageSizeStyleTag(editor: TextEditor) {
let getPropertyInsiderStyleTag = (editor) => {
const rootNode = parse(editor.document);
const rootNode = parseDocument(editor.document);
const currentNode = <HtmlNode>getNode(rootNode, editor.selection.active);
if (currentNode && currentNode.name === 'style'
&& currentNode.open.end.isBefore(editor.selection.active)
......@@ -109,7 +109,7 @@ function updateImageSizeCSS(editor: TextEditor, fetchNode: (editor) => Property)
* @return {HtmlNode}
*/
function getImageHTMLNode(editor: TextEditor): HtmlNode {
const rootNode = parse(editor.document);
const rootNode = parseDocument(editor.document);
const node = <HtmlNode>getNode(rootNode, editor.selection.active, true);
return node && node.name.toLowerCase() === 'img' ? node : null;
......@@ -122,7 +122,7 @@ function getImageHTMLNode(editor: TextEditor): HtmlNode {
* @return {Property}
*/
function getImageCSSNode(editor: TextEditor): Property {
const rootNode = parse(editor.document);
const rootNode = parseDocument(editor.document);
const node = getNode(rootNode, editor.selection.active, true);
return node && node.type === 'property' ? <Property>node : null;
}
......@@ -213,8 +213,8 @@ function updateHTMLTag(editor: TextEditor, node: HtmlNode, width: number, height
*/
function updateCSSNode(editor: TextEditor, srcProp: Property, width: number, height: number) {
const rule = srcProp.parent;
const widthProp = getCssProperty(rule, 'width');
const heightProp = getCssProperty(rule, 'height');
const widthProp = getCssPropertyFromRule(rule, 'width');
const heightProp = getCssPropertyFromRule(rule, 'height');
// Detect formatting
const separator = srcProp.separator || ': ';
......
......@@ -5,14 +5,14 @@
import * as vscode from 'vscode';
import { HtmlNode } from 'EmmetNode';
import { getNode, parse, validate } from './util';
import { getNode, parseDocument, validate } from './util';
export function updateTag(tagName: string): Thenable<boolean> {
let editor = vscode.window.activeTextEditor;
if (!validate(false)) {
return;
}
let rootNode = <HtmlNode>parse(editor.document);
let rootNode = <HtmlNode>parseDocument(editor.document);
if (!rootNode) {
return;
}
......
......@@ -63,7 +63,7 @@ export function getMappingForIncludedLanguages(): any {
* Parses the given document using emmet parsing modules
* @param document
*/
export function parse(document: vscode.TextDocument, showError: boolean = true): Node {
export function parseDocument(document: vscode.TextDocument, showError: boolean = true): Node {
let parseContent = isStyleSheet(document.languageId) ? parseStylesheet : parse;
let rootNode: Node;
try {
......@@ -283,7 +283,7 @@ export function iterateCSSToken(token: CssToken, fn) {
* @param {String} name
* @return {Property}
*/
export function getCssProperty(rule, name): Property {
export function getCssPropertyFromRule(rule, name): Property {
return rule.children.find(node => node.type === 'property' && node.name === name);
}
......@@ -293,8 +293,8 @@ export function getCssProperty(rule, name): Property {
* @param {TextEditor} editor
* @return {Property}
*/
export function getCssPropertyNode(editor: vscode.TextEditor, position: vscode.Position): Property {
const rootNode = this.parse(editor.document);
export function getCssPropertyFromDocument(editor: vscode.TextEditor, position: vscode.Position): Property {
const rootNode = parseDocument(editor.document);
const node = getNode(rootNode, position);
if (isStyleSheet(editor.document.languageId)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册