10000 Lanugage Service support for union types by mhegazy · Pull Request #861 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content

Lanugage Service support for union types #861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 11, 2014
Merged
Prev Previous commit
Next Next commit
Add a temporary fix to quick info
  • Loading branch information
mhegazy committed Oct 11, 2014
commit 4442b45bad79223c3ca6893a1c56eb81d30af23d
33 changes: 18 additions & 15 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2404,31 +2404,34 @@ module ts {

var documentationParts = getSymbolDocumentationDisplayParts(symbol);

// TODO: handle union properties appropriately when merging with master
var symbolFlags = typeInfoResolver.getRootSymbols(symbol)[0].flags;

// Having all this logic here is pretty unclean. Consider moving to the roslyn model
// where all symbol display logic is encapsulated into visitors and options.
var totalParts: SymbolDisplayPart[] = [];

if (symbol.flags & SymbolFlags.Class) {
if (symbolFlags & SymbolFlags.Class) {
totalParts.push(keywordPart(SyntaxKind.ClassKeyword));
totalParts.push(spacePart());
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, sourceFile));
}
else if (symbol.flags & SymbolFlags.Interface) {
else if (symbolFlags & SymbolFlags.Interface) {
totalParts.push(keywordPart(SyntaxKind.InterfaceKeyword));
totalParts.push(spacePart());
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, sourceFile));
}
else if (symbol.flags & SymbolFlags.Enum) {
else if (symbolFlags & SymbolFlags.Enum) {
totalParts.push(keywordPart(SyntaxKind.EnumKeyword));
totalParts.push(spacePart());
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, sourceFile));
}
else if (symbol.flags & SymbolFlags.Module) {
else if (symbolFlags & SymbolFlags.Module) {
totalParts.push(keywordPart(SyntaxKind.ModuleKeyword));
totalParts.push(spacePart());
totalParts.push.apply(totalParts, typeInfoResolver.symbolToDisplayParts(symbol, sourceFile));
}
else if (symbol.flags & SymbolFlags.TypeParameter) {
else if (symbolFlags & SymbolFlags.TypeParameter) {
totalParts.push(punctuationPart(SyntaxKind.OpenParenToken));
totalParts.push(new SymbolDisplayPart("type parameter", SymbolDisplayPartKind.text, undefined));
totalParts.push(punctuationPart(SyntaxKind.CloseParenToken));
Expand All @@ -2439,11 +2442,11 @@ module ts {
totalParts.push(punctuationPart(SyntaxKind.OpenParenToken));
var text: string;

if (symbol.flags & SymbolFlags.Property) { text = "property" }
else if (symbol.flags & SymbolFlags.EnumMember) { text = "enum member" }
else if (symbol.flags & SymbolFlags.Function) { text = "function" }
else if (symbol.flags & SymbolFlags.Variable) { text = "variable" }
else if (symbol.flags & SymbolFlags.Method) { text = "method" }
if (symbolFlags & SymbolFlags.Property) { text = "property" }
else if (symbolFlags & SymbolFlags.EnumMember) { text = "enum member" }
else if (symbolFlags & SymbolFlags.Function) { text = "function" }
else if (symbolFlags & SymbolFlags.Variable) { text = "variable" }
else if (symbolFlags & SymbolFlags.Method) { text = "method" }

if (!text) {
return undefined;
Expand All @@ -2457,22 +2460,22 @@ module ts {

var type = typeInfoResolver.getTypeOfSymbol(symbol);

if (symbol.flags & SymbolFlags.Property ||
symbol.flags & SymbolFlags.Variable) {
if (symbolFlags & SymbolFlags.Property ||
symbolFlags & SymbolFlags.Variable) {

if (type) {
totalParts.push(punctuationPart(SyntaxKind.ColonToken));
totalParts.push(spacePart());
totalParts.push.apply(totalParts, typeInfoResolver.typeToDisplayParts(type, getContainerNode(node)));
}
}
else if (symbol.flags & SymbolFlags.Function ||
symbol.flags & SymbolFlags.Method) {
else if (symbolFlags & SymbolFlags.Function ||
symbolFlags & SymbolFlags.Method) {
if (type) {
totalParts.push.apply(totalParts, typeInfoResolver.typeToDisplayParts(type, getContainerNode(node)));
}
}
else if (symbol.flags & SymbolFlags.EnumMember) {
else if (symbolFlags & SymbolFlags.EnumMember) {
var declaration = symbol.declarations[0];
if (declaration.kind === SyntaxKind.EnumMember) {
var constantValue = typeInfoResolver.getEnumMemberValue(<EnumMember>declaration);
Expand Down
0