Exemplo n.º 1
0
        public Node GetTypeDefinition(string typeName)
        {
            Project  project = this.Project;
            Document fromDoc = project.GetDocumentByPath(this.ModulePath);

            if (fromDoc == null)
            {
                return(null);
            }

            ImportClause importClause = this.ImportClause as ImportClause; // import name from './abc';

            if (importClause.Name != null && importClause.Name.Text == typeName)
            {
                return(fromDoc.GetExportDefaultTypeDefinition());
            }

            ImportSpecifier specifier = this.GetImportSpecifier(typeName);

            if (specifier != null)
            {
                string definitionName = specifier.DefinitionName;
                if (definitionName == "default")
                {
                    return(fromDoc.GetExportDefaultTypeDefinition());
                }
                else
                {
                    return(fromDoc.GetExportTypeDefinition(definitionName));
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        private ImportSpecifier GetImportSpecifier(string typeName)
        {
            ImportClause importClause = this.ImportClause as ImportClause;
            NamedImports namedImports = importClause.NamedBindings as NamedImports;

            if (namedImports != null)
            {
                foreach (ImportSpecifier specifier in namedImports.Elements)
                {
                    if (specifier.Name.Text == typeName)
                    {
                        return(specifier);
                    }
                }
            }
            return(null);
        }