mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Code review feedback - Show the type as any even inside the with block
This commit is contained in:
parent
8c231716db
commit
e1b76523b3
@ -967,22 +967,22 @@ module ts {
|
||||
// Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope
|
||||
// Meaning needs to be specified if the enclosing declaration is given
|
||||
function writeSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void {
|
||||
var previouslyWrittenSymbol: Symbol;
|
||||
var parentSymbol: Symbol;
|
||||
function writeSymbolName(symbol: Symbol): void {
|
||||
if (previouslyWrittenSymbol) {
|
||||
if (parentSymbol) {
|
||||
// Write type arguments of instantiated class/interface here
|
||||
if (flags & SymbolFormatFlags.WriteTypeParametersOrArguments) {
|
||||
if (symbol.flags & SymbolFlags.Instantiated) {
|
||||
writeTypeArguments(getTypeParametersOfClassOrInterface(previouslyWrittenSymbol),
|
||||
writeTypeArguments(getTypeParametersOfClassOrInterface(parentSymbol),
|
||||
(<TransientSymbol>symbol).mapper, writer, enclosingDeclaration);
|
||||
}
|
||||
else {
|
||||
writeTypeParametersOfSymbol(previouslyWrittenSymbol, writer, enclosingDeclaration);
|
||||
writeTypeParametersOfSymbol(parentSymbol, writer, enclosingDeclaration);
|
||||
}
|
||||
}
|
||||
writePunctuation(writer, SyntaxKind.DotToken);
|
||||
}
|
||||
previouslyWrittenSymbol = symbol;
|
||||
parentSymbol = symbol;
|
||||
if (symbol.declarations && symbol.declarations.length > 0) {
|
||||
var declaration = symbol.declarations[0];
|
||||
if (declaration.name) {
|
||||
@ -1022,7 +1022,7 @@ module ts {
|
||||
}
|
||||
else {
|
||||
// If we didn't find accessible symbol chain for this symbol, break if this is external module
|
||||
if (!previouslyWrittenSymbol && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) {
|
||||
if (!parentSymbol && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -6996,6 +6996,19 @@ module ts {
|
||||
return findChildAtPosition(sourceFile);
|
||||
}
|
||||
|
||||
function isInsideWithStatementBody(node: Node): boolean {
|
||||
if (node) {
|
||||
while (node.parent) {
|
||||
if (node.parent.kind === SyntaxKind.WithStatement && (<WithStatement>node.parent).statement === node) {
|
||||
return true;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]{
|
||||
var symbols: SymbolTable = {};
|
||||
var memberFlags: NodeFlags = 0;
|
||||
|
||||
@ -166,19 +166,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function isInsideWithStatementBody(node: Node): boolean {
|
||||
if (node) {
|
||||
while (node.parent) {
|
||||
if (node.parent.kind === SyntaxKind.WithStatement && (<WithStatement>node.parent).statement === node) {
|
||||
return true;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export var fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/
|
||||
|
||||
// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
|
||||
|
||||
@ -2970,18 +2970,16 @@ module ts {
|
||||
case SyntaxKind.QualifiedName:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
// For the identifiers/this/usper etc get the type at position if not inside if statement
|
||||
if (!isInsideWithStatementBody(node)) {
|
||||
var type = typeInfoResolver.getTypeOfNode(node);
|
||||
if (type) {
|
||||
return {
|
||||
kind: ScriptElementKind.unknown,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
textSpan: new TypeScript.TextSpan(node.getStart(), node.getWidth()),
|
||||
displayParts: typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)),
|
||||
documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined
|
||||
};
|
||||
}
|
||||
// For the identifiers/this/usper etc get the type at position
|
||||
var type = typeInfoResolver.getTypeOfNode(node);
|
||||
if (type) {
|
||||
return {
|
||||
kind: ScriptElementKind.unknown,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
textSpan: new TypeScript.TextSpan(node.getStart(), node.getWidth()),
|
||||
displayParts: typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)),
|
||||
documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,10 +7,10 @@
|
||||
|
||||
|
||||
goTo.marker('1');
|
||||
verify.not.quickInfoExists();
|
||||
verify.quickInfoIs("any");
|
||||
|
||||
goTo.marker('2');
|
||||
verify.not.quickInfoExists();
|
||||
verify.quickInfoIs("any");
|
||||
|
||||
goTo.marker('3');
|
||||
verify.not.quickInfoExists();
|
||||
verify.quickInfoIs("any");
|
||||
Loading…
x
Reference in New Issue
Block a user