public override VisualBasicSyntaxNode VisitUsingDirective(CSS.UsingDirectiveSyntax node) { ImportAliasClauseSyntax alias = null; if (node.Alias != null) { var name = node.Alias.Name; var id = SyntaxFactory.Identifier(name.Identifier.ValueText, SyntaxFacts.IsKeywordKind(name.Identifier.Kind()), name.Identifier.GetIdentifierText(), TypeCharacter.None); alias = SyntaxFactory.ImportAliasClause(id); } ImportsClauseSyntax clause = SyntaxFactory.SimpleImportsClause(alias, (NameSyntax)node.Name.Accept(this)); return(SyntaxFactory.ImportsStatement(SyntaxFactory.SingletonSeparatedList(clause))); }
public static INamespaceSymbol GetNamespaceSymbol(this ImportsClauseSyntax importsClause, SemanticModel semanticModel) { if (importsClause is SimpleImportsClauseSyntax simpleImport) { var nameSymbol = simpleImport.Name; if (nameSymbol == null) { return(null); } var symbolInfo = semanticModel.GetSymbolInfo(nameSymbol); return(symbolInfo.Symbol as INamespaceSymbol); } return(null); }