mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 11:35:40 +01:00
Merge pull request #67 from spahnke/deprecated-api
Adopt "deprecated" API
This commit is contained in:
commit
926a1051b8
1 changed files with 37 additions and 15 deletions
|
|
@ -330,6 +330,10 @@ export class DiagnosticsAdapter extends Adapter {
|
||||||
column: endColumn
|
column: endColumn
|
||||||
} = model.getPositionAt(diagStart + diagLength);
|
} = model.getPositionAt(diagStart + diagLength);
|
||||||
|
|
||||||
|
const tags: MarkerTag[] = [];
|
||||||
|
if (diag.reportsUnnecessary) tags.push(MarkerTag.Unnecessary);
|
||||||
|
if (diag.reportsDeprecated) tags.push(MarkerTag.Deprecated);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
severity: this._tsDiagnosticCategoryToMarkerSeverity(diag.category),
|
severity: this._tsDiagnosticCategoryToMarkerSeverity(diag.category),
|
||||||
startLineNumber,
|
startLineNumber,
|
||||||
|
|
@ -338,7 +342,7 @@ export class DiagnosticsAdapter extends Adapter {
|
||||||
endColumn,
|
endColumn,
|
||||||
message: flattenDiagnosticMessageText(diag.messageText, '\n'),
|
message: flattenDiagnosticMessageText(diag.messageText, '\n'),
|
||||||
code: diag.code.toString(),
|
code: diag.code.toString(),
|
||||||
tags: diag.reportsUnnecessary ? [MarkerTag.Unnecessary] : [],
|
tags,
|
||||||
relatedInformation: this._convertRelatedInformation(
|
relatedInformation: this._convertRelatedInformation(
|
||||||
model,
|
model,
|
||||||
diag.relatedInformation
|
diag.relatedInformation
|
||||||
|
|
@ -456,6 +460,10 @@ export class SuggestAdapter
|
||||||
range = new Range(p1.lineNumber, p1.column, p2.lineNumber, p2.column);
|
range = new Range(p1.lineNumber, p1.column, p2.lineNumber, p2.column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tags: languages.CompletionItemTag[] = [];
|
||||||
|
if (entry.kindModifiers?.indexOf('deprecated') !== -1)
|
||||||
|
tags.push(languages.CompletionItemTag.Deprecated);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uri: resource,
|
uri: resource,
|
||||||
position: position,
|
position: position,
|
||||||
|
|
@ -463,7 +471,8 @@ export class SuggestAdapter
|
||||||
label: entry.name,
|
label: entry.name,
|
||||||
insertText: entry.name,
|
insertText: entry.name,
|
||||||
sortText: entry.sortText,
|
sortText: entry.sortText,
|
||||||
kind: SuggestAdapter.convertKind(entry.kind)
|
kind: SuggestAdapter.convertKind(entry.kind),
|
||||||
|
tags
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -499,7 +508,7 @@ export class SuggestAdapter
|
||||||
kind: SuggestAdapter.convertKind(details.kind),
|
kind: SuggestAdapter.convertKind(details.kind),
|
||||||
detail: displayPartsToString(details.displayParts),
|
detail: displayPartsToString(details.displayParts),
|
||||||
documentation: {
|
documentation: {
|
||||||
value: displayPartsToString(details.documentation)
|
value: SuggestAdapter.createDocumentationString(details)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -536,6 +545,30 @@ export class SuggestAdapter
|
||||||
|
|
||||||
return languages.CompletionItemKind.Property;
|
return languages.CompletionItemKind.Property;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static createDocumentationString(
|
||||||
|
details: ts.CompletionEntryDetails
|
||||||
|
): string {
|
||||||
|
let documentationString = displayPartsToString(details.documentation);
|
||||||
|
if (details.tags) {
|
||||||
|
for (const tag of details.tags) {
|
||||||
|
documentationString += `\n\n${tagToString(tag)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return documentationString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tagToString(tag: ts.JSDocTagInfo): string {
|
||||||
|
let tagLabel = `*@${tag.name}*`;
|
||||||
|
if (tag.name === 'param' && tag.text) {
|
||||||
|
const [paramName, ...rest] = tag.text.split(' ');
|
||||||
|
tagLabel += `\`${paramName}\``;
|
||||||
|
if (rest.length > 0) tagLabel += ` — ${rest.join(' ')}`;
|
||||||
|
} else if (tag.text) {
|
||||||
|
tagLabel += ` — ${tag.text}`;
|
||||||
|
}
|
||||||
|
return tagLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SignatureHelpAdapter
|
export class SignatureHelpAdapter
|
||||||
|
|
@ -625,18 +658,7 @@ export class QuickInfoAdapter
|
||||||
|
|
||||||
const documentation = displayPartsToString(info.documentation);
|
const documentation = displayPartsToString(info.documentation);
|
||||||
const tags = info.tags
|
const tags = info.tags
|
||||||
? info.tags
|
? info.tags.map((tag) => tagToString(tag)).join(' \n\n')
|
||||||
.map((tag) => {
|
|
||||||
const label = `*@${tag.name}*`;
|
|
||||||
if (!tag.text) {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
label +
|
|
||||||
(tag.text.match(/\r\n|\n/g) ? ' \n' + tag.text : ` - ${tag.text}`)
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.join(' \n\n')
|
|
||||||
: '';
|
: '';
|
||||||
const contents = displayPartsToString(info.displayParts);
|
const contents = displayPartsToString(info.displayParts);
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue