Repository: microsoft/TypeScript
File: src/services/findAllReferences.ts (TypeScript)

Code before:
                    return prefixColon;
                }
                return suffixColon;
            }
            else {
                return prefixColon;
            }
        }
        else if (isImportSpecifier(parent) && !parent.propertyName) {
            // If the original symbol was using this alias, just rename the alias.
            const originalSymbol = isExportSpecifier(originalNode.parent) ? checker.getExportSpecifierLocalTargetSymbol(originalNode.parent) : checker.getSymbolAtLocation(originalNode);
            return contains(originalSymbol!.declarations, parent) ? { prefixText: name + " as " } : emptyOptions;
        }
        else if (isExportSpecifier(parent) && !parent.propertyName) {
            // If the symbol for the node is same as declared node symbol use prefix text
            return originalNode === entry.node || checker.getSymbolAtLocation(originalNode) === checker.getSymbolAtLocation(entry.node) ?
                { prefixText: name + " as " } :
                { suffixText: " as " + name };
        }
    }

    // If the node is a numerical indexing literal, then add quotes around the property access.
    if (entry.kind !== EntryKind.Span && isNumericLiteral(entry.node) && isAccessExpression(entry.node.parent)) {
        return {
            prefixText: "'",
            suffixText: "'"
        };
    }

    return emptyOptions;
}

function toImplementationLocation(entry: Entry, checker: TypeChecker): ImplementationLocation {
    const documentSpan = entryToDocumentSpan(entry);
    if (entry.kind !== EntryKind.Span) {
        const { node } = entry;
        return {
            ...documentSpan,
            ...implementationKindDisplayParts(node, checker)
        };
    }
    else {
        return { ...documentSpan, kind: ScriptElementKind.unknown, displayParts: [] };
    }
}

function implementationKindDisplayParts(node: Node, checker: TypeChecker): { kind: ScriptElementKind, displayParts: SymbolDisplayPart[] } {
    const symbol = checker.getSymbolAtLocation(isDeclaration(node) && node.name ? node.name : node);
    if (symbol) {
        return getDefinitionKindAndDisplayParts(symbol, checker, node);
    }

Review comment (suggestion):
Use `getQuoteFromPreference(getQuotePreference(...))`

Code after:
                    isBinaryExpression(grandParent.parent) &&
                    isModuleExportsAccessExpression(grandParent.parent.left)) {
                    return prefixColon;
                }
                return suffixColon;
            }
            else {
                return prefixColon;
            }
        }
        else if (isImportSpecifier(parent) && !parent.propertyName) {
            // If the original symbol was using this alias, just rename the alias.
            const originalSymbol = isExportSpecifier(originalNode.parent) ? checker.getExportSpecifierLocalTargetSymbol(originalNode.parent) : checker.getSymbolAtLocation(originalNode);
            return contains(originalSymbol!.declarations, parent) ? { prefixText: name + " as " } : emptyOptions;
        }
        else if (isExportSpecifier(parent) && !parent.propertyName) {
            // If the symbol for the node is same as declared node symbol use prefix text
            return originalNode === entry.node || checker.getSymbolAtLocation(originalNode) === checker.getSymbolAtLocation(entry.node) ?
                { prefixText: name + " as " } :
                { suffixText: " as " + name };
        }
    }

    // If the node is a numerical indexing literal, then add quotes around the property access.
    if (entry.kind !== EntryKind.Span && isNumericLiteral(entry.node) && isAccessExpression(entry.node.parent)) {
        const quote = getQuoteFromPreference(quotePreference);
        return { prefixText: quote, suffixText: quote };
    }

    return emptyOptions;
}

function toImplementationLocation(entry: Entry, checker: TypeChecker): ImplementationLocation {
    const documentSpan = entryToDocumentSpan(entry);
    if (entry.kind !== EntryKind.Span) {
        const { node } = entry;
        return {
            ...documentSpan,
            ...implementationKindDisplayParts(node, checker)
        };
    }
    else {
        return { ...documentSpan, kind: ScriptElementKind.unknown, displayParts: [] };
    }
}

function implementationKindDisplayParts(node: Node, checker: TypeChecker): { kind: ScriptElementKind, displayParts: SymbolDisplayPart[] } {
    const symbol = checker.getSymbolAtLocation(isDeclaration(node) && node.name ? node.name : node);
    if (symbol) {
        return getDefinitionKindAndDisplayParts(symbol, checker, node);
    }