本文整理匯總了TypeScript中vs/editor/common/editorCommon.IModel.getAssociatedResource方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IModel.getAssociatedResource方法的具體用法?TypeScript IModel.getAssociatedResource怎麽用?TypeScript IModel.getAssociatedResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/editorCommon.IModel
的用法示例。
在下文中一共展示了IModel.getAssociatedResource方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getDeclarationsAtPosition
export function getDeclarationsAtPosition(model: IModel, position: IPosition): TPromise<IReference[]> {
const resource = model.getAssociatedResource();
const provider = DeclarationRegistry.ordered(model);
// get results
const promises = provider.map((provider, idx) => {
return provider.findDeclaration(resource, position).then(result => {
return result;
}, err => {
onUnexpectedError(err);
});
});
return TPromise.join(promises).then(allReferences => {
let result: IReference[] = [];
for (let references of allReferences) {
if (Array.isArray(references)) {
result.push(...references);
} else if (references) {
result.push(references);
}
}
return result;
});
}
示例2: formatRange
export function formatRange(model: IModel, range: IRange, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
const [support] = FormatRegistry.ordered(model)
.filter(s => typeof s.formatRange === 'function');
if (!support) {
return TPromise.as(undefined);
}
return support.formatRange(model.getAssociatedResource(), range, options);
}
示例3: getParameterHints
export function getParameterHints(model:IModel, position:IPosition, triggerCharacter: string): TPromise<IParameterHints> {
let support = ParameterHintsRegistry.ordered(model)[0];
if (!support) {
return TPromise.as(undefined);
}
return support.getParameterHints(model.getAssociatedResource(), position, triggerCharacter);
}
示例4: formatAfterKeystroke
export function formatAfterKeystroke(model: IModel, position: IPosition, ch: string, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
const [support] = FormatOnTypeRegistry.ordered(model);
if (!support) {
return TPromise.as(undefined);
}
if (support.autoFormatTriggerCharacters.indexOf(ch) < 0) {
return TPromise.as(undefined);
}
return support.formatAfterKeystroke(model.getAssociatedResource(), position, ch, options);
}
示例5:
let promises = OutlineRegistry.all(model).map(support => {
return support.getOutline(model.getAssociatedResource()).then(result => {
if (Array.isArray(result)) {
entries.push(...result);
}
}, err => {
onUnexpectedError(err);
});
});
示例6:
const promises = CodeLensRegistry.all(model).map(support => {
return support.findCodeLensSymbols(model.getAssociatedResource()).then(result => {
if (!Array.isArray(result)) {
return;
}
for (let symbol of result) {
symbols.push({ symbol, support });
}
}, err => {
onUnexpectedError(err);
});
});
示例7: suggest
export function suggest(model: IModel, position: IPosition, triggerCharacter: string, groups?: ISuggestSupport[][]): TPromise<ISuggestResult2[]> {
if (!groups) {
groups = SuggestRegistry.orderedGroups(model);
}
const resource = model.getAssociatedResource();
const result: ISuggestResult2[] = [];
const factory = groups.map((supports, index) => {
return () => {
// stop as soon as a group produced a result
if (result.length > 0) {
return;
}
// for each support in the group ask for suggestions
return TPromise.join(supports.map(support => {
return support.suggest(resource, position, triggerCharacter).then(values => {
if (!values) {
return;
}
for (let suggestResult of values) {
if (!suggestResult || isFalsyOrEmpty(suggestResult.suggestions)) {
continue;
}
result.push({
support,
currentWord: suggestResult.currentWord,
incomplete: suggestResult.incomplete,
suggestions: suggestResult.suggestions
});
}
}, onUnexpectedError);
}));
};
});
return sequence(factory).then(() => {
// add snippets to the first group
const snippets = SnippetsRegistry.getSnippets(model, position);
result.push(snippets);
return result;
});
}
示例8: formatDocument
export function formatDocument(model: IModel, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
const [support] = FormatRegistry.ordered(model);
if (!support) {
return TPromise.as(undefined);
}
if (typeof support.formatDocument !== 'function') {
if (typeof support.formatRange === 'function') {
return formatRange(model, model.getFullModelRange(), options);
} else {
return TPromise.as(undefined);
}
}
return support.formatDocument(model.getAssociatedResource(), options);
}
示例9:
const promises = QuickFixRegistry.all(model).map(support => {
return support.getQuickFixes(model.getAssociatedResource(), range).then(result => {
if (!Array.isArray(result)) {
return;
}
for (let fix of result) {
quickFixes.push({
command: fix.command,
score: fix.score,
id: `quickfix_#${idPool++}`,
support
});
}
}, err => {
onUnexpectedError(err);
});
});
示例10:
let promises = OutlineRegistry.all(model).map(support => {
if (support.outlineGroupLabel) {
let keys = Object.keys(support.outlineGroupLabel);
for (let i = 0, len = keys.length; i < len; i++) {
let key = keys[i];
groupLabels[key] = support.outlineGroupLabel[key];
}
}
return support.getOutline(model.getAssociatedResource()).then(result => {
if (Array.isArray(result)) {
entries.push(...result);
}
}, err => {
onUnexpectedError(err);
});
});