本文整理匯總了TypeScript中cspell.Text類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Text類的具體用法?TypeScript Text怎麽用?TypeScript Text使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Text類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: genMultiWordSugs
function genMultiWordSugs(words: string[]): string[] {
const snakeCase = words.join('_').toLowerCase();
const camelCase = Text.snakeToCamel(snakeCase);
return [
snakeCase,
Text.ucFirst(camelCase),
Text.lcFirst(camelCase)
];
}
示例2: replaceText
.forEach(sugWord => {
commands.push(LangServer.Command.create(sugWord, 'cSpell.editText',
uri,
textDocument.version,
[ replaceText(diag.range, sugWord) ]
));
const words = sugWord.replace(/[ \-_.]/, '_').split('_');
if (words.length > 1) {
if (Text.isUpperCase(word)) {
const sug = words.join('_').toUpperCase();
commands.push(LangServer.Command.create(sug, 'cSpell.editText',
uri,
textDocument.version,
[ replaceText(diag.range, sug) ]
));
} else {
genMultiWordSugs(words).forEach(sugWord => {
commands.push(LangServer.Command.create(sugWord, 'cSpell.editText',
uri,
textDocument.version,
[ replaceText(diag.range, sugWord) ]
));
});
}
}
});
示例3: textToWords
function textToWords(text: string): string[] {
const setOfWords = new Set(
Text.extractWordsFromCode(text)
.map(t => t.text)
.map(t => t.toLowerCase())
);
return [...setOfWords];
}
示例4:
.map(sug => Text.matchCase(word, sug))