-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
524 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
coverage | ||
.vscode-test | ||
*.vsix | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"printWidth": 100, | ||
"singleQuote": false, | ||
"arrowParens": "always" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
//Formats the namespace so we can use it for search | ||
const getNamespace = (text, editor) => { | ||
const namespace = text.includes(":") ? text.split(":")[0] : ""; | ||
text = text.includes(":") ? text.split(":")[1] : text; | ||
|
||
let xmlns = editor.document | ||
.getText() | ||
.split("\n") | ||
.find((line) => { | ||
return namespace === "" | ||
? line.includes("xmlns=") | ||
: line.includes("xmlns") && line.includes(namespace); | ||
}) | ||
.trim(); | ||
|
||
xmlns = xmlns.includes(">") ? xmlns.slice(0, -1) : xmlns; | ||
const regex = new RegExp(namespace === "" ? `xmlns="(.*?)"` : `xmlns:${namespace}="(.*?)\"`); | ||
xmlns = xmlns.match(regex)[0].match(/\"(.*?)\"/)[1]; | ||
|
||
return `${xmlns}.${text}`; | ||
}; | ||
|
||
const findControl = (editor) => { | ||
const isLowerCase = (string) => { | ||
return /^[a-z]*$/.test(string); | ||
}; | ||
|
||
const cursorPosition = editor.selection.active; | ||
let line = editor.document.lineAt(cursorPosition.line); | ||
let text = line.text.trim(); | ||
|
||
if (text.includes("<")) { | ||
//If the first character after the < is lowercase, then it's an aggregation | ||
if ( | ||
isLowerCase(text.charAt(1) === "/" ? text.charAt(2) : text.charAt(1)) && | ||
isLowerCase(text.indexOf(":") === -1 ? true : text.charAt(text.indexOf(":") + 1)) | ||
) { | ||
let foundControl = false; | ||
let count = 1; | ||
const navigator = text.charAt(1) === "/" ? "-" : "+"; | ||
|
||
while (foundControl === false) { | ||
count = navigator === "+" ? cursorPosition.line - count : cursorPosition.line + count; | ||
line = editor.document.lineAt(count); | ||
text = line.text.trim(); | ||
if ( | ||
text.includes("<") && | ||
!isLowerCase(text.charAt(1) === "/" ? text.charAt(2) : text.charAt(1)) | ||
) { | ||
foundControl = true; | ||
} else { | ||
count++; | ||
} | ||
} | ||
} | ||
|
||
//just for good measure, check if it's the end tag | ||
const tagSplit = text.includes("</") ? "</" : "<"; | ||
const endSplit = text.includes(" ") ? " " : text.includes(">") ? ">" : "\n"; | ||
text = text.split(tagSplit)[1].split(endSplit)[0]; | ||
} else { | ||
let count = cursorPosition.line - 1; | ||
text = ""; | ||
|
||
while (!text) { | ||
line = editor.document.lineAt(count); | ||
text = line.text.trim(); | ||
|
||
if (text.includes("<")) { | ||
const endSplit = text.includes(">") ? ">" : text.includes(" ") ? " " : "\n"; | ||
text = text.split("<")[1].split(endSplit)[0]; | ||
} else { | ||
count = count - 1; | ||
} | ||
} | ||
} | ||
|
||
text = text.includes(">") ? text.slice(0, -1) : text; | ||
|
||
return getNamespace(text, editor); | ||
}; | ||
|
||
module.exports = { | ||
getNamespace, | ||
findControl, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const path = require("path"); | ||
const { runTests } = require("vscode-test"); | ||
|
||
async function main() { | ||
try { | ||
// The folder containing the Extension Manifest package.json | ||
// Passed to `--extensionDevelopmentPath` | ||
const extensionDevelopmentPath = path.resolve(__dirname, "../"); | ||
|
||
// The path to the extension test script | ||
// Passed to --extensionTestsPath | ||
const extensionTestsPath = path.resolve(__dirname, "./suite/index"); | ||
|
||
// Download VS Code, unzip it and run the integration test | ||
await runTests({ extensionDevelopmentPath, extensionTestsPath }); | ||
} catch (err) { | ||
console.error("Failed to run tests"); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const path = require("path"); | ||
const Mocha = require("mocha"); | ||
const glob = require("glob"); | ||
|
||
const doCoverage = true; | ||
|
||
function setupCoverage() { | ||
const NYC = require("nyc"); | ||
|
||
const nyc = new NYC({ | ||
cwd: path.join(__dirname, "..", ".."), | ||
exclude: ["**/test/**", ".vscode-test/**"], | ||
reporter: ["lcov"], | ||
all: true, | ||
instrument: true, | ||
hookRequire: true, | ||
hookRunInContext: true, | ||
hookRunInThisContext: true, | ||
}); | ||
|
||
nyc.reset(); | ||
nyc.wrap(); | ||
|
||
return nyc; | ||
} | ||
|
||
async function run() { | ||
const nyc = doCoverage ? setupCoverage() : null; | ||
|
||
const mocha = new Mocha({ | ||
ui: "bdd", | ||
color: true, | ||
timeout: 10 * 1000, | ||
}); | ||
|
||
const testsRoot = path.resolve(__dirname, ".."); | ||
const files = glob.sync("**/*.test.js", { cwd: testsRoot }); | ||
|
||
files.forEach((file) => { | ||
mocha.addFile(path.resolve(testsRoot, file)); | ||
}); | ||
|
||
try { | ||
await new Promise((resolve, reject) => { | ||
mocha.run((failures) => { | ||
failures ? reject(new Error(`${failures} tests failed`)) : resolve(undefined); | ||
}); | ||
}); | ||
} finally { | ||
if (nyc) { | ||
nyc.writeCoverageFile(); | ||
await nyc.report(); | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
run, | ||
}; |
Oops, something went wrong.