mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 14:31:31 +01:00
Emmet strict mode move, part 2 (#37840)
Continue moving emmet extension to strict mode. This change does the following: - Remove jsdoc types. These are unused in ts files and can easily get out of date - Annotate when something can return undefined - Add null checks for when something can be undefined - Add explicit types when something can be any
This commit is contained in:
@@ -52,15 +52,15 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
|
||||
}
|
||||
}
|
||||
|
||||
return noiseCheckPromise.then(noise => {
|
||||
return noiseCheckPromise.then((noise): vscode.CompletionList | undefined => {
|
||||
if (noise) {
|
||||
return;
|
||||
}
|
||||
|
||||
let result = helper.doComplete(document, position, syntax, getEmmetConfiguration(syntax));
|
||||
let result = helper.doComplete(document, position, syntax, getEmmetConfiguration(syntax!));
|
||||
let newItems: vscode.CompletionItem[] = [];
|
||||
if (result && result.items) {
|
||||
result.items.forEach(item => {
|
||||
result.items.forEach((item: any) => {
|
||||
let newItem = new vscode.CompletionItem(item.label);
|
||||
newItem.documentation = item.documentation;
|
||||
newItem.detail = item.detail;
|
||||
@@ -78,7 +78,7 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(new vscode.CompletionList(newItems, true));
|
||||
return new vscode.CompletionList(newItems, true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -101,23 +101,24 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
|
||||
|
||||
if (!isStyleSheet(syntax)) {
|
||||
const currentHtmlNode = <HtmlNode>currentNode;
|
||||
if (currentHtmlNode
|
||||
&& currentHtmlNode.close
|
||||
&& getInnerRange(currentHtmlNode).contains(position)) {
|
||||
if (currentHtmlNode.name === 'style') {
|
||||
return 'css';
|
||||
}
|
||||
if (currentHtmlNode.name === 'script') {
|
||||
if (currentHtmlNode.attributes
|
||||
&& currentHtmlNode.attributes.some(x => x.name.toString() === 'type' && allowedMimeTypesInScriptTag.indexOf(x.value.toString()) > -1)) {
|
||||
return syntax;
|
||||
if (currentHtmlNode && currentHtmlNode.close) {
|
||||
const innerRange = getInnerRange(currentHtmlNode);
|
||||
if (innerRange && innerRange.contains(position)) {
|
||||
if (currentHtmlNode.name === 'style') {
|
||||
return 'css';
|
||||
}
|
||||
if (currentHtmlNode.name === 'script') {
|
||||
if (currentHtmlNode.attributes
|
||||
&& currentHtmlNode.attributes.some(x => x.name.toString() === 'type' && allowedMimeTypesInScriptTag.indexOf(x.value.toString()) > -1)) {
|
||||
return syntax;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidLocationForEmmetAbbreviation(currentNode, syntax, position)) {
|
||||
if (!currentNode || !isValidLocationForEmmetAbbreviation(currentNode, syntax, position)) {
|
||||
return;
|
||||
}
|
||||
return syntax;
|
||||
|
||||
Reference in New Issue
Block a user