8000 Prototyping inline info. · i-spark/TypeScript@7d040f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d040f2

Browse files
Prototyping inline info.
1 parent 4b92e42 commit 7d040f2

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/services/services.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,8 @@ module ts {
885885
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
886886
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
887887

888+
getInlineInfo(fileName: string): InlineInfo[];
889+
888890
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
889891

890892
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan;
@@ -1040,6 +1042,11 @@ module ts {
10401042
documentation: SymbolDisplayPart[];
10411043
}
10421044

1045+
export interface InlineInfo {
1046+
position: number;
1047+
displayParts: SymbolDisplayPart[];
1048+
}
1049+
10431050
export interface RenameInfo {
10441051
canRename: boolean;
10451052
localizedErrorMessage: string;
@@ -5245,6 +5252,41 @@ module ts {
52455252
}
52465253
}
52475254

5255+
function getInlineInfo(fileName: string): InlineInfo[] {
5256+
synchronizeHostData();
5257+
5258+
fileName = normalizeSlashes(fileName);
5259+
5260+
var sourceFile = getValidSourceFile(fileName);
5261+
5262+
cancellationToken.throwIfCancellationRequested();
5263+
5264+
var result: InlineInfo[] = [];
5265+
5266+
forEachChild(sourceFile, function aggregateUnannotatedNodes(node) {
5267+
switch (node.kind) {
5268+
case SyntaxKind.Parameter:
5269+
if (!(<ParameterDeclaration>node).type) {
5270+
result.push(nodeToInlineInfo(<ParameterDeclaration>node));
5271+
}
5272+
}
5273+
5274+
forEachChild(node, aggregateUnannotatedNodes);
5275+
});
5276+
5277+
return result;
5278+
}
5279+
5280+
function nodeToInlineInfo(node: Declaration): InlineInfo {
5281+
var position = node.getEnd();
5282+
var type = typeInfoResolver.getTypeAtLocation(node);
5283+
5284+
return {
5285+
position,
5286+
displayParts: typeToDisplayParts(typeInfoResolver, type, getContainerNode(node))
5287+
};
5288+
}
5289+
52485290
function getOutliningSpans(fileName: string): OutliningSpan[] {
52495291
// doesn't use compiler - no need to synchronize with host
52505292
fileName = normalizeSlashes(fileName);
@@ -5572,6 +5614,7 @@ module ts {
55725614
getCompletionsAtPosition,
55735615
getCompletionEntryDetails,
55745616
getSignatureHelpItems,
5617+
getInlineInfo,
55755618
getQuickInfoAtPosition,
55765619
getDefinitionAtPosition,
55775620
getReferencesAtPosition,

src/services/shims.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ module ts {
9595
getCompletionsAtPosition(fileName: string, position: number): string;
9696
getCompletionEntryDetails(fileName: string, position: number, entryName: string): string;
9797

98+
getInlineInfo(fileName: string): string;
99+
98100
getQuickInfoAtPosition(fileName: string, position: number): string;
99101

100102
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string;
@@ -444,6 +446,15 @@ module ts {
444446
});
445447
}
446448

449+
public getInlineInfo(fileName: string): string {
450+
return this.forwardJSONCall(
451+
`getInlineInfo('${fileName}')`,
452+
() => {
453+
var inlineInfo = this.languageService.getInlineInfo(fileName);
454+
return inlineInfo;
455+
});
456+
}
457+
447458
/// QUICKINFO
448459

449460
/**

0 commit comments

Comments
 (0)
0