mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Basic implementation for finding all references
This commit is contained in:
parent
e9122b4d85
commit
7e39622d5d
@ -110,7 +110,8 @@ module ts {
|
||||
getAliasedSymbol: resolveImport,
|
||||
isUndefinedSymbol: symbol => symbol === undefinedSymbol,
|
||||
isArgumentsSymbol: symbol => symbol === argumentsSymbol,
|
||||
hasEarlyErrors: hasEarlyErrors
|
||||
hasEarlyErrors: hasEarlyErrors,
|
||||
resolveEntityNameForShortHandPropertyAssignment: resolveEntityNameForShortHandPropertyAssignment,
|
||||
};
|
||||
|
||||
var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
|
||||
@ -537,6 +538,10 @@ module ts {
|
||||
return symbol.flags & meaning ? symbol : resolveImport(symbol);
|
||||
}
|
||||
|
||||
function resolveEntityNameForShortHandPropertyAssignment(location: Node): Symbol {
|
||||
return resolveEntityName(location, <Identifier>location, SymbolFlags.Value);
|
||||
}
|
||||
|
||||
function isExternalModuleNameRelative(moduleName: string): boolean {
|
||||
// TypeScript 1.0 spec (April 2014): 11.2.1
|
||||
// An external module name is "relative" if the first term is "." or "..".
|
||||
|
||||
@ -733,6 +733,7 @@ module ts {
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
isValidPropertyAccess(node: PropertyAccess, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
resolveEntityNameForShortHandPropertyAssignment(location: Node): Symbol;
|
||||
}
|
||||
|
||||
export interface SymbolDisplayBuilder {
|
||||
|
||||
@ -4227,6 +4227,9 @@ module ts {
|
||||
forEach(getPropertySymbolsFromContextualType(location), contextualSymbol => {
|
||||
result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol));
|
||||
});
|
||||
if (location.kind === SyntaxKind.Identifier && location.parent.kind === SyntaxKind.ShortHandPropertyAssignment) {
|
||||
result.push(typeInfoResolver.resolveEntityNameForShortHandPropertyAssignment(location));
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a union property, add all the symbols from all its source symbols in all unioned types.
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
tests/cases/compiler/incompleteObjectLiteral1.ts(1,14): error TS1005: ':' expected.
|
||||
tests/cases/compiler/incompleteObjectLiteral1.ts(1,14): error TS1005: ',' expected.
|
||||
tests/cases/compiler/incompleteObjectLiteral1.ts(1,16): error TS1128: Declaration or statement expected.
|
||||
tests/cases/compiler/incompleteObjectLiteral1.ts(1,12): error TS2304: Cannot find name 'aa'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/incompleteObjectLiteral1.ts (2 errors) ====
|
||||
==== tests/cases/compiler/incompleteObjectLiteral1.ts (3 errors) ====
|
||||
var tt = { aa; }
|
||||
~
|
||||
!!! error TS1005: ':' expected.
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'aa'.
|
||||
var x = tt;
|
||||
@ -1,10 +1,9 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(12,6): error TS1112: A class member cannot be declared optional.
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(20,6): error TS1112: A class member cannot be declared optional.
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,6): error TS1005: ':' expected.
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,7): error TS1109: Expression expected.
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts(24,6): error TS1159: A object member cannot be declared optional.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts (4 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties.ts (3 errors) ====
|
||||
// Basic uses of optional properties
|
||||
|
||||
var a: {
|
||||
@ -33,8 +32,6 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWith
|
||||
|
||||
var b = {
|
||||
x?: 1 // error
|
||||
~
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
!!! error TS1159: A object member cannot be declared optional.
|
||||
}
|
||||
@ -1,13 +1,16 @@
|
||||
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,14): error TS1005: ':' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,14): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,16): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts(1,12): error TS2304: Cannot find name 'aa'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512097.ts (3 errors) ====
|
||||
var tt = { aa; } // After this point, no useful parsing occurs in the entire file
|
||||
~
|
||||
!!! error TS1005: ':' expected.
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'aa'.
|
||||
|
||||
if (true) {
|
||||
}
|
||||
@ -1,11 +1,14 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,1): error TS1005: ':' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,1): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(2,7): error TS1005: ':' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts(1,11): error TS2304: Cannot find name 'a'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ObjectLiterals/parserErrorRecovery_ObjectLiteral2.ts (3 errors) ====
|
||||
var v = { a
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
return;
|
||||
~~~~~~
|
||||
!!! error TS1005: ':' expected.
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1005: ':' expected.
|
||||
Loading…
x
Reference in New Issue
Block a user