示例#1
0
        private Possible <IReadOnlyList <SymbolLocation> > GetDefinitionFromSymbol([NotNull] ISymbol symbol, INode node)
        {
            var result          = new List <SymbolLocation>();
            var declarations    = symbol.GetDeclarations();
            var symbolName      = TypeChecker.SymbolToString(symbol);
            var symbolKind      = Utilities.GetSymbolKind(symbol, node);
            var containerSymbol = symbol.Parent;
            var containerName   = containerSymbol != null?TypeChecker.SymbolToString(containerSymbol, node) : string.Empty;

            if (!TryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
                !TryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result))
            {
                // Just add all the declarations
                foreach (var declaration in declarations)
                {
                    result.Add(GetLocationFromNode(declaration, symbol));
                }
            }

            return(result.Count != 0 ? Success(result.ToArray()) : SilentError());
        }
示例#2
0
        /// <nodoc />
        public static string GetDeclaredName(ITypeChecker typeChecker, ISymbol symbol, INode location)
        {
            // If this is an export or import specifier it could have been renamed using the 'as' syntax.
            // If so we want to search for whatever is under the cursor.
            if (IsImportOrExportSpecifierName(location))
            {
                return(location.GetText());
            }

            // Try to get the local symbol if we're dealing with an 'export default'
            // since that symbol has the "true" name.
            var localExportDefaultSymbol = GetLocalSymbolForExportDefault(symbol);

            return(typeChecker.SymbolToString(localExportDefaultSymbol ?? symbol));
        }