mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-30 15:15:38 -05:00
Get rid of getRootSymbol and include target's flags in transient symbol's flags
This commit is contained in:
@@ -605,6 +605,12 @@ module ts {
|
||||
}
|
||||
|
||||
function symbolIsValue(symbol: Symbol): boolean {
|
||||
// If it is an instantiated symbol, then it is a value if the symbol it is an
|
||||
// instantiation of is a value.
|
||||
if (symbol.flags & SymbolFlags.Instantiated) {
|
||||
return (getSymbolLinks(symbol).target.flags & SymbolFlags.Value) !== 0;
|
||||
}
|
||||
|
||||
// If the symbol has the value flag, it is trivially a value.
|
||||
if (symbol.flags & SymbolFlags.Value) {
|
||||
return true;
|
||||
@@ -615,12 +621,6 @@ module ts {
|
||||
return (resolveImport(symbol).flags & SymbolFlags.Value) !== 0;
|
||||
}
|
||||
|
||||
// If it is an instantiated symbol, then it is a value if the symbol it is an
|
||||
// instantiation of is a value.
|
||||
if (symbol.flags & SymbolFlags.Instantiated) {
|
||||
return (getSymbolLinks(symbol).target.flags & SymbolFlags.Value) !== 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1336,8 +1336,8 @@ module ts {
|
||||
}
|
||||
|
||||
function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) {
|
||||
var rootSymbol = getRootSymbol(symbol);
|
||||
if (rootSymbol.flags & SymbolFlags.Class || rootSymbol.flags & SymbolFlags.Interface) {
|
||||
var targetSymbol = getTargetSymbol(symbol);
|
||||
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface) {
|
||||
buildTypeParameterListDisplay(getTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags);
|
||||
}
|
||||
}
|
||||
@@ -1753,6 +1753,9 @@ module ts {
|
||||
}
|
||||
|
||||
function getTypeOfSymbol(symbol: Symbol): Type {
|
||||
if (symbol.flags & SymbolFlags.Instantiated) {
|
||||
return getTypeOfInstantiatedSymbol(symbol);
|
||||
}
|
||||
if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) {
|
||||
return getTypeOfVariableOrParameterOrProperty(symbol);
|
||||
}
|
||||
@@ -1768,9 +1771,6 @@ module ts {
|
||||
if (symbol.flags & SymbolFlags.Import) {
|
||||
return getTypeOfImport(symbol);
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.Instantiated) {
|
||||
return getTypeOfInstantiatedSymbol(symbol);
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.UnionProperty) {
|
||||
return getTypeOfUnionProperty(symbol);
|
||||
}
|
||||
@@ -1928,6 +1928,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getDeclaredTypeOfSymbol(symbol: Symbol): Type {
|
||||
Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0);
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
return getDeclaredTypeOfClass(symbol);
|
||||
}
|
||||
@@ -1943,7 +1944,6 @@ module ts {
|
||||
if (symbol.flags & SymbolFlags.Import) {
|
||||
return getDeclaredTypeOfImport(symbol);
|
||||
}
|
||||
Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0);
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@@ -2949,7 +2949,7 @@ module ts {
|
||||
|
||||
// Keep the flags from the symbol we're instantiating. Mark that is instantiated, and
|
||||
// also transient so that we can just store data on it directly.
|
||||
var result = <TransientSymbol>createSymbol(SymbolFlags.Instantiated | SymbolFlags.Transient, symbol.name);
|
||||
var result = <TransientSymbol>createSymbol(SymbolFlags.Instantiated | SymbolFlags.Transient | symbol.flags, symbol.name);
|
||||
result.declarations = symbol.declarations;
|
||||
result.parent = symbol.parent;
|
||||
result.target = symbol;
|
||||
@@ -3699,7 +3699,7 @@ module ts {
|
||||
var members: SymbolTable = {};
|
||||
var index = 0;
|
||||
forEach(properties, p => {
|
||||
var symbol = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient, p.name);
|
||||
var symbol = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | p.flags, p.name);
|
||||
symbol.declarations = p.declarations;
|
||||
symbol.parent = p.parent;
|
||||
symbol.type = widenedTypes[index++];
|
||||
@@ -4681,7 +4681,7 @@ module ts {
|
||||
var member = members[id];
|
||||
if (member.flags & SymbolFlags.Property) {
|
||||
var type = checkExpression((<PropertyDeclaration>member.declarations[0]).initializer, contextualMapper);
|
||||
var prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient, member.name);
|
||||
var prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name);
|
||||
prop.declarations = member.declarations;
|
||||
prop.parent = member.parent;
|
||||
if (member.valueDeclaration) prop.valueDeclaration = member.valueDeclaration;
|
||||
@@ -8110,10 +8110,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getRootSymbol(symbol: Symbol): Symbol {
|
||||
return symbol.flags & SymbolFlags.Transient && getSymbolLinks(symbol).target || symbol;
|
||||
}
|
||||
|
||||
function getRootSymbols(symbol: Symbol): Symbol[] {
|
||||
if (symbol.flags & SymbolFlags.UnionProperty) {
|
||||
var symbols: Symbol[] = [];
|
||||
|
||||
@@ -2662,7 +2662,7 @@ module ts {
|
||||
|
||||
// TODO(drosen): use contextual SemanticMeaning.
|
||||
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker): string {
|
||||
var flags = typeInfoResolver.getRootSymbols(symbol)[0].getFlags();
|
||||
var flags = symbol.getFlags();
|
||||
|
||||
if (flags & SymbolFlags.Class) return ScriptElementKind.classElement;
|
||||
if (flags & SymbolFlags.Enum) return ScriptElementKind.enumElement;
|
||||
@@ -2699,6 +2699,22 @@ module ts {
|
||||
if (flags & SymbolFlags.Property) return ScriptElementKind.memberVariableElement;
|
||||
if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement;
|
||||
|
||||
if (flags & SymbolFlags.UnionProperty) {
|
||||
return forEach(typeInfoResolver.getRootSymbols(symbol), rootSymbol => {
|
||||
var rootSymbolFlags = rootSymbol.getFlags();
|
||||
if (rootSymbolFlags & SymbolFlags.Property) {
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
}
|
||||
if (rootSymbolFlags & SymbolFlags.GetAccessor) return ScriptElementKind.memberVariableElement;
|
||||
if (rootSymbolFlags & SymbolFlags.SetAccessor) return ScriptElementKind.memberVariableElement;
|
||||
Debug.assert(rootSymbolFlags & SymbolFlags.Method);
|
||||
}) || ScriptElementKind.memberFunctionElement;
|
||||
|
||||
|
||||
//?
|
||||
//: ScriptElementKind.memberFunctionElement
|
||||
}
|
||||
|
||||
return ScriptElementKind.unknown;
|
||||
}
|
||||
|
||||
@@ -2750,7 +2766,7 @@ module ts {
|
||||
semanticMeaning = getMeaningFromLocation(location)) {
|
||||
var displayParts: SymbolDisplayPart[] = [];
|
||||
var documentation: SymbolDisplayPart[];
|
||||
var symbolFlags = typeResolver.getRootSymbols(symbol)[0].flags;
|
||||
var symbolFlags = symbol.flags;
|
||||
var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver);
|
||||
var hasAddedSymbolInfo: boolean;
|
||||
// Class at constructor site need to be shown as constructor apart from property,method, vars
|
||||
@@ -2977,7 +2993,8 @@ module ts {
|
||||
symbolFlags & SymbolFlags.Method ||
|
||||
symbolFlags & SymbolFlags.Constructor ||
|
||||
symbolFlags & SymbolFlags.Signature ||
|
||||
symbolFlags & SymbolFlags.Accessor) {
|
||||
symbolFlags & SymbolFlags.Accessor ||
|
||||
symbolKind === ScriptElementKind.memberFunctionElement) {
|
||||
var allSignatures = type.getCallSignatures();
|
||||
addSignatureDisplayParts(allSignatures[0], allSignatures);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user