Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Jul 31, 2020
1 parent a7190c4 commit 507fa45
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Remove leading empty line in diagnostic errors. #2067.
- `"vetur.completion.tagCasing": "initial"` causes double tag completion. #2053
- 🙌 Fix initializationOptions: Cannot read property 'config' of undefined. Thanks to contribution from [Dawid Pakuła](https://github.com/zulus). #1897 and #1341.
- 🙌 Component props auto-completion doesn't work when using PascalCase. Thanks to contribution from [@yoyo930021](@yoyo930021). #1841 and #2056.
- 🙌 When passing incorrect first arg to vti, show help message. Thanks to contribution from [Rafal Tynski](@rafalt). #1841.
- 🙌 Use CodeAction over command. Thanks to contribution from [Matt Bierner](@mjbvz). #1704.

Expand All @@ -18,7 +19,7 @@
- 🙌 Cusom tags IntelliSense for local `tags.json`/`attributes.json`. [Usage Docs](https://vuejs.github.io/vetur/framework.html#workspace-custom-tags). Thanks to contribution from [Carlos Rodrigues](https://github.com/pikax). #1364 and #2018.
- 🙌 Detect tags from @nuxt/components. Thanks to contribution from [pooya parsa](https://github.com/pi0). #1921.
- 🙌 Fix VTI crash by passing correct PID to language server. Thanks to contribution from [Daniil Yastremskiy](@TheBeastOfCaerbannog). #1699 and #1805.
- 🙌 Fix template interpolation hover info of v-for readonly array item. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #1788.
- 🙌 Fix template interpolation hover info of v-for readonly array item. Thanks to contribution from [@yoyo930021](@yoyo930021). #1788.
- 🙌 Improve performance while using template interpolation service. Thanks to contribution from [@IWANABETHATGUY](https://github.com/IWANABETHATGUY). #1839.

### 0.24.0 | 2020-03-04 | [VSIX](https://marketplace.visualstudio.com/_apis/public/gallery/publishers/octref/vsextensions/vetur/0.24.0/vspackage)
Expand Down
28 changes: 14 additions & 14 deletions server/src/modes/template/services/htmlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Range,
TextEdit,
InsertTextFormat,
CompletionItem,
CompletionItem
} from 'vscode-languageserver-types';
import { HTMLDocument } from '../parser/htmlParser';
import { TokenType, createScanner, ScannerState } from '../parser/htmlScanner';
Expand All @@ -26,7 +26,7 @@ export function doComplete(

const result: CompletionList = {
isIncomplete: false,
items: [],
items: []
};

const offset = document.offsetAt(position);
Expand All @@ -49,7 +49,7 @@ export function doComplete(

function collectOpenTagSuggestions(afterOpenBracket: number, tagNameEnd?: number): CompletionList {
const range = getReplaceRange(afterOpenBracket, tagNameEnd);
tagProviders.forEach((provider) => {
tagProviders.forEach(provider => {
const priority = provider.priority;
provider.collectTags((tag, label) => {
result.items.push({
Expand All @@ -58,7 +58,7 @@ export function doComplete(
documentation: label,
textEdit: TextEdit.replace(range, tag),
sortText: priority + tag,
insertTextFormat: InsertTextFormat.PlainText,
insertTextFormat: InsertTextFormat.PlainText
});
});
});
Expand Down Expand Up @@ -96,7 +96,7 @@ export function doComplete(
kind: CompletionItemKind.Property,
filterText: '/' + tag + closeTag,
textEdit: TextEdit.replace(range, '/' + tag + closeTag),
insertTextFormat: InsertTextFormat.PlainText,
insertTextFormat: InsertTextFormat.PlainText
};
const startIndent = getLineIndent(curr.start);
const endIndent = getLineIndent(afterOpenBracket - 1);
Expand All @@ -114,15 +114,15 @@ export function doComplete(
return result;
}

tagProviders.forEach((provider) => {
tagProviders.forEach(provider => {
provider.collectTags((tag, label) => {
result.items.push({
label: '/' + tag,
kind: CompletionItemKind.Property,
documentation: label,
filterText: '/' + tag + closeTag,
textEdit: TextEdit.replace(range, '/' + tag + closeTag),
insertTextFormat: InsertTextFormat.PlainText,
insertTextFormat: InsertTextFormat.PlainText
});
});
});
Expand All @@ -143,7 +143,7 @@ export function doComplete(
const value = isFollowedBy(text, nameEnd, ScannerState.AfterAttributeName, TokenType.DelimiterAssign)
? ''
: '="$1"';
tagProviders.forEach((provider) => {
tagProviders.forEach(provider => {
const priority = provider.priority;
provider.collectAttributes(currentTag, (attribute, type, documentation) => {
if ((type === 'event' && filterPrefix !== '@') || (type !== 'event' && filterPrefix === '@')) {
Expand All @@ -159,21 +159,21 @@ export function doComplete(
textEdit: TextEdit.replace(range, codeSnippet),
insertTextFormat: InsertTextFormat.Snippet,
sortText: priority + attribute,
documentation,
documentation
});
});
});
const attributeName = scanner.getTokenText();
if (/\.$/.test(attributeName)) {
function addModifier(modifiers: { items: Modifier[]; priority: number }) {
modifiers.items.forEach((modifier) => {
modifiers.items.forEach(modifier => {
result.items.push({
label: modifier.label,
kind: CompletionItemKind.Method,
textEdit: TextEdit.insert(document.positionAt(nameEnd), modifier.label),
insertTextFormat: InsertTextFormat.Snippet,
sortText: modifiers.priority + modifier.label,
documentation: modifier.documentation,
documentation: modifier.documentation
});
});
}
Expand Down Expand Up @@ -229,15 +229,15 @@ export function doComplete(
addQuotes = true;
}
const attribute = currentAttributeName.toLowerCase();
tagProviders.forEach((provider) => {
provider.collectValues(currentTag, attribute, (value) => {
tagProviders.forEach(provider => {
provider.collectValues(currentTag, attribute, value => {
const insertText = addQuotes ? '"' + value + '"' : value;
result.items.push({
label: value,
filterText: insertText,
kind: CompletionItemKind.Unit,
textEdit: TextEdit.replace(range, insertText),
insertTextFormat: InsertTextFormat.PlainText,
insertTextFormat: InsertTextFormat.PlainText
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion server/src/modes/template/services/htmlHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function doHover(
}
const tagRange = {
start: document.positionAt(scanner.getTokenOffset()),
end: document.positionAt(scanner.getTokenEnd()),
end: document.positionAt(scanner.getTokenEnd())
};
switch (token) {
case TokenType.StartTag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ export function getExternalTagProvider(id: string, tags: any, attributes: any):
for (const option of detail.options) {
collector(option);
}
},
}
};
}
30 changes: 15 additions & 15 deletions test/interpolation/features/completion/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ describe('Should autocomplete interpolation for <template>', () => {
}`,
'js'
),
kind: CompletionItemKind.Field,
kind: CompletionItemKind.Field
},
{
label: 'msg',
documentation: new MarkdownString('My msg').appendCodeblock(`msg: 'Vetur means "Winter" in icelandic.'`, 'js'),
kind: CompletionItemKind.Field,
kind: CompletionItemKind.Field
},
{
label: 'count',
Expand All @@ -37,7 +37,7 @@ describe('Should autocomplete interpolation for <template>', () => {
}`,
'js'
),
kind: CompletionItemKind.Field,
kind: CompletionItemKind.Field
},
{
label: 'hello',
Expand All @@ -48,8 +48,8 @@ describe('Should autocomplete interpolation for <template>', () => {
'js'
),

kind: CompletionItemKind.Function,
},
kind: CompletionItemKind.Function
}
];

describe('Should complete props, data, computed and methods', () => {
Expand All @@ -61,8 +61,8 @@ describe('Should autocomplete interpolation for <template>', () => {
await testCompletion(templateDocUri, position(3, 11), [
{
label: 'msg',
kind: CompletionItemKind.Field,
},
kind: CompletionItemKind.Field
}
]);
});

Expand All @@ -71,8 +71,8 @@ describe('Should autocomplete interpolation for <template>', () => {
{
label: 'basic',
kind: CompletionItemKind.Property,
documentationStart: 'My basic tag\n```js\nexport default {',
},
documentationStart: 'My basic tag\n```js\nexport default {'
}
]);
});

Expand All @@ -87,8 +87,8 @@ describe('Should autocomplete interpolation for <template>', () => {
default: false
}`,
'js'
),
},
)
}
]);
});

Expand All @@ -97,8 +97,8 @@ describe('Should autocomplete interpolation for <template>', () => {
{
label: 'bar',
kind: CompletionItemKind.Value,
documentation: new MarkdownString('My bar').appendCodeblock(`bar: String`, 'js'),
},
documentation: new MarkdownString('My bar').appendCodeblock(`bar: String`, 'js')
}
]);
});

Expand All @@ -107,8 +107,8 @@ describe('Should autocomplete interpolation for <template>', () => {
{
label: 'bar',
kind: CompletionItemKind.Value,
documentation: new MarkdownString('My bar').appendCodeblock(`bar: String`, 'js'),
},
documentation: new MarkdownString('My bar').appendCodeblock(`bar: String`, 'js')
}
]);
});

Expand Down

0 comments on commit 507fa45

Please sign in to comment.