in extension.ts [61:80]
function checkLinks(document: TextDocument, diagnostics: DiagnosticCollection) {
//Clear the diagnostics because we're sending new ones each time
diagnostics.clear();
// Get all Markdown style lnks in the document
getLinks(document).then((links) => {
// Iterate over the array, generating an array of promises
let countryCodePromise = Promise.all<Diagnostic>(links.map((link): Diagnostic => {
// For each link, check the country code...
return isCountryCodeLink(link);
// Then, when they are all done..
}));
// Finally, let's complete the promise for country code...
countryCodePromise.then((countryCodeDiag) => {
// Then filter out null ones
let filteredDiag = countryCodeDiag.filter(diagnostic => diagnostic != null);
// Then add the diagnostics
diagnostics.set(document.uri, filteredDiag);
})
}).catch();
}