vscode-tmgrammar-test
Advanced tools
Comparing version 0.0.8 to 0.0.9
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
import { ScopeAssertion, TestCaseMetadata, GrammarTestCase } from './model'; | ||
export declare function parseScopeAssertion(testCaseLineNumber: number, commentLength: number, as: String): ScopeAssertion | void; | ||
export declare function parseScopeAssertion(testCaseLineNumber: number, commentLength: number, as: String): ScopeAssertion[]; | ||
export declare function parseHeader(as: string[]): TestCaseMetadata; | ||
export declare function parseGrammarTestCase(str: string): GrammarTestCase; |
"use strict"; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// import { start } from 'repl'; | ||
var leftArrowAssertRegex = /^\s*<([~]*)([-]+)((?:\s*\w[-\w.]*)*)(?:\s*-)?((?:\s*\w[-\w.]*)*)\s*$/; | ||
var upArrowAssertRegex = /^\s*(\^+)((?:\s*\w[-\w.]*)*)(?:\s*-)?((?:\s*\w[-\w.]*)*)\s*$/; | ||
var upArrowAssertRegex = /^\s*((?:(?:\^+)\s*)+)((?:\s*\w[-\w.]*)*)(?:\s*-)?((?:\s*\w[-\w.]*)*)\s*$/; | ||
function parseScopeAssertion(testCaseLineNumber, commentLength, as) { | ||
var s = as.slice(commentLength); | ||
var upArrowMatch = upArrowAssertRegex.exec(s); | ||
if (upArrowMatch !== null) { | ||
var _ = upArrowMatch[0], arrows = upArrowMatch[1], _a = upArrowMatch[2], scopes = _a === void 0 ? "" : _a, _b = upArrowMatch[3], exclusions = _b === void 0 ? "" : _b; | ||
var startIdx = commentLength + s.indexOf("^"); | ||
if (scopes === "" && exclusions === "") { | ||
return undefined; | ||
if (s.trim().startsWith('^')) { | ||
var upArrowMatch = upArrowAssertRegex.exec(s); | ||
if (upArrowMatch !== null) { | ||
var _a = upArrowMatch[2], scopes = _a === void 0 ? "" : _a, _b = upArrowMatch[3], exclusions = _b === void 0 ? "" : _b; | ||
if (scopes === "" && exclusions === "") { | ||
throw new Error("Inalid assertion at line " + testCaseLineNumber + ":\n" + as + "\n Missing both required and prohibited scopes"); | ||
} | ||
else { | ||
var result = []; | ||
var startIdx = s.indexOf("^"); | ||
while (startIdx !== -1) { | ||
var endIndx = startIdx; | ||
while (s[endIndx + 1] === '^') { | ||
endIndx++; | ||
} | ||
result.push({ | ||
from: commentLength + startIdx, | ||
to: commentLength + endIndx + 1, | ||
scopes: scopes.split(/\s+/).filter(function (x) { return x; }), | ||
exclude: exclusions.split(/\s+/).filter(function (x) { return x; }) | ||
}); | ||
startIdx = s.indexOf("^", endIndx + 1); | ||
} | ||
return result; | ||
} | ||
} | ||
else { | ||
return { | ||
from: startIdx, | ||
to: startIdx + arrows.length, | ||
scopes: scopes.split(/\s+/).filter(function (x) { return x; }), | ||
exclude: exclusions.split(/\s+/).filter(function (x) { return x; }) | ||
}; | ||
throw new Error("Inalid assertion at line " + testCaseLineNumber + ":\n" + as + "\n"); | ||
} | ||
@@ -27,14 +49,14 @@ } | ||
if (scopes === "" && exclusions === "") { | ||
return undefined; | ||
throw new Error("Inalid assertion at line " + testCaseLineNumber + ":\n" + as + "\n Missing both required and prohibited scopes"); | ||
} | ||
else { | ||
return { | ||
from: tildas.length, | ||
to: tildas.length + dashes.length, | ||
scopes: scopes.split(/\s+/).filter(function (x) { return x; }), | ||
exclude: exclusions.split(/\s+/).filter(function (x) { return x; }) | ||
}; | ||
return [{ | ||
from: tildas.length, | ||
to: tildas.length + dashes.length, | ||
scopes: scopes.split(/\s+/).filter(function (x) { return x; }), | ||
exclude: exclusions.split(/\s+/).filter(function (x) { return x; }) | ||
}]; | ||
} | ||
} | ||
return undefined; | ||
return []; | ||
} | ||
@@ -87,6 +109,4 @@ exports.parseScopeAssertion = parseScopeAssertion; | ||
if (s.startsWith(commentToken)) { | ||
var a = parseScopeAssertion(tcLineNumber, commentToken.length, s); | ||
if (a !== undefined) { | ||
currentLineAssertion.scopeAssertions.push(a); | ||
} | ||
var as = parseScopeAssertion(tcLineNumber, commentToken.length, s); | ||
currentLineAssertion.scopeAssertions = __spreadArrays(currentLineAssertion.scopeAssertions, as); | ||
// if (!skipComments) { | ||
@@ -93,0 +113,0 @@ // source.push(s) |
{ | ||
"name": "vscode-tmgrammar-test", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Test helper for VSCode textmate grammars", | ||
@@ -35,20 +35,20 @@ "main": "./dist/src/index.js", | ||
"devDependencies": { | ||
"@types/chai": "^4.1.7", | ||
"@types/chai": "^4.2.11", | ||
"@types/diff": "^4.0.2", | ||
"@types/glob": "^7.1.1", | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "^12.0.0", | ||
"@types/diff": "^4.0.2", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.12.37", | ||
"chai": "^4.2.0", | ||
"tslint": "^5.16.0", | ||
"typescript": "^3.4.5", | ||
"ts-node": "^8.1.0", | ||
"mocha": "^6.2.0" | ||
"mocha": "^6.2.3", | ||
"ts-node": "^8.9.0", | ||
"tslint": "^5.20.1", | ||
"typescript": "^3.8.3" | ||
}, | ||
"dependencies": { | ||
"chalk": "^2.4.2", | ||
"commander": "^2.20.0", | ||
"diff": "^4.0.1", | ||
"glob": "^7.1.4", | ||
"commander": "^2.20.3", | ||
"diff": "^4.0.2", | ||
"glob": "^7.1.6", | ||
"vscode-textmate": "^4.1.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
93410
1099
Updatedcommander@^2.20.3
Updateddiff@^4.0.2
Updatedglob@^7.1.6