add more information to quickinfo for imported symbols
This commit is contained in:
Родитель
e3a20e7f0a
Коммит
56fc112d8d
|
@ -58,6 +58,7 @@ internal/
|
|||
!tests/baselines/reference/project/nodeModules*/**/*
|
||||
.idea
|
||||
yarn.lock
|
||||
yarn-error.log
|
||||
.parallelperf.*
|
||||
tests/cases/user/*/package-lock.json
|
||||
tests/cases/user/*/node_modules/
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace ts.SymbolDisplay {
|
|||
|
||||
// TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
|
||||
export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node,
|
||||
location: Node, semanticMeaning = getMeaningFromLocation(location)): SymbolDisplayPartsDocumentationAndSymbolKind {
|
||||
location: Node, semanticMeaning = getMeaningFromLocation(location), alias?: Symbol): SymbolDisplayPartsDocumentationAndSymbolKind {
|
||||
|
||||
const displayParts: SymbolDisplayPart[] = [];
|
||||
let documentation: SymbolDisplayPart[];
|
||||
|
@ -115,6 +115,7 @@ namespace ts.SymbolDisplay {
|
|||
let hasAddedSymbolInfo: boolean;
|
||||
const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isExpression(location);
|
||||
let type: Type;
|
||||
let documentationFromAlias: SymbolDisplayPart[];
|
||||
|
||||
// Class at constructor site need to be shown as constructor apart from property,method, vars
|
||||
if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Alias) {
|
||||
|
@ -243,6 +244,7 @@ namespace ts.SymbolDisplay {
|
|||
}
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo && !isThisExpression) {
|
||||
addAliasPrefixIfNecessary();
|
||||
if (getDeclarationOfKind(symbol, SyntaxKind.ClassExpression)) {
|
||||
// Special case for class expressions because we would like to indicate that
|
||||
// the class name is local to the class body (similar to function expression)
|
||||
|
@ -258,14 +260,14 @@ namespace ts.SymbolDisplay {
|
|||
writeTypeParametersOfSymbol(symbol, sourceFile);
|
||||
}
|
||||
if ((symbolFlags & SymbolFlags.Interface) && (semanticMeaning & SemanticMeaning.Type)) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
prefixNextMeaning();
|
||||
displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword));
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
writeTypeParametersOfSymbol(symbol, sourceFile);
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.TypeAlias) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
prefixNextMeaning();
|
||||
displayParts.push(keywordPart(SyntaxKind.TypeKeyword));
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
|
@ -276,7 +278,7 @@ namespace ts.SymbolDisplay {
|
|||
addRange(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, TypeFormatFlags.InTypeAlias));
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.Enum) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
prefixNextMeaning();
|
||||
if (forEach(symbol.declarations, isConstEnumDeclaration)) {
|
||||
displayParts.push(keywordPart(SyntaxKind.ConstKeyword));
|
||||
displayParts.push(spacePart());
|
||||
|
@ -286,7 +288,7 @@ namespace ts.SymbolDisplay {
|
|||
addFullSymbolName(symbol);
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.Module) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
prefixNextMeaning();
|
||||
const declaration = getDeclarationOfKind<ModuleDeclaration>(symbol, SyntaxKind.ModuleDeclaration);
|
||||
const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier;
|
||||
displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword));
|
||||
|
@ -294,7 +296,7 @@ namespace ts.SymbolDisplay {
|
|||
addFullSymbolName(symbol);
|
||||
}
|
||||
if ((symbolFlags & SymbolFlags.TypeParameter) && (semanticMeaning & SemanticMeaning.Type)) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
prefixNextMeaning();
|
||||
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
displayParts.push(textPart("type parameter"));
|
||||
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
|
||||
|
@ -354,7 +356,32 @@ namespace ts.SymbolDisplay {
|
|||
}
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.Alias) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
prefixNextMeaning();
|
||||
if (!hasAddedSymbolInfo) {
|
||||
const resolvedSymbol = typeChecker.getAliasedSymbol(symbol);
|
||||
if (resolvedSymbol !== symbol && resolvedSymbol.declarations && resolvedSymbol.declarations.length > 0) {
|
||||
const resolvedNode = resolvedSymbol.declarations[0];
|
||||
const declarationName = ts.getNameOfDeclaration(resolvedNode);
|
||||
if (declarationName) {
|
||||
const isExternalModuleDeclaration =
|
||||
ts.isModuleWithStringLiteralName(resolvedNode) &&
|
||||
ts.hasModifier(resolvedNode, ModifierFlags.Ambient);
|
||||
const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
|
||||
const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(
|
||||
typeChecker,
|
||||
resolvedSymbol,
|
||||
ts.getSourceFileOfNode(resolvedNode),
|
||||
resolvedNode,
|
||||
declarationName,
|
||||
semanticMeaning,
|
||||
shouldUseAliasName ? symbol : resolvedSymbol);
|
||||
displayParts.push(...resolvedInfo.displayParts);
|
||||
displayParts.push(lineBreakPart());
|
||||
documentationFromAlias = resolvedInfo.documentation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (symbol.declarations[0].kind) {
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
displayParts.push(keywordPart(SyntaxKind.ExportKeyword));
|
||||
|
@ -400,7 +427,7 @@ namespace ts.SymbolDisplay {
|
|||
if (symbolKind !== ScriptElementKind.unknown) {
|
||||
if (type) {
|
||||
if (isThisExpression) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
prefixNextMeaning();
|
||||
displayParts.push(keywordPart(SyntaxKind.ThisKeyword));
|
||||
}
|
||||
else {
|
||||
|
@ -472,12 +499,24 @@ namespace ts.SymbolDisplay {
|
|||
}
|
||||
}
|
||||
|
||||
if (documentation.length === 0 && documentationFromAlias) {
|
||||
documentation = documentationFromAlias;
|
||||
}
|
||||
|
||||
return { displayParts, documentation, symbolKind, tags };
|
||||
|
||||
function addNewLineIfDisplayPartsExist() {
|
||||
function prefixNextMeaning() {
|
||||
if (displayParts.length) {
|
||||
displayParts.push(lineBreakPart());
|
||||
}
|
||||
addAliasPrefixIfNecessary();
|
||||
}
|
||||
|
||||
function addAliasPrefixIfNecessary() {
|
||||
if (alias) {
|
||||
pushTypePart(ScriptElementKind.alias);
|
||||
displayParts.push(spacePart());
|
||||
}
|
||||
}
|
||||
|
||||
function addInPrefix() {
|
||||
|
@ -486,14 +525,17 @@ namespace ts.SymbolDisplay {
|
|||
displayParts.push(spacePart());
|
||||
}
|
||||
|
||||
function addFullSymbolName(symbol: Symbol, enclosingDeclaration?: Node) {
|
||||
const fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
|
||||
function addFullSymbolName(symbolToDisplay: Symbol, enclosingDeclaration?: Node) {
|
||||
if (alias && symbolToDisplay === symbol) {
|
||||
symbolToDisplay = alias;
|
||||
}
|
||||
const fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
|
||||
SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing);
|
||||
addRange(displayParts, fullSymbolDisplayParts);
|
||||
}
|
||||
|
||||
function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
prefixNextMeaning();
|
||||
if (symbolKind) {
|
||||
pushTypePart(symbolKind);
|
||||
if (symbol && !some(symbol.declarations, d => isArrowFunction(d) || (isFunctionExpression(d) || isClassExpression(d)) && !d.name)) {
|
||||
|
|
|
@ -0,0 +1,722 @@
|
|||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsInternalModuleAlias.ts",
|
||||
"position": 66
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "alias",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 66,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "alias",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "namespace",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a1",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "import",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a1",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=",
|
||||
"kind": "operator"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m",
|
||||
"kind": "moduleName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsInternalModuleAlias.ts",
|
||||
"position": 82
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "alias",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 82,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "alias",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "namespace",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a1",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "import",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a1",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=",
|
||||
"kind": "operator"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m",
|
||||
"kind": "moduleName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsInternalModuleAlias.ts",
|
||||
"position": 104
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "alias",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 104,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "alias",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "namespace",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a2",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "import",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a2",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=",
|
||||
"kind": "operator"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "m1",
|
||||
"kind": "moduleName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsInternalModuleAlias.ts",
|
||||
"position": 123
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "alias",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 123,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "alias",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "namespace",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a2",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "import",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a2",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=",
|
||||
"kind": "operator"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "m1",
|
||||
"kind": "moduleName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsInternalModuleAlias.ts",
|
||||
"position": 149
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "alias",
|
||||
"kindModifiers": "export",
|
||||
"textSpan": {
|
||||
"start": 149,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "alias",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "namespace",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m2",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "a3",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "import",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m2",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "a3",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=",
|
||||
"kind": "operator"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m",
|
||||
"kind": "moduleName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsInternalModuleAlias.ts",
|
||||
"position": 165
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "alias",
|
||||
"kindModifiers": "export",
|
||||
"textSpan": {
|
||||
"start": 165,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "alias",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "namespace",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m2",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "a3",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "import",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m2",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "a3",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=",
|
||||
"kind": "operator"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m",
|
||||
"kind": "moduleName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsInternalModuleAlias.ts",
|
||||
"position": 194
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "alias",
|
||||
"kindModifiers": "export",
|
||||
"textSpan": {
|
||||
"start": 194,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "alias",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "namespace",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m2",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "a4",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "import",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m2",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "a4",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=",
|
||||
"kind": "operator"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "m1",
|
||||
"kind": "moduleName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsInternalModuleAlias.ts",
|
||||
"position": 213
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "alias",
|
||||
"kindModifiers": "export",
|
||||
"textSpan": {
|
||||
"start": 213,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "alias",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "namespace",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m2",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "a4",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "import",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m2",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "a4",
|
||||
"kind": "aliasName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=",
|
||||
"kind": "operator"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "m",
|
||||
"kind": "moduleName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "m1",
|
||||
"kind": "moduleName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
}
|
||||
]
|
|
@ -12,5 +12,5 @@
|
|||
const ranges = test.ranges();
|
||||
const [r0, r1] = ranges;
|
||||
// TODO: Want these to be in the same group, but that would require creating a symbol for `x`.
|
||||
verify.singleReferenceGroup("import x", [r0]);
|
||||
verify.singleReferenceGroup("import x", [r1]);
|
||||
verify.singleReferenceGroup("(alias) module \"jquery\"\nimport x", [r0]);
|
||||
verify.singleReferenceGroup("(alias) module \"jquery\"\nimport x", [r1]);
|
|
@ -10,22 +10,22 @@
|
|||
////import [|/*importBang*/bang|] = require("jquery");
|
||||
////[|foo/*useFoo*/|]([|bar/*useBar*/|], [|baz/*useBaz*/|], [|bang/*useBang*/|]);
|
||||
|
||||
verify.quickInfoAt("useFoo", "import foo");
|
||||
verify.quickInfoAt("useFoo", "(alias) module \"jquery\"\nimport foo");
|
||||
verify.goToDefinition({
|
||||
useFoo: "module",
|
||||
importFoo: "module"
|
||||
});
|
||||
|
||||
verify.quickInfoAt("useBar", "import bar");
|
||||
verify.quickInfoAt("useBar", "(alias) module \"jquery\"\nimport bar");
|
||||
verify.goToDefinition("useBar", "module");
|
||||
|
||||
verify.quickInfoAt("useBaz", "import baz");
|
||||
verify.quickInfoAt("useBaz", "(alias) module \"jquery\"\nimport baz");
|
||||
verify.goToDefinition({
|
||||
useBaz: "importBaz",
|
||||
importBaz: "module"
|
||||
});
|
||||
|
||||
verify.quickInfoAt("useBang", "import bang = require(\"jquery\")");
|
||||
verify.quickInfoAt("useBang", "(alias) module \"jquery\"\nimport bang = require(\"jquery\")");
|
||||
verify.goToDefinition({
|
||||
useBang: "module",
|
||||
importBang: "module"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
////}
|
||||
|
||||
goTo.marker("1");
|
||||
verify.completionListContains("x", "import x = M", undefined);
|
||||
verify.completionListContains("x", "(alias) namespace x\nimport x = M", undefined);
|
||||
|
||||
goTo.marker("2");
|
||||
verify.completionListContains("value");
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
goTo.marker("");
|
||||
const options = { includeExternalModuleExports: true, sourceDisplay: undefined };
|
||||
verify.completionListContains({ name: "Test1", source: "/a" }, "function Test1(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./a" });
|
||||
verify.completionListContains("Test2", "import Test2", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ undefined, options);
|
||||
verify.completionListContains("Test2", "(alias) function Test2(): void\nimport Test2", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ undefined, options);
|
||||
verify.not.completionListContains({ name: "Test2", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options);
|
||||
|
||||
verify.applyCodeActionFromCompletion("", {
|
||||
|
|
|
@ -21,7 +21,7 @@ goTo.marker("");
|
|||
const options = { includeExternalModuleExports: true, sourceDisplay: "./a" };
|
||||
// TODO: https://github.com/Microsoft/TypeScript/issues/14003
|
||||
//TODO: verify that there's only one!
|
||||
verify.completionListContains({ name: "foo", source: "/a" }, "import foo", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ true, options);
|
||||
verify.completionListContains({ name: "foo", source: "/a" }, "(alias) const foo: 0\nimport foo", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ true, options);
|
||||
verify.not.completionListContains({ name: "foo", source: "/a_reexport" }, undefined, undefined, undefined, undefined, undefined, options);
|
||||
verify.not.completionListContains({ name: "foo", source: "/a_reexport_2" }, undefined, undefined, undefined, undefined, undefined, options);
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ verify.goToDefinition("useAX", "defAX");
|
|||
verify.goToDefinition("useBX", "defAX");
|
||||
|
||||
const [r0, r1, r2, r3, r4, r5] = test.ranges();
|
||||
const aImport = { definition: "import X", ranges: [r0, r1] };
|
||||
const aImport = { definition: "(alias) class X\nimport X", ranges: [r0, r1] };
|
||||
const def = { definition: "class X", ranges: [r2] };
|
||||
const bImport = { definition: "import X", ranges: [r3, r4] };
|
||||
const bImport = { definition: "(alias) class X\nimport X", ranges: [r3, r4] };
|
||||
verify.referenceGroups([r0, r1], [aImport, def, bImport]);
|
||||
verify.referenceGroups([r2], [def, aImport, bImport]);
|
||||
verify.referenceGroups([r3, r4], [bImport, def, aImport]);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
////var /*3*/r2 = t./*4*/foo; // t should have 'foo' in dropdown list and be of type 'string'
|
||||
|
||||
verify.quickInfos({
|
||||
1: "import test = require('./exportEqualTypes_file0')",
|
||||
1: "(alias) interface test\nimport test = require('./exportEqualTypes_file0')",
|
||||
2: "var r1: Date",
|
||||
3: "var r2: string"
|
||||
});
|
||||
|
|
|
@ -29,8 +29,22 @@
|
|||
////var v1: a1./*15*/connectExport;
|
||||
|
||||
goTo.file("externalModuleWithExportAssignment_file1.ts");
|
||||
verify.quickInfoAt("1", 'import a1 = require("./externalModuleWithExportAssignment_file0")');
|
||||
verify.quickInfoAt("2", "var a: {\n (): a1.connectExport;\n test1: a1.connectModule;\n test2(): a1.connectModule;\n}", undefined);
|
||||
verify.quickInfoAt("1", [
|
||||
"(alias) namespace a1",
|
||||
"(alias) var a1: {",
|
||||
" (): connectExport;",
|
||||
" test1: connectModule;",
|
||||
" test2(): connectModule;",
|
||||
"}",
|
||||
'import a1 = require("./externalModuleWithExportAssignment_file0")'
|
||||
].join("\n"));
|
||||
verify.quickInfoAt("2", [
|
||||
"var a: {",
|
||||
" (): a1.connectExport;",
|
||||
" test1: a1.connectModule;",
|
||||
" test2(): a1.connectModule;",
|
||||
"}"
|
||||
].join("\n"), undefined);
|
||||
|
||||
goTo.marker('3');
|
||||
verify.quickInfoIs("(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined);
|
||||
|
|
|
@ -48,7 +48,7 @@ verify.referenceGroups(a1, defs("constructor C(): C (+1 overload)"));
|
|||
function defs(definition: string) {
|
||||
return [
|
||||
{ definition, ranges: [a0, a1, a2, a3, d0, d1, a4] },
|
||||
{ definition: "import C", ranges: [b0] },
|
||||
{ definition: "import C", ranges: [c0] }
|
||||
{ definition: "(alias) class C\nimport C", ranges: [b0] },
|
||||
{ definition: "(alias) class C\nimport C", ranges: [c0] }
|
||||
]
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
const [r0, r1, r2] = test.ranges();
|
||||
const defs = { definition: "(property) A: typeof (Anonymous class)", ranges: [r0] };
|
||||
const imports = { definition: "import A", ranges: [r1, r2] };
|
||||
const imports = { definition: "(alias) (property) A: typeof (Anonymous class)\nimport A", ranges: [r1, r2] };
|
||||
verify.referenceGroups([r0], [defs, imports]);
|
||||
verify.referenceGroups([r1, r2], [imports, defs]);
|
||||
|
|
|
@ -18,7 +18,7 @@ const ranges = test.ranges();
|
|||
const [r0, r1, r2] = ranges;
|
||||
|
||||
const globals = { definition: "function f(): void", ranges: [r0, r2] };
|
||||
const imports = { definition: "import f", ranges: [r1] };
|
||||
const imports = { definition: "(alias) function f(): void\nimport f", ranges: [r1] };
|
||||
|
||||
verify.referenceGroups([r0, r2], [globals, imports]);
|
||||
verify.referenceGroups(r1, [imports, globals]);
|
||||
|
|
|
@ -12,6 +12,6 @@ const [C0, D0, C1, D1] = test.ranges();
|
|||
verify.singleReferenceGroup("class C", [C0, C1]);
|
||||
|
||||
const d0Group = { definition: "const D: typeof C", ranges: [D0] };
|
||||
const d1Group = { definition: "import D", ranges: [D1] };
|
||||
const d1Group = { definition: "(alias) const D: typeof C\nimport D", ranges: [D1] };
|
||||
verify.referenceGroups(D0, [d0Group, d1Group]);
|
||||
verify.referenceGroups(D1, [d1Group, d0Group]);
|
||||
|
|
|
@ -14,9 +14,9 @@ const ranges = test.ranges();
|
|||
const [r0, r1, r2] = ranges;
|
||||
verify.referenceGroups(r0, [
|
||||
{ definition: "function f(): void", ranges: [r0] },
|
||||
{ definition: "import g", ranges: [r1, r2] }
|
||||
{ definition: "(alias) function g(): void\nimport g", ranges: [r1, r2] }
|
||||
]);
|
||||
verify.referenceGroups(r1, [{ definition: "import g", ranges: [r1, r2] }]);
|
||||
verify.referenceGroups(r1, [{ definition: "(alias) function g(): void\nimport g", ranges: [r1, r2] }]);
|
||||
verify.referenceGroups(r2, [{ definition: "(alias) g(): void\nimport g", ranges: [r1, r2] }]);
|
||||
|
||||
verify.goToDefinition("ref", "def");
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
const [r0, r1, r2, r3, r4] = test.ranges();
|
||||
verify.referenceGroups([r0, r2], [
|
||||
{ definition: "const a: 0", ranges: [r0, r2] },
|
||||
{ definition: "import a", ranges: [r3, r4] }
|
||||
{ definition: "(alias) const a: 0\nimport a", ranges: [r3, r4] }
|
||||
]);
|
||||
verify.referenceGroups(r1, [
|
||||
{ definition: "export default a", ranges: [r1] },
|
||||
{ definition: "import a", ranges: [r3, r4] },
|
||||
{ definition: "(alias) const a: 0\nexport default a", ranges: [r1] },
|
||||
{ definition: "(alias) const a: 0\nimport a", ranges: [r3, r4] },
|
||||
]);
|
||||
verify.referenceGroups([r3, r4], [
|
||||
{ definition: "import a", ranges: [r3, r4] },
|
||||
{ definition: "export default a", ranges: [r1] },
|
||||
{ definition: "(alias) const a: 0\nimport a", ranges: [r3, r4] },
|
||||
{ definition: "(alias) const a: 0\nexport default a", ranges: [r1] },
|
||||
]);
|
||||
|
|
|
@ -13,16 +13,16 @@
|
|||
const [r0, r1, r2, r3] = test.ranges();
|
||||
verify.referenceGroups([r0, r1], [
|
||||
{ definition: "const foo: 1", ranges: [r0, r1] },
|
||||
{ definition: "import default", ranges: [r2], },
|
||||
{ definition: "import fooDefault", ranges: [r3] },
|
||||
{ definition: "(alias) const foo: 1\nimport default", ranges: [r2], },
|
||||
{ definition: "(alias) const fooDefault: 1\nimport fooDefault", ranges: [r3] },
|
||||
]);
|
||||
verify.referenceGroups(r2, [
|
||||
{ definition: "import default", ranges: [r2] },
|
||||
{ definition: "import fooDefault", ranges: [r3] },
|
||||
{ definition: "(alias) const foo: 1\nimport default", ranges: [r2] },
|
||||
{ definition: "(alias) const fooDefault: 1\nimport fooDefault", ranges: [r3] },
|
||||
{ definition: "const foo: 1", ranges: [r0, r1] },
|
||||
]);
|
||||
verify.referenceGroups(r3, [
|
||||
{ definition: "import fooDefault", ranges: [r3] },
|
||||
{ definition: "import default", ranges: [r2] },
|
||||
{ definition: "(alias) const fooDefault: 1\nimport fooDefault", ranges: [r3] },
|
||||
{ definition: "(alias) const foo: 1\nimport default", ranges: [r2] },
|
||||
{ definition: "const foo: 1", ranges: [r0, r1] },
|
||||
]);
|
||||
|
|
|
@ -17,16 +17,16 @@ verify.noErrors();
|
|||
const [r0, r1, r2, r3] = test.ranges();
|
||||
verify.referenceGroups([r0, r1], [
|
||||
{ definition: "const foo: 1", ranges: [r0, r1] },
|
||||
{ definition: "import default", ranges: [r2], },
|
||||
{ definition: "import fooDefault", ranges: [r3] },
|
||||
{ definition: "(alias) const foo: 1\nimport default", ranges: [r2], },
|
||||
{ definition: "(alias) const fooDefault: 1\nimport fooDefault", ranges: [r3] },
|
||||
]);
|
||||
verify.referenceGroups(r2, [
|
||||
{ definition: "import default", ranges: [r2] },
|
||||
{ definition: "import fooDefault", ranges: [r3] },
|
||||
{ definition: "(alias) const foo: 1\nimport default", ranges: [r2] },
|
||||
{ definition: "(alias) const fooDefault: 1\nimport fooDefault", ranges: [r3] },
|
||||
{ definition: "const foo: 1", ranges: [r0, r1] },
|
||||
]);
|
||||
verify.referenceGroups(r3, [
|
||||
{ definition: "import fooDefault", ranges: [r3] },
|
||||
{ definition: "import default", ranges: [r2] },
|
||||
{ definition: "(alias) const fooDefault: 1\nimport fooDefault", ranges: [r3] },
|
||||
{ definition: "(alias) const foo: 1\nimport default", ranges: [r2] },
|
||||
{ definition: "const foo: 1", ranges: [r0, r1] },
|
||||
]);
|
||||
|
|
|
@ -28,31 +28,31 @@ const cRanges = [c0, c1, c2];
|
|||
|
||||
verify.referenceGroups(a0, [
|
||||
{ definition: "function a(): void\nnamespace a", ranges: aRanges },
|
||||
{ definition: "import b", ranges: bRanges },
|
||||
{ definition: "import a", ranges: cRanges }
|
||||
{ definition: "(alias) function b(): void\n(alias) namespace b\nimport b", ranges: bRanges },
|
||||
{ definition: "(alias) function a(): void\n(alias) namespace a\nimport a", ranges: cRanges }
|
||||
]);
|
||||
verify.referenceGroups([a1, a2], [
|
||||
{ definition: "namespace a\nfunction a(): void", ranges: aRanges },
|
||||
{ definition: "import b", ranges: bRanges },
|
||||
{ definition: "import a", ranges: cRanges }
|
||||
{ definition: "(alias) function b(): void\n(alias) namespace b\nimport b", ranges: bRanges },
|
||||
{ definition: "(alias) function a(): void\n(alias) namespace a\nimport a", ranges: cRanges }
|
||||
]);
|
||||
|
||||
verify.referenceGroups([b0, b0], [
|
||||
{ definition: "import b", ranges: bRanges }
|
||||
{ definition: "(alias) function b(): void\n(alias) namespace b\nimport b", ranges: bRanges }
|
||||
]);
|
||||
verify.referenceGroups(b1, [
|
||||
{ definition: "(alias) b(): void\nimport b", ranges: bRanges }
|
||||
]);
|
||||
|
||||
verify.referenceGroups([c0, c2], [
|
||||
{ definition: "import a", ranges: cRanges },
|
||||
{ definition: "(alias) function a(): void\n(alias) namespace a\nimport a", ranges: cRanges },
|
||||
{ definition: "namespace a\nfunction a(): void", ranges: aRanges },
|
||||
{ definition: "import b", ranges: bRanges }
|
||||
{ definition: "(alias) function b(): void\n(alias) namespace b\nimport b", ranges: bRanges }
|
||||
]);
|
||||
verify.referenceGroups(c1, [
|
||||
{ definition: "(alias) a(): void\nimport a", ranges: cRanges },
|
||||
{ definition: "namespace a\nfunction a(): void", ranges: aRanges },
|
||||
{ definition: "import b", ranges: bRanges }
|
||||
{ definition: "(alias) function b(): void\n(alias) namespace b\nimport b", ranges: bRanges }
|
||||
]);
|
||||
|
||||
verify.renameLocations(aRanges, aRanges.concat(cRanges));
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
const ranges = test.ranges();
|
||||
const [r0, r1, r2, r3] = ranges;
|
||||
const classes = { definition: "class Class", ranges: [r0] };
|
||||
const imports = { definition: "import Class", ranges: [r1, r2] };
|
||||
const reExports = { definition: "import Class", ranges: [r3] };
|
||||
const imports = { definition: "(alias) class Class\nimport Class", ranges: [r1, r2] };
|
||||
const reExports = { definition: "(alias) class Class\nimport Class", ranges: [r3] };
|
||||
verify.referenceGroups(r0, [classes, imports, reExports]);
|
||||
verify.referenceGroups(r1, [imports, classes, reExports]);
|
||||
verify.referenceGroups(r2, [
|
||||
|
|
|
@ -17,8 +17,8 @@ const c2Ranges = ranges.get("C2");
|
|||
const [c2_0, c2_1] = c2Ranges;
|
||||
const c3Ranges = ranges.get("C3");
|
||||
const classes = { definition: "class Class", ranges: classRanges };
|
||||
const c2s = { definition: "import C2", ranges: c2Ranges };
|
||||
const c3s = { definition: "import C3", ranges: c3Ranges };
|
||||
const c2s = { definition: "(alias) class C2\nimport C2", ranges: c2Ranges };
|
||||
const c3s = { definition: "(alias) class C3\nimport C3", ranges: c3Ranges };
|
||||
|
||||
verify.referenceGroups(classRanges, [classes, c2s, c3s]);
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ const axRanges = [ax0, ax1, ax2];
|
|||
const bxRanges = [bx0, bx1];
|
||||
const byRanges = [by0, by1];
|
||||
const axGroup = { definition: "var x: any", ranges: axRanges };
|
||||
const bxGroup = { definition: "import x", ranges: bxRanges };
|
||||
const ayGroup = { definition: "import y", ranges: [ay] }
|
||||
const byGroup = { definition: "import y", ranges: byRanges }
|
||||
const bxGroup = { definition: "(alias) var x: any\nimport x", ranges: bxRanges };
|
||||
const ayGroup = { definition: "(alias) var y: any\nimport y", ranges: [ay] }
|
||||
const byGroup = { definition: "(alias) var y: any\nimport y", ranges: byRanges }
|
||||
|
||||
verify.referenceGroups(axRanges, [axGroup, bxGroup, ayGroup, byGroup]);
|
||||
verify.referenceGroups(bxRanges, [bxGroup, axGroup, ayGroup, byGroup]);
|
||||
|
|
|
@ -19,13 +19,13 @@ const [a, b, cFromB, cFromA, cUse, d] = test.ranges();
|
|||
const cFromARanges = [cFromA, cUse];
|
||||
|
||||
const aGroup = { definition: "const x: 0", ranges: [a] };
|
||||
const cFromAGroup = { definition: "import x", ranges: cFromARanges };
|
||||
const cFromAGroup = { definition: "(alias) const x: 0\nimport x", ranges: cFromARanges };
|
||||
|
||||
verify.referenceGroups(a, [aGroup, cFromAGroup]);
|
||||
|
||||
const bGroup = { definition: "const x: 0", ranges: [b] };
|
||||
const cFromBGroup = { definition: "import x", ranges: [cFromB] };
|
||||
const dGroup = { definition: "import x", ranges: [d] };
|
||||
const cFromBGroup = { definition: "(alias) const x: 0\nimport x", ranges: [cFromB] };
|
||||
const dGroup = { definition: "(alias) const x: 0\nimport x", ranges: [d] };
|
||||
verify.referenceGroups(b, [bGroup, cFromBGroup, dGroup]);
|
||||
|
||||
verify.referenceGroups(cFromB, [cFromBGroup, dGroup, bGroup]);
|
||||
|
|
|
@ -13,6 +13,6 @@ verify.noErrors();
|
|||
const ranges = test.ranges();
|
||||
const [r0, r1] = ranges;
|
||||
const a = { definition: "function foo(): void", ranges: [r0] };
|
||||
const c = { definition: "import foo", ranges: [r1] };
|
||||
const c = { definition: "(alias) function foo(): void\nimport foo", ranges: [r1] };
|
||||
verify.referenceGroups(r0, [a, c]);
|
||||
verify.referenceGroups(r1, [c, a]);
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
verify.noErrors();
|
||||
const [foo0, foo1, bar0, foo2, defaultC, defaultD, bar1, baz0, defaultE, bang0, boom0, bar2, baz1, bang1, boom1] = test.ranges();
|
||||
const a = { definition: "function foo(): void", ranges: [foo0, foo1, foo2] };
|
||||
const b = { definition: "import bar", ranges: [bar0] };
|
||||
const c = { definition: "import default", ranges: [defaultC, defaultE] };
|
||||
const d = { definition: "import default", ranges: [defaultD] };
|
||||
const eBar = { definition: "import bar", ranges: [bar1, bar2] };
|
||||
const eBaz = { definition: "import baz", ranges: [baz0, baz1] };
|
||||
const eBang = { definition: "import bang", ranges: [bang0, bang1] };
|
||||
const eBoom = { definition: "import boom", ranges: [boom0, boom1] };
|
||||
const b = { definition: "(alias) function bar(): void\nimport bar", ranges: [bar0] };
|
||||
const c = { definition: "(alias) function foo(): void\nimport default", ranges: [defaultC, defaultE] };
|
||||
const d = { definition: "(alias) function foo(): void\nimport default", ranges: [defaultD] };
|
||||
const eBar = { definition: "(alias) function bar(): void\nimport bar", ranges: [bar1, bar2] };
|
||||
const eBaz = { definition: "(alias) function baz(): void\nimport baz", ranges: [baz0, baz1] };
|
||||
const eBang = { definition: "(alias) function bang(): void\nimport bang", ranges: [bang0, bang1] };
|
||||
const eBoom = { definition: "(alias) function boom(): void\nimport boom", ranges: [boom0, boom1] };
|
||||
|
||||
verify.referenceGroups([foo0, foo1, foo2], [a, b, eBar, c, d, eBoom, eBaz, eBang]);
|
||||
|
||||
|
|
|
@ -10,5 +10,5 @@ verify.noErrors();
|
|||
const [r0, r1, r2] = test.ranges();
|
||||
verify.referenceGroups(r0, [
|
||||
{ definition: "function foo(): void", ranges: [r0, r1] },
|
||||
{ definition: "import oof", ranges: [r2] }
|
||||
{ definition: "(alias) function oof(): void\nimport oof", ranges: [r2] }
|
||||
]);
|
||||
|
|
|
@ -12,7 +12,7 @@ const [r0, r1, r2, r3] = test.ranges();
|
|||
const aRanges = [r0, r1];
|
||||
const bRanges = [r2, r3];
|
||||
const aGroup = { definition: "const x: 0", ranges: aRanges };
|
||||
const bGroup = { definition: "import x", ranges: bRanges };
|
||||
const bGroup = { definition: "(alias) const x: 0\nimport x", ranges: bRanges };
|
||||
verify.referenceGroups(aRanges, [aGroup, bGroup]);
|
||||
verify.referenceGroups(bRanges, [bGroup]);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
//// <div style={{ fontFamily: "sans-serif" }}></div>;
|
||||
|
||||
const [r0, r1, r2] = test.ranges();
|
||||
const imports = { definition: "import SubmissionComp", ranges: [r0, r1] };
|
||||
const imports = { definition: "(alias) const SubmissionComp: (submission: any) => any\nimport SubmissionComp", ranges: [r0, r1] };
|
||||
const def = { definition: "const SubmissionComp: (submission: any) => any", ranges: [r2] };
|
||||
verify.referenceGroups([r0, r1], [imports, def]);
|
||||
verify.referenceGroups(r2, [def, imports]);
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
const ranges = test.ranges();
|
||||
const [r0, r1, r2] = ranges;
|
||||
const defs = { definition: "var x: number", ranges: [r0] };
|
||||
const imports = { definition: "import x", ranges: [r1, r2] };
|
||||
const imports = { definition: "(alias) var x: number\nimport x", ranges: [r1, r2] };
|
||||
verify.referenceGroups(r0, [defs, imports]);
|
||||
verify.referenceGroups([r1, r2], [imports, defs]);
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
////var /*3*/z = new /*2*/Foo();
|
||||
////var /*5*/r2 = Foo./*4*/x;
|
||||
|
||||
verify.quickInfoAt("1", "import Foo = require('./mergedDeclarationsWithExportAssignment1_file0')");
|
||||
verify.quickInfoAt("1", [
|
||||
"(alias) class Foo",
|
||||
"(alias) namespace Foo",
|
||||
"import Foo = require('./mergedDeclarationsWithExportAssignment1_file0')"
|
||||
].join("\n"));
|
||||
|
||||
goTo.marker('2');
|
||||
verify.completionListContains('Foo');
|
||||
|
|
|
@ -15,33 +15,4 @@
|
|||
//// new /*8*/a4.c();
|
||||
////}
|
||||
|
||||
var marker = 0;
|
||||
function goToMarker() {
|
||||
marker++;
|
||||
goTo.marker(marker.toString());
|
||||
}
|
||||
|
||||
function verifyImport(name: string, assigningDisplay:ts.SymbolDisplayPart[], optionalParentName?: string) {
|
||||
goToMarker();
|
||||
var moduleNameDisplay = [{ text: name, kind: "aliasName" }];
|
||||
if (optionalParentName) {
|
||||
moduleNameDisplay = [{ text: optionalParentName, kind: "moduleName" }, { text: ".", kind: "punctuation" }].concat(moduleNameDisplay);
|
||||
}
|
||||
verify.verifyQuickInfoDisplayParts("alias", optionalParentName ? "export" : "", { start: test.markerByName(marker.toString()).position, length: name.length },
|
||||
[{ text: "import", kind: "keyword" }, { text: " ", kind: "space" }].concat(moduleNameDisplay).concat(
|
||||
{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { text: " ", kind: "space" }).concat(assigningDisplay),
|
||||
[], []);
|
||||
}
|
||||
|
||||
var moduleMDisplay = [{ text: "m", kind: "moduleName" }];
|
||||
var moduleMDotM1Display = moduleMDisplay.concat({ text: ".", kind: "punctuation" }, { text: "m1", kind: "moduleName" });
|
||||
|
||||
verifyImport("a1", moduleMDisplay);
|
||||
verifyImport("a1", moduleMDisplay);
|
||||
verifyImport("a2", moduleMDotM1Display);
|
||||
verifyImport("a2", moduleMDotM1Display);
|
||||
|
||||
verifyImport("a3", moduleMDisplay, "m2");
|
||||
verifyImport("a3", moduleMDisplay, "m2");
|
||||
verifyImport("a4", moduleMDotM1Display, "m2");
|
||||
verifyImport("a4", moduleMDotM1Display, "m2");
|
||||
verify.baselineQuickInfo();
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: quickInfoImportedTypes.ts
|
||||
//// /** This is an interface */
|
||||
//// export interface Foo {
|
||||
//// a?: number;
|
||||
//// }
|
||||
//// /** One or two */
|
||||
//// export type Bar = 1 | 2
|
||||
//// /** This is a class */
|
||||
//// export class Baz<T extends {}> {
|
||||
//// public x: T = {} as T
|
||||
//// }
|
||||
|
||||
// @Filename: two.ts
|
||||
//// import { Foo, Bar, Baz } from './quickInfoImportedTypes';
|
||||
//// let x: Foo/*1*/;
|
||||
//// let y: Bar/*2*/<any>;
|
||||
//// let z: Baz/*3*/;
|
||||
|
||||
verify.quickInfoAt("1", [
|
||||
"(alias) interface Foo",
|
||||
"import Foo",
|
||||
].join("\n"), "This is an interface ");
|
||||
|
||||
verify.quickInfoAt("2", [
|
||||
"(alias) type Bar = 1 | 2",
|
||||
"import Bar",
|
||||
].join("\n"), "One or two ");
|
||||
|
||||
verify.quickInfoAt("3", [
|
||||
"(alias) class Baz<T extends {}>",
|
||||
"import Baz",
|
||||
].join("\n"), "This is a class ");
|
|
@ -0,0 +1,28 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: quickInfoImportedTypesWithMergedMeanings.ts
|
||||
//// export namespace Original { }
|
||||
//// export type Original<T> = () => T;
|
||||
//// /** some docs */
|
||||
//// export function Original() { }
|
||||
|
||||
// @Filename: transient.ts
|
||||
//// export { Original/*1*/ } from './quickInfoImportedTypesWithMergedMeanings';
|
||||
|
||||
// @Filename: importer.ts
|
||||
//// import { Original as Alias } from './quickInfoImportedTypesWithMergedMeanings';
|
||||
//// Alias/*2*/;
|
||||
|
||||
verify.quickInfoAt("1", [
|
||||
"(alias) type Original<T> = () => T",
|
||||
"(alias) namespace Original",
|
||||
"(alias) function Original(): void",
|
||||
"import Original",
|
||||
].join("\n"), "some docs ");
|
||||
|
||||
verify.quickInfoAt("2", [
|
||||
"(alias) type Alias<T> = () => T",
|
||||
"(alias) namespace Alias",
|
||||
"(alias) function Alias(): void",
|
||||
"import Alias",
|
||||
].join("\n"), "some docs ");
|
|
@ -29,7 +29,7 @@ verify.quickInfoIs("const foo: number");
|
|||
verify.goToDefinitionIs("foo_value_declaration");
|
||||
|
||||
goTo.marker("foo_type");
|
||||
verify.quickInfoIs("import foo = require(\"foo_module\")");
|
||||
verify.quickInfoIs("(alias) interface foo\nimport foo = require(\"foo_module\")");
|
||||
verify.goToDefinitionIs("foo_type_declaration");
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ verify.navigationItemsListContains("bar", "alias", "bar", "exact");
|
|||
verify.navigationItemsListContains("bar", "interface", "bar", "exact");
|
||||
|
||||
goTo.marker("bar_value");
|
||||
verify.quickInfoIs("import bar = require(\"bar_module\")");
|
||||
verify.quickInfoIs("(alias) const bar: number\nimport bar = require(\"bar_module\")");
|
||||
verify.goToDefinitionIs("bar_value_declaration");
|
||||
|
||||
goTo.marker("bar_type");
|
||||
|
|
|
@ -21,16 +21,16 @@
|
|||
|
||||
verify.quickInfos({
|
||||
1: ["class m1.m2.c", "class comment;"],
|
||||
2: ["import internalAlias = m1.m2.c", "This is on import declaration"],
|
||||
2: ["(alias) class internalAlias\nimport internalAlias = m1.m2.c", "This is on import declaration"],
|
||||
3: ["class m1.m2.c", "class comment;"],
|
||||
4: "var newVar: internalAlias",
|
||||
5: "(alias) new internalAlias(): internalAlias\nimport internalAlias = m1.m2.c",
|
||||
6: "var anotherAliasVar: typeof internalAlias",
|
||||
7: ["import internalAlias = m1.m2.c", "This is on import declaration"],
|
||||
8: "import internalFoo = m1.foo",
|
||||
7: ["(alias) class internalAlias\nimport internalAlias = m1.m2.c", "This is on import declaration"],
|
||||
8: "(alias) function internalFoo(): void\nimport internalFoo = m1.foo",
|
||||
9: "function m1.foo(): void",
|
||||
10: "var callVar: void",
|
||||
11: "(alias) internalFoo(): void\nimport internalFoo = m1.foo",
|
||||
12: "var anotherAliasFoo: () => void",
|
||||
13: "import internalFoo = m1.foo"
|
||||
13: "(alias) function internalFoo(): void\nimport internalFoo = m1.foo"
|
||||
});
|
||||
|
|
|
@ -17,5 +17,5 @@
|
|||
const [moduleFoo0, f0, moduleBar0, foo0, moduleFoo1, foo1, f1, moduleBar1, foo2] = test.ranges();
|
||||
verify.singleReferenceGroup('module "foo"', [moduleFoo1, moduleFoo0]);
|
||||
verify.singleReferenceGroup('module "bar"', [moduleBar1, moduleBar0]);
|
||||
verify.singleReferenceGroup('import foo = require("foo")', [foo0, foo1, foo2]);
|
||||
verify.singleReferenceGroup('(alias) module "foo"\nimport foo = require("foo")', [foo0, foo1, foo2]);
|
||||
verify.singleReferenceGroup("var f: number", [f0, f1]);
|
||||
|
|
|
@ -12,4 +12,4 @@
|
|||
// @Filename: referencesForGlobals_2.ts
|
||||
////var m = [|globalAlias|];
|
||||
|
||||
verify.singleReferenceGroup("import globalAlias = globalModule");
|
||||
verify.singleReferenceGroup("(alias) namespace globalAlias\nimport globalAlias = globalModule");
|
||||
|
|
|
@ -11,4 +11,8 @@
|
|||
////var a: [|alias|].Bar; // namespace
|
||||
////[|alias|].call(this); // value
|
||||
|
||||
verify.singleReferenceGroup("import alias = ATest");
|
||||
verify.singleReferenceGroup([
|
||||
"(alias) namespace alias",
|
||||
"(alias) function alias(): void",
|
||||
"import alias = ATest"
|
||||
].join("\n"));
|
||||
|
|
|
@ -18,7 +18,7 @@ const ranges = test.ranges();
|
|||
const [C, B0, B1] = ranges;
|
||||
|
||||
const classes = { definition: "class B", ranges: [C] };
|
||||
const imports = { definition: "import B", ranges: [B0, B1] };
|
||||
const imports = { definition: "(alias) class B\nimport B", ranges: [B0, B1] };
|
||||
verify.referenceGroups(C, [classes, imports]);
|
||||
verify.referenceGroups(B0, [imports, classes]);
|
||||
verify.referenceGroups(B1, [
|
||||
|
|
|
@ -18,7 +18,7 @@ const ranges = test.ranges();
|
|||
const [C, B0, B1] = ranges;
|
||||
const bRanges = [B0, B1];
|
||||
const classes = { definition: "class C", ranges: [C] };
|
||||
const imports = { definition: "import B", ranges: [B0, B1] };
|
||||
const imports = { definition: "(alias) class B\nimport B", ranges: [B0, B1] };
|
||||
verify.referenceGroups(C, [classes, imports]);
|
||||
verify.referenceGroups(B0, [imports]);
|
||||
verify.referenceGroups(B1, [{ definition: "(alias) new B(): B\nimport B", ranges: bRanges }]);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
const ranges = test.ranges();
|
||||
const [r0, r1, r2] = ranges;
|
||||
const vars = { definition: "var a: any", ranges: [r0] };
|
||||
const imports = { definition: "import a", ranges: [r1, r2] };
|
||||
const imports = { definition: "(alias) var a: any\nimport a", ranges: [r1, r2] };
|
||||
verify.referenceGroups(r0, [vars, imports]);
|
||||
verify.referenceGroups(r1, [imports, vars]);
|
||||
verify.referenceGroups(r2, [imports, vars]);
|
||||
|
|
|
@ -22,8 +22,8 @@ const bRanges = [b0, b1];
|
|||
const xRanges = [x0, x1];
|
||||
|
||||
const nGroup = { definition: "namespace N", ranges: nRanges };
|
||||
const aGroup = { definition: "import N", ranges: aRanges };
|
||||
const bGroup = { definition: "import N", ranges: [b0, b1] };
|
||||
const aGroup = { definition: "(alias) namespace N\nimport N", ranges: aRanges };
|
||||
const bGroup = { definition: "(alias) namespace N\nimport N", ranges: [b0, b1] };
|
||||
|
||||
verify.referenceGroups(nRanges, [nGroup, aGroup, bGroup]);
|
||||
verify.referenceGroups([a0, a1], [aGroup, nGroup, bGroup]);
|
||||
|
|
|
@ -24,9 +24,9 @@ const pRanges = [P0, P1];
|
|||
const qRanges = [Q0, Q1];
|
||||
|
||||
const ns = { definition: "namespace N", ranges: nRanges };
|
||||
const os = { definition: "import O", ranges: oRanges };
|
||||
const ps = { definition: "import P", ranges: pRanges };
|
||||
const qs = { definition: "import Q", ranges: qRanges };
|
||||
const os = { definition: "(alias) namespace O\nimport O", ranges: oRanges };
|
||||
const ps = { definition: "(alias) namespace P\nimport P", ranges: pRanges };
|
||||
const qs = { definition: "(alias) namespace Q\nimport Q", ranges: qRanges };
|
||||
|
||||
verify.referenceGroups(nRanges, [ns, os, ps, qs]);
|
||||
verify.referenceGroups(oRanges, [os, ps, qs]);
|
||||
|
|
|
@ -20,8 +20,8 @@ const ranges = test.ranges();
|
|||
const [r0, r1, r2, r3] = ranges;
|
||||
const importRanges = [r2, r3];
|
||||
const classes = { definition: "class C", ranges: [r0] };
|
||||
const bs = { definition: "import C", ranges: [r1] };
|
||||
const imports = { definition: "import C", ranges: importRanges };
|
||||
const bs = { definition: "(alias) class C\nimport C", ranges: [r1] };
|
||||
const imports = { definition: "(alias) class C\nimport C", ranges: importRanges };
|
||||
verify.referenceGroups(r0, [classes, bs, imports]);
|
||||
verify.referenceGroups(r1, [bs, imports, classes]);
|
||||
verify.referenceGroups(importRanges, [imports, bs, classes]);
|
||||
|
|
|
@ -18,8 +18,8 @@ const cRanges = ranges.get("C");
|
|||
const [d0, d1, d2] = ranges.get("D");
|
||||
|
||||
const classes = { definition: "class C", ranges: cRanges };
|
||||
const bImports = { definition: "import D", ranges: [d0] };
|
||||
const cImports = { definition: "import D", ranges: [d1, d2] };
|
||||
const bImports = { definition: "(alias) class D\nimport D", ranges: [d0] };
|
||||
const cImports = { definition: "(alias) class D\nimport D", ranges: [d1, d2] };
|
||||
verify.referenceGroups(cRanges, [classes, bImports, cImports]);
|
||||
|
||||
verify.referenceGroups(d0, [bImports, cImports]);
|
||||
|
|
|
@ -21,7 +21,7 @@ const aRanges = [a0, a1];
|
|||
const bRanges = [b0, c2];
|
||||
const cRanges = [c0, c1];
|
||||
|
||||
const bGroup = { definition: "import b = require('./a')", ranges: bRanges }
|
||||
const bGroup = { definition: "(alias) class b\nimport b = require('./a')", ranges: bRanges }
|
||||
|
||||
verify.referenceGroups(aRanges, [
|
||||
{ definition: "class A", ranges: aRanges },
|
||||
|
|
|
@ -20,8 +20,8 @@ const bRanges = [B0, B1];
|
|||
const cRanges = [B2];
|
||||
|
||||
const aGroup = { definition: "namespace A", ranges: aRanges };
|
||||
const bGroup = { definition: "import B = A", ranges: bRanges };
|
||||
const cGroup = { definition: "import B", ranges: cRanges };
|
||||
const bGroup = { definition: "(alias) namespace B\nimport B = A", ranges: bRanges };
|
||||
const cGroup = { definition: "(alias) namespace B\nimport B", ranges: cRanges };
|
||||
|
||||
verify.referenceGroups(aRanges, [aGroup, bGroup, cGroup]);
|
||||
verify.referenceGroups(bRanges, [bGroup, cGroup]);
|
||||
|
|
|
@ -13,9 +13,9 @@ verify.noErrors();
|
|||
const [f0, f1, g0, f2, g1] = test.ranges();
|
||||
|
||||
const af = { definition: "function f(): void", ranges: [f0, f1] };
|
||||
const g0Group = { definition: "import g", ranges: [g0] };
|
||||
const g1Group = { definition: "import g", ranges: [g1] };
|
||||
const bf = { definition: "import f", ranges: [f2] };
|
||||
const g0Group = { definition: "(alias) function g(): void\nimport g", ranges: [g0] };
|
||||
const g1Group = { definition: "(alias) function g(): void\nimport g", ranges: [g1] };
|
||||
const bf = { definition: "(alias) function f(): void\nimport f", ranges: [f2] };
|
||||
|
||||
verify.referenceGroups([f0, f1], [af, g0Group, g1Group, bf]);
|
||||
verify.referenceGroups(g0, [g0Group, g1Group]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче